Added basic photo uploader in wall posts. Description is not supported

This commit is contained in:
2016-04-11 11:48:35 -05:00
parent c7874759b1
commit 64b4b5573a
7 changed files with 109 additions and 44 deletions

View File

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
import wx
import widgetUtils
class attachDialog(widgetUtils.BaseDialog):
def __init__(self):
super(attachDialog, self).__init__(None, title=_(u"Add an attachment"))
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
lbl1 = wx.StaticText(panel, wx.NewId(), _(u"Attachments"))
self.attachments = widgetUtils.list(panel, _(u"Type"), _(u"Title"), style=wx.LC_REPORT)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl1, 0, wx.ALL, 5)
box.Add(self.attachments.list, 0, wx.ALL, 5)
sizer.Add(box, 0, wx.ALL, 5)
static = wx.StaticBox(panel, label=_(u"Add attachments"))
self.photo = wx.Button(panel, wx.NewId(), _(u"&Photo"))
btnsizer = wx.StaticBoxSizer(static, wx.HORIZONTAL)
btnsizer.Add(self.photo, 0, wx.ALL, 5)
sizer.Add(btnsizer, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK)
ok.SetDefault()
cancelBtn = wx.Button(panel, wx.ID_CANCEL)
btnSizer = wx.BoxSizer()
btnSizer.Add(ok, 0, wx.ALL, 5)
btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
sizer.Add(btnSizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def get_image(self):
openFileDialog = wx.FileDialog(self, _(u"Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None
dsc = ""
return (openFileDialog.GetPath(), dsc)
def ask_description(self):
dlg = wx.TextEntryDialog(self, _(u"please provide a description"), _(u"Description"), defaultValue="")
dlg.ShowModal()
result = dlg.GetValue()
dlg.Destroy()
return result

View File

@@ -58,15 +58,14 @@ class post(textMessage):
self.mainBox.Add(self.textBox, 0, wx.ALL, 5)
self.create_privacy_box()
self.mainBox.Add(self.privacyBox, 0, wx.ALL, 5)
self.upload_image = wx.Button(self.panel, -1, _(u"Upload a &picture"), size=wx.DefaultSize)
self.upload_image.Enable(False)
self.attach = wx.Button(self.panel, -1, _(u"Attach"), size=wx.DefaultSize)
self.spellcheck = wx.Button(self.panel, -1, _("Spelling &correction"), size=wx.DefaultSize)
self.translateButton = wx.Button(self.panel, -1, _(u"&Translate message"), size=wx.DefaultSize)
self.okButton = wx.Button(self.panel, wx.ID_OK, _(u"Send"), size=wx.DefaultSize)
self.okButton.SetDefault()
cancelButton = wx.Button(self.panel, wx.ID_CANCEL, _(u"Close"), size=wx.DefaultSize)
self.buttonsBox1 = wx.BoxSizer(wx.HORIZONTAL)
self.buttonsBox1.Add(self.upload_image, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.attach, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.spellcheck, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.translateButton, 0, wx.ALL, 10)
self.mainBox.Add(self.buttonsBox1, 0, wx.ALL, 10)
@@ -86,11 +85,6 @@ class post(textMessage):
self.createControls(message, title, text)
self.SetClientSize(self.mainBox.CalcMin())
def get_image(self):
openFileDialog = wx.FileDialog(self, _(u"Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None
return openFileDialog.GetPath()
class comment(textMessage):
def createControls(self, title, message, text):

View File

@@ -52,3 +52,9 @@ class toolsMenu(wx.Menu):
self.AppendItem(self.translate)
self.CheckSpelling = wx.MenuItem(self, -1, _(u"Check Spelling"))
self.AppendItem(self.CheckSpelling)
class attachMenu(wx.Menu):
def __init__(self):
super(attachMenu, self).__init__()
self.photo = wx.MenuItem(self, wx.NewId(), _(u"Picture"))
self.AppendItem(self.photo)