Getting ready for build

This commit is contained in:
Ruud
2012-09-09 17:28:23 +02:00
parent 5d4efb60cf
commit ac081d3e10
5 changed files with 77 additions and 47 deletions
+57 -26
View File
@@ -2,8 +2,10 @@ from threading import Thread
from wx.lib.softwareupdate import SoftwareUpdate
import os
import sys
import time
import webbrowser
import wx
import subprocess
# Include proper dirs
@@ -24,9 +26,12 @@ class TaskBarIcon(wx.TaskBarIcon):
TBMENU_OPEN = wx.NewId()
TBMENU_SETTINGS = wx.NewId()
TBMENU_ABOUT = wx.ID_ABOUT
TBMENU_EXIT = wx.ID_EXIT
closed = False
menu = False
enabled = False
def __init__(self, frame):
wx.TaskBarIcon.__init__(self)
self.frame = frame
@@ -34,21 +39,42 @@ class TaskBarIcon(wx.TaskBarIcon):
icon = wx.Icon('icon.png', wx.BITMAP_TYPE_PNG)
self.SetIcon(icon)
self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.onTaskBarActivate)
self.Bind(wx.EVT_TASKBAR_LEFT_UP, self.OnTaskBarClick)
self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTaskBarClick)
self.Bind(wx.EVT_MENU, self.onOpen, id = self.TBMENU_OPEN)
self.Bind(wx.EVT_MENU, self.onSettings, id = self.TBMENU_SETTINGS)
self.Bind(wx.EVT_MENU, self.onAbout, id = self.TBMENU_ABOUT)
self.Bind(wx.EVT_MENU, self.onTaskBarClose, id = self.TBMENU_EXIT)
def OnTaskBarClick(self, evt):
menu = self.CreatePopupMenu()
self.PopupMenu(menu)
menu.Destroy()
def enable(self):
self.enabled = True
if self.menu:
self.open_menu.Enable(True)
self.setting_menu.Enable(True)
self.open_menu.SetText('Open')
def CreatePopupMenu(self):
menu = wx.Menu()
menu.Append(self.TBMENU_OPEN, "Open")
menu.Append(self.TBMENU_SETTINGS, "Settings")
menu.Append(self.TBMENU_ABOUT, "About")
menu.Append(self.TBMENU_EXIT, "Close")
return menu
if not self.menu:
self.menu = wx.Menu()
self.open_menu = self.menu.Append(self.TBMENU_OPEN, 'Open')
self.setting_menu = self.menu.Append(self.TBMENU_SETTINGS, 'About')
self.exit_menu = self.menu.Append(self.TBMENU_EXIT, 'Quit')
if not self.enabled:
self.open_menu.Enable(False)
self.setting_menu.Enable(False)
self.open_menu.SetText('Loading...')
return self.menu
def onOpen(self, event):
url = self.frame.parent.getSetting('base_url')
@@ -58,17 +84,16 @@ class TaskBarIcon(wx.TaskBarIcon):
url = self.frame.parent.getSetting('base_url') + '/settings/'
webbrowser.open(url)
def onAbout(self, event):
print 'onAbout'
def onTaskBarActivate(self, evt):
if not self.frame.IsShown():
self.frame.Show(True)
self.frame.Raise()
def onTaskBarClose(self, evt):
if self.closed:
return
self.closed = True
self.RemoveIcon()
wx.CallAfter(self.frame.Close)
def makeIcon(self, img):
if "wxMSW" in wx.PlatformInfo:
img = img.Scale(16, 16)
@@ -82,7 +107,7 @@ class TaskBarIcon(wx.TaskBarIcon):
class MainFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, None)
wx.Frame.__init__(self, None, style = wx.FRAME_NO_TASKBAR)
self.parent = parent
self.tbicon = TaskBarIcon(self)
@@ -136,6 +161,7 @@ class CouchPotatoApp(wx.App, SoftwareUpdate):
settings = {}
events = {}
restart = False
closing = False
def OnInit(self):
@@ -152,6 +178,9 @@ class CouchPotatoApp(wx.App, SoftwareUpdate):
return True
def onAppLoad(self):
self.frame.tbicon.enable()
def setSettings(self, settings = {}):
self.settings = settings
@@ -164,24 +193,26 @@ class CouchPotatoApp(wx.App, SoftwareUpdate):
def onClose(self, event):
onClose = self.events.get('onClose')
if self.events.get('onClose'):
if not self.closing:
self.closing = True
self.frame.tbicon.onTaskBarClose(event)
onClose = self.events.get('onClose')
onClose(event)
else:
self.afterShutdown()
def afterShutdown(self, restart = False):
self.frame.Destroy()
self.restart = restart
self.ExitMainLoop()
if __name__ == '__main__':
app = CouchPotatoApp(redirect = False)
app.MainLoop()
path = os.path.join(sys.path[0].decode(sys.getfilesystemencoding()), sys.argv[0])
time.sleep(1)
if app.restart:
pass
#wx.Process.Open(path)
args = [sys.executable] + [os.path.join(base_path, 'Desktop.py')] + sys.argv[1:]
subprocess.Popen(args)
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 345 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 543 B

+20 -21
View File
@@ -16,7 +16,6 @@ def getDataFiles(dirs):
data_files = []
for directory in dirs:
for root, dirs, files in os.walk(directory):
print files
if files:
for filename in files:
if filename[:-4] is not '.pyc':
@@ -24,6 +23,19 @@ def getDataFiles(dirs):
return data_files
includes = [
'telnetlib',
'xml.etree.ElementTree',
'xml.etree.cElementTree',
'xml.dom',
'xml.dom.minidom',
'netrc',
'csv',
'HTMLParser',
'version',
'distutils',
]
# Windows
if sys.platform == "win32":
import py2exe
@@ -39,19 +51,12 @@ if sys.platform == "win32":
'USP10.dll',
],
packages = ['couchpotato', 'libs'],
includes = [
'telnetlib',
'xml.etree.ElementTree',
'xml.etree.cElementTree',
'xml.dom',
'xml.dom.minidom',
'netrc',
'csv',
],
includes = includes,
skip_archive = 1,
)
exeICON = 'icon.ico'
exeICON = os.path.join(base_path, 'icon.ico')
DATA_FILES = getDataFiles([r'.\\couchpotato', r'.\\libs'])
DATA_FILES.append('icon.png')
# OSX
@@ -60,28 +65,22 @@ elif sys.platform == "darwin":
FREEZER = 'py2app'
FREEZER_OPTIONS = dict(
strip = True,
argv_emulation = False,
site_packages = False,
iconfile = 'icon.icns',
plist = dict(
LSUIElement = True,
),
packages = ['couchpotato', 'libs'],
includes = [
'telnetlib',
'xml.etree.ElementTree',
'xml.etree.cElementTree',
'xml.dom',
'xml.dom.minidom',
'netrc',
'csv',
],
includes = includes,
)
exeICON = None
DATA_FILES = ['icon.png']
# Common
NAME = "CouchPotato"
APP = [bdist_esky.Executable("Desktop.py", name = NAME, icon = exeICON,)]
APP = [bdist_esky.Executable("Desktop.py", name = NAME, icon = exeICON, gui_only = True,)]
ESKY_OPTIONS = dict(
freezer_module = FREEZER,
freezer_options = FREEZER_OPTIONS,