projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added taborder sample
[wxWidgets.git]
/
wxPython
/
demo
/
Menu.py
diff --git
a/wxPython/demo/Menu.py
b/wxPython/demo/Menu.py
index 516241efcf0b4030feb1eb89549f527e8a7abfe7..57bd44ce8077d91c37f1d6b147e7a77d81d2eaad 100644
(file)
--- a/
wxPython/demo/Menu.py
+++ b/
wxPython/demo/Menu.py
@@
-4,10
+4,12
@@
# menus in wxPython 2.3.3
#
#-------------------------------------------------------------------
# menus in wxPython 2.3.3
#
#-------------------------------------------------------------------
-# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
#
-# o Updated for wx namespace
-#
+# o Debug message when adding a menu item (see last menu):
+#
+# Debug: ..\..\src\msw\menuitem.cpp(370): 'GetMenuState' failed with
+# error 0x00000002 (the system cannot find the file specified.).
+#
import time
import wx
import time
import wx
@@
-133,13
+135,13
@@
check the source for this sample to see how to implement them.
# Methods
def OnMenuHighlight(self, event):
# Methods
def OnMenuHighlight(self, event):
- # Show how to get menu item i
m
fo from this event handler
+ # Show how to get menu item i
n
fo from this event handler
id = event.GetMenuId()
item = self.GetMenuBar().FindItemById(id)
id = event.GetMenuId()
item = self.GetMenuBar().FindItemById(id)
- text = item.GetText()
- help = item.GetHelp()
+ if item:
+ text = item.GetText()
+ help = item.GetHelp()
- #print text, help
# but in this case just call Skip so the default is done
event.Skip()
# but in this case just call Skip so the default is done
event.Skip()
@@
-249,21
+251,34
@@
check the source for this sample to see how to implement them.
menu.InsertItem(pos, item)
menu.InsertItem(pos, item)
-#-------------------------------------------------------------------
+#-------------------------------------------------------------------
--------
-wx.RegisterId(10000)
+class TestPanel(wx.Panel):
+ def __init__(self, parent, log):
+ self.log = log
+ wx.Panel.__init__(self, parent, -1)
+
+ b = wx.Button(self, -1, "Show the Menu sample", (50,50))
+ self.Bind(wx.EVT_BUTTON, self.OnButton, b)
-def runTest(frame, nb, log):
- win = MyFrame(frame, -1, log)
- frame.otherWin = win
- win.Show(True)
+ def OnButton(self, evt):
+ win = MyFrame(self, -1, self.log)
+ win.Show(True)
+
+
+#---------------------------------------------------------------------------
+
+
+def runTest(frame, nb, log):
+ win = TestPanel(nb, log)
+ return win
#-------------------------------------------------------------------
overview = """\
#-------------------------------------------------------------------
overview = """\
-A demo of using wx
MenuBar and wx
Menu in various ways.
+A demo of using wx
.MenuBar and wx.
Menu in various ways.
A menu is a popup (or pull down) list of items, one of which may be selected
before the menu goes away (clicking elsewhere dismisses the menu). Menus may be
A menu is a popup (or pull down) list of items, one of which may be selected
before the menu goes away (clicking elsewhere dismisses the menu). Menus may be
@@
-278,7
+293,7
@@
Menu items may be either normal items, check items or radio items. Normal items
don't have any special properties while the check items have a boolean flag associated
to them and they show a checkmark in the menu when the flag is set. wxWindows
automatically toggles the flag value when the item is clicked and its value may
don't have any special properties while the check items have a boolean flag associated
to them and they show a checkmark in the menu when the flag is set. wxWindows
automatically toggles the flag value when the item is clicked and its value may
-be retrieved using either IsChecked method of wx
Menu or wx
MenuBar itself or by
+be retrieved using either IsChecked method of wx
.Menu or wx.
MenuBar itself or by
using wxEvent.IsChecked when you get the menu notification for the item in question.
The radio items are similar to the check items except that all the other items
using wxEvent.IsChecked when you get the menu notification for the item in question.
The radio items are similar to the check items except that all the other items
@@
-296,5
+311,5
@@
and GTK+ currently.
if __name__ == '__main__':
import sys,os
import run
if __name__ == '__main__':
import sys,os
import run
- run.main(['', os.path.basename(sys.argv[0])])
+ run.main(['', os.path.basename(sys.argv[0])]
+ sys.argv[1:]
)