I have previously posted a simple app I am working on, and while I love
python and wxWindows, after checking the memory usage on such a simple
app (system try application launcher) I see that it climbs to over
17mb! I have reduced all my imports to the bare workable minimum and
that just gets it under 17mb. Is there any way that I could compile or
optimize the my program and/or its memory usage?
(Note: I don't have a problem with making this program win32 specific,
as it already is only win32)
CODE:
#this section broken down soley for readability, normally one line
from wxPython.wx import wxMessageDialog ,wxFrame,wxMenu ,
wxBitmap,wxOK,w xID_ANY,wxID_EX IT,wxID_ABOUT,
wxBITMAP_TYPE_I CO,wxBITMAP_TYP E_PNG,wxMenuIte m,
wxPySimpleApp,w xTaskBarIcon,wx Icon,EVT_TASKBA R_RIGHT_UP,EVT_ MENU
#end
from os import startfile
from sys import exit
class MainWindow(wxFr ame):
def OnAbout (self, event):
m = wxMessageDialog ( self, " LUNCH Bar 0.1 \n"
" A launch bar written in Python using
wxWindows","Abo ut LUNCH", wxOK)
m.ShowModal()
m.Destroy
def OnExit (self, event):
self.tbi.Destro y()
exit()
def OnTrayRight (self, event):
self.PopupMenu( self.rhtmenu)
def OnLaunch (self, event):
print event.GetString ()
path = 'D:\Program Files\Mozilla Firefox\Firefox .exe'
startfile(path)
def __init__(self,p arent,id,title) :
wxID_FIREFOX = 1117
wxFrame.__init_ _(self,parent,w xID_ANY, title, size = (
200,100))
self.tbi = wxTaskBarIcon()
icon = wxIcon('package .ico',wxBITMAP_ TYPE_ICO)
self.tbi.SetIco n(icon, '')
self.rhtmenu = wxMenu()
icon = wxBitmap(name = 'ffico.png', type = wxBITMAP_TYPE_P NG)
item = wxMenuItem(pare ntMenu = self.rhtmenu, id = wxID_FIREFOX,
text='Firefox')
item.SetBitmap( icon)
self.rhtmenu.Ap pend(wxID_EXIT, "&Exit"," Terminate this program")
self.rhtmenu.Ap pend(wxID_ABOUT , "&About"," Information about this
program")
self.rhtmenu.Ap pendSeparator()
self.rhtmenu.Ap pendItem(item)
EVT_TASKBAR_RIG HT_UP(self.tbi, self.OnTrayRigh t)
EVT_MENU(self, wxID_ABOUT, self.OnAbout)
EVT_MENU(self, wxID_EXIT, self.OnExit)
EVT_MENU(self, wxID_FIREFOX, self.OnLaunch)
appwin = wxPySimpleApp()
frame = MainWindow(None , -1, "Small editor")
appwin.MainLoop ()
python and wxWindows, after checking the memory usage on such a simple
app (system try application launcher) I see that it climbs to over
17mb! I have reduced all my imports to the bare workable minimum and
that just gets it under 17mb. Is there any way that I could compile or
optimize the my program and/or its memory usage?
(Note: I don't have a problem with making this program win32 specific,
as it already is only win32)
CODE:
#this section broken down soley for readability, normally one line
from wxPython.wx import wxMessageDialog ,wxFrame,wxMenu ,
wxBitmap,wxOK,w xID_ANY,wxID_EX IT,wxID_ABOUT,
wxBITMAP_TYPE_I CO,wxBITMAP_TYP E_PNG,wxMenuIte m,
wxPySimpleApp,w xTaskBarIcon,wx Icon,EVT_TASKBA R_RIGHT_UP,EVT_ MENU
#end
from os import startfile
from sys import exit
class MainWindow(wxFr ame):
def OnAbout (self, event):
m = wxMessageDialog ( self, " LUNCH Bar 0.1 \n"
" A launch bar written in Python using
wxWindows","Abo ut LUNCH", wxOK)
m.ShowModal()
m.Destroy
def OnExit (self, event):
self.tbi.Destro y()
exit()
def OnTrayRight (self, event):
self.PopupMenu( self.rhtmenu)
def OnLaunch (self, event):
print event.GetString ()
path = 'D:\Program Files\Mozilla Firefox\Firefox .exe'
startfile(path)
def __init__(self,p arent,id,title) :
wxID_FIREFOX = 1117
wxFrame.__init_ _(self,parent,w xID_ANY, title, size = (
200,100))
self.tbi = wxTaskBarIcon()
icon = wxIcon('package .ico',wxBITMAP_ TYPE_ICO)
self.tbi.SetIco n(icon, '')
self.rhtmenu = wxMenu()
icon = wxBitmap(name = 'ffico.png', type = wxBITMAP_TYPE_P NG)
item = wxMenuItem(pare ntMenu = self.rhtmenu, id = wxID_FIREFOX,
text='Firefox')
item.SetBitmap( icon)
self.rhtmenu.Ap pend(wxID_EXIT, "&Exit"," Terminate this program")
self.rhtmenu.Ap pend(wxID_ABOUT , "&About"," Information about this
program")
self.rhtmenu.Ap pendSeparator()
self.rhtmenu.Ap pendItem(item)
EVT_TASKBAR_RIG HT_UP(self.tbi, self.OnTrayRigh t)
EVT_MENU(self, wxID_ABOUT, self.OnAbout)
EVT_MENU(self, wxID_EXIT, self.OnExit)
EVT_MENU(self, wxID_FIREFOX, self.OnLaunch)
appwin = wxPySimpleApp()
frame = MainWindow(None , -1, "Small editor")
appwin.MainLoop ()
Comment