Hi, Robbin,
Sorry to trouble you again. Here is my code:
from wxPython.wx import *
import os
ID_CONNECT = 101
ID_DISCONNECT = 102
ID_EXIT = 103
class MyFrame(wxFrame):
title = "Phone Bill"
def __init__(self, parent):
wxFrame.__init__(self, parent, -1, self.title,
wxDefaultPosition, wxSize(600, 400))
self.CreateStatusBar()
self.MakeMenu()
self.SetStatusText("Phone Bill Application")
self.id = 0
def MakeMenu(self):
menu1 = wxMenu()
menu1.Append(ID_CONNECT, "Connect", "Connect to the database", checkable = true)
menu1.Append(ID_DISCONNECT, "Disconnect", "Disconnect to the database", checkable = true)
menu1.Append(ID_EXIT, "Exit", "Quit the application", checkable = true)
EVT_MENU_RANGE(self, ID_CONNECT, ID_EXIT, self.setID)
EVT_UPDATE_UI_RANGE(self, ID_CONNECT, ID_EXIT, self.onCheckMenu)
EVT_MENU(self, ID_CONNECT, self.connect)
EVT_MENU(self, ID_DISCONNECT, self.disconnect)
EVT_MENU(self, ID_EXIT, self.exit)
menuBar = wxMenuBar()
menuBar.Append(menu1, "File");
self.SetMenuBar(menuBar)
def onCheckMenu(self,event):
if event.GetId() == self.id:
event.Check(true)
else:
event.Check(false)
def setID(self, event):
self.id = event.GetId()
def connect(self,event):
pass
def disconnect(self,event):
pass
def exit(self,event):
dlg = wxMessageDialog(self, 'Are you sure you want to exit the program?',
'Reconfirmation', wxYES_NO| wxICON_INFORMATION)
if dlg.ShowModal() == wxID_YES:
self.Close()
dlg.Destroy()
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL)
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
···
#-----------------------------------------------------
Thanks a lot.
Jenny
ps. Hope this time the code looks fine!
From: "Robin Dunn" <robin@alldunn.com>
Reply-To: wxpython-users@lists.wxwindows.org
To: <wxpython-users@lists.wxwindows.org>
Subject: Re: [wxPython] how can I get both check mark and event work at the menu item?
Date: Tue, 19 Jun 2001 14:21:52 -0700> Hi, Robin,
> Here I post my code again, you would find that I did implement those
events,Try sending your mail as plain text, not HTML. I do not see a onCheckMenu
in your code, only a "&nnbsp;pass" in the middle where I would expect it and
a bunch of other code to be.Please everyone, set your mailers to send plain text to this list. And if
you paste in code, make sure it doesn't have leading tabs. If you wonder
why, take a look at
http://lists.wxwindows.org/pipermail/wxpython-users/2001-June/006110.html
which is what messages like this look like to someone who doesn't have a
HTML capble mail reader, is getting the list traffic in digest form, or who
is browsing the archives.--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com