All pastes #367001 Raw Edit

scabootssca

public python v1 · immutable
#367001 ·published 2007-02-22 01:26 UTC
rendered paste body
import wx#MyFrame is the actual program windowclass MyFrame(wx.Frame):    def __init__(self,parent,id,title,app):        wx.Frame.__init__(self,parent,id,title,wx.DefaultPosition,wx.Size(600,400))        self.app = app        # Bind Da Shitz        self.Bind(wx.EVT_ICONIZE, self.onMinimize)        self.Bind(wx.EVT_CLOSE, self.onQuit)    #This is activated when the window is minimized    def onMinimize(self,event):        self.Hide() #    #This happens when the window is closed    def onQuit(self,event):        self.Destroy() #Kill the window        self.app.tray.Destroy() #Kill the tray icon#MyIcon is the taskbar iconclass MyIcon(wx.TaskBarIcon):    def __init__(self, app):        wx.TaskBarIcon.__init__(self)        # Some values        self.app = app        self.TBMENU_QUIT = wx.NewId()        # Set the image        self.SetIcon(self.app.makeIcon("icon.png"), "irc")         # bind some events        self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.onTaskbarLeft)        self.Bind(wx.EVT_MENU,self.onTaskbarQuit,id=self.TBMENU_QUIT)    def onTaskbarLeft(self,event):        if self.app.frame.IsIconized():            try: self.app.frame.Iconize(False)            except: pass        if not self.app.frame.IsShown():            self.app.frame.Show(True)        self.app.frame.Raise()    def onTaskbarQuit(self,event):        self.app.frame.Destroy() #Kill the Window        self.Destroy() #Kille the icon    def CreatePopupMenu(self):        menu = wx.Menu()        menu.Append(self.TBMENU_QUIT,"Quit")        return menuclass MyApp(wx.App):    def OnInit(self):        self.frame = MyFrame(None,-1,"",self) #Make the window        self.frame.Show() #Show the window         self.tray = MyIcon(self)        return 1        def makeIcon(self, img):        """        The various platforms have different requirements for the        icon size...        """        img = wx.Image("icon.png")        if "wxMSW" in wx.PlatformInfo:            img = img.Scale(16, 16)        elif "wxGTK" in wx.PlatformInfo:            img = img.Scale(22, 22)        # wxMac can be any size upto 128x128, so leave the source img alone....        icon = wx.IconFromBitmap(img.ConvertToBitmap())        return iconapp = MyApp()app.MainLoop()