From 500671d2a732ba8dfe74f64659d0bb1971a8a84c Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Mon, 12 Mar 2018 09:24:27 -0600 Subject: [PATCH] Added changes to make GUI compatible for Python 2 and 3 --- src/wxUI/mainWindow.py | 24 ++++++++++++------------ src/wxUI/menus.py | 13 +++++++++---- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index 86174fb..0e8d5cc 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -25,8 +25,8 @@ class mainWindow(wx.Frame): help_ = wx.Menu() self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,)) self.check_for_updates = help_.Append(wx.NewId(), _(u"Check for updates")) - self.changelog = help_.Append(wx.NewId(), _("What's new in this version?")) - self.website = help_.Append(wx.NewId(), _("Visit website")) + self.changelog = help_.Append(wx.NewId(), _(u"What's new in this version?")) + self.website = help_.Append(wx.NewId(), _(u"Visit website")) mb.Append(player, _(u"Player")) mb.Append(help_, _(u"Help")) self.SetMenuBar(mb) @@ -43,29 +43,29 @@ class mainWindow(wx.Frame): box = wx.BoxSizer(wx.HORIZONTAL) box.Add(lbl2, 0, wx.GROW) box.Add(self.text, 1, wx.GROW) - box.Add(wx.StaticText(self.panel, wx.NewId(), _("Search in")), 0, wx.GROW) + box.Add(wx.StaticText(self.panel, wx.NewId(), _(u"Search in")), 0, wx.GROW) self.extractor = wx.ComboBox(self.panel, wx.NewId(), choices=["youtube", "vk", "mail.ru", "zaycev.net"], value="youtube", style=wx.CB_READONLY) box.Add(self.extractor, 1, wx.GROW) - self.search = wx.Button(self.panel, wx.NewId(), _("Search")) + self.search = wx.Button(self.panel, wx.NewId(), _(u"Search")) self.search.SetDefault() box.Add(self.search, 0, wx.GROW) self.sizer.Add(box, 0, wx.GROW) - lbl = wx.StaticText(self.panel, wx.NewId(), _("Results")) + lbl = wx.StaticText(self.panel, wx.NewId(), _(u"Results")) self.list = wx.ListBox(self.panel, wx.NewId()) self.sizer.Add(lbl, 0, wx.GROW) self.sizer.Add(self.list, 1, wx.GROW) box1 = wx.BoxSizer(wx.HORIZONTAL) box2 = wx.BoxSizer(wx.HORIZONTAL) - box1.Add(wx.StaticText(self.panel, wx.NewId(), _("Position")), 0, wx.GROW) + box1.Add(wx.StaticText(self.panel, wx.NewId(), _(u"Position")), 0, wx.GROW) self.time_slider = wx.Slider(self.panel, -1) box1.Add(self.time_slider, 1, wx.GROW) - box1.Add(wx.StaticText(self.panel, wx.NewId(), _("Volume")), 0, wx.GROW) + box1.Add(wx.StaticText(self.panel, wx.NewId(), _(u"Volume")), 0, wx.GROW) self.vol_slider = wx.Slider(self.panel, -1, 0, 0, 100, size=(100, -1)) box1.Add(self.vol_slider, 1, wx.GROW) - self.previous = wx.Button(self.panel, wx.NewId(), _("Previous")) - self.play = wx.Button(self.panel, wx.NewId(), _("Play")) - self.stop = wx.Button(self.panel, wx.NewId(), _("Stop")) - self.next = wx.Button(self.panel, wx.NewId(), _("Next")) + self.previous = wx.Button(self.panel, wx.NewId(), _(u"Previous")) + self.play = wx.Button(self.panel, wx.NewId(), _(u"Play")) + self.stop = wx.Button(self.panel, wx.NewId(), _(u"Stop")) + self.next = wx.Button(self.panel, wx.NewId(), _(u"Next")) box2.Add(self.previous) box2.Add(self.play, flag=wx.RIGHT, border=5) box2.Add(self.stop) @@ -116,5 +116,5 @@ class mainWindow(wx.Frame): try: self.notification = wx.adv.NotificationMessage(title, text, parent=self) except AttributeError: - self.notification = wx.NotificationMessage(title, text, parent=self) + self.notification = wx.NotificationMessage(title, text) self.notification.Show() \ No newline at end of file diff --git a/src/wxUI/menus.py b/src/wxUI/menus.py index ad0fffc..1eed723 100644 --- a/src/wxUI/menus.py +++ b/src/wxUI/menus.py @@ -1,10 +1,15 @@ # -*- coding: utf-8 -*- import wx +import application class contextMenu(wx.Menu): def __init__(self, *args, **kwargs): super(contextMenu, self).__init__(*args, **kwargs) - self.play = wx.MenuItem(self, wx.NewId(), _("Play/Pause")) - self.Append(self.play) - self.download = wx.MenuItem(self, wx.NewId(), _("Download")) - self.Append(self.download) + self.play = wx.MenuItem(self, wx.NewId(), _(u"Play/Pause")) + self.download = wx.MenuItem(self, wx.NewId(), _(u"Download")) + if application.python_version == 3: + self.Append(self.play) + self.Append(self.download) + else: + self.AppendItem(self.play) + self.AppendItem(self.download)