Added menu sample, and some other minor changes to the demo
authorRobin Dunn <robin@alldunn.com>
Tue, 2 Jul 2002 17:08:55 +0000 (17:08 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 2 Jul 2002 17:08:55 +0000 (17:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/Main.py
wxPython/demo/ScrolledPanel.py
wxPython/demo/wxListCtrl.py
wxPython/demo/wxMenu.py [new file with mode: 0644]
wxPython/demo/wxTreeCtrl.py

index e9beb449ad2e049d77b40e5854a93daa266223c3..e91c7cb8e31a4c90a38d6925ce790423adb8ed34 100644 (file)
@@ -32,6 +32,7 @@ _treeList = [
         'wxImageFromStream',
         'wxArtProvider',
         'ScrolledPanel',
+        'wxMenu',
         ]),
 
     # managed windows == things with a caption you can close
@@ -78,6 +79,7 @@ _treeList = [
         'wxListBox',
         'wxListCtrl',
         'wxListCtrl_virtual',
+        'wxMenu',
         'wxNotebook',
         'wxPopupWindow',
         'wxRadioBox',
index e4a0bb507df63df4c5ce26d48d0928709b74be02..bd54d5bf2913d62d1fb99047523f3320890b3a83 100644 (file)
@@ -10,8 +10,7 @@ class ScrolledPanel(wxScrolledWindow):
     def __init__(self, parent, log):
         self.log = log
         wxScrolledWindow.__init__(self, parent, -1,
-                                  style = wxTAB_TRAVERSAL|wxHSCROLL|wxVSCROLL)
-
+                                  style = wxTAB_TRAVERSAL)
 
         box = wxBoxSizer(wxVERTICAL)
         box.Add(wxStaticText(self, -1,
@@ -73,10 +72,6 @@ class ScrolledPanel(wxScrolledWindow):
 
 #----------------------------------------------------------------------
 
-## class ScrollToHandler(wxEvtHandler):
-##     """This class helps to scroll the panel
-
-#----------------------------------------------------------------------
 
 def runTest(frame, nb, log):
     win = ScrolledPanel(nb, log)
index bce9073e98bd28f310ff0b63b75696cb6cb2becf..9c23d2e6749d5d8b21b849682e96f0c5674a6586 100644 (file)
@@ -228,7 +228,10 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
         self.log.WriteText("OnColClick: %d\n" % event.GetColumn())
 
     def OnColRightClick(self, event):
-        self.log.WriteText("OnColRightClick: %d\n" % event.GetColumn())
+        item = self.list.GetColumn(event.GetColumn())
+        self.log.WriteText("OnColRightClick: %d %s\n" %
+                           (event.GetColumn(), (item.GetText(), item.GetAlign(),
+                                                item.GetWidth(), item.GetImage())))
 
     def OnColBeginDrag(self, event):
         self.log.WriteText("OnColBeginDrag\n")
@@ -311,19 +314,17 @@ def runTest(frame, nb, log):
 
 
 
+overview = """\
+A list control presents lists in a number of formats: list view, report view, icon view and small icon view. Elements are numbered from zero.
 
+"""
 
 
 
 
 
+if __name__ == '__main__':
+    import sys,os
+    import run
+    run.main(['', os.path.basename(sys.argv[0])])
 
-
-
-
-
-
-overview = """\
-A list control presents lists in a number of formats: list view, report view, icon view and small icon view. Elements are numbered from zero.
-
-"""
diff --git a/wxPython/demo/wxMenu.py b/wxPython/demo/wxMenu.py
new file mode 100644 (file)
index 0000000..223a222
--- /dev/null
@@ -0,0 +1,165 @@
+#-------------------------------------------------------------------
+# essaimenu.py
+#
+# menus in wxPython 2.3.3
+#
+#-------------------------------------------------------------------
+
+from wxPython.wx import *
+
+#-------------------------------------------------------------------
+
+class MyFrame(wxFrame):
+
+    def __init__(self, parent, id, log):
+        wxFrame.__init__(self, parent, id, 'Playing with menus', size=(400, 200))
+        self.log = log
+        self.CenterOnScreen()
+
+        self.CreateStatusBar()
+        self.SetStatusText("This is the statusbar")
+
+        # Prepare the menu bar
+        menuBar = wxMenuBar()
+
+        # 1st menu from left
+        menu1 = wxMenu()
+        menu1.Append(101, "Mercury", "This the text in the Statusbar")
+        menu1.Append(102, "Venus", "")
+        menu1.Append(103, "Earth", "You may select Earth too")
+        menu1.AppendSeparator()
+        menu1.Append(104, "Exit", "Close this frame")
+        # Add menu to the menu bar
+        menuBar.Append(menu1, "&Planets")
+
+        # 2nd menu from left
+        menu2 = wxMenu()
+        menu2.Append(201, "Hydrogen")
+        menu2.Append(202, "Helium")
+        # a submenu in the 2nd menu
+        submenu = wxMenu()
+        submenu.Append(2031,"Lanthanium")
+        submenu.Append(2032,"Cerium")
+        submenu.Append(2033,"Praseodymium")
+        menu2.AppendMenu(203, "Lanthanides", submenu)
+        # Append 2nd menu
+        menuBar.Append(menu2, "&Elements")
+
+        menu3 = wxMenu()
+        menu3.Append(301, "IDLE", "a Python shell using tcl/tk as GUI", wxITEM_RADIO)
+        menu3.Append(302, "PyCrust", "a Python shell using wxPython as GUI", wxITEM_RADIO)
+        menu3.Append(303, "psi", "a simple Python shell using wxPython as GUI", wxITEM_RADIO)
+        menu3.AppendSeparator()
+        menu3.Append(304, "project1", "", wxITEM_NORMAL)
+        menu3.Append(305, "project2", "", wxITEM_NORMAL)
+        menuBar.Append(menu3, "&Shells")
+
+        menu4 = wxMenu()
+        menu4.Append(401, "letters", "abcde...", wxITEM_CHECK)
+        menu4.Append(402, "digits", "123...", wxITEM_CHECK)
+        menu4.Append(403, "letters and digits", "abcd... + 123...", wxITEM_CHECK)
+        menuBar.Append(menu4, "Chec&k")
+
+        menu5 = wxMenu()
+        menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
+
+        menu5.AppendSeparator()
+        menu5.Append(502, "Hello\tShift+H")
+        menuBar.Append(menu5, "&Fun")
+
+        self.SetMenuBar(menuBar)
+
+        # Menu events
+        EVT_MENU(self, 101, self.Menu101)
+        EVT_MENU(self, 102, self.Menu102)
+        EVT_MENU(self, 103, self.Menu103)
+        EVT_MENU(self, 104, self.OnCloseWindow)
+
+        EVT_MENU(self, 201, self.Menu201)
+        EVT_MENU(self, 202, self.Menu202)
+        EVT_MENU(self, 2031, self.Menu2031)
+        EVT_MENU(self, 2032, self.Menu2032)
+        EVT_MENU(self, 2033, self.Menu2033)
+
+        EVT_MENU(self, 301, self.Menu301To303)
+        EVT_MENU(self, 302, self.Menu301To303)
+        EVT_MENU(self, 303, self.Menu301To303)
+        EVT_MENU(self, 304, self.Menu304)
+        EVT_MENU(self, 305, self.Menu305)
+
+        EVT_MENU_RANGE(self, 401, 403, self.Menu401To403)
+
+        EVT_MENU(self, 501, self.Menu501)
+        EVT_MENU(self, 502, self.Menu502)
+
+    # Methods
+
+    def Menu101(self, event):
+        self.log.write('Welcome to Mercury\n')
+
+    def Menu102(self, event):
+        self.log.write('Welcome to Venus\n')
+
+    def Menu103(self, event):
+        self.log.write('Welcome to the Earth\n')
+
+    def OnCloseWindow(self, event):
+        self.Destroy()
+
+    def Menu201(self, event):
+        self.log.write('Chemical element number 1\n')
+
+    def Menu202(self, event):
+        self.log.write('Chemical element number 2\n')
+
+    def Menu2031(self, event):
+        self.log.write('Element number 57\n')
+
+    def Menu2032(self, event):
+        self.log.write('Element number 58\n')
+
+    def Menu2033(self, event):
+        self.log.write('Element number 59\n')
+
+    def Menu301To303(self, event):
+        id = event.GetId()
+        self.log.write('Event id: %d\n' % id)
+
+    def Menu304(self, event):
+        self.log.write('Not yet available\n')
+
+    def Menu305(self, event):
+        self.log.write('Still vapour\n')
+
+    def Menu401To403(self, event):
+        self.log.write('From a EVT_MENU_RANGE event\n')
+
+    def Menu501(self, event):
+        self.log.write('Look in the code how the shortcut has been realized\n')
+
+    def Menu502(self, event):
+        self.log.write('Hello from Jean-Michel\n')
+
+#-------------------------------------------------------------------
+
+def runTest(frame, nb, log):
+    win = MyFrame(frame, -1, log)
+    frame.otherWin = win
+    win.Show(true)
+
+
+#-------------------------------------------------------------------
+
+
+overview = """\
+A demo of using wxMenuBar and wxMenu in various ways.
+"""
+
+
+
+
+if __name__ == '__main__':
+    import sys,os
+    import run
+    run.main(['', os.path.basename(sys.argv[0])])
+
index 5d48ef5050a74f561724cc3dd26260e23587dcd9..877c92bf61fa27db4230da39010692c580f67ee0 100644 (file)
@@ -80,6 +80,7 @@ class TestTreeCtrlPanel(wxPanel):
         EVT_RIGHT_UP(self.tree, self.OnRightUp)
 
 
+
     def OnRightClick(self, event):
         pt = event.GetPosition();
         item, flags = self.tree.HitTest(pt)
@@ -88,7 +89,6 @@ class TestTreeCtrlPanel(wxPanel):
         self.tree.SelectItem(item)
 
 
-
     def OnRightUp(self, event):
         pt = event.GetPosition();
         item, flags = self.tree.HitTest(pt)
@@ -165,15 +165,15 @@ def runTest(frame, nb, log):
 
 
 
+overview = """\
+A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles.
 
+"""
 
 
 
+if __name__ == '__main__':
+    import sys,os
+    import run
+    run.main(['', os.path.basename(sys.argv[0])])
 
-
-
-
-overview = """\
-A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles.
-
-"""