Getting ready for build
This commit is contained in:
1 parent
5d4efb60cf
commit
ac081d3e10
5 files changed
+77
-47
No files matched your search
+57
-26
@@ -2,8 +2,10 @@ from threading import Thread
|
|||||||
from wx.lib.softwareupdate import SoftwareUpdate
|
from wx.lib.softwareupdate import SoftwareUpdate
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import wx
|
import wx
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
# Include proper dirs
|
# Include proper dirs
|
||||||
@@ -24,9 +26,12 @@ class TaskBarIcon(wx.TaskBarIcon):
|
|||||||
|
|
||||||
TBMENU_OPEN = wx.NewId()
|
TBMENU_OPEN = wx.NewId()
|
||||||
TBMENU_SETTINGS = wx.NewId()
|
TBMENU_SETTINGS = wx.NewId()
|
||||||
TBMENU_ABOUT = wx.ID_ABOUT
|
|
||||||
TBMENU_EXIT = wx.ID_EXIT
|
TBMENU_EXIT = wx.ID_EXIT
|
||||||
|
|
||||||
|
closed = False
|
||||||
|
menu = False
|
||||||
|
enabled = False
|
||||||
|
|
||||||
def __init__(self, frame):
|
def __init__(self, frame):
|
||||||
wx.TaskBarIcon.__init__(self)
|
wx.TaskBarIcon.__init__(self)
|
||||||
self.frame = frame
|
self.frame = frame
|
||||||
@@ -34,21 +39,42 @@ class TaskBarIcon(wx.TaskBarIcon):
|
|||||||
icon = wx.Icon('icon.png', wx.BITMAP_TYPE_PNG)
|
icon = wx.Icon('icon.png', wx.BITMAP_TYPE_PNG)
|
||||||
self.SetIcon(icon)
|
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.onOpen, id = self.TBMENU_OPEN)
|
||||||
self.Bind(wx.EVT_MENU, self.onSettings, id = self.TBMENU_SETTINGS)
|
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)
|
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):
|
def CreatePopupMenu(self):
|
||||||
menu = wx.Menu()
|
|
||||||
menu.Append(self.TBMENU_OPEN, "Open")
|
if not self.menu:
|
||||||
menu.Append(self.TBMENU_SETTINGS, "Settings")
|
self.menu = wx.Menu()
|
||||||
menu.Append(self.TBMENU_ABOUT, "About")
|
self.open_menu = self.menu.Append(self.TBMENU_OPEN, 'Open')
|
||||||
menu.Append(self.TBMENU_EXIT, "Close")
|
self.setting_menu = self.menu.Append(self.TBMENU_SETTINGS, 'About')
|
||||||
return menu
|
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):
|
def onOpen(self, event):
|
||||||
url = self.frame.parent.getSetting('base_url')
|
url = self.frame.parent.getSetting('base_url')
|
||||||
@@ -58,17 +84,16 @@ class TaskBarIcon(wx.TaskBarIcon):
|
|||||||
url = self.frame.parent.getSetting('base_url') + '/settings/'
|
url = self.frame.parent.getSetting('base_url') + '/settings/'
|
||||||
webbrowser.open(url)
|
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):
|
def onTaskBarClose(self, evt):
|
||||||
|
if self.closed:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.closed = True
|
||||||
|
|
||||||
|
self.RemoveIcon()
|
||||||
wx.CallAfter(self.frame.Close)
|
wx.CallAfter(self.frame.Close)
|
||||||
|
|
||||||
|
|
||||||
def makeIcon(self, img):
|
def makeIcon(self, img):
|
||||||
if "wxMSW" in wx.PlatformInfo:
|
if "wxMSW" in wx.PlatformInfo:
|
||||||
img = img.Scale(16, 16)
|
img = img.Scale(16, 16)
|
||||||
@@ -82,7 +107,7 @@ class TaskBarIcon(wx.TaskBarIcon):
|
|||||||
class MainFrame(wx.Frame):
|
class MainFrame(wx.Frame):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
wx.Frame.__init__(self, None)
|
wx.Frame.__init__(self, None, style = wx.FRAME_NO_TASKBAR)
|
||||||
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.tbicon = TaskBarIcon(self)
|
self.tbicon = TaskBarIcon(self)
|
||||||
@@ -136,6 +161,7 @@ class CouchPotatoApp(wx.App, SoftwareUpdate):
|
|||||||
settings = {}
|
settings = {}
|
||||||
events = {}
|
events = {}
|
||||||
restart = False
|
restart = False
|
||||||
|
closing = False
|
||||||
|
|
||||||
def OnInit(self):
|
def OnInit(self):
|
||||||
|
|
||||||
@@ -152,6 +178,9 @@ class CouchPotatoApp(wx.App, SoftwareUpdate):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def onAppLoad(self):
|
||||||
|
self.frame.tbicon.enable()
|
||||||
|
|
||||||
def setSettings(self, settings = {}):
|
def setSettings(self, settings = {}):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
|
|
||||||
@@ -164,24 +193,26 @@ class CouchPotatoApp(wx.App, SoftwareUpdate):
|
|||||||
|
|
||||||
def onClose(self, event):
|
def onClose(self, event):
|
||||||
|
|
||||||
onClose = self.events.get('onClose')
|
if not self.closing:
|
||||||
if self.events.get('onClose'):
|
self.closing = True
|
||||||
|
self.frame.tbicon.onTaskBarClose(event)
|
||||||
|
|
||||||
|
onClose = self.events.get('onClose')
|
||||||
onClose(event)
|
onClose(event)
|
||||||
else:
|
|
||||||
self.afterShutdown()
|
|
||||||
|
|
||||||
def afterShutdown(self, restart = False):
|
def afterShutdown(self, restart = False):
|
||||||
self.frame.Destroy()
|
self.frame.Destroy()
|
||||||
self.restart = restart
|
self.restart = restart
|
||||||
|
|
||||||
self.ExitMainLoop()
|
self.ExitMainLoop()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
app = CouchPotatoApp(redirect = False)
|
app = CouchPotatoApp(redirect = False)
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
path = os.path.join(sys.path[0].decode(sys.getfilesystemencoding()), sys.argv[0])
|
time.sleep(1)
|
||||||
|
|
||||||
if app.restart:
|
if app.restart:
|
||||||
pass
|
args = [sys.executable] + [os.path.join(base_path, 'Desktop.py')] + sys.argv[1:]
|
||||||
#wx.Process.Open(path)
|
subprocess.Popen(args)
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 345 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 543 B |
@@ -16,7 +16,6 @@ def getDataFiles(dirs):
|
|||||||
data_files = []
|
data_files = []
|
||||||
for directory in dirs:
|
for directory in dirs:
|
||||||
for root, dirs, files in os.walk(directory):
|
for root, dirs, files in os.walk(directory):
|
||||||
print files
|
|
||||||
if files:
|
if files:
|
||||||
for filename in files:
|
for filename in files:
|
||||||
if filename[:-4] is not '.pyc':
|
if filename[:-4] is not '.pyc':
|
||||||
@@ -24,6 +23,19 @@ def getDataFiles(dirs):
|
|||||||
|
|
||||||
return data_files
|
return data_files
|
||||||
|
|
||||||
|
includes = [
|
||||||
|
'telnetlib',
|
||||||
|
'xml.etree.ElementTree',
|
||||||
|
'xml.etree.cElementTree',
|
||||||
|
'xml.dom',
|
||||||
|
'xml.dom.minidom',
|
||||||
|
'netrc',
|
||||||
|
'csv',
|
||||||
|
'HTMLParser',
|
||||||
|
'version',
|
||||||
|
'distutils',
|
||||||
|
]
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
import py2exe
|
import py2exe
|
||||||
@@ -39,19 +51,12 @@ if sys.platform == "win32":
|
|||||||
'USP10.dll',
|
'USP10.dll',
|
||||||
],
|
],
|
||||||
packages = ['couchpotato', 'libs'],
|
packages = ['couchpotato', 'libs'],
|
||||||
includes = [
|
includes = includes,
|
||||||
'telnetlib',
|
|
||||||
'xml.etree.ElementTree',
|
|
||||||
'xml.etree.cElementTree',
|
|
||||||
'xml.dom',
|
|
||||||
'xml.dom.minidom',
|
|
||||||
'netrc',
|
|
||||||
'csv',
|
|
||||||
],
|
|
||||||
skip_archive = 1,
|
skip_archive = 1,
|
||||||
)
|
)
|
||||||
exeICON = 'icon.ico'
|
exeICON = os.path.join(base_path, 'icon.ico')
|
||||||
DATA_FILES = getDataFiles([r'.\\couchpotato', r'.\\libs'])
|
DATA_FILES = getDataFiles([r'.\\couchpotato', r'.\\libs'])
|
||||||
|
DATA_FILES.append('icon.png')
|
||||||
|
|
||||||
|
|
||||||
# OSX
|
# OSX
|
||||||
@@ -60,28 +65,22 @@ elif sys.platform == "darwin":
|
|||||||
|
|
||||||
FREEZER = 'py2app'
|
FREEZER = 'py2app'
|
||||||
FREEZER_OPTIONS = dict(
|
FREEZER_OPTIONS = dict(
|
||||||
|
strip = True,
|
||||||
argv_emulation = False,
|
argv_emulation = False,
|
||||||
|
site_packages = False,
|
||||||
iconfile = 'icon.icns',
|
iconfile = 'icon.icns',
|
||||||
plist = dict(
|
plist = dict(
|
||||||
LSUIElement = True,
|
LSUIElement = True,
|
||||||
),
|
),
|
||||||
packages = ['couchpotato', 'libs'],
|
packages = ['couchpotato', 'libs'],
|
||||||
includes = [
|
includes = includes,
|
||||||
'telnetlib',
|
|
||||||
'xml.etree.ElementTree',
|
|
||||||
'xml.etree.cElementTree',
|
|
||||||
'xml.dom',
|
|
||||||
'xml.dom.minidom',
|
|
||||||
'netrc',
|
|
||||||
'csv',
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
exeICON = None
|
exeICON = None
|
||||||
DATA_FILES = ['icon.png']
|
DATA_FILES = ['icon.png']
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
NAME = "CouchPotato"
|
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(
|
ESKY_OPTIONS = dict(
|
||||||
freezer_module = FREEZER,
|
freezer_module = FREEZER,
|
||||||
freezer_options = FREEZER_OPTIONS,
|
freezer_options = FREEZER_OPTIONS,
|
||||||
|
|||||||
Reference in new issue
Block a user