Mae profile viewer a tabbed window. Added photo to the dialog. Separated profile code from other post types

This commit is contained in:
Manuel Cortez 2018-09-06 10:47:10 -05:00
parent 964ff00520
commit 71a15a24bc
6 changed files with 341 additions and 107 deletions

View File

@ -9,6 +9,7 @@ import buffers
import configuration
import player
import posts
import profiles
import webbrowser
import logging
import longpollthread
@ -160,6 +161,7 @@ class Controller(object):
# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up)
# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute)
pub.subscribe(self.get_chat, "order-sent-message")
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile, menuitem=self.window.view_profile)
def disconnect_events(self):
log.debug("Disconnecting some events...")
@ -577,4 +579,7 @@ class Controller(object):
player.player.volume = 0
def user_profile(self, person):
p = posts.userProfile(self.session, person)
p = profiles.userProfile(self.session, person)
def view_my_profile(self, *args, **kwargs):
self.user_profile(self.session.user_id)

View File

@ -16,7 +16,7 @@ import logging
from sessionmanager import session # We'll use some functions from there
from sessionmanager.session import utils
from pubsub import pub
from wxUI.dialogs import postDialogs, urlList
from wxUI.dialogs import postDialogs, urlList, profiles
from extra import SpellChecker, translator
from mysc.thread_utils import call_threaded
from wxUI import menus
@ -513,36 +513,39 @@ class userProfile(object):
self.person = None
self.session = session
self.user_id = user_id
self.dialog = postDialogs.userProfile()
self.dialog = profiles.userProfile(title=_(u"Profile"))
self.dialog.create_controls("main_info")
self.dialog.realice()
self.get_basic_information()
if self.person != None:
self.dialog.get_response()
def get_basic_information(self):
""" Gets and inserts basic user information"""
fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives"
""" Gets and inserts basic user information.
See https://vk.com/dev/users.get"""
fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives, personal, connections, activities, interests, music, movies, tv, books, games, about, quotes, can_write_private_message"
person = self.session.vk.client.users.get(user_ids=self.user_id, fields=fields)
if len(person) == 0:
return output.speak(_(u"Information for groups is not supported, yet."))
person = person[0]
print person.keys()
print person
# Gets full name.
n = u"{0} {1}".format(person["first_name"], person["last_name"])
# Gets birthdate.
if person.has_key("bdate") and person["bdate"] != "":
self.dialog.enable("bdate")
self.dialog.main_info.enable("bdate")
if len(person["bdate"]) <= 5:
d = arrow.get(person["bdate"], "D.m")
self.dialog.set("bdate", d.format(_(u"MMMM D"), locale=languageHandler.getLanguage()))
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D"), locale=languageHandler.getLanguage()))
else:
d = arrow.get(person["bdate"], "D.M.YYYY")
self.dialog.set("bdate", d.format(_(u"MMMM D, YYYY"), locale=languageHandler.getLanguage()))
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D, YYYY"), locale=languageHandler.getLanguage()))
# Gets current city and home town
city = ""
if person.has_key("home_town") and person["home_town"] != "":
home_town = person["home_town"]
self.dialog.enable("home_town")
self.dialog.set("home_town", home_town)
self.dialog.main_info.enable("home_town")
self.dialog.main_info.set("home_town", home_town)
if person.has_key("city") and len(person["city"]) > 0:
city = person["city"]["title"]
if person.has_key("country") and person["country"] != "":
@ -550,18 +553,19 @@ class userProfile(object):
city = city+u", {0}".format(person["country"]["title"])
else:
city = person["country"]["title"]
self.dialog.enable("city")
self.dialog.set("city", city)
self.dialog.set("name", n)
self.dialog.main_info.enable("city")
self.dialog.main_info.set("city", city)
self.dialog.main_info.set("name", n)
self.dialog.SetTitle(_(u"{name}'s profile").format(name=n,))
# Gets website
if person.has_key("site") and person["site"] != "":
self.dialog.enable("website")
self.dialog.set("website", person["site"])
self.dialog.enable("go_site")
widgetUtils.connect_event(self.dialog.go_site, widgetUtils.BUTTON_PRESSED, self.visit_website)
self.dialog.main_info.enable("website")
self.dialog.main_info.set("website", person["site"])
self.dialog.main_info.enable("go_site")
widgetUtils.connect_event(self.dialog.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.visit_website)
if person.has_key("status") and person["status"] != "":
self.dialog.enable("status")
self.dialog.set("status", person["status"])
self.dialog.main_info.enable("status")
self.dialog.main_info.set("status", person["status"])
if person.has_key("occupation") and person["occupation"] != None:
if person["occupation"]["type"] == "work": c1 = _(u"Work ")
elif person["occupation"]["type"] == "school": c1 = _(u"Student ")
@ -570,8 +574,8 @@ class userProfile(object):
c2 = _(u"In {0}").format(person["occupation"]["name"],)
else:
c2 = ""
self.dialog.enable("occupation")
self.dialog.set("occupation", c1+c2)
self.dialog.main_info.enable("occupation")
self.dialog.main_info.set("occupation", c1+c2)
if person.has_key("relation") and person["relation"] != 0:
print person["relation"]
if person["relation"] == 1:
@ -591,14 +595,14 @@ class userProfile(object):
r = _(u"Actively searching")
elif person["relation"] == 7:
r = _(u"In love")
self.dialog.enable("relation")
self.dialog.relation.SetLabel(_(u"Relationship: ")+r)
self.dialog.main_info.enable("relation")
self.dialog.main_info.relation.SetLabel(_(u"Relationship: ")+r)
if person.has_key("last_seen") and person["last_seen"] != False:
original_date = arrow.get(person["last_seen"]["time"])
# Translators: This is the date of last seen
last_seen = _(u"{0}").format(original_date.humanize(locale=languageHandler.getLanguage()),)
self.dialog.enable("last_seen")
self.dialog.set("last_seen", last_seen)
self.dialog.main_info.enable("last_seen")
self.dialog.main_info.set("last_seen", last_seen)
log.info("getting info...")
self.person = person
self.dialog.SetClientSize(self.dialog.sizer.CalcMin())

138
src/controller/profiles.py Normal file
View File

@ -0,0 +1,138 @@
# -*- coding: utf-8 -*-
import arrow
import requests
import languageHandler
import widgetUtils
import output
import wx
import cStringIO
import webbrowser
import logging
from sessionmanager.session import utils
from wxUI.dialogs import urlList, profiles
log = logging.getLogger("controller.post")
def get_user(id, profiles):
""" Returns an user name and last name based in the id receibed."""
for i in profiles:
if i["id"] == id:
return u"{0} {1}".format(i["first_name"], i["last_name"])
# Translators: This string is used when socializer can't find the right user information.
return _(u"Unknown username")
def get_message(status):
message = ""
if status.has_key("text"):
message = utils.clean_text(status["text"])
return message
class userProfile(object):
def __init__(self, session, user_id):
self.person = None
self.session = session
self.user_id = user_id
self.dialog = profiles.userProfile(title=_(u"Profile"))
self.dialog.create_controls("main_info")
self.dialog.realice()
self.get_basic_information()
if self.person != None:
self.dialog.get_response()
def get_basic_information(self):
""" Gets and inserts basic user information.
See https://vk.com/dev/users.get"""
fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives, personal, connections, activities, interests, music, movies, tv, books, games, about, quotes, can_write_private_message"
person = self.session.vk.client.users.get(user_ids=self.user_id, fields=fields)
if len(person) == 0:
return output.speak(_(u"Information for groups is not supported, yet."))
person = person[0]
# print person
# Gets full name.
n = u"{0} {1}".format(person["first_name"], person["last_name"])
# Gets birthdate.
if person.has_key("bdate") and person["bdate"] != "":
self.dialog.main_info.enable("bdate")
if len(person["bdate"]) <= 5:
d = arrow.get(person["bdate"], "D.m")
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D"), locale=languageHandler.getLanguage()))
else:
d = arrow.get(person["bdate"], "D.M.YYYY")
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D, YYYY"), locale=languageHandler.getLanguage()))
# Gets current city and home town
city = ""
if person.has_key("home_town") and person["home_town"] != "":
home_town = person["home_town"]
self.dialog.main_info.enable("home_town")
self.dialog.main_info.set("home_town", home_town)
if person.has_key("city") and len(person["city"]) > 0:
city = person["city"]["title"]
if person.has_key("country") and person["country"] != "":
if city != "":
city = city+u", {0}".format(person["country"]["title"])
else:
city = person["country"]["title"]
self.dialog.main_info.enable("city")
self.dialog.main_info.set("city", city)
self.dialog.main_info.set("name", n)
self.dialog.SetTitle(_(u"{name}'s profile").format(name=n,))
# Gets website
if person.has_key("site") and person["site"] != "":
self.dialog.main_info.enable("website")
self.dialog.main_info.set("website", person["site"])
self.dialog.main_info.enable("go_site")
widgetUtils.connect_event(self.dialog.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.visit_website)
if person.has_key("status") and person["status"] != "":
self.dialog.main_info.enable("status")
self.dialog.main_info.set("status", person["status"])
if person.has_key("occupation") and person["occupation"] != None:
if person["occupation"]["type"] == "work": c1 = _(u"Work ")
elif person["occupation"]["type"] == "school": c1 = _(u"Student ")
elif person["occupation"]["type"] == "university": c1 = _(u"Student ")
if person["occupation"].has_key("name") and person["occupation"]["name"] != "":
c2 = _(u"In {0}").format(person["occupation"]["name"],)
else:
c2 = ""
self.dialog.main_info.enable("occupation")
self.dialog.main_info.set("occupation", c1+c2)
if person.has_key("relation") and person["relation"] != 0:
if person["relation"] == 1:
r = _(u"Single")
elif person["relation"] == 2:
if person.has_key("relation_partner"):
r = _(u"Dating with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
else:
r = _(u"Dating")
elif person["relation"] == 3:
r = _(u"Engaged with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
elif person["relation"] == 4:
r = _(u"Married with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
elif person["relation"] == 5:
r = _(u"It's complicated")
elif person["relation"] == 6:
r = _(u"Actively searching")
elif person["relation"] == 7:
r = _(u"In love")
self.dialog.main_info.enable("relation")
self.dialog.main_info.relation.SetLabel(_(u"Relationship: ")+r)
if person.has_key("last_seen") and person["last_seen"] != False:
original_date = arrow.get(person["last_seen"]["time"])
# Translators: This is the date of last seen
last_seen = _(u"{0}").format(original_date.humanize(locale=languageHandler.getLanguage()),)
self.dialog.main_info.enable("last_seen")
self.dialog.main_info.set("last_seen", last_seen)
log.info("getting info...")
self.person = person
if person.has_key("photo_200_orig"):
img = requests.get(person["photo_200_orig"])
image = wx.Image(stream=cStringIO.StringIO(requests.get(person["photo_200_orig"]).content))
try:
self.dialog.image.SetBitmap(wx.Bitmap(image))
except ValueError:
return
self.dialog.panel.Layout()
def visit_website(self, *args, **kwargs):
output.speak(_(u"Opening website..."))
webbrowser.open_new_tab(self.person["site"])

View File

@ -221,84 +221,4 @@ class friendship(widgetUtils.BaseDialog):
btnbox.Add(close, 0, wx.ALL, 5)
sizer.Add(btnbox, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
class userProfile(widgetUtils.BaseDialog):
def __init__(self):
super(userProfile, self).__init__(parent=None)
panel = wx.Panel(self)
self.sizer = wx.BoxSizer(wx.VERTICAL)
lblName = wx.StaticText(panel, wx.NewId(), _(u"Name"))
self.name = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
sizerName = wx.BoxSizer(wx.HORIZONTAL)
sizerName.Add(lblName, 0, wx.ALL, 5)
sizerName.Add(self.name, 0, wx.ALL, 5)
self.sizer.Add(sizerName, 0, wx.ALL, 5)
lblStatus = wx.StaticText(panel, wx.NewId(), _(u"Status"))
self.status = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.status.Enable(False)
sizerStatus = wx.BoxSizer(wx.HORIZONTAL)
sizerStatus.Add(lblStatus, 0, wx.ALL, 5)
sizerStatus.Add(self.status, 0, wx.ALL, 5)
self.sizer.Add(sizerStatus, 0, wx.ALL, 5)
lblLastSeen = wx.StaticText(panel, wx.NewId(), _(u"Last seen"))
self.last_seen = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.last_seen.Enable(False)
sizerLastSeen = wx.BoxSizer(wx.HORIZONTAL)
sizerLastSeen.Add(lblLastSeen, 0, wx.ALL, 5)
sizerLastSeen.Add(self.last_seen, 0, wx.ALL, 5)
self.sizer.Add(sizerLastSeen, 0, wx.ALL, 5)
lblBDate = wx.StaticText(panel, wx.NewId(), _(u"Birthdate"))
self.bdate = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.bdate.Enable(False)
sizerBDate = wx.BoxSizer(wx.HORIZONTAL)
sizerBDate.Add(lblBDate, 0, wx.ALL, 5)
sizerBDate.Add(self.bdate, 0, wx.ALL, 5)
self.sizer.Add(sizerBDate, 0, wx.ALL, 5)
self.relation = wx.Button(panel, -1, "")
self.relation.Enable(False)
self.sizer.Add(self.relation, 0, wx.ALL, 5)
lblCity = wx.StaticText(panel, wx.NewId(), _(u"Current city"))
self.city = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.city.Enable(False)
sizerCity = wx.BoxSizer(wx.HORIZONTAL)
sizerCity.Add(lblCity, 0, wx.ALL, 5)
sizerCity.Add(self.city, 0, wx.ALL, 5)
self.sizer.Add(sizerCity, 0, wx.ALL, 5)
lblHometown = wx.StaticText(panel, wx.NewId(), _(u"Home Town"))
self.home_town = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.home_town.Enable(False)
sizerHometown = wx.BoxSizer(wx.HORIZONTAL)
sizerHometown.Add(lblHometown, 0, wx.ALL, 5)
sizerHometown.Add(self.home_town, 0, wx.ALL, 5)
self.sizer.Add(sizerHometown, 0, wx.ALL, 5)
lblWebsite = wx.StaticText(panel, wx.NewId(), _(u"Website"))
self.website = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.website.Enable(False)
self.go_site = wx.Button(panel, -1, _(u"Visit website"))
self.go_site.Enable(False)
sizerWebsite = wx.BoxSizer(wx.HORIZONTAL)
sizerWebsite.Add(lblWebsite, 0, wx.ALL, 5)
sizerWebsite.Add(self.website, 0, wx.ALL, 5)
sizerWebsite.Add(self.go_site, 0, wx.ALL, 5)
self.sizer.Add(sizerWebsite, 0, wx.ALL, 5)
lblOccupation = wx.StaticText(panel, wx.NewId(), _(u"Occupation"))
self.occupation = wx.TextCtrl(panel, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.occupation.Enable(False)
sizerOccupation = wx.BoxSizer(wx.HORIZONTAL)
sizerOccupation.Add(lblOccupation, 0, wx.ALL, 5)
sizerOccupation.Add(self.occupation, 0, wx.ALL, 5)
self.sizer.Add(sizerOccupation, 0, wx.ALL, 5)
cancel = wx.Button(panel, wx.ID_CANCEL)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(cancel, 0, wx.ALL, 5)
self.sizer.Add(cancel, 0, wx.ALL, 5)
panel.SetSizer(self.sizer)
self.SetClientSize(self.sizer.CalcMin())
self.SetClientSize(sizer.CalcMin())

View File

@ -0,0 +1,159 @@
# -*- coding: utf-8 -*-
""" A set of dialogs related to user and community profiles."""
import wx
import widgetUtils
def text_size(wxObject, chars):
""" Takes a wx object and the amount of characters supposed to hold and gives the best size for the control.
wxObject wx.TextCtrl: Text control to be taken as a reference.
chars int: Number of characters the control would hold.
returns (x, y)"""
dc = wx.WindowDC(wxObject)
dc.SetFont(wxObject.GetFont())
(x, y) = dc.GetMultiLineTextExtent("0"*chars)
return (x, -1)
class mainInfo(wx.Panel):
""" Panel to store main user information in a profile viewer."""
def get(self, control):
if hasattr(self, control):
control = getattr(self, control)
if hasattr(control, "GetValue"): return getattr(control, "GetValue")()
elif hasattr(control, "GetLabel"): return getattr(control, "GetLabel")()
else: return -1
else: return 0
def set(self, control, text):
if hasattr(self, control):
control = getattr(self, control)
if hasattr(control, "SetValue"): return getattr(control, "SetValue")(text)
elif hasattr(control, "SetLabel"): return getattr(control, "SetLabel")(text)
elif hasattr(control, "ChangeValue"): return getattr(control, "ChangeValue")(text)
else: return -1
else: return 0
def enable(self, control):
getattr(self, control).Enable(True)
def disable(self, control):
getattr(self, control).Enable(False)
def __init__(self, panel):
super(mainInfo, self).__init__(panel)
# self.SetSizerType("vertical")
sizer = wx.BoxSizer(wx.VERTICAL)
lblName = wx.StaticText(self, wx.NewId(), _(u"Name"))
self.name = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.name.SetMinSize(text_size(self.name, 60))
sizerName = wx.BoxSizer(wx.HORIZONTAL)
sizerName.Add(lblName, 0, wx.ALL, 5)
sizerName.Add(self.name, 0, wx.ALL, 5)
sizer.Add(sizerName, 0, wx.ALL, 5)
lblStatus = wx.StaticText(self, wx.NewId(), _(u"Status"))
self.status = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.status.Enable(False)
self.status.SetMinSize(text_size(self.status, 300))
sizerStatus = wx.BoxSizer(wx.HORIZONTAL)
sizerStatus.Add(lblStatus, 0, wx.ALL, 5)
sizerStatus.Add(self.status, 0, wx.ALL, 5)
sizer.Add(sizerStatus, 0, wx.ALL, 5)
lblLastSeen = wx.StaticText(self, wx.NewId(), _(u"Last seen"))
self.last_seen = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.last_seen.Enable(False)
sizerLastSeen = wx.BoxSizer(wx.HORIZONTAL)
sizerLastSeen.Add(lblLastSeen, 0, wx.ALL, 5)
sizerLastSeen.Add(self.last_seen, 0, wx.ALL, 5)
sizer.Add(sizerLastSeen, 0, wx.ALL, 5)
lblBDate = wx.StaticText(self, wx.NewId(), _(u"Birthdate"))
self.bdate = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.bdate.Enable(False)
sizerBDate = wx.BoxSizer(wx.HORIZONTAL)
sizerBDate.Add(lblBDate, 0, wx.ALL, 5)
sizerBDate.Add(self.bdate, 0, wx.ALL, 5)
sizer.Add(sizerBDate, 0, wx.ALL, 5)
self.relation = wx.Button(self, -1, "")
self.relation.Enable(False)
sizer.Add(self.relation, 0, wx.ALL, 5)
lblCity = wx.StaticText(self, wx.NewId(), _(u"Current city"))
self.city = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.city.SetMinSize(text_size(self.city, 40))
self.city.Enable(False)
sizerCity = wx.BoxSizer(wx.HORIZONTAL)
sizerCity.Add(lblCity, 0, wx.ALL, 5)
sizerCity.Add(self.city, 0, wx.ALL, 5)
sizer.Add(sizerCity, 0, wx.ALL, 5)
lblHometown = wx.StaticText(self, wx.NewId(), _(u"Home Town"))
self.home_town = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.home_town.SetMinSize(text_size(self.home_town, 40))
self.home_town.Enable(False)
sizerHometown = wx.BoxSizer(wx.HORIZONTAL)
sizerHometown.Add(lblHometown, 0, wx.ALL, 5)
sizerHometown.Add(self.home_town, 0, wx.ALL, 5)
sizer.Add(sizerHometown, 0, wx.ALL, 5)
lblWebsite = wx.StaticText(self, wx.NewId(), _(u"Website"))
self.website = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)#size=(500, -1))
self.website.SetMinSize(text_size(self.website, 90))
self.website.Enable(False)
self.go_site = wx.Button(self, -1, _(u"Visit website"))
self.go_site.Enable(False)
sizerWebsite = wx.BoxSizer(wx.HORIZONTAL)
sizerWebsite.Add(lblWebsite, 0, wx.ALL, 5)
sizerWebsite.Add(self.website, 1, wx.ALL, 5)
sizerWebsite.Add(self.go_site, 1, wx.ALL, 5)
sizer.Add(sizerWebsite, 1, wx.ALL, 5)
lblOccupation = wx.StaticText(self, wx.NewId(), _(u"Occupation"))
self.occupation = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.occupation.SetMinSize(text_size(self.occupation, 90))
self.occupation.Enable(False)
sizerOccupation = wx.BoxSizer(wx.HORIZONTAL)
sizerOccupation.Add(lblOccupation, 0, wx.ALL, 5)
sizerOccupation.Add(self.occupation, 0, wx.ALL, 5)
sizer.Add(sizerOccupation, 0, wx.ALL, 5)
self.SetSizer(sizer)
class userProfile(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs):
super(userProfile, self).__init__(parent=None, *args, **kwargs)
self.panel = wx.Panel(self)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.notebook = wx.Notebook(self.panel)
def create_controls(self, section):
if section == "main_info":
self.main_info = mainInfo(self.notebook)
self.notebook.AddPage(self.main_info, _(u"Basic information"))
self.main_info.SetFocus()
def realice(self):
self.image = wx.StaticBitmap(self.panel, bitmap=wx.Bitmap(200, 200), size=(200, 200))
self.sizer.Add(self.image, 1, wx.ALL, 10)
self.sizer.Add(self.notebook, 1, wx.ALL, 5)
cancel = wx.Button(self.panel, wx.ID_CANCEL)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(cancel, 0, wx.ALL, 5)
self.sizer.Add(btnSizer, 0, wx.ALL, 5)
self.panel.SetSizer(self.sizer)
self.SetClientSize(self.sizer.CalcMin())
def get_value(self, panel, key):
p = getattr(self, panel)
return getattr(p, key).GetValue()
def set_value(self, panel, key, value):
p = getattr(self, panel)
control = getattr(p, key)
getattr(control, "SetValue")(value)
def enable(self, panel, key, value=False):
p = getattr(self, panel)
control = getattr(p, key)
getattr(control, "Enable")(value)

View File

@ -18,6 +18,13 @@ class mainWindow(wx.Frame):
self.delete_video_album = delete.Append(wx.NewId(), _(u"Video album"))
app_.Append(wx.NewId(), _(u"Delete"), delete)
self.settings_dialog = app_.Append(wx.NewId(), _(u"Preferences"))
me = wx.Menu()
profile = wx.Menu()
self.view_profile = profile.Append(wx.NewId(), _(u"View profile"))
self.edit_profile = profile.Append(wx.NewId(), _(u"Edit profile"))
self.open_in_browser = profile.Append(wx.NewId(), _(u"Open in browser"))
me.Append(wx.NewId(), _(u"Profile"), profile)
self.set_status = me.Append(wx.NewId(), _(u"Set status message"))
buffer = wx.Menu()
search = wx.Menu()
# self.search_audios = search.Append(wx.NewId(), _(u"Audio"))
@ -29,6 +36,7 @@ class mainWindow(wx.Frame):
self.load_previous_items = buffer.Append(wx.NewId(), _(u"Load previous items"))
self.remove_buffer_ = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
mb.Append(app_, _(u"Application"))
mb.Append(me, _(u"Me"))
mb.Append(buffer, _(u"Buffer"))
# player = wx.Menu()
# self.player_play = player.Append(wx.NewId(), _(u"Play"))