Added some code for starting

This commit is contained in:
2016-02-13 17:06:36 -06:00
parent 364472da5c
commit 0266100d66
110 changed files with 6044 additions and 0 deletions

View File

@@ -0,0 +1 @@
import message

122
src/wxUI/dialogs/message.py Normal file
View File

@@ -0,0 +1,122 @@
# -*- coding: utf-8 -*-
import wx
import widgetUtils
class textMessage(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs):
super(textLimited, self).__init__(parent=None, *args, **kwargs)
def createTextArea(self, message="", text=""):
self.panel = wx.Panel(self)
self.label = wx.StaticText(self.panel, -1, message)
self.text = wx.TextCtrl(self.panel, -1, text, size=(439, -1), style=wx.TE_MULTILINE)
self.text.SetFocus()
self.textBox = wx.BoxSizer(wx.HORIZONTAL)
self.textBox.Add(self.label, 0, wx.ALL, 5)
self.textBox.Add(self.text, 0, wx.ALL, 5)
def create_privacy_box(self):
lbl = wx.StaticText(self.panel, wx.NewId(), _(u"Privacy"))
self.privacy = wx.ComboBox(self.panel, wx.NewId(), choices=[_(u"All users"), _(u"Friends of friends"),], value=_(u"All users"), style=wx.CB_READONLY)
self.privacyBox = wx.BoxSizer(wx.HORIZONTAL)
self.privacyBox.Add(lbl, 0, wx.ALL, 5)
self.privacyBox.Add(self.privacy, 0, wx.ALL, 5)
def text_focus(self):
self.text.SetFocus()
def get_text(self):
return self.text.GetValue()
def set_text(self, text):
return self.text.ChangeValue(text)
def enable_button(self, buttonName):
if getattr(self, buttonName):
return getattr(self, buttonName).Enable()
def disable_button(self, buttonName):
if getattr(self, buttonName):
return getattr(self, buttonName).Disable()
def onSelect(self, ev):
self.text.SelectAll()
def set_cursor_at_end(self):
self.text.SetInsertionPoint(len(self.text.GetValue()))
def set_cursor_at_position(self, position):
self.text.SetInsertionPoint(position)
def get_position(self):
return self.text.GetInsertionPoint()
class post(textMessage):
def createControls(self, title, message, text):
self.mainBox = wx.BoxSizer(wx.VERTICAL)
self.createTextArea(message, text)
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.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.spellcheck, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.translateButton, 0, wx.ALL, 10)
self.mainBox.Add(self.buttonsBox1, 0, wx.ALL, 10)
self.ok_cancelSizer = wx.BoxSizer(wx.HORIZONTAL)
self.ok_cancelSizer.Add(self.okButton, 0, wx.ALL, 10)
self.ok_cancelSizer.Add(cancelButton, 0, wx.ALL, 10)
self.mainBox.Add(self.ok_cancelSizer)
selectId = wx.NewId()
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
self.accel_tbl = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('A'), selectId),])
self.SetAcceleratorTable(self.accel_tbl)
self.panel.SetSizer(self.mainBox)
def __init__(self, title, message, text):
super(post, self).__init__()
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):
self.mainBox = wx.BoxSizer(wx.VERTICAL)
self.createTextArea(message, text)
self.mainBox.Add(self.textBox, 0, wx.ALL, 5)
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.spellcheck, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.translateButton, 0, wx.ALL, 10)
self.mainBox.Add(self.buttonsBox1, 0, wx.ALL, 10)
self.ok_cancelSizer = wx.BoxSizer(wx.HORIZONTAL)
self.ok_cancelSizer.Add(self.okButton, 0, wx.ALL, 10)
self.ok_cancelSizer.Add(cancelButton, 0, wx.ALL, 10)
self.mainBox.Add(self.ok_cancelSizer)
selectId = wx.NewId()
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
self.accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('A'), selectId),])
self.SetAcceleratorTable(self.accel_tbl)
self.panel.SetSizer(self.mainBox)
def __init__(self, title, message, text):
super(comment, self).__init__()
self.createControls(message, title, text)
self.SetClientSize(self.mainBox.CalcMin())

View File

@@ -0,0 +1,104 @@
# -*- coding: utf-8 -*-
import wx
import widgetUtils
class basicPost(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs):
super(basicPost, self).__init__(parent=None, *args, **kwargs)
self.panel = wx.Panel(self, -1)
self.sizer = wx.BoxSizer(wx.VERTICAL)
def done(self):
self.panel.SetSizer(self.sizer)
self.SetClientSize(self.sizer.CalcMin())
def create_post_view(self, label=_(u"Message")):
lbl = wx.StaticText(self.panel, -1, label)
self.post_view = wx.TextCtrl(self.panel, -1, size=(730, -1), style=wx.TE_READONLY|wx.TE_MULTILINE)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl, 0, wx.ALL, 5)
box.Add(self.post_view, 0, wx.ALL, 5)
return box
def create_comments_list(self):
self.comments = widgetUtils.list(self.panel, _(u"User"), _(u"Comment"), _(u"Date"), _(u"Likes"), style=wx.LC_REPORT)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.comments.list, 0, wx.ALL, 5)
return box
def create_likes_box(self):
self.likes = wx.Button(self.panel, -1, _(u"Loading data..."))
return self.likes
def create_shares_box(self):
self.shares = wx.Button(self.panel, -1, _(u"Loading data..."))
return self.shares
def create_action_buttons(self, comment=True):
self.like = wx.Button(self.panel, -1, _(u"Like"))
if comment: self.comment = wx.Button(self.panel, -1, _(u"Add comment"))
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.like, 0, wx.ALL, 5)
if comment: box.Add(self.comment, 0, wx.ALL, 5)
return box
def create_tools_button(self):
self.tools = wx.Button(self.panel, -1, _(u"Actions"))
def create_dialog_buttons(self):
self.close = wx.Button(self.panel, wx.ID_CANCEL, _(u"Close"))
return self.close
def set_post(self, text):
if hasattr(self, "post_view"):
self.post_view.ChangeValue(text)
else:
return False
def insert_comments(self, comments):
for i in comments:
self.comments.insert_item(False, *i)
def set_likes(self, likes):
if hasattr(self, "likes"):
self.likes.SetLabel(_(u"{0} people like this").format(likes,))
else:
return False
def set_shares(self, shares):
if hasattr(self, "shares"):
self.shares.SetLabel(_(u"Shared {0} times").format(shares,))
else:
return False
class post(basicPost):
def __init__(self, *args, **kwargs):
super(post, self).__init__(*args, **kwargs)
post_view_box = self.create_post_view()
self.sizer.Add(post_view_box, 0, wx.ALL, 5)
self.create_tools_button()
self.sizer.Add(self.tools, 0, wx.ALL, 5)
likes_box = self.create_likes_box()
self.sizer.Add(likes_box, 0, wx.ALL, 5)
shares_box = self.create_shares_box()
self.sizer.Add(shares_box, 0, wx.ALL, 5)
actions_box = self.create_action_buttons()
self.sizer.Add(actions_box, 0, wx.ALL, 5)
comments_box = self.create_comments_list()
self.sizer.Add(comments_box, 0, wx.ALL, 5)
self.sizer.Add(self.create_dialog_buttons())
self.done()
class comment(basicPost):
def __init__(self, *args, **kwargs):
super(comment, self).__init__(*args, **kwargs)
post_view_box = self.create_post_view()
self.sizer.Add(post_view_box, 0, wx.ALL, 5)
self.create_tools_button()
self.sizer.Add(self.tools, 0, wx.ALL, 5)
likes_box = self.create_likes_box()
self.sizer.Add(likes_box, 0, wx.ALL, 5)
actions_box = self.create_action_buttons(comment=False)
self.sizer.Add(actions_box, 0, wx.ALL, 5)
self.sizer.Add(self.create_dialog_buttons())
self.done()

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
import wx
class selectAlbum(wx.Dialog):
def __init__(self, albums):
super(selectAlbum, self).__init__(parent=None, title=_(u"Select the album where you will upload the photo"))
panel = wx.Panel(self)
self.lista = wx.ListBox(panel, -1, choices=albums)
self.lista.SetFocus()
self.lista.SetSelection(0)
self.lista.SetSize(self.lista.GetBestSize())
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.lista, 0, wx.ALL, 5)
goBtn = wx.Button(panel, wx.ID_OK)
goBtn.SetDefault()
cancelBtn = wx.Button(panel, wx.ID_CANCEL)
btnSizer = wx.BoxSizer()
btnSizer.Add(goBtn, 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_string(self):
return self.lista.GetStringSelection()
def get_item(self):
return self.lista.GetSelection()
def get_response(self):
return self.ShowModal()

View File

@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
import wx
class urlList(wx.Dialog):
def __init__(self):
super(urlList, self).__init__(parent=None, title=_(u"Select URL"))
panel = wx.Panel(self)
self.lista = wx.ListBox(panel, -1)
self.lista.SetFocus()
self.lista.SetSize(self.lista.GetBestSize())
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.lista, 0, wx.ALL, 5)
goBtn = wx.Button(panel, wx.ID_OK)
goBtn.SetDefault()
cancelBtn = wx.Button(panel, wx.ID_CANCEL)
btnSizer = wx.BoxSizer()
btnSizer.Add(goBtn, 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 populate_list(self, urls):
for i in urls:
self.lista.Append(i)
self.lista.SetSelection(0)
def get_string(self):
return self.lista.GetStringSelection()
def get_item(self):
return self.lista.GetSelection()
def get_response(self):
return self.ShowModal()