wxwindows event function arguments

lotmr stealthwang at gmail.com
Thu Apr 7 19:55:50 EDT 2005


I have a windows launch bar application that sits in the system tray.
What I want to do is when i click on a button in the launch menu, it
calls the event which then calls 'OnLaunch('path')' this does not seem
possible. When I change 'OnLaunch(self, event)' to 'OnLaunch(self,
event, path)' it says I dont have enough arguments. When I remove
'event', the OnLaunch runs as soon as the program loads. Using Google I
can absolutly not find a way to pass arguments to a function called by
a event. If indeed it is absolutly impossible, what could be the best
alternate possibility?

Any help would be appreciated,
Nils Lundquist

CODE:

from wxPython.wx import *
import os, sys
class MainWindow(wxFrame):
    def OnAbout (self, event):
        m = wxMessageDialog( self, " LUNCH Bar 0.1 \n"
                             " A launch bar written in Python using
wxWindows","About LUNCH", wxOK)
        m.ShowModal()
        m.Destroy
    def OnExit (self, event):
        self.tbi.Destroy()
        sys.exit()
    def OnTrayRight (self, event):
    	self.PopupMenu(self.rhtmenu)
    def OnLaunch (self, event):
        print event.GetString()
        path = 'D:\Program Files\Mozilla Firefox\Firefox.exe'
        os.startfile(path)
    def __init__(self,parent,id,title):
        wxID_FIREFOX = 1117
        wxFrame.__init__(self,parent,wxID_ANY, title, size = (
200,100),
            style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
	self.tbi = wxTaskBarIcon()
	icon = wxIcon('package.ico',wxBITMAP_TYPE_ICO)
	self.tbi.SetIcon(icon, '')
        self.rhtmenu = wxMenu()
    	icon = wxBitmap(name = 'ffico.png', type = wxBITMAP_TYPE_PNG)
    	item = wxMenuItem(parentMenu = self.rhtmenu, id = wxID_FIREFOX,
text='Firefox')
    	item.SetBitmap(icon)
    	self.rhtmenu.Append(wxID_EXIT, "&Exit"," Terminate this program")
    	self.rhtmenu.Append(wxID_ABOUT, "&About"," Information about this
program")
    	self.rhtmenu.AppendSeparator()
    	self.rhtmenu.AppendItem(item)
        EVT_TASKBAR_RIGHT_UP(self.tbi, self.OnTrayRight)
        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()




More information about the Python-list mailing list