I have refactored my code to take your suggestion into account. However, it
still fails to work as I expect it.
Here is a concise example demonstrating my problem:
from wxPython.wx import *
class MainWindow(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self,
parent,
-4,
title,
style=wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
#Create the popup menu
self.popupItem1 = wxNewId()
self.popupItem2 = wxNewId()
self.popupItem3 = wxNewId()
EVT_MENU(self, self.popupItem1, self.OutputBlah)
EVT_MENU(self, self.popupItem2, self.OutputBlah)
EVT_MENU(self, self.popupItem3, self.OutputBlah)
self.submenu = wxMenu()
self.submenu.AppendRadioItem(self.popupItem2, "Choice 1")
self.submenu.AppendRadioItem(self.popupItem3, "Choice 2")
self.menu = wxMenu()
self.menu.AppendMenu(self.popupItem1, "Submenu", self.submenu)
#Register an event handler that will display the popmenu on a right
click
EVT_RIGHT_UP(self, self.OnRightClick)
#Display
self.Show(True)
def OnRightClick(self, event):
self.PopupMenu(self.menu, event.GetPosition())
def OutputBlah(self, event):
print "Blah."
app = wxPySimpleApp()
frame = MainWindow(None, -1, "Popup")
app.MainLoop()
-----Message d'origine-----
···
De : Robin Dunn [mailto:robin@alldunn.com]
Envoyé : Tuesday, February 24, 2004 12:44 PM
À : wxPython-users@lists.wxwindows.org
Objet : Re: [wxPython-users] Popup menu and radio items
CÔTÉ Marc-Alexis wrote:
Hello
I have a Popup menu with 3 "radio items". Is there a way for the
checking/unchecking to be done automatically? Looking at the demo, it
seems
to be automatic for normal menus, but I was wondering if it was automatic
for Popup menus as well...
I would think it should be, as long as you are using the same menu each
time you pop it up and not recreating it each time.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
*************************************************************************************
Ce courrier électronique s'adresse uniquement à la personne désignée
ci-dessus, il est confidentiel et ne doit pas être remis à une autre
personne, ni reproduit et son contenu ne peut être autrement divulgué.
Si ce courrier électronique vous est transmis par erreur, veuillez
nous en avertir immédiatement à l'adresse securite@ino.ca. Nous
vous remercions de votre collaboration.
This email is directed in confidence solely to the person named above,
and may not otherwise be distributed, copied or disclosed. If you have
received this email by error, please notify us immediately by email to
address security@ino.ca. Thank you for your cooperation.
***********************************************************************************