Lots of wx namespace updates for the wx.lib package and the demo from

Jeff Grimmett with some tweaks and changes from Robin


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24889 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-12-17 00:34:40 +00:00
parent e1f4ff6ddc
commit b881fc787d
69 changed files with 2756 additions and 2103 deletions

View File

@@ -1,76 +1,87 @@
# 11/13/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Updated for wx namespace
from wxPython.wx import *
import images
import wx
import images
#----------------------------------------------------------------------
text = """\
Right-click on the panel (or Ctrl-click on the Mac) to show a popup
menu. Then look at the code for this sample. Notice how the
PopupMenu method is similar to the ShowModal method of a wxDialog in
that it doesn't return until the popup menu has been dismissed. The
event handlers for the popup menu items can either be attached to the
menu itself, or to the window that invokes PopupMenu.
Right-click on any bare area of this panel (or Ctrl-click on the Mac)
to show a popup menu. Then look at the code for this sample. Notice
how the PopupMenu method is similar to the ShowModal method of a
wx.Dialog in that it doesn't return until the popup menu has been
dismissed. The event handlers for the popup menu items can either be
attached to the menu itself, or to the window that invokes PopupMenu.
"""
#----------------------------------------------------------------------
class TestPanel(wxPanel):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wxPanel.__init__(self, parent, -1)
box = wxBoxSizer(wxVERTICAL)
wx.Panel.__init__(self, parent, -1)
box = wx.BoxSizer(wx.VERTICAL)
# Make and layout the controls
fs = self.GetFont().GetPointSize()
bf = wxFont(fs+4, wxSWISS, wxNORMAL, wxBOLD)
nf = wxFont(fs+2, wxSWISS, wxNORMAL, wxNORMAL)
bf = wx.Font(fs+4, wx.SWISS, wx.NORMAL, wx.BOLD)
nf = wx.Font(fs+2, wx.SWISS, wx.NORMAL, wx.NORMAL)
t = wxStaticText(self, -1, "PopupMenu")
t = wx.StaticText(self, -1, "PopupMenu")
t.SetFont(bf)
box.Add(t, 0, wxCENTER|wxALL, 5)
box.Add(t, 0, wx.CENTER|wx.ALL, 5)
self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
box.Add(wxStaticLine(self, -1), 0, wxEXPAND)
box.Add(wx.StaticLine(self, -1), 0, wx.EXPAND)
box.Add((10,20))
t = wxStaticText(self, -1, text)
t = wx.StaticText(self, -1, text)
t.SetFont(nf)
box.Add(t, 0, wxCENTER|wxALL, 5)
box.Add(t, 0, wx.CENTER|wx.ALL, 5)
self.SetSizer(box)
EVT_RIGHT_UP(self, self.OnRightClick)
self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
def OnRightClick(self, event):
self.log.WriteText("OnRightClick\n")
# only do this part the first time so the events are only bound once
#
# Yet another anternate way to do IDs. Some prefer them up top to
# avoid clutter, some prefer them close to the object of interest
# for clarity.
if not hasattr(self, "popupID1"):
self.popupID1 = wxNewId()
self.popupID2 = wxNewId()
self.popupID3 = wxNewId()
self.popupID4 = wxNewId()
self.popupID5 = wxNewId()
self.popupID6 = wxNewId()
self.popupID7 = wxNewId()
self.popupID8 = wxNewId()
self.popupID9 = wxNewId()
EVT_MENU(self, self.popupID1, self.OnPopupOne)
EVT_MENU(self, self.popupID2, self.OnPopupTwo)
EVT_MENU(self, self.popupID3, self.OnPopupThree)
EVT_MENU(self, self.popupID4, self.OnPopupFour)
EVT_MENU(self, self.popupID5, self.OnPopupFive)
EVT_MENU(self, self.popupID6, self.OnPopupSix)
EVT_MENU(self, self.popupID7, self.OnPopupSeven)
EVT_MENU(self, self.popupID8, self.OnPopupEIght)
EVT_MENU(self, self.popupID9, self.OnPopupNine)
self.popupID1 = wx.NewId()
self.popupID2 = wx.NewId()
self.popupID3 = wx.NewId()
self.popupID4 = wx.NewId()
self.popupID5 = wx.NewId()
self.popupID6 = wx.NewId()
self.popupID7 = wx.NewId()
self.popupID8 = wx.NewId()
self.popupID9 = wx.NewId()
self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
self.Bind(wx.EVT_MENU, self.OnPopupFour, id=self.popupID4)
self.Bind(wx.EVT_MENU, self.OnPopupFive, id=self.popupID5)
self.Bind(wx.EVT_MENU, self.OnPopupSix, id=self.popupID6)
self.Bind(wx.EVT_MENU, self.OnPopupSeven, id=self.popupID7)
self.Bind(wx.EVT_MENU, self.OnPopupEight, id=self.popupID8)
self.Bind(wx.EVT_MENU, self.OnPopupNine, id=self.popupID9)
# make a menu
menu = wxMenu()
menu = wx.Menu()
# Show how to put an icon in the menu
item = wxMenuItem(menu, self.popupID1,"One")
item = wx.MenuItem(menu, self.popupID1,"One")
item.SetBitmap(images.getSmilesBitmap())
menu.AppendItem(item)
# add some other items
@@ -80,7 +91,7 @@ class TestPanel(wxPanel):
menu.Append(self.popupID5, "Five")
menu.Append(self.popupID6, "Six")
# make a submenu
sm = wxMenu()
sm = wx.Menu()
sm.Append(self.popupID8, "sub item 1")
sm.Append(self.popupID9, "sub item 1")
menu.AppendMenu(self.popupID7, "Test Submenu", sm)
@@ -113,7 +124,7 @@ class TestPanel(wxPanel):
def OnPopupSeven(self, event):
self.log.WriteText("Popup seven\n")
def OnPopupEIght(self, event):
def OnPopupEight(self, event):
self.log.WriteText("Popup eight\n")
def OnPopupNine(self, event):