From: Robin Dunn Date: Sat, 3 Jan 2004 01:14:17 +0000 (+0000) Subject: Renamed demo modules to be wx-less. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/299647acac7960652aadb008775429c1f8ea9b8d Renamed demo modules to be wx-less. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/demo/ArtProvider.py b/wxPython/demo/ArtProvider.py new file mode 100644 index 0000000000..02b326680e --- /dev/null +++ b/wxPython/demo/ArtProvider.py @@ -0,0 +1,859 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import cStringIO +import wx + +#---------------------------------------------------------------------- + +ArtClients = [ "wx.ART_TOOLBAR", + "wx.ART_MENU", + "wx.ART_FRAME_ICON", + "wx.ART_CMN_DIALOG", + "wx.ART_HELP_BROWSER", + "wx.ART_MESSAGE_BOX", + "wx.ART_OTHER", + ] + +ArtIDs = [ "wx.ART_ADD_BOOKMARK", + "wx.ART_DEL_BOOKMARK", + "wx.ART_HELP_SIDE_PANEL", + "wx.ART_HELP_SETTINGS", + "wx.ART_HELP_BOOK", + "wx.ART_HELP_FOLDER", + "wx.ART_HELP_PAGE", + "wx.ART_GO_BACK", + "wx.ART_GO_FORWARD", + "wx.ART_GO_UP", + "wx.ART_GO_DOWN", + "wx.ART_GO_TO_PARENT", + "wx.ART_GO_HOME", + "wx.ART_FILE_OPEN", + "wx.ART_PRINT", + "wx.ART_HELP", + "wx.ART_TIP", + "wx.ART_REPORT_VIEW", + "wx.ART_LIST_VIEW", + "wx.ART_NEW_DIR", + "wx.ART_FOLDER", + "wx.ART_GO_DIR_UP", + "wx.ART_EXECUTABLE_FILE", + "wx.ART_NORMAL_FILE", + "wx.ART_TICK_MARK", + "wx.ART_CROSS_MARK", + "wx.ART_ERROR", + "wx.ART_QUESTION", + "wx.ART_WARNING", + "wx.ART_INFORMATION", + ] + + +#---------------------------------------------------------------------- + +class MyArtProvider(wx.ArtProvider): + def __init__(self, log): + wx.ArtProvider.__init__(self) + self.log = log + + def CreateBitmap(self, artid, client, size): + # You can do anything here you want, such as using the same + # image for any size, any client, etc., or using specific + # images for specific sizes, whatever... + + # See end of file for the image data + + bmp = wx.NullBitmap + # use this one for all 48x48 images + if size.width == 48: + bmp = makeBitmap(smile48_png) + + # but be more specific for these + elif size.width == 16 and artid == wx.ART_ADD_BOOKMARK: + bmp = makeBitmap(smile16_png) + elif size.width == 32 and artid == wx.ART_ADD_BOOKMARK: + bmp = makeBitmap(smile32_png) + + # and just ignore the size for these + elif artid == wx.ART_GO_BACK: + bmp = makeBitmap(left_png) + elif artid == wx.ART_GO_FORWARD: + bmp = makeBitmap(right_png) + elif artid == wx.ART_GO_UP: + bmp = makeBitmap(up_png) + elif artid == wx.ART_GO_DOWN: + bmp = makeBitmap(down_png) + elif artid == wx.ART_GO_TO_PARENT: + bmp = makeBitmap(back_png) + + elif artid == wx.ART_CROSS_MARK: + bmp = makeBitmap(cross_png) + elif artid == wx.ART_TICK_MARK: + bmp = makeBitmap(tick_png) + + if bmp.Ok(): + self.log.write("MyArtProvider: providing %s:%s at %s\n" %(artid, client, size)) + return bmp + + + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + sizer = wx.BoxSizer(wx.VERTICAL) + + title = wx.StaticText(self, -1, "ArtProvider") + title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) + sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + fgs = wx.FlexGridSizer(0, 3, 10, 10) + + combo = wx.ComboBox(self, -1, "", choices = ArtClients, + style = wx.CB_DROPDOWN|wx.CB_READONLY) + fgs.Add(combo, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + self.Bind(wx.EVT_COMBOBOX, self.OnSelectClient, combo) + combo.Select(0) + + combo = wx.ComboBox(self, -1, "", choices = ArtIDs, + style = wx.CB_DROPDOWN|wx.CB_READONLY) + fgs.Add(combo, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + self.Bind(wx.EVT_COMBOBOX, self.OnSelectID, combo) + combo.Select(0) + + cb = wx.CheckBox(self, -1, "Use custom provider") + fgs.Add(cb, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + self.Bind(wx.EVT_CHECKBOX, self.OnUseCustom, cb) + + fgs.Add((10, 10), 0, wx.ALIGN_CENTRE|wx.ALL, 5) + fgs.Add((10, 10), 0, wx.ALIGN_CENTRE|wx.ALL, 5) + fgs.Add((10, 10), 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + box = wx.BoxSizer(wx.VERTICAL) + bmp = wx.EmptyBitmap(16,16) + self.bmp16 = wx.StaticBitmap(self, -1, bmp) + box.Add(self.bmp16, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + text = wx.StaticText(self, -1, "16x16") + box.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + fgs.Add(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + box = wx.BoxSizer(wx.VERTICAL) + bmp = wx.EmptyBitmap(32,32) + self.bmp32 = wx.StaticBitmap(self, -1, bmp) + box.Add(self.bmp32, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + text = wx.StaticText(self, -1, "32x32") + box.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + fgs.Add(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + box = wx.BoxSizer(wx.VERTICAL) + bmp = wx.EmptyBitmap(48,48) + self.bmp48 = wx.StaticBitmap(self, -1, bmp) + box.Add(self.bmp48, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + text = wx.StaticText(self, -1, "48x48") + box.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + fgs.AddSizer(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.Add(fgs, 0, wx.ALL, 5) + self.SetSizer(sizer) + + self.client = eval(ArtClients[0]) + self.artid = eval(ArtIDs[0]) + self.getArt() + + + def OnSelectClient(self, evt): + self.log.write("OnSelectClient\n") + self.client = eval(evt.GetString()) + self.getArt() + + + def OnSelectID(self, evt): + self.log.write("OnSelectID\n") + self.artid = eval(evt.GetString()) + self.getArt() + + + def OnUseCustom(self, evt): + if evt.IsChecked(): + self.log.write("Images will now be provided by MyArtProvider\n") + wx.ArtProvider_PushProvider( MyArtProvider(self.log) ) + else: + self.log.write("MyArtProvider deactivated\n") + wx.ArtProvider_PopProvider() + self.getArt() + + + def getArt(self): + self.log.write("Getting art for %s:%s\n" % (self.client, self.artid)) + + bmp = wx.ArtProvider_GetBitmap(self.artid, self.client, (16,16)) + + if not bmp.Ok(): + bmp = wxEmptyBitmap(16,16) + + self.bmp16.SetBitmap(bmp) + + bmp = wx.ArtProvider_GetBitmap(self.artid, self.client, (32,32)) + + if not bmp.Ok(): + bmp = wxEmptyBitmap(32,32) + + self.bmp32.SetBitmap(bmp) + + bmp = wx.ArtProvider_GetBitmap(self.artid, self.client, (48,48)) + + if not bmp.Ok(): + bmp = wxEmptyBitmap(48,48) + + self.bmp48.SetBitmap(bmp) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """ +

wxArtProvider

+ +wxArtProvider class can be used to customize the look of wxWindows +applications. When wxWindows internal classes need to display an icon +or a bitmap (e.g. in the standard file dialog), it does not use a +hard-coded resource but asks wxArtProvider for it instead. This way +the users can plug in their own wxArtProvider class and easily replace +standard art with his/her own version. It is easy thing to do: all +that is needed is to derive a class from wxArtProvider, override it's +CreateBitmap method and register the provider with +wxArtProvider_PushProvider. +

+ +This class can also be used to get the platform native icons as +provided by wxArtProvider_GetBitmap or wxArtProvider_GetIcon methods. + + +""" + + +#---------------------------------------------------------------------- +# Image data + + +def makeBitmap(data): + stream = cStringIO.StringIO(data) + return wx.BitmapFromImage(wx.ImageFromStream(stream)) + + +back_png = \ +'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x07YID\ +ATx\x9c\xa5\x97Ml\x9dG\x15\x86\x9fsf\xbe\xef^\xfb:\xaeS\xd7\xa9\x1d;!IK)\xfd\ +A\x05\x95BQ\xc5\xdf\x02\xb1(\x12\x0b\x10\x8b\x8a\x05]Vl\xd8\xb2`\xcb\x92\xee\ +Q\x85\xd8U\xaa\xba\x03\tD+@j\x91J\x11\x8aT\xd14\xfd\xa7\xf9q\x9a\xc6\x8e\xe3\ +\xd8\xb1\xefwg\xcea1s\xaf\x13;\xaa*1\xd2h4su\xe7=\xe7\xcc{\xdes>\x99\x9b\x9b\ +\x03\xe0\xf9\x17\xff\xe2[\xb6B;u\'\x86`\x19\x9299Ar\xc8\x19\xb29\xd9 \xe5\ +\xb2O\x069\x97\xb3\x03{\x1b\xff\xa7\x9c\xa5zf\xe6,\x1e\xda\xe0\xe1\xe5U\xe6g\ +\xb6\x91\xb9\xb99~\xf7\xc2i\x1f\xcc-3\xdd\x8f\xe5r\x83Q\x86\x94\xa0K\x05p\ +\xbc\x1f\xe5\xba\xff?\xcf{\xb1\xe3;_x\x17\xf9\xd3\xcb\xaf\xbb\xce>\xc2\xcctd\ +\x94*x\xca\\\xdb\xd8\xe2Fg\x98\x0b\x96\x95l\xc2\xc8 \xbb\xe0Y\xc8&\xd5+!eadB\ +JBv\xa9`R\xef\x12FYH\x19\xcc\x84.\xcb\xc4\xb0\xa5\xd9k\xc4-[f\xb1_\xc0\xdda\ +\xed\xca*k\xabg\xd9\xda\xfc\x84\xeb;\x01\x97\x1eh\x03\x12A"N\x03D\\"\xe6\x81\ +LK\xf6H\xb6H\xf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eb\xb5\xa8\x94\ +\x0e\xa7+\nge?>/kWz\x00\xebp7<\x0f9yr\x19\xfd\xc9\x8f\x9e\x94o}\xfe=\xee]\ +\xf8\x04%\x17A\x1aW\xc7}_\xb5\xd9J+\xfd\xa9\xc3\r\xb7\\V\xb7\xc9\xea\x9e\x8b\ +b\xba!\x18G\x97\xe6\xf9\xc1\xb7\x97\xf9\x1f\x92tznH\x8fy\x14\x00\x00\x00\x00\ +IEND\xaeB`\x82' + +down_png = \ +'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x042ID\ +ATx\x9c\xa5\xd5Ko\x1bU\x14\xc0\xf1\xff\x8c\xe7\xe1g\xe2\xa6\x84\xa8\xa8\x82\ +\xd0\x88E\xabJ\x08\t\x8a*\xb1@\x02v\xec@l`\x87\xf8\x1e\x91\xf8\x06 \x90\xd8\ +\xb3\xe2S\xb0aS\x1ej\x8bhIe\xd2\xa8i\xa8\x13\xc7\x8f\xda\xe3\x99\xb93\xf7\ +\xcee1\x1e\xc7\xae\xed\xc4c\x16Wc\xddk\xfbw\xce\xf1\xf1\xb9\xc6\x0fw\xb5\xfe\ +h\x1b\x02\t\x91\x02\xa1 N&^+\x88\x12\x08%\x08\x99\xeeE\xa3\xf3l\t\x05~\x9c>\ +\xc3\xd1^(\'>7:\x7fqOH0\x13\r\x00\xa6\x91\xae\x82\x01F\xba5~\xca\x04\x94\x86\ +db\xa9\xd1\x92I\x1a|\x16t<\x91\x84\x18%\x15\xc4g\x81\x87Y\xa2\x12\x94R\x98J\ +\x8f\x0e\'\xb2\x11\nNzC\xfex\xb0\x8f\x17\xeb\xf4|"\xfb\xec\xfdB\x82\x17\x9fe\ +\xfcb\x05\xc6\x99gU\x12\n!\x13\xc2\x11\x8e\x14X*\x99\xc5#\x05a\x9c\xf0\xfdw\ +\xdf\xb0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p\x92\r\ +\xf3\x81T\x86\x1f\x0c/\x8a\x8fn\xb5\\r\x96\x97n\xb3\xbc\xf0\x0f\xbf\xcf\x9d\ +\xe4\xbb\xab\xdfr\xf1\xb3\x0f\x98?\xfd6[\x8f\xee\xf7\xda+\xbc\xf3\xbf9\xa7\ +\xed\xcb\xc5\'\xadvDQ\x08}\xf2N\x0b\'\xe9\xf8\x1a\xd8\xff\xb9\xf4*p\'\n\x95\ +\xa9\xc1\x93\x0f\xce\x81\xd7\x85\x0f\xdb\xef;\x07\x8e\x13w\xa2\xf0\x8f\x13G\ +\x14\xff\x03\xe8\x84\x1b+\xdf\xf26\x9e\x00\x00\x00\x00IEND\xaeB`\x82' + +right_png = \ +'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\nI\ +DATx\x9c\xc5\x96Ko\x1bU\x14\xc7\x7f\xf3\xb4=&\xd4mQ_H\xd0"\xdaD,\xda\x8aR\nB\ +\xa8\xb0a\x83\xc4\x82\r{>\x01_\x00\xa9;>\x04\x0b\xb6,\xd9\xb0fQ@\x08\x81BU\ +\x92\xaa\xa1\xa5\x0f\xbbQ\x12\'c{\xecy\xdf\x07\x8b\xf1\xb86u\x9c\xa4I\x95\ +\xd5\x9ds\xe6\xce\xfd\x9d9\xf7\x9c\xff\xbdF\xa3\xd1\xe0\xbb\xdf;:S \x15\xe4\ +\n\xa4\x06!Ah\x10C\x7f\xaa \x97O\xe7\x08]\xd8\xb9*\xe6\xc4\xa2\xb0\xb3\xe1\ +\xfbT\x0emY<\xc7\xa2\x18K;\x93\x90\x08\xb0\xbf\xf9\xa9\xa3/\x9dx\xea,\'\x8c\ +\xdbQ\xf9q9\xaa\xb1\xc5\x04\x0cr\xa8X\xa0u\x11|\x0e\x18\x80\x1a\xda\xd90\xd0\ +\\M\xc2\xa5\x94\x98R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\x8d\x83\xf5\xae\xa1]8\x8a`s\x88\ +\xb0m\x918\xd4\xe8\xc5\x18t\x1d\x7f\xcb\xc2B\x08l\x02\xcb@\xbd\x0f\x16h\x8b\ +\xaf\x0e\xc6!\x1c\x800\x0e\x80\x99\xcd\x0eS\xaf\xff\x0b\xbc\x02\xea\xe4\xf3\ +\x8f\x80\x87\xdd\xce\xfa\x04\x13Bd\xb2\xf6\xf2-\xb4\x92\xd4W\r\xb2\x87R\xd8\ +\xe3\xe3gY\\\xfc\x85\xb1\xb1\x18 j5H$D\xb3\xd7\x98m`\x0b"\x83\xe3G\x93\xe8\ +\xf90\xb4v\xb3\xf8\xe05\xe3g&z1\x1a\n\x82\x81nL;Q)\x1eW,\x16\x93m[J\xc4m\x1d\ +\x1b\xdd+m\x1c\x91j\xa7\x15<\xfeN\xe9\xfd1\xf9Ke\x19\xae\xeb\xe2y\x17\x14E?S\ +*\xd9}\x92\x05\xe66\xc4,&\x8e\x0eQ\xfe-\x05\xed$\x84\xbb\x98\xbeY\xc3J~\xcb\ +\xaf\xbfW\x8c\xbeQ\xfeZ\x99\xcc\x12\xf3\xf3\xe08=\xf5&\xbc\xdf\x03o\xf6C;I\ +\xd8\x8c1s\xebo\x1a\xff\x1d\xa0\xfa\xd7\xda\xa7Q\x06\xa8V\x97\r\xcb\x9abt\ +\x14\xe6\xe6`e\x05\xc2\x8eE\xd81Yy\xfa\x8e\xb9\x9f^0z\xee!\xd6\xee\xd3\x1fa\ +\x00>_O\xdf\xf7U,^S.\xb7O\x8e\x8d\x1c\x1b\xe5\x0e\x0f\xa98}E\xfe\x1fK_\xac\ +\xf3\x07\xc0b=\xfa\xc1x\xb5\x84\x00\x00\x00\x00IEND\xaeB`\x82' + +smile32_png = \ +'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\t\xc0I\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\x12\x89\ +D(\x1a\x8d\xe2\xe4\xe4\x04\xb9\\\x0e\x8c1X,\x16\xf8|>\xac\xae\xae\xea\x06\ +\x16\n\x00\x80\xdd\xdd]\xba\xbd\xbdE&\x93A{{;\xfa\xfb\xfb1;;\xab;\\(\xe0\'\ +\xed\xf7\xfd\x9c~\xb5\xbf\x8a\xf3q\xb2q\x86\xa0|\x00\x00\x00\x00IEND\xaeB`\ +\x82' + + +cross_png = \ +'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ +\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x03\ +\x9fIDATx\x9c\xc5\x97OH*_\x14\xc7\xbfW~\x82\x8c\x19Sh\xc2\x80\x8b\xfe\x10\ +\x04A\x90P.\x84(r\x13ER\x14\x11\x18A\x11\x14\xba0\n\x83B\xa1\x90\\\x88\xa5\ +\x05\xe5B\x11%7\x89\x14B\x08\xc2\xac\xda\xb6\x88V\xd12\xb0M\xb4jWx\xde\xe2a<\ +_3\xe3(\xef\xf7\xde\x81\xb3P\xef9\xdf\xcf\x9d+\xdfs\x87\xf1<\x8f\x7f\x19\x9a\ +\x7f\xaa\xfe7\x01\x82\xc1 \xcd\xcf\xcfS<\x1e\xa7_\xbfg\xf5\x8e \x9dNSKK\x0bf\ +ffX3\xc2\xc9d\x92r\xb9\x1c\x8a\xc5"\xde\xde\xde044\x84\xbd\xbd=,--1Y\x80t:M\ +\x8c1\xdc\xde\xde\xe2\xea\xea\n\x13\x13\x13\x98\x9a\x9aj\x18\xe2\xf0\xf0\x90\ +\xe2\xf18\xee\xef\xefA\xf4s\xe3Z\xad\x16\xa3\xa3\xa3\xb0\xdb\xed\xb0\xdb\xed\ +\x00\xcf\xf35y||L\xfd\xfd\xfd\xd4\xd3\xd3C\x1c\xc7\x11\x00\xe28\x8e\xbc^/\ +\x89\xa2H\xbf\xaf\x97\xcaR\xa9D>\x9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\xdd\xdd\x01\x00\xacVk\xd3\xafdM\x03\xfc\xed\ +\xf8\x01\xe9\t\x94\x8c\xa7\xf9\xf9<\x00\x00\x00\x00IEND\xaeB`\x82' + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + + diff --git a/wxPython/demo/Button.py b/wxPython/demo/Button.py new file mode 100644 index 0000000000..039ff89e4b --- /dev/null +++ b/wxPython/demo/Button.py @@ -0,0 +1,81 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import images + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1, + style=wx.NO_FULL_REPAINT_ON_RESIZE) + self.log = log + + b = wx.Button(self, 10, "Default Button", (20, 20)) + self.Bind(wx.EVT_BUTTON, self.OnClick, b) + b.SetDefault() + b.SetSize(b.GetBestSize()) + + b = wx.Button(self, 20, "HELLO AGAIN!", (20, 80), (120, 45)) + self.Bind(wx.EVT_BUTTON, self.OnClick, b) + b.SetToolTipString("This is a Hello button...") + + if 0: # a test case for catching wx.PyAssertionError + + #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS) + #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION) + #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG) + #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG) + + try: + bmp = wx.Bitmap("nosuchfile.bmp", wx.BITMAP_TYPE_BMP) + mask = wx.MaskColour(bmp, wx.BLUE) + except wx.PyAssertionError: + self.log.write("Caught wx.PyAssertionError! I will fix the problem.\n") + bmp = images.getTest2Bitmap() + mask = wx.MaskColour(bmp, wx.BLUE) + else: + bmp = images.getTest2Bitmap() + mask = wx.MaskColour(bmp, wx.BLUE) + + bmp.SetMask(mask) + wx.BitmapButton(self, 30, bmp, (160, 20), + (bmp.GetWidth()+10, bmp.GetHeight()+10)) + self.Bind(wx.EVT_BUTTON, self.OnClick, id=30) + + + def OnClick(self, event): + self.log.write("Click! (%d)\n" % event.GetId()) + ##wxLogDebug("debug message") + + +## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """ +

Button

+ +A button is a control that contains a text string or a bitmap and can be +placed on nearly any kind of window. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Calendar.py b/wxPython/demo/Calendar.py new file mode 100644 index 0000000000..d9134beb5d --- /dev/null +++ b/wxPython/demo/Calendar.py @@ -0,0 +1,684 @@ +#---------------------------------------------------------------------------- +# Name: wxCalendar.py +# Purpose: Calendar control display testing on panel for wxPython demo +# +# Author: Lorne White (email: lwhite1@planet.eon.net) +# +# Version 0.9 +# Date: Feb 26, 2001 +# Licence: wxWindows license +#---------------------------------------------------------------------------- +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o Some updating of the library itself will be needed for this demo to work +# correctly. +# +# 11/26/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Problems have changed a little. The print dialog requires +# a wx.Size to work with the calendar library. wx.core doesn't +# approve, though, so we get deprecation warnings. +# o Ugh. AFter updating to the Bind() method, things lock up +# on various control clicks. Will have to debug. Only seems +# to happen on windows with calendar controls, though. +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Lockup issue clarification: it appears that the spinner is +# the culprit. +# +# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o New Bind() method now fully supported. +# +# 12/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxCalendar renamed to Calendar +# o Got rid of unneeded IDs where Bind() could figure it +# out for itself. +# + +import os + +import wx +import wx.lib.calendar + +import images + + +# highlighted days in month + +test_days ={ 0: [], + 1: [3, 7, 9, 21], + 2: [2, 10, 4, 9], + 3: [4, 20, 29], + 4: [1, 12, 22], + 5: [2, 10, 15], + 6: [4, 8, 17], + 7: [6, 7, 8], + 8: [5, 10, 20], + 9: [1, 2, 5, 29], + 10: [2, 4, 6, 22], + 11: [6, 9, 12, 28, 29], + 12: [8, 9, 10, 11, 20] } + +# test of full window calendar control functions + +def GetMonthList(): + + monthlist = [] + + for i in range(13): + name = wx.lib.calendar.Month[i] + + if name != None: + monthlist.append(name) + + return monthlist + +class TestPanel(wx.Panel): + def __init__(self, parent, log, frame): + wx.Panel.__init__(self, parent, -1) + + self.log = log + self.frame = frame + + self.calend = wx.lib.calendar.Calendar(self, -1, (100, 50), (200, 180)) + +# start_month = 2 # preselect the date for calendar +# start_year = 2001 + + start_month = self.calend.GetMonth() # get the current month & year + start_year = self.calend.GetYear() + + # month list from DateTime module + + monthlist = GetMonthList() + + self.date = wx.ComboBox(self, -1, "", + (100, 20), (90, -1), + monthlist, wx.CB_DROPDOWN) + + self.date.SetSelection(start_month-1) + self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, self.date) + + # set start month and year + + self.calend.SetMonth(start_month) + self.calend.SetYear(start_year) + + # set attributes of calendar + + self.calend.hide_title = True + self.calend.HideGrid() + self.calend.SetWeekColor('WHITE', 'BLACK') + + # display routine + + self.ResetDisplay() + + # mouse click event + self.Bind(wx.lib.calendar.EVT_CALENDAR, self.MouseClick, self.calend) + + # scroll bar for month selection + self.scroll = wx.ScrollBar(self, -1, (100, 240), (200, 20), wx.SB_HORIZONTAL) + self.scroll.SetScrollbar(start_month-1, 1, 12, 1, True) + self.Bind(wx.EVT_COMMAND_SCROLL, self.Scroll, self.scroll) + + # spin control for year selection + + self.dtext = wx.TextCtrl(self, -1, str(start_year), (200, 20), (60, -1)) + h = self.dtext.GetSize().height + + self.spin = wx.SpinButton(self, -1, (270, 20), (h*2, h)) + self.spin.SetRange(1980, 2010) + self.spin.SetValue(start_year) + self.Bind(wx.EVT_SPIN, self.OnSpin, self.spin) + + # button for calendar dialog test + + wx.StaticText(self, -1, "Test Calendar Dialog", (350, 50), (150, -1)) + + bmp = images.getCalendarBitmap() + self.but1 = wx.BitmapButton(self, -1, bmp, (380, 80)) + self.Bind(wx.EVT_BUTTON, self.TestDlg, self.but1) + + # button for calendar window test + + wx.StaticText(self, -1, "Test Calendar Window", (350, 150), (150, -1)) + + self.but2 = wx.BitmapButton(self, -1, bmp, (380, 180)) + self.Bind(wx.EVT_BUTTON, self.TestFrame, self.but2) + + wx.StaticText(self, -1, "Test Calendar Print", (350, 250), (150, -1)) + + self.but3 = wx.BitmapButton(self, -1, bmp, (380, 280)) + self.Bind(wx.EVT_BUTTON, self.OnPreview, self.but3) + + # calendar dialog + + def TestDlg(self, event): # test the date dialog + dlg = wx.lib.calendar.CalenDlg(self) + dlg.Centre() + + if dlg.ShowModal() == wx.ID_OK: + result = dlg.result + day = result[1] + month = result[2] + year = result[3] + new_date = str(month) + '/'+ str(day) + '/'+ str(year) + self.log.WriteText('Date Selected: %s\n' % new_date) + else: + self.log.WriteText('No Date Selected') + + # calendar window test + + def TestFrame(self, event): + frame = CalendFrame(self, -1, "Test Calendar", self.log) + frame.Show(True) + return True + + # calendar print preview + + def OnPreview(self, event): + month = self.calend.GetMonth() + year = self.calend.GetYear() + + prt = PrintCalend(self.frame, month, year) + prt.Preview() + + # month and year control events + + def OnSpin(self, event): + year = event.GetPosition() + self.dtext.SetValue(str(year)) + self.calend.SetYear(year) + self.calend.Refresh() + + def EvtComboBox(self, event): + name = event.GetString() + self.log.WriteText('EvtComboBox: %s\n' % name) + monthval = self.date.FindString(name) + self.scroll.SetScrollbar(monthval, 1, 12, 1, True) + + self.calend.SetMonth(monthval+1) + self.ResetDisplay() + + def Scroll(self, event): + value = self.scroll.GetThumbPosition() + monthval = int(value)+1 + self.calend.SetMonth(monthval) + self.ResetDisplay() + self.log.WriteText('Month: %s\n' % value) + + name = wx.lib.calendar.Month[monthval] + self.date.SetValue(name) + + # log mouse events + + def MouseClick(self, evt): + text = '%s CLICK %02d/%02d/%d' % (evt.click, evt.day, evt.month, evt.year) # format date + self.log.WriteText('Date Selected: ' + text + '\n') + + + # set the highlighted days for the calendar + + def ResetDisplay(self): + month = self.calend.GetMonth() + + try: + set_days = test_days[month] + except: + set_days = [1, 5, 12] + + self.calend.AddSelect([4, 11], 'BLUE', 'WHITE') + self.calend.SetSelDay(set_days) + self.calend.Refresh() + + # increment and decrement toolbar controls + + def OnIncYear(self, event): + self.calend.IncYear() + self.ResetDisplay() + + def OnDecYear(self, event): + self.calend.DecYear() + self.ResetDisplay() + + def OnIncMonth(self, event): + self.calend.IncMonth() + self.ResetDisplay() + + def OnDecMonth(self, event): + self.calend.DecMonth() + self.ResetDisplay() + + def OnCurrent(self, event): + self.calend.SetCurrentDay() + self.ResetDisplay() + +# test of full window calendar control functions + +class CalendFrame(wx.Frame): + def __init__(self, parent, id, title, log): + wx.Frame.__init__(self, parent, id, title, size=(400, 400), + style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE) + + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + + self.log = log + self.CreateStatusBar() + self.mainmenu = wx.MenuBar() + menu = wx.Menu() + + menu = self.MakeFileMenu() + self.mainmenu.Append(menu, '&File') + + self.MakeToolMenu() # toolbar + + self.SetMenuBar(self.mainmenu) + self.calend = wx.lib.calendar.Calendar(self, -1) + self.calend.SetCurrentDay() + self.calend.grid_color = 'BLUE' + self.calend.SetBusType() +# self.calend.ShowWeekEnd() + + self.ResetDisplay() + + self.Bind(wx.lib.calendar.EVT_CALENDAR, self.MouseClick, self.calend) + + def MouseClick(self, evt): + text = '%s CLICK %02d/%02d/%d' % (evt.click, evt.day, evt.month, evt.year) # format date + self.log.WriteText('Date Selected: ' + text + '\n') + + def OnCloseWindow(self, event): + self.Destroy() + + def ResetDisplay(self): + month = self.calend.GetMonth() + + try: + set_days = test_days[month] + except: + set_days = [1, 5, 12] + + self.calend.AddSelect([2, 16], 'GREEN', 'WHITE') + + self.calend.SetSelDay(set_days) + self.calend.Refresh() + + def OnIncYear(self, event): + self.calend.IncYear() + self.ResetDisplay() + + def OnDecYear(self, event): + self.calend.DecYear() + self.ResetDisplay() + + def OnIncMonth(self, event): + self.calend.IncMonth() + self.ResetDisplay() + + def OnDecMonth(self, event): + self.calend.DecMonth() + self.ResetDisplay() + + def OnCurrent(self, event): + self.calend.SetCurrentDay() + self.ResetDisplay() + + def MakeFileMenu(self): + menu = wx.Menu() + + mID = wx.NewId() + menu.Append(mID, 'Decrement', 'Next') + self.Bind(wx.EVT_MENU, self.OnDecMonth, id=mID) + + mID = wx.NewId() + menu.Append(mID, 'Increment', 'Dec') + self.Bind(wx.EVT_MENU, self.OnIncMonth, id=mID) + + menu.AppendSeparator() + + mID = wx.NewId() + menu.Append(mID, 'E&xit', 'Exit') + self.Bind(wx.EVT_MENU, self.OnCloseWindow, id=mID) + + return menu + + def MakeToolMenu(self): + tb = self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER) + + mID = wx.NewId() + SetToolPath(self, tb, mID, images.getDbDecBitmap(), 'Dec Year') + self.Bind(wx.EVT_TOOL, self.OnDecYear, id=mID) + + mID = wx.NewId() + SetToolPath(self, tb, mID, images.getDecBitmap(), 'Dec Month') + self.Bind(wx.EVT_TOOL, self.OnDecMonth, id=mID) + + mID = wx.NewId() + SetToolPath(self, tb, mID, images.getPtBitmap(), 'Current Month') + self.Bind(wx.EVT_TOOL, self.OnCurrent, id=mID) + + mID = wx.NewId() + SetToolPath(self, tb, mID, images.getIncBitmap(), 'Inc Month') + self.Bind(wx.EVT_TOOL, self.OnIncMonth, id=mID) + + mID = wx.NewId() + SetToolPath(self, tb, mID, images.getDbIncBitmap(), 'Inc Year') + self.Bind(wx.EVT_TOOL, self.OnIncYear, id=mID) + + tb.Realize() + +#--------------------------------------------------------------------------- + +# example class for printing/previewing calendars + +class PrintCalend: + def __init__(self, parent, month, year): + self.frame = parent + self.month = month + self.year = year + + self.SetParms() + self.SetCal() + self.printData = wx.PrintData() + + def SetCal(self): + self.grid_color = 'BLUE' + self.back_color = 'WHITE' + self.sel_color = 'RED' + self.high_color = 'LIGHT BLUE' + self.font = wx.SWISS + self.bold = wx.NORMAL + + self.sel_key = None # last used by + self.sel_lst = [] # highlighted selected days + + self.size = None + self.hide_title = False + self.hide_grid = False + self.set_day = None + + def SetParms(self): + self.ymax = 1 + self.xmax = 1 + self.page = 1 + self.total_pg = 1 + + self.preview = None + self.scale = 1.0 + + self.pagew = 8.5 + self.pageh = 11.0 + + self.txt_marg = 0.1 + self.lf_marg = 0 + self.top_marg = 0 + + self.page = 0 + + def SetDates(self, month, year): + self.month = month + self.year = year + + def SetStyleDef(self, desc): + self.style = desc + + def SetCopies(self, copies): # number of copies of label + self.copies = copies + + def SetStart(self, start): # start position of label + self.start = start + + def Preview(self): + printout = SetPrintout(self) + printout2 = SetPrintout(self) + self.preview = wx.PrintPreview(printout, printout2, self.printData) + + if not self.preview.Ok(): + wx.MessageBox("There was a problem printing!", "Printing", wx.OK) + return + + self.preview.SetZoom(60) # initial zoom value + + frame = wx.PreviewFrame(self.preview, self.frame, "Print preview") + + frame.Initialize() + frame.SetPosition(self.frame.GetPosition()) + frame.SetSize(self.frame.GetSize()) + frame.Show(True) + + def Print(self): + pdd = wx.PrintDialogData() + pdd.SetPrintData(self.printData) + printer = wx.Printer(pdd) + printout = SetPrintout(self) + frame = wx.Frame(None, -1, "Test") + + if not printer.Print(frame, printout): + wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK) + else: + self.printData = printer.GetPrintDialogData().GetPrintData() + + printout.Destroy() + + def DoDrawing(self, DC): + size = DC.GetSize() + DC.BeginDrawing() + + cal = wx.lib.calendar.PrtCalDraw(self) + + if self.preview is None: + cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh) + cal.SetPreview(False) + + else: + if self.preview == 1: + cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh) + else: + cal.SetPSize(self.pwidth, self.pheight) + + cal.SetPreview(self.preview) + + cal.hide_title = self.hide_title # set the calendar parameters + cal.hide_grid = self.hide_grid + + cal.grid_color = self.grid_color + cal.high_color = self.high_color + cal.back_color = self.back_color + cal.outer_border = False + cal.font = self.font + cal.bold = self.bold + + cal_size = (3.0, 3.0) + cal.SetSize(cal_size) + + year, month = self.year, self.month + + x = 0.5 + for i in range(2): + y = 0.5 + + for j in range(3): + cal.SetCal(year, month) # current month + cal.SetPos(x, y) + + try: + set_days = test_days[month] + except: + set_days = [1, 5, 12] + + cal.AddSelect([2, 16], 'GREEN', 'WHITE') + + cal.DrawCal(DC, set_days) + + year, month = self.IncMonth(year, month) + y = y + 3.5 + + x = x + 4.0 # next column + + DC.EndDrawing() + + self.ymax = DC.MaxY() + self.xmax = DC.MaxX() + + def IncMonth(self, year, month): # next month + month = month + 1 + + if month > 12: + month = 1 + year = year + 1 + + return year, month + + def GetTotalPages(self): + self.pg_cnt = 1 + return self.pg_cnt + + def SetPage(self, page): + self.page = page + + def SetPageSize(self, width, height): + self.pwidth, self.pheight = width, height + + def SetTotalSize(self, width, height): + self.ptwidth, self.ptheight = width, height + + def SetPreview(self, preview, scale): + self.preview = preview + self.scale = scale + + def SetTotalSize(self, width, height): + self.ptwidth = width + self.ptheight = height + +def SetToolPath(self, tb, id, bmp, title): + tb.AddSimpleTool(id, bmp, title, title) + +class SetPrintout(wx.Printout): + def __init__(self, canvas): + wx.Printout.__init__(self) + self.canvas = canvas + self.end_pg = 1 + + def OnBeginDocument(self, start, end): + return self.base_OnBeginDocument(start, end) + + def OnEndDocument(self): + self.base_OnEndDocument() + + def HasPage(self, page): + if page <= self.end_pg: + return True + else: + return False + + def GetPageInfo(self): + self.end_pg = self.canvas.GetTotalPages() + str_pg = 1 + + try: + end_pg = self.end_pg + except: + end_pg = 1 + + return (str_pg, end_pg, str_pg, end_pg) + + def OnPreparePrinting(self): + self.base_OnPreparePrinting() + + def OnBeginPrinting(self): + dc = self.GetDC() + + self.preview = self.IsPreview() + + if (self.preview): + self.pixelsPerInch = self.GetPPIScreen() + else: + self.pixelsPerInch = self.GetPPIPrinter() + + (w, h) = dc.GetSize() + scaleX = float(w) / 1000 + scaleY = float(h) / 1000 + self.printUserScale = min(scaleX, scaleY) + + self.base_OnBeginPrinting() + + def GetSize(self): + self.psizew, self.psizeh = self.GetPPIPrinter() + return self.psizew, self.psizeh + + def GetTotalSize(self): + self.ptsizew, self.ptsizeh = self.GetPageSizePixels() + return self.ptsizew, self.ptsizeh + + def OnPrintPage(self, page): + dc = self.GetDC() + (w, h) = dc.GetSize() + scaleX = float(w) / 1000 + scaleY = float(h) / 1000 + self.printUserScale = min(scaleX, scaleY) + dc.SetUserScale(self.printUserScale, self.printUserScale) + + self.preview = self.IsPreview() + + self.canvas.SetPreview(self.preview, self.printUserScale) + self.canvas.SetPage(page) + + self.ptsizew, self.ptsizeh = self.GetPageSizePixels() + self.canvas.SetTotalSize(self.ptsizew, self.ptsizeh) + + self.psizew, self.psizeh = self.GetPPIPrinter() + self.canvas.SetPageSize(self.psizew, self.psizeh) + + self.canvas.DoDrawing(dc) + return True + +class MyApp(wx.App): + def OnInit(self): + frame = CalendFrame(None, -1, "Test Calendar", log) + frame.Show(True) + self.SetTopWindow(frame) + return True + +#--------------------------------------------------------------------------- + +def MessageDlg(self, message, type = 'Message'): + dlg = wx.MessageDialog(self, message, type, wx.OK | wx.ICON_INFORMATION) + dlg.ShowModal() + dlg.Destroy() + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log, frame) + return win + +#--------------------------------------------------------------------------- + + +overview = """\ +This control provides a Calendar control class for displaying and selecting dates. +In addition, the class is extended and can be used for printing/previewing. + +Additional features include weekend highlighting and business type Monday-Sunday +format. + +See example for various methods used to set display month, year, and highlighted +dates (different font and background colours). + +by Lorne White + +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/CalendarCtrl.py b/wxPython/demo/CalendarCtrl.py new file mode 100644 index 0000000000..03fc569b4d --- /dev/null +++ b/wxPython/demo/CalendarCtrl.py @@ -0,0 +1,73 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import wx.lib.calendar as calendar + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, ID, log): + wx.Panel.__init__(self, parent, ID) + self.log = log + + cal = calendar.CalendarCtrl(self, -1, wx.DateTime_Now(), pos = (25,50), + style = calendar.CAL_SHOW_HOLIDAYS + | calendar.CAL_SUNDAY_FIRST + | calendar.CAL_SEQUENTIAL_MONTH_SELECTION + ) + + self.Bind(calendar.EVT_CALENDAR, self.OnCalSelected, id=cal.GetId()) + + b = wx.Button(self, -1, "Destroy the Calendar", pos = (250, 50)) + self.Bind(wx.EVT_BUTTON, self.OnButton, id= b.GetId()) + self.cal = cal + + # Set up control to display a set of holidays: + self.Bind(calendar.EVT_CALENDAR_MONTH, self.OnChangeMonth, id=cal.GetId()) + self.holidays = [(1,1), (10,31), (12,25) ] # (these don't move around) + self.OnChangeMonth() + + def OnButton(self, evt): + self.cal.Destroy() + self.cal = None + + def OnCalSelected(self, evt): + self.log.write('OnCalSelected: %s\n' % evt.GetDate()) + + def OnChangeMonth(self, evt=None): + cur_month = self.cal.GetDate().GetMonth() + 1 # convert wxDateTime 0-11 => 1-12 + + for month, day in self.holidays: + if month == cur_month: + self.cal.SetHoliday(day) + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, -1, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ + +

wxCalendarCtrl

+ +Yet another calendar control. This one is a wrapper around the C++ +version described in the docs. This one will probably be a bit more efficient +than the one in wxPython.lib.calendar, but I like a few things about it better, +so I think both will stay in wxPython. +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/CheckBox.py b/wxPython/demo/CheckBox.py new file mode 100644 index 0000000000..41fb677987 --- /dev/null +++ b/wxPython/demo/CheckBox.py @@ -0,0 +1,53 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class TestCheckBox(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + wx.StaticText(self, -1, "This example uses the wxCheckBox control.", (10, 10)) + + cID = wx.NewId() + cb1 = wx.CheckBox(self, cID, " Apples", (65, 40), (150, 20), wx.NO_BORDER) + cb2 = wx.CheckBox(self, cID+1, " Oranges", (65, 60), (150, 20), wx.NO_BORDER) + cb2.SetValue(True) + cb3 = wx.CheckBox(self, cID+2, " Pears", (65, 80), (150, 20), wx.NO_BORDER) + + self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb1) + self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb2) + self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb3) + + def EvtCheckBox(self, event): + self.log.WriteText('EvtCheckBox: %d\n' % event.IsChecked()) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestCheckBox(nb, log) + return win + +#--------------------------------------------------------------------------- + + + + + +overview = """\ +A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark). + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/CheckListBox.py b/wxPython/demo/CheckListBox.py new file mode 100644 index 0000000000..ef80a7637b --- /dev/null +++ b/wxPython/demo/CheckListBox.py @@ -0,0 +1,92 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o Why is there a popup menu in this demo? +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', + 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', + 'twelve', 'thirteen', 'fourteen'] + + wx.StaticText(self, -1, "This example uses the wxCheckListBox control.", (45, 15)) + + lb = wx.CheckListBox(self, 60, (80, 50), (80, 120), sampleList) + self.Bind(wx.EVT_LISTBOX, self.EvtListBox, id=60) + self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, id=60) + lb.SetSelection(0) + self.lb = lb + + pos = lb.GetPosition().x + lb.GetSize().width + 25 + btn = wx.Button(self, -1, "Test SetString", (pos, 50)) + self.Bind(wx.EVT_BUTTON, self.OnTestButton, id=btn.GetId()) + self.Bind(wx.EVT_RIGHT_UP, self.OnDoPopup) + + def EvtListBox(self, event): + self.log.WriteText('EvtListBox: %s\n' % event.GetString()) + + def EvtListBoxDClick(self, event): + self.log.WriteText('EvtListBoxDClick:\n') + + def OnTestButton(self, evt): + self.lb.SetString(4, "FUBAR") + + + def OnDoPopup(self, evt): + menu = wx.Menu() + # Make this first item bold + item = wx.MenuItem(menu, wx.NewId(), "If supported, this is bold") + df = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) + + nf = wx.Font( + df.GetPointSize(), df.GetFamily(), df.GetStyle(), + wx.BOLD, False, df.GetFaceName() + ) + + item.SetFont(nf) + menu.AppendItem(item) + + menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &1")) + menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &2")) + menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &3")) + menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &4")) + + self.PopupMenu(menu, evt.GetPosition()) + menu.Destroy() + evt.Skip() + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +A checklistbox is like a Listbox, but allows items to be checked or unchecked rather +than relying on extended selection (e.g. shift-select) to select multiple items in +the list. + +This class is currently implemented under Windows and GTK. + +This demo shows the basic CheckListBox and how to use the SetString method to change +labels dynamically. +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Choice.py b/wxPython/demo/Choice.py new file mode 100644 index 0000000000..39e2db847a --- /dev/null +++ b/wxPython/demo/Choice.py @@ -0,0 +1,60 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class TestChoice(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', + 'six', 'seven', 'eight'] + + wx.StaticText(self, -1, "This example uses the wxChoice control.", (15, 10)) + wx.StaticText(self, -1, "Select one:", (15, 50), (75, 20)) + self.ch = wx.Choice(self, -1, (80, 50), choices = sampleList) + self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch) + + + def EvtChoice(self, event): + self.log.WriteText('EvtChoice: %s\n' % event.GetString()) + self.ch.Append("A new item") + + if event.GetString() == 'one': + self.log.WriteText('Well done!\n') + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestChoice(nb, log) + return win + +#--------------------------------------------------------------------------- + +overview = """ +A Choice control is used to select one of a list of strings. Unlike a listbox, +only the current selection is visible until the user pulls down the menu of +choices. + +This demo illustrates how to set up the Choice control and how to extract the +selected choice once it is selected. + +Note that the syntax of the constructor is different than the C++ implementation. +The number of choices and the choice array are consilidated into one python +list. +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/ColourDB.py b/wxPython/demo/ColourDB.py index 39e35fb296..3db76c0a06 100644 --- a/wxPython/demo/ColourDB.py +++ b/wxPython/demo/ColourDB.py @@ -141,8 +141,8 @@ class TestWindow(wx.ScrolledWindow): dc.EndDrawing() -# On wxGTK there needs to be a panel under wxScrolledWindows if they are -# going to be in a wxNotebook. And, in the demo, we are. +# On wxGTK there needs to be a panel under wx.ScrolledWindows if they are +# going to be in a wxNotebook. And, in this demo, we are. class TestPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, -1) diff --git a/wxPython/demo/ColourDialog.py b/wxPython/demo/ColourDialog.py new file mode 100644 index 0000000000..be0fc703d4 --- /dev/null +++ b/wxPython/demo/ColourDialog.py @@ -0,0 +1,59 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + dlg = wx.ColourDialog(frame) + + # Ensure the full colour dialog is displayed, + # not the abbreviated version. + dlg.GetColourData().SetChooseFull(True) + + if dlg.ShowModal() == wx.ID_OK: + + # If the user selected OK, then the dialog's wx.ColourData will + # contain valid information. Fetch the data ... + data = dlg.GetColourData() + + # ... then do something with it. The actual colour data will be + # returned as a three-tuple (r, g, b) in this particular case. + log.WriteText('You selected: %s\n' % str(data.GetColour().Get())) + + # Once the dialog is destroyed, Mr. wx.ColourData is no longer your + # friend. Don't use it again! + dlg.Destroy() + +#--------------------------------------------------------------------------- + + +overview = """\ +This class represents the colour chooser dialog. + +Use of this dialog is a multi-stage process. + +The actual information about how to display the dialog and the colors in the +dialog's 'registers' are contained in a wx.ColourData instance that is created by +the dialog at init time. Before displaying the dialog, you may alter these settings +to suit your needs. In the example, we set the dialog up to show the extended colour +data selection pane. Otherwise, only the more compact and less extensive colour +dialog is shown. You may also preset the colour as well as other items. + +If the user selects something and selects OK, then the wxColourData instance contains +the colour data that the user selected. Before destroying the dialog, retrieve the data. +Do not try to retain the wx.ColourData instance. It will probably not be valid +after the dialog is destroyed. + +Along with he wxColourDialog documentation, see also the wx.ColourData documentation +for details. +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/ComboBox.py b/wxPython/demo/ComboBox.py new file mode 100644 index 0000000000..eb995d51a5 --- /dev/null +++ b/wxPython/demo/ComboBox.py @@ -0,0 +1,115 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class TestComboBox(wx.Panel): + def OnSetFocus(self, evt): + print "OnSetFocus" + evt.Skip() + + def OnKillFocus(self, evt): + print "OnKillFocus" + evt.Skip() + + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', + #'this is a long item that needs a scrollbar...', + 'six', 'seven', 'eight'] + + wx.StaticText(self, -1, "This example uses the wxComboBox control.", (8, 10)) + wx.StaticText(self, -1, "Select one:", (15, 50), (75, 18)) + + # This combobox is created with a preset list of values. + cb = wx.ComboBox( + self, 500, "default value", (90, 50), + (95, -1), sampleList, wx.CB_DROPDOWN #|wxTE_PROCESS_ENTER + ) + + ##import win32api, win32con + ##win32api.SendMessage(cb.GetHandle(), + ## win32con.CB_SETHORIZONTALEXTENT, + ## 200, 0) + + self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, cb) + self.Bind(wx.EVT_TEXT, self.EvtText, cb) + self.Bind(wx.EVT_TEXT_ENTER, self.EvtTextEnter, cb) + cb.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) + cb.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) + + # Once the combobox is set up, we append some more data to it. + cb.Append("foo", "This is some client data for this item") + + # This combobox is created with no values initially. + cb = wx.ComboBox( + self, 501, "default value", (90, 80), (95, -1), [], wx.CB_SIMPLE) + + # Here we dynamically add our values to the second combobox. + for item in sampleList: + cb.Append(item, item.upper()) + + self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, cb) + self.Bind(wx.EVT_COMBOBOX, self.EvtText, cb) + + # The user selects something, we go here. + def EvtComboBox(self, evt): + cb = evt.GetEventObject() + data = cb.GetClientData(cb.GetSelection()) + self.log.WriteText('EvtComboBox: %s\nClientData: %s\n' % (evt.GetString(), data)) + + if evt.GetString() == 'one': + self.log.WriteText("You follow directions well!\n\n") + + # Capture events every time a user hits a key in the text entry field. + def EvtText(self, evt): + self.log.WriteText('EvtText: %s\n' % evt.GetString()) + + # Capture events when the user types something into the control then + # hits ENTER. + def EvtTextEnter(self, evt): + self.log.WriteText('EvtTextEnter: %s' % evt.GetString()) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestComboBox(nb, log) + return win + +#--------------------------------------------------------------------------- + + + +overview = """\ +A ComboBox is like a combination of an edit control and a listbox. It can be +displayed as static list with editable or read-only text field; or a drop-down +list with text field; or a drop-down list without a text field. + +This example shows both a preset ComboBox and one that is dynamically created +(that is, it is initially empty but then we 'grow' it out of program-supplied +data). The former is common for read-only controls. + +This example also shows the two form factors for the ComboBox. The first is more +common, and resembles a Choice control. The latter, although less common, shows +how all the values in the ComboBox can be visible, yet the functionality is the +same for both. + +Finally, this demo shows how event handling can differ. The first ComboBox is set +up to handle EVT_TEXT_ENTER events, in which text is typed in and then ENTER is +hit by the user. This allows the user to enter a line of text which can then be +processed by the program. EVT_TEXT can also be processed, but in that case the +event is generated every time that the user hits a key in the ComboBox entry field. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Dialog.py b/wxPython/demo/Dialog.py new file mode 100644 index 0000000000..263c2cfb50 --- /dev/null +++ b/wxPython/demo/Dialog.py @@ -0,0 +1,137 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- +# Create and set a help provider. Normally you would do this in +# the app's OnInit as it must be done before any SetHelpText calls. +provider = wx.SimpleHelpProvider() +wx.HelpProvider_Set(provider) + +#--------------------------------------------------------------------------- + +class TestDialog(wx.Dialog): + def __init__( + self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition, + style=wx.DEFAULT_DIALOG_STYLE + ): + + # Instead of calling wxDialog.__init__ we precreate the dialog + # so we can set an extra style that must be set before + # creation, and then we create the GUI dialog using the Create + # method. + pre = wx.PreDialog() + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) + pre.Create(parent, ID, title, pos, size, style) + + # This next step is the most important, it turns this Python + # object into the real wrapper of the dialog (instead of pre) + # as far as the wxPython extension is concerned. + self.this = pre.this + + # Now continue with the normal construction of the dialog + # contents + sizer = wx.BoxSizer(wx.VERTICAL) + + label = wx.StaticText(self, -1, "This is a wxDialog") + label.SetHelpText("This is the help text for the label") + sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + box = wx.BoxSizer(wx.HORIZONTAL) + + label = wx.StaticText(self, -1, "Field #1:") + label.SetHelpText("This is the help text for the label") + box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + text = wx.TextCtrl(self, -1, "", size=(80,-1)) + text.SetHelpText("Here's some help text for field #1") + box.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL, 5) + + sizer.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + box = wx.BoxSizer(wx.HORIZONTAL) + + label = wx.StaticText(self, -1, "Field #2:") + label.SetHelpText("This is the help text for the label") + box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + text = wx.TextCtrl(self, -1, "", size=(80,-1)) + text.SetHelpText("Here's some help text for field #2") + box.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL, 5) + + sizer.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) + sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) + + box = wx.BoxSizer(wx.HORIZONTAL) + + if wx.Platform != "__WXMSW__": + btn = wx.ContextHelpButton(self) + box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + btn = wx.Button(self, wx.ID_OK, " OK ") + btn.SetDefault() + btn.SetHelpText("The OK button completes the dialog") + box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + btn = wx.Button(self, wx.ID_CANCEL, " Cancel ") + btn.SetHelpText("The Cancel button cnacels the dialog. (Cool, huh?)") + box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + + sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + sizer.Fit(self) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestDialog(frame, -1, "This is a Dialog", size=(350, 200), + #style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME + style = wx.DEFAULT_DIALOG_STYLE + ) + win.CenterOnScreen() + val = win.ShowModal() + + if val == wx.ID_OK: + log.WriteText("You pressed OK\n") + else: + log.WriteText("You pressed Cancel\n") + + win.Destroy() + + + +#--------------------------------------------------------------------------- + + +overview = """\ +wxPython offers quite a few general purpose dialogs for useful data input from +the user; they are all based on the wx.Dialog class, which you can also subclass +to create custom dialogs to suit your needs. + +The Dialog class, in addition to dialog-like behaviors, also supports the full +wxWindows layout featureset, which means that you can incorporate sizers or +layout constraints as needed to achieve the look and feel desired. It even supports +context-sensitive help, which is illustrated in this example. + +The example is very simple; in real world situations, a dialog that had input +fields such as this would no doubt be required to deliver those values back to +the calling function. The Dialog class supports data retrieval in this manner. +However, the data must be retrieved prior to the dialog being destroyed. +The example shown here is modal; non-modal dialogs are possible as well. + +See the documentation for the Dialog class for more details. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/DirDialog.py b/wxPython/demo/DirDialog.py new file mode 100644 index 0000000000..dc936d2272 --- /dev/null +++ b/wxPython/demo/DirDialog.py @@ -0,0 +1,40 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + + # In this case we include a "New directory" button. + dlg = wx.DirDialog(frame, "Choose a directory:", + style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON) + + # If the user selects OK, then we process the dialog's data. + # This is done by getting the path data from the dialog - BEFORE + # we destroy it. + if dlg.ShowModal() == wx.ID_OK: + log.WriteText('You selected: %s\n' % dlg.GetPath()) + + # Only destroy a dialog after you're done with it. + dlg.Destroy() + +#--------------------------------------------------------------------------- + + + +overview = """\ +This class represents the directory chooser dialog. It is used when all you +need from the user is the name of a directory. Data is retrieved via utility +methods; see the DirDialog documentation for specifics. +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/DragImage.py b/wxPython/demo/DragImage.py new file mode 100644 index 0000000000..ad8f880a5d --- /dev/null +++ b/wxPython/demo/DragImage.py @@ -0,0 +1,345 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import images + +#---------------------------------------------------------------------- + +class DragShape: + def __init__(self, bmp): + self.bmp = bmp + self.pos = (0,0) + self.shown = True + self.text = None + self.fullscreen = False + + def HitTest(self, pt): + rect = self.GetRect() + return rect.InsideXY(pt.x, pt.y) + + def GetRect(self): + return wx.Rect(self.pos[0], self.pos[1], + self.bmp.GetWidth(), self.bmp.GetHeight()) + + def Draw(self, dc, op = wx.COPY): + if self.bmp.Ok(): + memDC = wx.MemoryDC() + memDC.SelectObject(self.bmp) + + dc.Blit((self.pos[0], self.pos[1]), + (self.bmp.GetWidth(), self.bmp.GetHeight()), + memDC, (0, 0), op, True) + + return True + else: + return False + + + +#---------------------------------------------------------------------- + +class DragCanvas(wx.ScrolledWindow): + def __init__(self, parent, ID): + wx.ScrolledWindow.__init__(self, parent, ID) + self.shapes = [] + self.dragImage = None + self.dragShape = None + self.hiliteShape = None + + self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + self.bg_bmp = images.getBackgroundBitmap() + + # Make a shape from an image and mask. This one will demo + # dragging outside the window + bmp = images.getTestStarBitmap() + shape = DragShape(bmp) + shape.pos = (5, 5) + shape.fullscreen = True + self.shapes.append(shape) + + # Make a shape from some text + text = "Some Text" + bg_colour = wx.Colour(57, 115, 57) # matches the bg image + font = wx.Font(15, wx.ROMAN, wx.NORMAL, wx.BOLD) + textExtent = self.GetFullTextExtent(text, font) + + # create a bitmap the same size as our text + bmp = wx.EmptyBitmap(textExtent[0], textExtent[1]) + + # 'draw' the text onto the bitmap + dc = wx.MemoryDC() + dc.SelectObject(bmp) + dc.SetBackground(wx.Brush(bg_colour, wx.SOLID)) + dc.Clear() + dc.SetTextForeground(wx.RED) + dc.SetFont(font) + dc.DrawText(text, (0, 0)) + dc.SelectObject(wx.NullBitmap) + mask = wx.MaskColour(bmp, bg_colour) + bmp.SetMask(mask) + shape = DragShape(bmp) + shape.pos = (5, 100) + shape.text = "Some dragging text" + self.shapes.append(shape) + + + # Make some shapes from some playing card images. + x = 200 + + for card in ['_01c_', '_12h_', '_13d_', '_10s_']: + bmpFunc = getattr(images, "get%sBitmap" % card) + bmp = bmpFunc() + shape = DragShape(bmp) + shape.pos = (x, 5) + self.shapes.append(shape) + x = x + 80 + + + self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) + self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) + self.Bind(wx.EVT_MOTION, self.OnMotion) + self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) + + + # We're not doing anything here, but you might have reason to. + # for example, if you were dragging something, you might elect to + # 'drop it' when the cursor left the window. + def OnLeaveWindow(self, evt): + pass + + + # tile the background bitmap + def TileBackground(self, dc): + sz = self.GetClientSize() + w = self.bg_bmp.GetWidth() + h = self.bg_bmp.GetHeight() + + x = 0 + + while x < sz.width: + y = 0 + + while y < sz.height: + dc.DrawBitmap(self.bg_bmp, (x, y)) + y = y + h + + x = x + w + + + # Go through our list of shapes and draw them in whatever place they are. + def DrawShapes(self, dc): + for shape in self.shapes: + if shape.shown: + shape.Draw(dc) + + # This is actually a sophisticated 'hit test', but in this + # case we're also determining which shape, if any, was 'hit'. + def FindShape(self, pt): + for shape in self.shapes: + if shape.HitTest(pt): + return shape + return None + + # Remove a shape from the display + def EraseShape(self, shape, dc): + r = shape.GetRect() + dc.SetClippingRect(r) + self.TileBackground(dc) + self.DrawShapes(dc) + dc.DestroyClippingRegion() + + # Clears the background, then redraws it. If the DC is passed, then + # we only do so in the area so designated. Otherwise, it's the whole thing. + def OnEraseBackground(self, evt): + dc = evt.GetDC() + + if not dc: + dc = wxClientDC(self) + rect = self.GetUpdateRegion().GetBox() + dc.SetClippingRect(rect) + self.TileBackground(dc) + + # Fired whenever a paint event occurs + def OnPaint(self, evt): + dc = wx.PaintDC(self) + self.PrepareDC(dc) + self.DrawShapes(dc) + + # Left mouse button is down. + def OnLeftDown(self, evt): + # Did the mouse go down on one of our shapes? + shape = self.FindShape(evt.GetPosition()) + + # If a shape was 'hit', then set that as the shape we're going to + # drag around. Get our start position. Dragging has not yet started. + # That will happen once the mouse moves, OR the mouse is released. + if shape: + self.dragShape = shape + self.dragStartPos = evt.GetPosition() + + # Left mouse button up. + def OnLeftUp(self, evt): + if not self.dragImage or not self.dragShape: + self.dragImage = None + self.dragShape = None + return + + # Hide the image, end dragging, and nuke out the drag image. + self.dragImage.Hide() + self.dragImage.EndDrag() + self.dragImage = None + + dc = wx.ClientDC(self) + + if self.hiliteShape: + self.hiliteShape.Draw(dc) + self.hiliteShape = None + + # reposition and draw the shape + + # Note by jmg 11/28/03 + # Here's the original: + # + # self.dragShape.pos = self.dragShape.pos + evt.GetPosition() - self.dragStartPos + # + # So if there are any problems associated with this, use that as + # a starting place in your investigation. I've tried to simulate the + # wx.Point __add__ method here -- it won't work for tuples as we + # have now from the various methods + # + # There must be a better way to do this :-) + # + + self.dragShape.pos = ( + self.dragShape.pos[0] + evt.GetPosition()[0] - self.dragStartPos[0], + self.dragShape.pos[1] + evt.GetPosition()[1] - self.dragStartPos[1] + ) + + self.dragShape.shown = True + self.dragShape.Draw(dc) + self.dragShape = None + + # The mouse is moving + def OnMotion(self, evt): + # Ignore mouse movement if we're not dragging. + if not self.dragShape or not evt.Dragging() or not evt.LeftIsDown(): + return + + # if we have a shape, but haven't started dragging yet + if self.dragShape and not self.dragImage: + + # only start the drag after having moved a couple pixels + tolerance = 2 + pt = evt.GetPosition() + dx = abs(pt.x - self.dragStartPos.x) + dy = abs(pt.y - self.dragStartPos.y) + if dx <= tolerance and dy <= tolerance: + return + + # erase the shape since it will be drawn independently now + dc = wx.ClientDC(self) + self.dragShape.shown = False + self.EraseShape(self.dragShape, dc) + + + if self.dragShape.text: + self.dragImage = wx.DragString(self.dragShape.text, + wx.StockCursor(wx.CURSOR_HAND)) + else: + self.dragImage = wx.DragImage(self.dragShape.bmp, + wx.StockCursor(wx.CURSOR_HAND)) + + hotspot = self.dragStartPos - self.dragShape.pos + self.dragImage.BeginDrag(hotspot, self, self.dragShape.fullscreen) + + self.dragImage.Move(pt) + self.dragImage.Show() + + + # if we have shape and image then move it, posibly highlighting another shape. + elif self.dragShape and self.dragImage: + onShape = self.FindShape(evt.GetPosition()) + unhiliteOld = False + hiliteNew = False + + # figure out what to hilite and what to unhilite + if self.hiliteShape: + if onShape is None or self.hiliteShape is not onShape: + unhiliteOld = True + + if onShape and onShape is not self.hiliteShape and onShape.shown: + hiliteNew = True + + # if needed, hide the drag image so we can update the window + if unhiliteOld or hiliteNew: + self.dragImage.Hide() + + if unhiliteOld: + dc = wx.ClientDC(self) + self.hiliteShape.Draw(dc) + self.hiliteShape = None + + if hiliteNew: + dc = wx.ClientDC(self) + self.hiliteShape = onShape + self.hiliteShape.Draw(dc, wx.INVERT) + + # now move it and show it again if needed + self.dragImage.Move(evt.GetPosition()) + if unhiliteOld or hiliteNew: + self.dragImage.Show() + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + + win = wx.Panel(nb, -1) + canvas = DragCanvas(win, -1) + + def onSize(evt, panel=win, canvas=canvas): + canvas.SetSize(panel.GetSize()) + + win.Bind(wx.EVT_SIZE, onSize) + return win + +#---------------------------------------------------------------------- + + + +overview = """\ +DragImage is used when you wish to drag an object on the screen, and a simple +cursor is not enough. + +On Windows, the WIN32 API is used to do achieve smooth dragging. On other +platforms, GenericDragImage is used. Applications may also prefer to use +GenericDragImage on Windows, too. + +wxPython note: wxPython uses GenericDragImage on all +platforms, but uses the DragImage name. + +To use this class, when you wish to start dragging an image, create a +DragImage object and store it somewhere you can access it as the +drag progresses. Call BeginDrag to start, and EndDrag to stop the drag. To move +the image, initially call Show and then Move. If you wish to update the screen +contents during the drag (for example, highlight an item as in the example), first +call Hide, update the screen, call Move, and then call Show. + +You can drag within one window, or you can use full-screen dragging either across +the whole screen, or just restricted to one area of the screen to save resources. +If you want the user to drag between two windows, then you will need to use +full-screen dragging. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/DynamicSashWindow.py b/wxPython/demo/DynamicSashWindow.py new file mode 100644 index 0000000000..8deeceb0d7 --- /dev/null +++ b/wxPython/demo/DynamicSashWindow.py @@ -0,0 +1,168 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import wx.gizmos as gizmos +import wx.stc as stc + +#---------------------------------------------------------------------- +# This is an example of the complex view that manages its own scrollbars +# as described in the overview below. + +class TestView(stc.StyledTextCtrl): + def __init__(self, parent, ID, log): + stc.StyledTextCtrl.__init__(self, parent, ID, style=wx.NO_BORDER) + self.dyn_sash = parent + self.log = log + self.SetupScrollBars() + self.SetMarginWidth(1,0) + + self.StyleSetFont(stc.STC_STYLE_DEFAULT, + wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) + + self.Bind(gizmos.EVT_DYNAMIC_SASH_SPLIT, self.OnSplit) + self.Bind(gizmos.EVT_DYNAMIC_SASH_UNIFY, self.OnUnify) + #self.SetScrollWidth(500) + + def SetupScrollBars(self): + # hook the scrollbars provided by the wxDynamicSashWindow + # to this view + v_bar = self.dyn_sash.GetVScrollBar(self) + h_bar = self.dyn_sash.GetHScrollBar(self) + v_bar.Bind(wx.EVT_SCROLL, self.OnSBScroll) + h_bar.Bind(wx.EVT_SCROLL, self.OnSBScroll) + v_bar.Bind(wx.EVT_SET_FOCUS, self.OnSBFocus) + h_bar.Bind(wx.EVT_SET_FOCUS, self.OnSBFocus) + + # And set the wxStyledText to use these scrollbars instead + # of its built-in ones. + self.SetVScrollBar(v_bar) + self.SetHScrollBar(h_bar) + + + def __del__(self): + self.log.write("TestView.__del__\n") + + def OnSplit(self, evt): + self.log.write("TestView.OnSplit\n"); + newview = TestView(self.dyn_sash, -1, self.log) + newview.SetDocPointer(self.GetDocPointer()) # use the same document + self.SetupScrollBars() + + + def OnUnify(self, evt): + self.log.write("TestView.OnUnify\n"); + self.SetupScrollBars() + + + def OnSBScroll(self, evt): + # redirect the scroll events from the dyn_sash's scrollbars to the STC + self.GetEventHandler().ProcessEvent(evt) + + def OnSBFocus(self, evt): + # when the scrollbar gets the focus move it back to the STC + self.SetFocus() + + +sampleText="""\ +You can drag the little tabs above the vertical scrollbar, or to the +left of the horizontal scrollbar to split this view, and you can +continue splitting the new views as much as you like. Try it and see. + +In this case the views also share the same document so changes in one +are instantly seen in the others. This is a feature of the +StyledTextCtrl that is used for the view class in this sample. +""" + +#---------------------------------------------------------------------- +# This one is simpler, but doesn't do anything with the scrollbars +# except the default wxDynamicSashWindow behaviour + +class SimpleView(wx.Panel): + def __init__(self, parent, ID, log): + wx.Panel.__init__(self, parent, ID) + self.dyn_sash = parent + self.log = log + self.SetBackgroundColour("LIGHT BLUE") + self.Bind(gizmos.EVT_DYNAMIC_SASH_SPLIT, self.OnSplit) + + def OnSplit(self, evt): + v = SimpleView(self.dyn_sash, -1, self.log) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + if wx.Platform == "__WXMAC__": + wx.MessageBox("This demo currently fails on the Mac. The problem is being looked into...", "Sorry") + return + + if 1: + win = gizmos.DynamicSashWindow(nb, -1, style = wx.CLIP_CHILDREN + #| wxDS_MANAGE_SCROLLBARS + #| wxDS_DRAG_CORNER + ) + + win.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) + view = TestView(win, -1, log) + view.SetText(sampleText) + else: + win = wx.DynamicSashWindow(nb, -1) + view = SimpleView(win, -1, log) + return win + +#---------------------------------------------------------------------- + +overview = """\ + +

DynamicSashWindow

+

+wxDynamicSashWindow widgets manages the way other widgets are viewed. +When a wxDynamicSashWindow is first shown, it will contain one child +view, a viewport for that child, and a pair of scrollbars to allow the +user to navigate the child view area. Next to each scrollbar is a small +tab. By clicking on either tab and dragging to the appropriate spot, a +user can split the view area into two smaller views separated by a +draggable sash. Later, when the user wishes to reunify the two subviews, +the user simply drags the sash to the side of the window. +wxDynamicSashWindow will automatically reparent the appropriate child +view back up the window hierarchy, and the wxDynamicSashWindow will have +only one child view once again. +

+As an application developer, you will simply create a wxDynamicSashWindow +using either the Create() function or the more complex constructor +provided below, and then create a view window whose parent is the +wxDynamicSashWindow. The child should respond to +wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by +constructing a new view window whose parent is also the +wxDynamicSashWindow. That's it! Now your users can dynamically split +and reunify the view you provided. +

+If you wish to handle the scrollbar events for your view, rather than +allowing wxDynamicSashWindow to do it for you, things are a bit more +complex. (You might want to handle scrollbar events yourself, if, +for instance, you wish to scroll a subwindow of the view you add to +your wxDynamicSashWindow object, rather than scrolling the whole view.) +In this case, you will need to construct your wxDynamicSashWindow without +the wxDS_MANAGE_SCROLLBARS style and you will need to use the +GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar +controls and call SetEventHanler() on them to redirect the scrolling +events whenever your window is reparented by wxDyanmicSashWindow. +You will need to set the scrollbars' event handler at three times: +

+

+ +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/EditableListBox.py b/wxPython/demo/EditableListBox.py new file mode 100644 index 0000000000..6d10604a54 --- /dev/null +++ b/wxPython/demo/EditableListBox.py @@ -0,0 +1,102 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o Added overview text based on source code delving. +# + +import wx +import wx.gizmos as gizmos + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + self.elb = gizmos.EditableListBox( + self, -1, "List of Stuff", (50,50), (250, 250) + ) + #style=wx.EL_ALLOW_NEW | wx.EL_ALLOW_EDIT | wx.EL_ALLOW_DELETE) + + self.elb.SetStrings(["This is a nifty ListBox widget", + "that is editable by the user.", + "", + "Use the buttons above to", + "manipulate items in the list", + "Or to add new ones.", + ]) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """\ + + +This class provides a composite control that lets the user easily enter and edit +a list of strings. + +

Styles supported:

+ +

+ +

Init: +

+ EditableListBox(wxWindow *parent, wxWindowID id=-1,
+                 const wxString& label,
+                 const wxPoint& pos = wxDefaultPosition,
+                 const wxSize& size = wxDefaultSize,
+                 long style = EL_ALLOW_NEW | EL_ALLOW_EDIT | EL_ALLOW_DELETE,
+                 const wxString& name = "editableListBox")
+
+ +

Methods: +

+ + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Editor.py b/wxPython/demo/Editor.py new file mode 100644 index 0000000000..904dc3f144 --- /dev/null +++ b/wxPython/demo/Editor.py @@ -0,0 +1,81 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o editor lib hasn't been hit by the renamer yet. +# +# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxEditor -> Editor +# + +import wx +import wx.lib.editor as editor + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = wx.Panel(nb, -1) + ed = editor.Editor(win, -1, style=wx.SUNKEN_BORDER) + box = wx.BoxSizer(wx.VERTICAL) + box.Add(ed, 1, wx.ALL|wx.GROW, 1) + win.SetSizer(box) + win.SetAutoLayout(True) + + ed.SetText(["", + "This is a simple text editor, the class name is", + "Editor. Type a few lines and try it out.", + "", + "It uses Windows-style key commands that can be overridden by subclassing.", + "Mouse select works. Here are the key commands:", + "", + "Cursor movement: Arrow keys or mouse", + "Beginning of line: Home", + "End of line: End", + "Beginning of buffer: Control-Home", + "End of the buffer: Control-End", + "Select text: Hold down Shift while moving the cursor", + "Copy: Control-Insert, Control-C", + "Cut: Shift-Delete, Control-X", + "Paste: Shift-Insert, Control-V", + ""]) + + return win + +#---------------------------------------------------------------------- + + +overview = """ +The Editor class implements a simple text editor using wxPython. You +can create a custom editor by subclassing Editor. Even though much of +the editor is implemented in Python, it runs surprisingly smoothly on +normal hardware with small files. + +How to use it +------------- +The demo code (demo/Editor.py) shows how to use Editor as a simple text +box. Use the SetText() and GetText() methods to set or get text from +the component; these both use a list of strings. + +The samples/FrogEdit directory has an example of a simple text editor +application that uses the Editor component. + +Subclassing +----------- +To add or change functionality, you can subclass this +component. One example of this might be to change the key +Alt key commands. In that case you would (for example) override the +SetAltFuncs() method. + +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/FileDialog.py b/wxPython/demo/FileDialog.py new file mode 100644 index 0000000000..0d42aa54e6 --- /dev/null +++ b/wxPython/demo/FileDialog.py @@ -0,0 +1,70 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import os +import wx + +#--------------------------------------------------------------------------- + +# This is how you pre-establish a file filter so that the dialog +# only shows the extention(s) you want it to. +wildcard = "Python source (*.py)|*.py|" \ + "Compiled Python (*.pyc)|*.pyc|" \ + "All files (*.*)|*.*" + +def runTest(frame, nb, log): + log.WriteText("CWD: %s\n" % os.getcwd()) + + # Create the dialog. In this case the current directory is forced as the starting + # directory for the dialog, and no default file name is forced. This can easilly + # be changed in your program. This is an 'open' dialog, and allows multitple + # file selection to boot. + # + # Finally, of the directory is changed in the process of getting files, this + # dialog is set up to change the current working directory to the path chosen. + dlg = wx.FileDialog( + frame, message="Choose a file", defaultDir=os.getcwd(), + defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR + ) + + # Show the dialog and retrieve the user response. If it is the OK response, + # process the data. + if dlg.ShowModal() == wx.ID_OK: + # This returns a Python list of files that were selected. + paths = dlg.GetPaths() + + log.WriteText('You selected %d files:' % len(paths)) + + for path in paths: + log.WriteText(' %s\n' % path) + + # Compare this with the debug above; did we change working dirs? + log.WriteText("CWD: %s\n" % os.getcwd()) + + # Destroy the dialog. Don't do this until you are done with it! + # BAD things can happen otherwise! + dlg.Destroy() + +#--------------------------------------------------------------------------- + + +overview = """\ +This class provides the file selection dialog. It incorporates OS-native features +depending on the OS in use, and can be used both for open and save operations. +The files displayed can be filtered by setting up a wildcard filter, multiple files +can be selected (open only), and files can be forced in a read-only mode. + +There are two ways to get the results back from the dialog. GetFiles() returns only +the file names themselves, in a Python list. GetPaths() returns the full path and +filenames combined as a Python list. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/FileDialog_Save.py b/wxPython/demo/FileDialog_Save.py new file mode 100644 index 0000000000..55fdae0596 --- /dev/null +++ b/wxPython/demo/FileDialog_Save.py @@ -0,0 +1,91 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import os +import wx + +#--------------------------------------------------------------------------- + +# This is how you pre-establish a file filter so that the dialog +# only shows the extention(s) you want it to. +wildcard = "Python source (*.py)|*.py|" \ + "Compiled Python (*.pyc)|*.pyc|" \ + "SPAM files (*.spam)|*.spam|" \ + "Egg file (*.egg)|*.egg|" \ + "All files (*.*)|*.*" + +def runTest(frame, nb, log): + log.WriteText("CWD: %s\n" % os.getcwd()) + + # Create the dialog. In this case the current directory is forced as the starting + # directory for the dialog, and no default file name is forced. This can easilly + # be changed in your program. This is an 'save' dialog. + # + # Unlike the 'open dialog' example found elsewhere, this example does NOT + # force the current working directory to change if the user chooses a different + # directory than the one initially set. + dlg = wx.FileDialog( + frame, message="Save file as ...", defaultDir=os.getcwd(), + defaultFile="", wildcard=wildcard, style=wx.SAVE + ) + + # This sets the default filter that the user will initially see. Otherwise, + # the first filter in the list will be used by default. + dlg.SetFilterIndex(2) + + # Show the dialog and retrieve the user response. If it is the OK response, + # process the data. + if dlg.ShowModal() == wx.ID_OK: + path = dlg.GetPath() + log.WriteText('You selected "%s"' % path) + + # Normally, at this point you would save your data using the file and path + # data that the user provided to you, but since we didn't actually start + # with any data to work with, that would be difficult. + # + # The code to do so would be similar to this, assuming 'data' contains + # the data you want to save: + # + # fp = file(path, 'w') # Create file anew + # fp.write(data) + # fp.close() + # + # You might want to add some error checking :-) + # + + # Note that the current working dir didn't change. This is good since + # that's the way we set it up. + log.WriteText("CWD: %s\n" % os.getcwd()) + + # Destroy the dialog. Don't do this until you are done with it! + # BAD things can happen otherwise! + dlg.Destroy() + +#--------------------------------------------------------------------------- + + +overview = """\ +This class provides the file selection dialog. It incorporates OS-native features +depending on the OS in use, and can be used both for open and save operations. +The files displayed can be filtered by setting up a wildcard filter, multiple files +can be selected (open only), and files can be forced in a read-only mode. + +There are two ways to get the results back from the dialog. GetFiles() returns only +the file names themselves, in a Python list. GetPaths() returns the full path and +filenames combined as a Python list. + +One important thing to note: if you use the file extention filters, then files saved +with the filter set to something will automatically get that extention appended to them +if it is not already there. For example, suppose the dialog was displaying the 'egg' +extention and you entered a file name of 'fried'. It would be saved as 'fried.egg.' +Yum! +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/FileHistory.py b/wxPython/demo/FileHistory.py new file mode 100644 index 0000000000..7a0dc4962f --- /dev/null +++ b/wxPython/demo/FileHistory.py @@ -0,0 +1,147 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import os +import wx + +#---------------------------------------------------------------------- + +text = """\ +Right-click on the panel above the line to get a menu. This menu will +be managed by a FileHistory object and so the files you select will +automatically be added to the end of the menu and will be selectable +the next time the menu is viewed. The filename selected, either via the +Open menu item, or from the history, will be displayed in the log +window below. +""" + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + box = wx.BoxSizer(wx.VERTICAL) + + # Make and layout the controls + fs = self.GetFont().GetPointSize() + bf = wx.Font(fs+4, wx.SWISS, wx.NORMAL, wx.BOLD) + nf = wx.Font(fs+2, wx.SWISS, wx.NORMAL, wx.NORMAL) + + t = wx.StaticText(self, -1, "FileHistory") + t.SetFont(bf) + box.Add(t, 0, wx.CENTER|wx.ALL, 5) + + box.Add(wx.StaticLine(self, -1), 0, wx.EXPAND) + box.Add((10,20)) + + t = wx.StaticText(self, -1, text) + t.SetFont(nf) + box.Add(t, 0, wx.CENTER|wx.ALL, 5) + + self.SetSizer(box) + self.SetAutoLayout(True) + + # Make a menu + self.menu = m = wx.Menu() + + # Little know wx Fact #42: there are a number of pre-set IDs + # in the wx package, to be used for common controls such as those + # illustrated below. Neat, huh? + m.Append(wx.ID_NEW, "&New") + m.Append(wx.ID_OPEN, "&Open...") + m.Append(wx.ID_CLOSE, "&Close") + m.Append(wx.ID_SAVE, "&Save") + m.Append(wx.ID_SAVEAS, "Save &as...") + m.Enable(wx.ID_NEW, False) + m.Enable(wx.ID_CLOSE, False) + m.Enable(wx.ID_SAVE, False) + m.Enable(wx.ID_SAVEAS, False) + + # and a file history + self.filehistory = wx.FileHistory() + self.filehistory.UseMenu(self.menu) + + # and finally the event handler bindings + self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick) + + self.Bind(wx.EVT_MENU, self.OnFileOpenDialog, id=wx.ID_OPEN) + + self.Bind( + wx.EVT_MENU_RANGE, self.OnFileHistory, id=wx.ID_FILE1, id2=wx.ID_FILE9 + ) + + self.Bind(wx.EVT_WINDOW_DESTROY, self.Cleanup) + + + def Cleanup(self, *args): + # A little extra cleanup is required for the FileHistory control + del self.filehistory + self.menu.Destroy() + + + def OnRightClick(self, evt): + self.PopupMenu(self.menu, evt.GetPosition()) + + + def OnFileOpenDialog(self, evt): + dlg = wx.FileDialog(self, + defaultDir = os.getcwd(), + wildcard = "All Files|*", + style = wx.OPEN | wx.CHANGE_DIR) + + if dlg.ShowModal() == wx.ID_OK: + path = dlg.GetPath() + self.log.write("You selected %s\n" % path) + + # add it to the history + self.filehistory.AddFileToHistory(path) + + dlg.Destroy() + + + def OnFileHistory(self, evt): + # get the file based on the menu ID + fileNum = evt.GetId() - wx.ID_FILE1 + path = self.filehistory.GetHistoryFile(fileNum) + self.log.write("You selected %s\n" % path) + + # add it back to the history so it will be moved up the list + self.filehistory.AddFileToHistory(path) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

FileHistory

+ +wxFileHistory encapsulates functionality to record the last few files +visited, and to allow the user to quickly load these files using the +list appended to a menu, such as the File menu. + +

Note that this inclusion is not automatic; as illustrated in this example, +you must add files (and remove them) as deemed necessary within the framework +of your program. + +

Note also the additional cleanup required for this class, namely trapping the +enclosing window's Destroy event and deleting the file history control and its +associated menu. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/FindReplaceDialog.py b/wxPython/demo/FindReplaceDialog.py new file mode 100644 index 0000000000..54cc07ee3b --- /dev/null +++ b/wxPython/demo/FindReplaceDialog.py @@ -0,0 +1,123 @@ +# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Changed the event binding slightly. +# o There are issues with the GetReplaceText() method of the +# FindDialogEvent. Must be retested when this is fixed. +# + +import wx + +#--------------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + b = wx.Button(self, -1, "Show Find Dialog", (25, 50)) + self.Bind(wx.EVT_BUTTON, self.OnShowFind, b) + + b = wx.Button(self, -1, "Show Find && Replace Dialog", (25, 90)) + self.Bind(wx.EVT_BUTTON, self.OnShowFindReplace, b) + + + # jg - 11/28/03 - corrected a long standing issue here where + # EVT_COMMAND_FIND_* was being used for these event binders + # instead of the actual event IDs shown below. As a result, + # onFind() was never showing the appropriate type. I guess + # nobody really paid much attention to that little + # debugging window :-) + # + self.Bind(wx.EVT_FIND, self.OnFind) + self.Bind(wx.EVT_FIND_NEXT, self.OnFind) + self.Bind(wx.EVT_FIND_REPLACE, self.OnFind) + self.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnFind) + self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose) + + + def OnShowFind(self, evt): + data = wx.FindReplaceData() + dlg = wx.FindReplaceDialog(self, data, "Find") + dlg.data = data # save a reference to it... + dlg.Show(True) + + + def OnShowFindReplace(self, evt): + data = wx.FindReplaceData() + dlg = wx.FindReplaceDialog(self, data, "Find & Replace", wx.FR_REPLACEDIALOG) + dlg.data = data # save a reference to it... + dlg.Show(True) + + + def OnFind(self, evt): + map = { + wx.wxEVT_COMMAND_FIND : "FIND", + wx.wxEVT_COMMAND_FIND_NEXT : "FIND_NEXT", + wx.wxEVT_COMMAND_FIND_REPLACE : "REPLACE", + wx.wxEVT_COMMAND_FIND_REPLACE_ALL : "REPLACE_ALL", + } + + et = evt.GetEventType() + + #print evt.GetReplaceString() + + if et in map: + evtType = map[et] + else: + evtType = "**Unknown Event Type**" + + #>> Todo: the GetReplaceString() method is broken. Has to be + # fixed. + if et == wx.EVT_COMMAND_FIND_REPLACE or et == wx.EVT_COMMAND_FIND_REPLACE_ALL: + replaceTxt = "Replace text: %s" % evt.GetReplaceString() + else: + replaceTxt = "" + + self.log.write("%s -- Find text: %s %s Flags: %d \n" % + (evtType, evt.GetFindString(), replaceTxt, evt.GetFlags())) + + + def OnFindClose(self, evt): + self.log.write("FindReplaceDialog closing...\n") + evt.GetDialog().Destroy() + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#--------------------------------------------------------------------------- + + + + +overview = """\ +FindReplaceDialog is a standard modeless dialog which is used to allow the user +to search for some text (and possibly replace it with something else). The actual +searching is supposed to be done in the owner window which is the parent of this +dialog. Note that it means that unlike for the other standard dialogs this one +must have a parent window. Also note that there is no way to use this +dialog in a modal way; it is always, by design and implementation, modeless. + +FileReplaceDialog requires the use of FindReplaceData. This holds the +data for the dialog. It is used to initialize the dialog with the default values +and will keep the last values from the dialog when it is closed. It is also +updated each time a FindDialogEvent is generated so instead of using the +FindDialogEvent methods you can also directly query this object. Care must be +taken not to use this object after the dialog is destroyed. The data within +will be invalid after the parent dialog is destroyed. +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/FloatBar.py b/wxPython/demo/FloatBar.py new file mode 100644 index 0000000000..c218731bb4 --- /dev/null +++ b/wxPython/demo/FloatBar.py @@ -0,0 +1,124 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o OK, Main.py indicates this is deprecated. But I don't see a +# replacement yet. So conversion is done anyway. +# +# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Issues - library has to be converted to work properly +# with new namespace. +# +# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxFloatBar -> FloatBar +# + +import wx +import wx.lib.floatbar + +import images + + +class TestFloatBar(wx.Frame): + def __init__(self, parent, log): + wx.Frame.__init__( + self, parent, -1, 'Test ToolBar', wx.DefaultPosition, (500, 300) + ) + + self.log = log + + win = wx.Window(self, -1) + win.SetBackgroundColour("WHITE") + wx.StaticText( + win, -1, "Drag the toolbar to float it,\n" + "Toggle the last tool to remove\nthe title.", (15,15) + ) + + tb = wx.lib.floatbar.FloatBar(self, -1) + self.SetToolBar(tb) + tb.SetFloatable(1) + tb.SetTitle("Floating!") + self.CreateStatusBar() + + tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10) + + tb.AddSimpleTool(20, images.getOpenBitmap(), "Open") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20) + + tb.AddSeparator() + tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30) + + tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40) + + tb.AddSeparator() + + tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap()) + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60) + + tb.Realize() + + self.tb = tb + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + + + def OnCloseWindow(self, event): + self.Destroy() + + def OnToolClick(self, event): + self.log.WriteText("tool %s clicked\n" % event.GetId()) + + if event.GetId() == 60: + print event.GetExtraLong(), event.IsChecked(), event.GetInt(), self.tb.GetToolState(60) + + if event.GetExtraLong(): + self.tb.SetTitle("") + else: + self.tb.SetTitle("Floating!") + + def OnToolRClick(self, event): + self.log.WriteText("tool %s right-clicked\n" % event.GetId()) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestFloatBar(frame, log) + frame.otherWin = win + win.Show(True) + +#--------------------------------------------------------------------------- + +overview = """\ +FloatBar is a subclass of wx.ToolBar, implemented in Python, which +can be detached from its frame. + +Drag the toolbar with the mouse to make it float, and drag it back, or +close it to make the toolbar return to its original position. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + + + + + + + + + + + + diff --git a/wxPython/demo/FontDialog.py b/wxPython/demo/FontDialog.py new file mode 100644 index 0000000000..2135c491f1 --- /dev/null +++ b/wxPython/demo/FontDialog.py @@ -0,0 +1,144 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + btn = wx.Button(self, -1, "Select Font") + self.Bind(wx.EVT_BUTTON, self.OnSelectFont, btn) + + self.sampleText = wx.TextCtrl(self, -1, "Sample Text") + #from wxPython.lib.stattext import wxGenStaticText + #self.sampleText = wxGenStaticText(self, -1, "Sample Text") + + self.curFont = self.sampleText.GetFont() + self.curClr = wx.BLACK + + fgs = wx.FlexGridSizer(cols=2, vgap=5, hgap=5) + fgs.AddGrowableCol(1) + fgs.AddGrowableRow(0) + + fgs.Add(btn) + fgs.Add(self.sampleText, 0, wx.ADJUST_MINSIZE|wx.GROW) + + fgs.Add((15,15)); fgs.Add((15,15)) # an empty row + + fgs.Add(wx.StaticText(self, -1, "PointSize:")) + self.ps = wx.StaticText(self, -1, "") + font = self.ps.GetFont() + font.SetWeight(wx.BOLD) + self.ps.SetFont(font) + fgs.Add(self.ps, 0, wx.ADJUST_MINSIZE) + + fgs.Add(wx.StaticText(self, -1, "Family:")) + self.family = wx.StaticText(self, -1, "") + self.family.SetFont(font) + fgs.Add(self.family, 0, wx.ADJUST_MINSIZE) + + fgs.Add(wx.StaticText(self, -1, "Style:")) + self.style = wx.StaticText(self, -1, "") + self.style.SetFont(font) + fgs.Add(self.style, 0, wx.ADJUST_MINSIZE) + + fgs.Add(wx.StaticText(self, -1, "Weight:")) + self.weight = wx.StaticText(self, -1, "") + self.weight.SetFont(font) + fgs.Add(self.weight, 0, wx.ADJUST_MINSIZE) + + fgs.Add(wx.StaticText(self, -1, "Face:")) + self.face = wx.StaticText(self, -1, "") + self.face.SetFont(font) + fgs.Add(self.face, 0, wx.ADJUST_MINSIZE) + + fgs.Add((15,15)); fgs.Add((15,15)) # an empty row + + fgs.Add(wx.StaticText(self, -1, "wx.NativeFontInfo:")) + self.nfi = wx.StaticText(self, -1, "") + self.nfi.SetFont(font) + fgs.Add(self.nfi, 0, wx.ADJUST_MINSIZE) + + # give it some border space + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(fgs, 0, wx.GROW|wx.ADJUST_MINSIZE|wx.ALL, 25) + + self.SetSizer(sizer) + self.UpdateUI() + + + def UpdateUI(self): + self.sampleText.SetFont(self.curFont) + self.ps.SetLabel(str(self.curFont.GetPointSize())) + self.family.SetLabel(self.curFont.GetFamilyString()) + self.style.SetLabel(self.curFont.GetStyleString()) + self.weight.SetLabel(self.curFont.GetWeightString()) + self.face.SetLabel(self.curFont.GetFaceName()) + self.nfi.SetLabel(self.curFont.GetNativeFontInfo().ToString()) + self.Layout() + + + def OnSelectFont(self, evt): + data = wx.FontData() + data.EnableEffects(True) + data.SetColour(self.curClr) # set colour + data.SetInitialFont(self.curFont) + + dlg = wx.FontDialog(self, data) + + if dlg.ShowModal() == wx.ID_OK: + data = dlg.GetFontData() + font = data.GetChosenFont() + colour = data.GetColour() + + self.log.WriteText('You selected: "%s", %d points, color %s\n' % + (font.GetFaceName(), font.GetPointSize(), + colour.Get())) + + self.curFont = font + self.curClr = colour + self.UpdateUI() + + # Don't destroy the dialog until you get everything you need from the + # dialog! + dlg.Destroy() + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#--------------------------------------------------------------------------- + + +overview = """\ +This class allows you to use the system font selection dialog +from within your program. Generally speaking, this allows you +to select a font by its name, font size, and weight, and +on some systems such things as strikethrough and underline. + +As with other dialogs used in wxPython, it is important to +use the class' methods to extract the information you need +about the font before you destroy the dialog. Failure +to observe this almost always leads to a program failure of +some sort, often ugly. + +This demo serves two purposes; it shows how to use the dialog +to GET font information from the user, but also shows how +to APPLY that information once you get it. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Frame.py b/wxPython/demo/Frame.py new file mode 100644 index 0000000000..b2028e6eb5 --- /dev/null +++ b/wxPython/demo/Frame.py @@ -0,0 +1,71 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class MyFrame(wx.Frame): + def __init__( + self, parent, ID, title, pos=wx.DefaultPosition, + size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE + ): + + wx.Frame.__init__(self, parent, ID, title, pos, size, style) + panel = wx.Panel(self, -1) + + button = wx.Button(panel, 1003, "Close Me") + button.SetPosition((15, 15)) + self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + + + def OnCloseMe(self, event): + self.Close(True) + + def OnCloseWindow(self, event): + self.Destroy() + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = MyFrame(frame, -1, "This is a wxFrame", size=(350, 200), + style = wx.DEFAULT_FRAME_STYLE)# | wx.FRAME_TOOL_WINDOW ) + frame.otherWin = win + win.Show(True) + + +#--------------------------------------------------------------------------- + + +overview = """\ +A Frame is a window whose size and position can (usually) be changed by +the user. It usually has thick borders and a title bar, and can optionally +contain a menu bar, toolbar and status bar. A frame can contain any window +that is not a Frame or Dialog. It is one of the most fundamental of the +wxWindows components. + +A Frame that has a status bar and toolbar created via the +CreateStatusBar / CreateToolBar functions manages +these windows, and adjusts the value returned by GetClientSize +to reflect the remaining size available to application windows. + +By itself, a Frame is not too useful, but with the addition of Panels and +other child objects, it encompasses the framework around which most user +interfaces are constructed. + +If you plan on using Sizers and auto-layout features, be aware that the Frame +class lacks the ability to handle these features unless it contains a Panel. +The Panel has all the necessary functionality to both control the size of +child components, and also communicate that information in a useful way to +the Frame itself. +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/GLCanvas.py b/wxPython/demo/GLCanvas.py new file mode 100644 index 0000000000..51c231e22a --- /dev/null +++ b/wxPython/demo/GLCanvas.py @@ -0,0 +1,283 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o Note: unable to install PyOpenGL on my system as I am running Python 2.3 +# and PyOpenGL does not support anything above Python 2.2. Did what I could, +# but odds are good there are problems. +# + +import wx + +try: + import wx.glcanvas as glcanvas + haveGLCanvas = True +except ImportError: + haveGLCanvas = False + +try: + # The Python OpenGL package can be found at + # http://PyOpenGL.sourceforge.net/ + + import OpenGL.GL as gl + import OpenGL.GLUT as glut + haveOpenGL = True +except ImportError: + haveOpenGL = False + +#---------------------------------------------------------------------- + +if not haveGLCanvas: + def runTest(frame, nb, log): + dlg = wx.MessageDialog( + frame, 'The wxGLCanvas has not been included with this build of wxPython!', + 'Sorry', wx.OK | wx.ICON_INFORMATION + ) + + dlg.ShowModal() + dlg.Destroy() + +elif not haveOpenGL: + def runTest(frame, nb, log): + dlg = wx.MessageDialog( + frame, 'The OpenGL package was not found. You can get it at\n' + 'http://PyOpenGL.sourceforge.net/', 'Sorry', wx.OK | wx.ICON_INFORMATION + ) + + dlg.ShowModal() + dlg.Destroy() + + +else: + buttonDefs = { + wx.NewId() : ('CubeCanvas', 'Cube'), + wx.NewId() : ('ConeCanvas', 'Cone'), + } + + class ButtonPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + box = wx.BoxSizer(wx.VERTICAL) + box.Add((20, 30)) + keys = buttonDefs.keys() + keys.sort() + + for k in keys: + text = buttonDefs[k][1] + btn = wx.Button(self, k, text) + box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 15) + self.Bind(wx.EVT_BUTTON, self.OnButton, id=k) + + #** Enable this to show putting a wxGLCanvas on the wxPanel + if 0: + c = CubeCanvas(self) + c.SetSize((200, 200)) + box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15) + + self.SetAutoLayout(True) + self.SetSizer(box) + + + def OnButton(self, evt): + canvasClassName = buttonDefs[evt.GetId()][0] + canvasClass = eval(canvasClassName) + frame = wx.Frame(None, -1, canvasClassName, size=(400,400)) + canvas = canvasClass(frame) + frame.Show(True) + + + + def runTest(frame, nb, log): + win = ButtonPanel(nb, log) + return win + + + + + class MyCanvasBase(glcanvas.GLCanvas): + def __init__(self, parent): + glcanvas.GLCanvas.__init__(self, parent, -1) + self.init = False + # initial mouse position + self.lastx = self.x = 30 + self.lasty = self.y = 30 + self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) + self.Bind(wx.EVT_SIZE, self.OnSize) + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) # needs fixing... + self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) + self.Bind(wx.EVT_MOTION, self.OnMouseMotion) + + def OnEraseBackground(self, event): + pass # Do nothing, to avoid flashing on MSW. + + def OnSize(self, event): + size = self.GetClientSize() + + if self.GetContext(): + self.SetCurrent() + glcanvas.glViewport(0, 0, size.width, size.height) + + def OnPaint(self, event): + dc = wx.PaintDC(self) + self.SetCurrent() + + if not self.init: + self.InitGL() + self.init = True + + self.OnDraw() + + def OnMouseDown(self, evt): + self.CaptureMouse() + + def OnMouseUp(self, evt): + self.ReleaseMouse() + + def OnMouseMotion(self, evt): + if evt.Dragging() and evt.LeftIsDown(): + self.x, self.y = self.lastx, self.lasty + self.x, self.y = evt.GetPosition() + self.Refresh(False) + + + class CubeCanvas(MyCanvasBase): + def InitGL(self): + # set viewing projection + glcanvas.glMatrixMode(glcanvas.GL_PROJECTION); + glcanvas.glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0); + + # position viewer + glcanvas.glMatrixMode(glcanvas.GL_MODELVIEW); + glcanvas.glTranslatef(0.0, 0.0, -2.0); + + # position object + glcanvas.glRotatef(self.y, 1.0, 0.0, 0.0); + glcanvas.glRotatef(self.x, 0.0, 1.0, 0.0); + + glcanvas.glEnable(glcanvas.GL_DEPTH_TEST); + glcanvas.glEnable(glcanvas.GL_LIGHTING); + glcanvas.glEnable(glcanvas.GL_LIGHT0); + + + def OnDraw(self): + # clear color and depth buffers + glcanvas.glClear(glcanvas.GL_COLOR_BUFFER_BIT | glcanvas.GL_DEPTH_BUFFER_BIT) + + # draw six faces of a cube + glcanvas.glBegin(glcanvas.GL_QUADS) + glcanvas.glNormal3f( 0.0, 0.0, 1.0) + glcanvas.glVertex3f( 0.5, 0.5, 0.5) + glcanvas.glVertex3f(-0.5, 0.5, 0.5) + glcanvas.glVertex3f(-0.5,-0.5, 0.5) + glcanvas.glVertex3f( 0.5,-0.5, 0.5) + + glcanvas.glNormal3f( 0.0, 0.0,-1.0) + glcanvas.glVertex3f(-0.5,-0.5,-0.5) + glcanvas.glVertex3f(-0.5, 0.5,-0.5) + glcanvas.glVertex3f( 0.5, 0.5,-0.5) + glcanvas.glVertex3f( 0.5,-0.5,-0.5) + + glcanvas.glNormal3f( 0.0, 1.0, 0.0) + glcanvas.glVertex3f( 0.5, 0.5, 0.5) + glcanvas.glVertex3f( 0.5, 0.5,-0.5) + glcanvas.glVertex3f(-0.5, 0.5,-0.5) + glcanvas.glVertex3f(-0.5, 0.5, 0.5) + + glcanvas.glNormal3f( 0.0,-1.0, 0.0) + glcanvas.glVertex3f(-0.5,-0.5,-0.5) + glcanvas.glVertex3f( 0.5,-0.5,-0.5) + glcanvas.glVertex3f( 0.5,-0.5, 0.5) + glcanvas.glVertex3f(-0.5,-0.5, 0.5) + + glcanvas.glNormal3f( 1.0, 0.0, 0.0) + glcanvas.glVertex3f( 0.5, 0.5, 0.5) + glcanvas.glVertex3f( 0.5,-0.5, 0.5) + glcanvas.glVertex3f( 0.5,-0.5,-0.5) + glcanvas.glVertex3f( 0.5, 0.5,-0.5) + + glcanvas.glNormal3f(-1.0, 0.0, 0.0) + glcanvas.glVertex3f(-0.5,-0.5,-0.5) + glcanvas.glVertex3f(-0.5,-0.5, 0.5) + glcanvas.glVertex3f(-0.5, 0.5, 0.5) + glcanvas.glVertex3f(-0.5, 0.5,-0.5) + glcanvas.glEnd() + + glcanvas.glRotatef((self.lasty - self.y)/100., 1.0, 0.0, 0.0); + glcanvas.glRotatef((self.lastx - self.x)/100., 0.0, 1.0, 0.0); + + self.SwapBuffers() + + + class ConeCanvas(MyCanvasBase): + def InitGL( self ): + glcanvas.glMatrixMode(glcanvas.GL_PROJECTION); + # camera frustrum setup + glcanvas.glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0); + glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_AMBIENT, [0.2, 0.2, 0.2, 1.0]) + glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0]) + glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_SPECULAR, [1.0, 0.0, 1.0, 1.0]) + glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_SHININESS, 50.0) + glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_AMBIENT, [0.0, 1.0, 0.0, 1.0]) + glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0]) + glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_SPECULAR, [1.0, 1.0, 1.0, 1.0]) + glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_POSITION, [1.0, 1.0, 1.0, 0.0]); + glcanvas.glLightModel(glcanvas.GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0]) + glcanvas.glEnable(glcanvas.GL_LIGHTING) + glcanvas.glEnable(glcanvas.GL_LIGHT0) + glcanvas.glDepthFunc(glcanvas.GL_LESS) + glcanvas.glEnable(glcanvas.GL_DEPTH_TEST) + glcanvas.glClear(glcanvas.GL_COLOR_BUFFER_BIT | glcanvas.GL_DEPTH_BUFFER_BIT) + # position viewer + glcanvas.glMatrixMode(glcanvas.GL_MODELVIEW); + + + def OnDraw(self): + # clear color and depth buffers + glcanvas.glClear(glcanvas.GL_COLOR_BUFFER_BIT | glcanvas.GL_DEPTH_BUFFER_BIT); + # use a fresh transformation matrix + glcanvas.glPushMatrix() + # position object + glcanvas.glTranslate(0.0, 0.0, -2.0); + glcanvas.glRotate(30.0, 1.0, 0.0, 0.0); + glcanvas.glRotate(30.0, 0.0, 1.0, 0.0); + + glcanvas.glTranslate(0, -1, 0) + glcanvas.glRotate(250, 1, 0, 0) + glcanvas.glutSolidCone(0.5, 1, 30, 5) + glcanvas.glPopMatrix() + glcanvas.glRotatef((self.lasty - self.y)/100., 0.0, 0.0, 1.0); + glcanvas.glRotatef(0.0, (self.lastx - self.x)/100., 1.0, 0.0); + # push into visible buffer + self.SwapBuffers() + + + + +#---------------------------------------------------------------------- + + + +overview = """\ +""" + + +#---------------------------------------------------------------------- + +def _test(): + class MyApp(wxApp): + def OnInit(self): + frame = wx.Frame(None, -1, "GL Demos", wx.DefaultPosition, (600,300)) + #win = ConeCanvas(frame) + MySplitter(frame) + frame.Show(True) + self.SetTopWindow(frame) + return True + + app = MyApp(0) + app.MainLoop() + +if __name__ == '__main__': + _test() + diff --git a/wxPython/demo/Gauge.py b/wxPython/demo/Gauge.py new file mode 100644 index 0000000000..5d65255f09 --- /dev/null +++ b/wxPython/demo/Gauge.py @@ -0,0 +1,70 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + self.count = 0 + + wx.StaticText(self, -1, "This example shows the wxGauge control.", (45, 15)) + + self.g1 = wx.Gauge(self, -1, 50, (110, 50), (250, 25)) + self.g1.SetBezelFace(3) + self.g1.SetShadowWidth(3) + + self.g2 = wx.Gauge( + self, -1, 50, (110, 95), (250, 25), + wx.GA_HORIZONTAL|wx.GA_SMOOTH + ) + + self.g2.SetBezelFace(5) + self.g2.SetShadowWidth(5) + + self.Bind(wx.EVT_IDLE, self.IdleHandler) + + + def IdleHandler(self, event): + self.count = self.count + 1 + + if self.count >= 50: + self.count = 0 + + self.g1.SetValue(self.count) + self.g2.SetValue(self.count) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +A Gauge is a horizontal or vertical bar which shows a quantity in a graphical +fashion. It is often used to indicate progress through lengthy tasks, such as +file copying or data analysis. + +When the Gauge is initialized, it's "complete" value is usually set; at any rate, +before using the Gauge, the maximum value of the control must be set. As the task +progresses, the Gauge is updated by the program via the SetValue method. + +This control is for use within a GUI; there is a seperate ProgressDialog class +to present the same sort of control as a dialog to the user. +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/GenericDirCtrl.py b/wxPython/demo/GenericDirCtrl.py new file mode 100644 index 0000000000..30d8bbb75e --- /dev/null +++ b/wxPython/demo/GenericDirCtrl.py @@ -0,0 +1,73 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + txt1 = wx.StaticText(self, -1, "style=0") + dir1 = wx.GenericDirCtrl(self, -1, size=(200,225), style=0) + + txt2 = wx.StaticText(self, -1, "wx.DIRCTRL_DIR_ONLY") + dir2 = wx.GenericDirCtrl(self, -1, size=(200,225), style=wx.DIRCTRL_DIR_ONLY) + + txt3 = wx.StaticText(self, -1, "wx.DIRCTRL_SHOW_FILTERS") + dir3 = wx.GenericDirCtrl(self, -1, size=(200,225), style=wx.DIRCTRL_SHOW_FILTERS, + filter="All files (*.*)|*.*|Python files (*.py)|*.py") + + sz = wx.FlexGridSizer(cols=3, hgap=5, vgap=5) + sz.Add((35, 35)) # some space above + sz.Add((35, 35)) + sz.Add((35, 35)) + + sz.Add(txt1) + sz.Add(txt2) + sz.Add(txt3) + + sz.Add(dir1, 0, wx.EXPAND) + sz.Add(dir2, 0, wx.EXPAND) + sz.Add(dir3, 0, wx.EXPAND) + + sz.Add((35,35)) # some space below + + sz.AddGrowableRow(2) + sz.AddGrowableCol(0) + sz.AddGrowableCol(1) + sz.AddGrowableCol(2) + + self.SetSizer(sz) + self.SetAutoLayout(True) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +This control can be used to place a directory listing (with optional files) +on an arbitrary window. The control contains a TreeCtrl window representing +the directory hierarchy, and optionally, a Choice window containing a list +of filters. + +The filters work in the same manner as in FileDialog. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Grid.py b/wxPython/demo/Grid.py new file mode 100644 index 0000000000..78eae6b678 --- /dev/null +++ b/wxPython/demo/Grid.py @@ -0,0 +1,104 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +buttonDefs = { + 814 : ('GridSimple', ' Simple wxGrid, catching all events '), + 815 : ('GridStdEdRend', ' wxGrid showing Editors and Renderers '), + 818 : ('GridHugeTable', ' A wxGrid with a HUGE table (100 MILLION cells!) '), + 817 : ('GridCustTable', ' wxGrid using a custom Table, with non-string data '), + 819 : ('GridEnterHandler',' Remapping keys to behave differently '), + 820 : ('GridCustEditor', ' Shows how to create a custom Cell Editor '), + 821 : ('GridDragable', ' A wxGrid with dragable rows and columns '), + 822 : ('GridDragAndDrop', ' Shows how to make a grid a drop target for files'), + } + + +class ButtonPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + box = wx.BoxSizer(wx.VERTICAL) + box.Add((20, 20)) + keys = buttonDefs.keys() + keys.sort() + + for k in keys: + text = buttonDefs[k][1] + btn = wx.Button(self, k, text) + box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 10) + self.Bind(wx.EVT_BUTTON, self.OnButton, btn) + + self.SetAutoLayout(True) + self.SetSizer(box) + + + def OnButton(self, evt): + modName = buttonDefs[evt.GetId()][0] + module = __import__(modName) + frame = module.TestFrame(None, self.log) + frame.Show(True) + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = ButtonPanel(nb, log) + return win + +#--------------------------------------------------------------------------- + + + +overview = """\ + +

wxGrid

+ +This demo shows various ways of using the new and +improved wxGrid class. Unfortunatly it has not been +documented yet, and while it is somewhat backwards compatible, if you +try to go by the current wxGrid documentation you will probably just +confuse yourself. +

+You can look at the sources for these samples to learn a lot about how +the new classes work. +

    +
  1. GridSimple.py A simple grid that shows +how to catch all the various events. + +

    +

  2. GridStdEdRend.py A grid that +uses non-default Cell Editors and Cell Renderers. + +

    +

  3. GridHugeTable.py A grid that +uses a non-default Grid Table. This table is read-only and simply +generates on the fly a unique string for each cell. + +

    +

  4. GridCustTable.py This grid +shows how to deal with tables that have non-string data, and how Cell +Editors and Cell Renderers are automatically chosen based on the data +type. + +

    +

  5. GridEnterHandler.pyThis one +changes how the ENTER key works, moving the current cell left to right +and wrapping around to the next row when needed. +
+

+ +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/GridBagSizer.py b/wxPython/demo/GridBagSizer.py new file mode 100644 index 0000000000..51ebb0c1de --- /dev/null +++ b/wxPython/demo/GridBagSizer.py @@ -0,0 +1,148 @@ + +import wx # This module uses the new wx namespace + +#---------------------------------------------------------------------- +gbsDescription = """\ +The wxGridBagSizer is similar to the wxFlexGridSizer except the items are explicitly positioned +in a virtual cell of the layout grid, and column or row spanning is allowed. For example, this +static text is positioned at (0,0) and it spans 7 columns. +""" + + +class TestFrame(wx.Frame): + def __init__(self): + wx.Frame.__init__(self, None, -1, "wxGridBagSizer") + p = wx.Panel(self, -1) + p.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) + + gbs = self.gbs = wx.GridBagSizer(5, 5) + + gbs.Add( wx.StaticText(p, -1, gbsDescription), + (0,0), (1,7), wx.ALIGN_CENTER | wx.ALL, 5) + + gbs.Add( wx.TextCtrl(p, -1, "pos(1,0)"), (1,0) ) + gbs.Add( wx.TextCtrl(p, -1, "pos(1,1)"), (1,1) ) + gbs.Add( wx.TextCtrl(p, -1, "pos(2,0)"), (2,0) ) + gbs.Add( wx.TextCtrl(p, -1, "pos(2,1)"), (2,1) ) + + gbs.Add( wx.TextCtrl(p, -1, "pos(3,2), span(1,2)\nthis row and col are growable", style=wx.TE_MULTILINE), + (3,2), (1,2), flag=wx.EXPAND ) + + gbs.Add( wx.TextCtrl(p, -1, "pos(4,3), span(3,1)", style=wx.TE_MULTILINE), + (4,3), (3,1), wx.EXPAND) + + gbs.Add( wx.TextCtrl(p, -1, "pos(5,4)"), (5,4), flag=wx.EXPAND ) + gbs.Add( wx.TextCtrl(p, -1, "pos(6,5)"), (6,5), flag=wx.EXPAND ) + gbs.Add( wx.TextCtrl(p, -1, "pos(7,6)"), (7,6) ) + + moveBtn1 = wx.Button(p, -1, "Move this to (3,6)") + moveBtn2 = wx.Button(p, -1, "Move this to (3,6)"); + gbs.Add( moveBtn1, (10,2) ) + gbs.Add( moveBtn2, (10,3) ) + + hideBtn = wx.Button(p, -1, "Hide this item -->") + gbs.Add(hideBtn, (12, 3)) + + hideTxt = wx.TextCtrl(p, -1, "pos(12,4), size(150, -1)", size = (150,-1)) + gbs.Add( hideTxt, (12,4) ) + + showBtn = wx.Button(p, -1, "<-- Show it again") + gbs.Add(showBtn, (12, 5)) + showBtn.Disable() + self.hideBtn = hideBtn + self.showBtn = showBtn + self.hideTxt = hideTxt + + self.Bind(wx.EVT_BUTTON, self.OnHideButton, hideBtn) + self.Bind(wx.EVT_BUTTON, self.OnShowButton, showBtn) + self.Bind(wx.EVT_BUTTON, self.OnMoveButton, moveBtn1) + self.Bind(wx.EVT_BUTTON, self.OnMoveButton, moveBtn2) + + # Add a spacer at the end to ensure some extra space at the bottom + gbs.Add((10,10), (14,7)) + + gbs.AddGrowableRow(3) + gbs.AddGrowableCol(2) + + p.SetSizerAndFit(gbs) + self.SetClientSize(p.GetSize()) + + + def OnHideButton(self, evt): + self.gbs.Hide(self.hideTxt) + self.hideBtn.Disable() + self.showBtn.Enable() + self.gbs.Layout() + + + def OnShowButton(self, evt): + self.gbs.Show(self.hideTxt) + self.hideBtn.Enable() + self.showBtn.Disable() + self.gbs.Layout() + + + def OnMoveButton(self, evt): + btn = evt.GetEventObject() + curPos = self.gbs.GetItemPosition(btn) + + # if it's already at the "other" spot then move it back + if curPos == (3,6): + self.gbs.SetItemPosition(btn, self.lastPos) + btn.SetLabel("Move this to (3,6)") + else: + if self.gbs.CheckForIntersection( (3,6), (1,1) ): + wx.MessageBox("""\ +wxGridBagSizer will not allow items to be in the same cell as +another item, so this operation will fail. You will also get an assert +when compiled in debug mode.""", + "Warning", wx.OK | wx.ICON_INFORMATION) + + try: + if self.gbs.SetItemPosition(btn, (3,6)): + self.lastPos = curPos + btn.SetLabel("Move it back") + except wx.PyAssertionError: + pass + + self.gbs.Layout() + + + def OnLeftDown(self, evt): + pt = evt.GetPosition() + item = self.gbs.FindItemAtPoint(pt) + if item is None: + print "no item at", `pt` + else: + print "item found: ", `item.GetPos()`, "--", `item.GetSpan()` + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestFrame() + frame.otherWin = win + win.Show(True) + + +#---------------------------------------------------------------------- + + + +overview = """ +

wxGridBagSizer

+ +The wxGridBagSizer is more or less a port of the the RowColSizer (that +has been in the wxPython.lib package for quite some time) to C++. It +allows items to be placed at specific layout grid cells, and items can +span across more than one row or column. + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Grid_MegaExample.py b/wxPython/demo/Grid_MegaExample.py new file mode 100644 index 0000000000..751e7ab291 --- /dev/null +++ b/wxPython/demo/Grid_MegaExample.py @@ -0,0 +1,487 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import wx.grid as Grid + +import images + +class MegaTable(Grid.PyGridTableBase): + """ + A custom wxGrid Table using user supplied data + """ + def __init__(self, data, colnames, plugins): + """data is a list of the form + [(rowname, dictionary), + dictionary.get(colname, None) returns the data for column + colname + """ + # The base class must be initialized *first* + Grid.PyGridTableBase.__init__(self) + self.data = data + self.colnames = colnames + self.plugins = plugins or {} + # XXX + # we need to store the row length and column length to + # see if the table has changed size + self._rows = self.GetNumberRows() + self._cols = self.GetNumberCols() + + def GetNumberCols(self): + return len(self.colnames) + + def GetNumberRows(self): + return len(self.data) + + def GetColLabelValue(self, col): + return self.colnames[col] + + def GetRowLabelValue(self, row): + return "row %03d" % int(self.data[row][0]) + + def GetValue(self, row, col): + return str(self.data[row][1].get(self.GetColLabelValue(col), "")) + + def GetRawValue(self, row, col): + return self.data[row][1].get(self.GetColLabelValue(col), "") + + def SetValue(self, row, col, value): + self.data[row][1][self.GetColLabelValue(col)] = value + + def ResetView(self, grid): + """ + (Grid) -> Reset the grid view. Call this to + update the grid if rows and columns have been added or deleted + """ + grid.BeginBatch() + + for current, new, delmsg, addmsg in [ + (self._rows, self.GetNumberRows(), Grid.GRIDTABLE_NOTIFY_ROWS_DELETED, Grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), + (self._cols, self.GetNumberCols(), Grid.GRIDTABLE_NOTIFY_COLS_DELETED, Grid.GRIDTABLE_NOTIFY_COLS_APPENDED), + ]: + + if new < current: + msg = Grid.GridTableMessage(self,delmsg,new,current-new) + grid.ProcessTableMessage(msg) + elif new > current: + msg = Grid.GridTableMessage(self,addmsg,new-current) + grid.ProcessTableMessage(msg) + self.UpdateValues(grid) + + grid.EndBatch() + + self._rows = self.GetNumberRows() + self._cols = self.GetNumberCols() + # update the column rendering plugins + self._updateColAttrs(grid) + + # update the scrollbars and the displayed part of the grid + grid.AdjustScrollbars() + grid.ForceRefresh() + + + def UpdateValues(self, grid): + """Update all displayed values""" + # This sends an event to the grid table to update all of the values + msg = Grid.GridTableMessage(self, Grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) + grid.ProcessTableMessage(msg) + + def _updateColAttrs(self, grid): + """ + wxGrid -> update the column attributes to add the + appropriate renderer given the column name. (renderers + are stored in the self.plugins dictionary) + + Otherwise default to the default renderer. + """ + col = 0 + + for colname in self.colnames: + attr = Grid.GridCellAttr() + if colname in self.plugins: + renderer = self.plugins[colname](self) + + if renderer.colSize: + grid.SetColSize(col, renderer.colSize) + + if renderer.rowSize: + grid.SetDefaultRowSize(renderer.rowSize) + + attr.SetReadOnly(True) + attr.SetRenderer(renderer) + + grid.SetColAttr(col, attr) + col += 1 + + # ------------------------------------------------------ + # begin the added code to manipulate the table (non wx related) + def AppendRow(self, row): + #print 'append' + entry = {} + + for name in self.colnames: + entry[name] = "Appended_%i"%row + + # XXX Hack + # entry["A"] can only be between 1..4 + entry["A"] = random.choice(range(4)) + self.data.insert(row, ["Append_%i"%row, entry]) + + def DeleteCols(self, cols): + """ + cols -> delete the columns from the dataset + cols hold the column indices + """ + # we'll cheat here and just remove the name from the + # list of column names. The data will remain but + # it won't be shown + deleteCount = 0 + cols = cols[:] + cols.sort() + + for i in cols: + self.colnames.pop(i-deleteCount) + # we need to advance the delete count + # to make sure we delete the right columns + deleteCount += 1 + + if not len(self.colnames): + self.data = [] + + def DeleteRows(self, rows): + """ + rows -> delete the rows from the dataset + rows hold the row indices + """ + deleteCount = 0 + rows = rows[:] + rows.sort() + + for i in rows: + self.data.pop(i-deleteCount) + # we need to advance the delete count + # to make sure we delete the right rows + deleteCount += 1 + + def SortColumn(self, col): + """ + col -> sort the data based on the column indexed by col + """ + name = self.colnames[col] + _data = [] + + for row in self.data: + rowname, entry = row + _data.append((entry.get(name, None), row)) + + _data.sort() + self.data = [] + + for sortvalue, row in _data: + self.data.append(row) + + # end table manipulation code + # ---------------------------------------------------------- + + +# -------------------------------------------------------------------- +# Sample wxGrid renderers + +class MegaImageRenderer(Grid.PyGridCellRenderer): + def __init__(self, table): + """ + Image Renderer Test. This just places an image in a cell + based on the row index. There are N choices and the + choice is made by choice[row%N] + """ + Grid.PyGridCellRenderer.__init__(self) + self.table = table + self._choices = [images.getSmilesBitmap, + images.getMondrianBitmap, + images.get_10s_Bitmap, + images.get_01c_Bitmap] + + self.colSize = None + self.rowSize = None + + def Draw(self, grid, attr, dc, rect, row, col, isSelected): + choice = self.table.GetRawValue(row, col) + bmp = self._choices[ choice % len(self._choices)]() + image = wx.MemoryDC() + image.SelectObject(bmp) + + # clear the background + dc.SetBackgroundMode(wx.SOLID) + + if isSelected: + dc.SetBrush(wx.Brush(wx.BLUE, wx.SOLID)) + dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID)) + else: + dc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID)) + dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID)) + dc.DrawRectangleRect(rect) + + #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height)) + + # copy the image but only to the size of the grid cell + width, height = bmp.GetWidth(), bmp.GetHeight() + + if width > rect.width-2: + width = rect.width-2 + + if height > rect.height-2: + height = rect.height-2 + + dc.Blit((rect.x+1, rect.y+1), (width, height), + image, + (0, 0), wx.COPY, True) + + +class MegaFontRenderer(Grid.PyGridCellRenderer): + def __init__(self, table, color="blue", font="ARIAL", fontsize=8): + """Render data in the specified color and font and fontsize""" + Grid.PyGridCellRenderer.__init__(self) + self.table = table + self.color = color + self.font = wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, font) + self.selectedBrush = wx.Brush("blue", wx.SOLID) + self.normalBrush = wx.Brush(wx.WHITE, wx.SOLID) + self.colSize = None + self.rowSize = 50 + + def Draw(self, grid, attr, dc, rect, row, col, isSelected): + # Here we draw text in a grid cell using various fonts + # and colors. We have to set the clipping region on + # the grid's DC, otherwise the text will spill over + # to the next cell + dc.SetClippingRect(rect) + + # clear the background + dc.SetBackgroundMode(wx.SOLID) + + if isSelected: + dc.SetBrush(wx.Brush(wx.BLUE, wx.SOLID)) + dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID)) + else: + dc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID)) + dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID)) + dc.DrawRectangleRect(rect) + + #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height)) + + text = self.table.GetValue(row, col) + dc.SetBackgroundMode(wx.SOLID) + + # change the text background based on whether the grid is selected + # or not + if isSelected: + dc.SetBrush(self.selectedBrush) + dc.SetTextBackground("blue") + else: + dc.SetBrush(self.normalBrush) + dc.SetTextBackground("white") + + dc.SetTextForeground(self.color) + dc.SetFont(self.font) + dc.DrawText(text, (rect.x+1, rect.y+1)) + + # Okay, now for the advanced class :) + # Let's add three dots "..." + # to indicate that that there is more text to be read + # when the text is larger than the grid cell + + width, height = dc.GetTextExtent(text) + + if width > rect.width-2: + width, height = dc.GetTextExtent("...") + x = rect.x+1 + rect.width-2 - width + dc.DrawRectangle((x, rect.y+1), (width+1, height)) + dc.DrawText("...", (x, rect.y+1)) + + dc.DestroyClippingRegion() + + +# -------------------------------------------------------------------- +# Sample Grid using a specialized table and renderers that can +# be plugged in based on column names + +class MegaGrid(Grid.Grid): + def __init__(self, parent, data, colnames, plugins=None): + """parent, data, colnames, plugins=None + Initialize a grid using the data defined in data and colnames + (see MegaTable for a description of the data format) + plugins is a dictionary of columnName -> column renderers. + """ + + # The base class must be initialized *first* + Grid.Grid.__init__(self, parent, -1) + self._table = MegaTable(data, colnames, plugins) + self.SetTable(self._table) + self._plugins = plugins + + self.Bind(Grid.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClicked) + + def Reset(self): + """reset the view based on the data in the table. Call + this when rows are added or destroyed""" + self._table.ResetView(self) + + def OnLabelRightClicked(self, evt): + # Did we click on a row or a column? + row, col = evt.GetRow(), evt.GetCol() + if row == -1: self.colPopup(col, evt) + elif col == -1: self.rowPopup(row, evt) + + def rowPopup(self, row, evt): + """(row, evt) -> display a popup menu when a row label is right clicked""" + appendID = wx.NewId() + deleteID = wx.NewId() + x = self.GetRowSize(row)/2 + + if not self.GetSelectedRows(): + self.SelectRow(row) + + menu = wx.Menu() + xo, yo = evt.GetPosition() + menu.Append(appendID, "Append Row") + menu.Append(deleteID, "Delete Row(s)") + + def append(event, self=self, row=row): + self._table.AppendRow(row) + self.Reset() + + def delete(event, self=self, row=row): + rows = self.GetSelectedRows() + self._table.DeleteRows(rows) + self.Reset() + + self.Bind(wx.EVT_MENU, append, id=appendID) + self.Bind(wx.EVT_MENU, delete, id=deleteID) + self.PopupMenu(menu, (x, yo)) + menu.Destroy() + return + + + def colPopup(self, col, evt): + """(col, evt) -> display a popup menu when a column label is + right clicked""" + x = self.GetColSize(col)/2 + menu = wx.Menu() + id1 = wx.NewId() + sortID = wx.NewId() + + xo, yo = evt.GetPosition() + self.SelectCol(col) + cols = self.GetSelectedCols() + self.Refresh() + menu.Append(id1, "Delete Col(s)") + menu.Append(sortID, "Sort Column") + + def delete(event, self=self, col=col): + cols = self.GetSelectedCols() + self._table.DeleteCols(cols) + self.Reset() + + def sort(event, self=self, col=col): + self._table.SortColumn(col) + self.Reset() + + self.Bind(wx.EVT_MENU, delete, id=id1) + + if len(cols) == 1: + self.Bind(wx.EVT_MENU, sort, id=sortID) + + self.PopupMenu(menu, (xo, 0)) + menu.Destroy() + return + +# ----------------------------------------------------------------- +# Test data +# data is in the form +# [rowname, dictionary] +# where dictionary.get(colname, None) -> returns the value for the cell +# +# the colname must also be supplied +import random +colnames = ["Row", "This", "Is", "A", "Test"] + +data = [] + +for row in range(1000): + d = {} + for name in ["This", "Test", "Is"]: + d[name] = random.random() + + d["Row"] = len(data) + # XXX + # the "A" column can only be between one and 4 + d["A"] = random.choice(range(4)) + data.append((str(row), d)) + +class MegaFontRendererFactory: + def __init__(self, color, font, fontsize): + """ + (color, font, fontsize) -> set of a factory to generate + renderers when called. + func = MegaFontRenderFactory(color, font, fontsize) + renderer = func(table) + """ + self.color = color + self.font = font + self.fontsize = fontsize + + def __call__(self, table): + return MegaFontRenderer(table, self.color, self.font, self.fontsize) + + +#--------------------------------------------------------------------------- + +class TestFrame(wx.Frame): + def __init__(self, parent, plugins={"This":MegaFontRendererFactory("red", "ARIAL", 8), + "A":MegaImageRenderer, + "Test":MegaFontRendererFactory("orange", "TIMES", 24),}): + wx.Frame.__init__(self, parent, -1, + "Test Frame", size=(640,480)) + + grid = MegaGrid(self, data, colnames, plugins) + grid.Reset() + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestFrame(frame) + frame.otherWin = win + win.Show(True) + + + +overview = """Mega Grid Example + +This example attempts to show many examples and tricks of +using a virtual grid object. Hopefully the source isn't too jumbled. + +Features: +
    +
  1. Uses a virtual grid +
  2. Columns and rows have popup menus (right click on labels) +
  3. Columns and rows can be deleted (i.e. table can be + resized) +
  4. Dynamic renderers. Renderers are plugins based on + column header name. Shows a simple Font Renderer and + an Image Renderer. +
+ +Look for 'XXX' in the code to indicate some workarounds for non-obvious +behavior and various hacks. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/HtmlWindow.py b/wxPython/demo/HtmlWindow.py new file mode 100644 index 0000000000..edfe7027b6 --- /dev/null +++ b/wxPython/demo/HtmlWindow.py @@ -0,0 +1,239 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o got the wxpTag stuff working right. +# +# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxScrolledMessageDialog -> ScrolledMessageDialog +# + +import os +import sys + +import wx +import wx.html as html +import wx.lib.wxpTag + +from Main import opj + +#---------------------------------------------------------------------- + +# This shows how to catch the OnLinkClicked non-event. (It's a virtual +# method in the C++ code...) +class MyHtmlWindow(html.HtmlWindow): + def __init__(self, parent, id, log): + html.HtmlWindow.__init__(self, parent, id, style=wx.NO_FULL_REPAINT_ON_RESIZE) + self.log = log + self.Bind(wx.EVT_SCROLLWIN, self.OnScroll ) + + def OnScroll( self, event ): + #print 'event.GetOrientation()',event.GetOrientation() + #print 'event.GetPosition()',event.GetPosition() + event.Skip() + + def OnLinkClicked(self, linkinfo): + self.log.WriteText('OnLinkClicked: %s\n' % linkinfo.GetHref()) + + # Virtuals in the base class have been renamed with base_ on the front. + self.base_OnLinkClicked(linkinfo) + + + def OnSetTitle(self, title): + self.log.WriteText('OnSetTitle: %s\n' % title) + self.base_OnSetTitle(title) + + def OnCellMouseHover(self, cell, x, y): + self.log.WriteText('OnCellMouseHover: %s, (%d %d)\n' % (cell, x, y)) + self.base_OnCellMouseHover(cell, x, y) + + def OnCellClicked(self, cell, x, y, evt): + self.log.WriteText('OnCellClicked: %s, (%d %d)\n' % (cell, x, y)) + self.base_OnCellClicked(cell, x, y, evt) + + +# This filter doesn't really do anything but show how to use filters +class MyHtmlFilter(html.HtmlFilter): + def __init__(self, log): + html.HtmlFilter.__init__(self) + self.log = log + + # This method decides if this filter is able to read the file + def CanRead(self, fsfile): + self.log.write("CanRead: %s\n" % fsfile.GetMimeType()) + return False + + # If CanRead returns True then this method is called to actually + # read the file and return the contents. + def ReadFile(self, fsfile): + return "" + + +class TestHtmlPanel(wx.Panel): + def __init__(self, parent, frame, log): + wx.Panel.__init__(self, parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) + self.log = log + self.frame = frame + self.cwd = os.path.split(sys.argv[0])[0] + + if not self.cwd: + self.cwd = os.getcwd() + if frame: + self.titleBase = frame.GetTitle() + + html.HtmlWindow_AddFilter(MyHtmlFilter(log)) + + self.html = MyHtmlWindow(self, -1, log) + self.html.SetRelatedFrame(frame, self.titleBase + " -- %s") + self.html.SetRelatedStatusBar(0) + + self.printer = html.HtmlEasyPrinting() + + self.box = wx.BoxSizer(wx.VERTICAL) + self.box.Add(self.html, 1, wx.GROW) + + subbox = wx.BoxSizer(wx.HORIZONTAL) + + btn = wx.Button(self, -1, "Load File") + self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn) + subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) + + btn = wx.Button(self, -1, "Load URL") + self.Bind(wx.EVT_BUTTON, self.OnLoadURL, btn) + subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) + + btn = wx.Button(self, -1, "With Widgets") + self.Bind(wx.EVT_BUTTON, self.OnWithWidgets, btn) + subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) + + btn = wx.Button(self, -1, "Back") + self.Bind(wx.EVT_BUTTON, self.OnBack, btn) + subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) + + btn = wx.Button(self, -1, "Forward") + self.Bind(wx.EVT_BUTTON, self.OnForward, btn) + subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) + + btn = wx.Button(self, -1, "Print") + self.Bind(wx.EVT_BUTTON, self.OnPrint, btn) + subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) + + btn = wx.Button(self, -1, "View Source") + self.Bind(wx.EVT_BUTTON, self.OnViewSource, btn) + subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) + + self.box.Add(subbox, 0, wx.GROW) + self.SetSizer(self.box) + self.SetAutoLayout(True) + + # A button with this ID is created on the widget test page. + self.Bind(wx.EVT_BUTTON, self.OnOk, id=wx.ID_OK) + + self.OnShowDefault(None) + + + def ShutdownDemo(self): + # put the frame title back + if self.frame: + self.frame.SetTitle(self.titleBase) + + + def OnShowDefault(self, event): + name = os.path.join(self.cwd, opj('data/test.htm')) + self.html.LoadPage(name) + + + def OnLoadFile(self, event): + dlg = wx.FileDialog(self, wildcard = '*.htm*', style=wx.OPEN) + + if dlg.ShowModal(): + path = dlg.GetPath() + self.html.LoadPage(path) + + dlg.Destroy() + + + def OnLoadURL(self, event): + dlg = wx.TextEntryDialog(self, "Enter a URL") + + if dlg.ShowModal(): + url = dlg.GetValue() + self.html.LoadPage(url) + + dlg.Destroy() + + + def OnWithWidgets(self, event): + os.chdir(self.cwd) + name = os.path.join(self.cwd, opj('data/widgetTest.htm')) + self.html.LoadPage(name) + + + def OnOk(self, event): + self.log.WriteText("It works!\n") + + def OnBack(self, event): + if not self.html.HistoryBack(): + wx.MessageBox("No more items in history!") + + + def OnForward(self, event): + if not self.html.HistoryForward(): + wx.MessageBox("No more items in history!") + + + def OnViewSource(self, event): + import wx.lib.dialogs + + source = self.html.GetParser().GetSource() + + dlg = wx.lib.dialogs.ScrolledMessageDialog(self, source, 'HTML Source') + dlg.ShowModal() + dlg.Destroy() + + + def OnPrint(self, event): + self.printer.GetPrintData().SetPaperId(wx.PAPER_LETTER) + self.printer.PrintFile(self.html.GetOpenedPage()) + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestHtmlPanel(nb, frame, log) + print wx.Window_FindFocus() + return win + + +#---------------------------------------------------------------------- + + +overview = """ +

wxHtmlWindow

+ +

wxHtmlWindow is capable of parsing and rendering most +simple HTML tags. + +

It is not intended to be a high-end HTML browser. If you're +looking for something like that see the IEHtmlWin class, which +wraps the core MSIE HTML viewer. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + + + + + + + diff --git a/wxPython/demo/IEHtmlWin.py b/wxPython/demo/IEHtmlWin.py new file mode 100644 index 0000000000..33e5b8c8be --- /dev/null +++ b/wxPython/demo/IEHtmlWin.py @@ -0,0 +1,221 @@ +# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o iewin.py is missing +# + +import wx + +if wx.Platform == '__WXMSW__': + import wx.iewin as iewin + +#---------------------------------------------------------------------- + +class TestPanel(wx.Window): + def __init__(self, parent, log, frame=None): + wx.Window.__init__( + self, parent, -1, + style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE + ) + + self.log = log + self.current = "http://wxPython.org/" + self.frame = frame + + if frame: + self.titleBase = frame.GetTitle() + + sizer = wx.BoxSizer(wx.VERTICAL) + btnSizer = wx.BoxSizer(wx.HORIZONTAL) + + self.ie = iewin.IEHtmlWin(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE) + + + btn = wx.Button(self, wx.NewId(), "Open", style=wx.BU_EXACTFIT) + wx.EVT_BUTTON(self, btn.GetId(), self.OnOpenButton) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, wx.NewId(), "Home", style=wx.BU_EXACTFIT) + wx.EVT_BUTTON(self, btn.GetId(), self.OnHomeButton) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, wx.NewId(), "<--", style=wx.BU_EXACTFIT) + wx.EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, wx.NewId(), "-->", style=wx.BU_EXACTFIT) + wx.EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, wx.NewId(), "Stop", style=wx.BU_EXACTFIT) + wx.EVT_BUTTON(self, btn.GetId(), self.OnStopButton) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, wx.NewId(), "Search", style=wx.BU_EXACTFIT) + wx.EVT_BUTTON(self, btn.GetId(), self.OnSearchPageButton) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, wx.NewId(), "Refresh", style=wx.BU_EXACTFIT) + wx.EVT_BUTTON(self, btn.GetId(), self.OnRefreshPageButton) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + txt = wx.StaticText(self, -1, "Location:") + btnSizer.Add(txt, 0, wx.CENTER|wx.ALL, 2) + + self.location = wx.ComboBox( + self, wx.NewId(), "", style=wx.CB_DROPDOWN|wx.PROCESS_ENTER + ) + + wx.EVT_COMBOBOX(self, self.location.GetId(), self.OnLocationSelect) + wx.EVT_KEY_UP(self.location, self.OnLocationKey) + wx.EVT_CHAR(self.location, self.IgnoreReturn) + btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2) + + sizer.Add(btnSizer, 0, wx.EXPAND) + sizer.Add(self.ie, 1, wx.EXPAND) + + self.ie.Navigate(self.current) + self.location.Append(self.current) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + wx.EVT_SIZE(self, self.OnSize) + + # Hook up the event handlers for the IE window + iewin.EVT_MSHTML_BEFORENAVIGATE2(self, -1, self.OnBeforeNavigate2) + iewin.EVT_MSHTML_NEWWINDOW2(self, -1, self.OnNewWindow2) + iewin.EVT_MSHTML_DOCUMENTCOMPLETE(self, -1, self.OnDocumentComplete) + #EVT_MSHTML_PROGRESSCHANGE(self, -1, self.OnProgressChange) + iewin.EVT_MSHTML_STATUSTEXTCHANGE(self, -1, self.OnStatusTextChange) + iewin.EVT_MSHTML_TITLECHANGE(self, -1, self.OnTitleChange) + + + def ShutdownDemo(self): + # put the frame title back + if self.frame: + self.frame.SetTitle(self.titleBase) + + + def OnSize(self, evt): + self.Layout() + + + def OnLocationSelect(self, evt): + url = self.location.GetStringSelection() + self.log.write('OnLocationSelect: %s\n' % url) + self.ie.Navigate(url) + + def OnLocationKey(self, evt): + if evt.KeyCode() == wx.WXK_RETURN: + URL = self.location.GetValue() + self.location.Append(URL) + self.ie.Navigate(URL) + else: + evt.Skip() + + + def IgnoreReturn(self, evt): + if evt.GetKeyCode() != wx.WXK_RETURN: + evt.Skip() + + def OnOpenButton(self, event): + dlg = wx.TextEntryDialog(self, "Open Location", + "Enter a full URL or local path", + self.current, wx.OK|wx.CANCEL) + dlg.CentreOnParent() + + if dlg.ShowModal() == wx.ID_OK: + self.current = dlg.GetValue() + self.ie.Navigate(self.current) + + dlg.Destroy() + + def OnHomeButton(self, event): + self.ie.GoHome() ## ET Phone Home! + + def OnPrevPageButton(self, event): + self.ie.GoBack() + + def OnNextPageButton(self, event): + self.ie.GoForward() + + def OnStopButton(self, evt): + self.ie.Stop() + + def OnSearchPageButton(self, evt): + self.ie.GoSearch() + + def OnRefreshPageButton(self, evt): + self.ie.Refresh(iewin.IEHTML_REFRESH_COMPLETELY) + + + def logEvt(self, name, event): + self.log.write('%s: %s\n' % + (name, (event.GetLong1(), event.GetLong2(), event.GetText1()))) + + def OnBeforeNavigate2(self, evt): + self.logEvt('OnBeforeNavigate2', evt) + + def OnNewWindow2(self, evt): + self.logEvt('OnNewWindow2', evt) + evt.Veto() # don't allow it + + def OnDocumentComplete(self, evt): + self.logEvt('OnDocumentComplete', evt) + self.current = evt.GetText1() + self.location.SetValue(self.current) + + def OnTitleChange(self, evt): + self.logEvt('OnTitleChange', evt) + if self.frame: + self.frame.SetTitle(self.titleBase + ' -- ' + evt.GetText1()) + + def OnStatusTextChange(self, evt): + self.logEvt('OnStatusTextChange', evt) + if self.frame: + self.frame.SetStatusText(evt.GetText1()) + + +#---------------------------------------------------------------------- +# for the demo framework... + +def runTest(frame, nb, log): + if wx.Platform == '__WXMSW__': + win = TestPanel(nb, log, frame) + return win + else: + dlg = wx.MessageDialog(frame, 'This demo only works on MSW.', + 'Sorry', wx.OK | wx.ICON_INFORMATION) + dlg.ShowModal() + dlg.Destroy() + + + +overview = """\ + +

wxIEHtmlWin

+ +The wxIEHtmlWin class is the first example of using a contributed +wxActiveX class in wxWindows C++. It is still experimental, but +I think it is useful. + +

Using this class is simpler than ActiveXWrapper, doesn't rely on +the win32all extensions, and is more "wx\'ish", meaning that it uses +events and etc. as would be expected from any other wx window. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + +#---------------------------------------------------------------------- + diff --git a/wxPython/demo/Image.py b/wxPython/demo/Image.py new file mode 100644 index 0000000000..415bfd9ce7 --- /dev/null +++ b/wxPython/demo/Image.py @@ -0,0 +1,81 @@ +# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +from Main import opj + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + bmp = wx.Image(opj('bitmaps/image.bmp'), wx.BITMAP_TYPE_BMP).ConvertToBitmap() + gif = wx.Image(opj('bitmaps/image.gif'), wx.BITMAP_TYPE_GIF).ConvertToBitmap() + png = wx.Image(opj('bitmaps/image.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() + jpg = wx.Image(opj('bitmaps/image.jpg'), wx.BITMAP_TYPE_JPEG).ConvertToBitmap() + + panel = wx.Panel(nb, -1) + + pos = 10 + wx.StaticBitmap(panel, -1, bmp, (10, pos), (bmp.GetWidth(), bmp.GetHeight())) + + pos = pos + bmp.GetHeight() + 10 + wx.StaticBitmap(panel, -1, gif, (10, pos), (gif.GetWidth(), gif.GetHeight())) + + pos = pos + gif.GetHeight() + 10 + wx.StaticBitmap(panel, -1, png, (10, pos), (png.GetWidth(), png.GetHeight())) + + pos = pos + png.GetHeight() + 10 + wx.StaticBitmap(panel, -1, jpg, (10, pos), (jpg.GetWidth(), jpg.GetHeight())) + + return panel + +#---------------------------------------------------------------------- + + + +overview = """\ + + +This class encapsulates a platform-independent image. An image can be created +from data, or using wxBitmap.ConvertToImage. An image can be loaded from +a file in a variety of formats, and is extensible to new formats via image +format handlers. Functions are available to set and get image bits, so it can +be used for basic image manipulation. + +

The following image handlers are available. wxBMPHandler is always installed +by default. To use other image formats, install the appropriate handler or use +wx.InitAllImageHandlers(). + +

+ + + + + + + + + + + + + +
wxBMPHandler For loading and saving, always installed.
wxPNGHandler For loading and saving.
wxJPEGHandler For loading and saving.
wxGIFHandler Only for loading, due to legal issues.
wxPCXHandler For loading and saving.
wxPNMHandler For loading and saving.
wxTIFFHandler For loading and saving.
wxIFFHandler For loading only.
wxXPMHandler For loading and saving.
wxICOHandler For loading and saving.
wxCURHandler For loading and saving.
wxANIHandler For loading only.
+ +

When saving in PCX format, wxPCXHandler will count the number of different +colours in the image; if there are 256 or less colours, it will save as 8 bit, +else it will save as 24 bit. + +

Loading PNMs only works for ASCII or raw RGB images. When saving in PNM format, +wxPNMHandler will always save as raw RGB. + + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/ImageFromStream.py b/wxPython/demo/ImageFromStream.py new file mode 100644 index 0000000000..720389a818 --- /dev/null +++ b/wxPython/demo/ImageFromStream.py @@ -0,0 +1,50 @@ +# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import cStringIO + +import wx + +from Main import opj + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + + data = open(opj('bitmaps/image.png'), "rb").read() + stream = cStringIO.StringIO(data) + + bmp = wx.BitmapFromImage( wx.ImageFromStream( stream )) + + wx.StaticText( + self, -1, "This image was loaded from a Python file-like object:", + (15, 15) + ) + + wx.StaticBitmap(self, -1, bmp, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight())) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +At long last there is finally a way to load any supported image type +directly from any Python file-like object, such as a memory buffer +using StringIO. """ + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/IntCtrl.py b/wxPython/demo/IntCtrl.py new file mode 100644 index 0000000000..27b968c5a2 --- /dev/null +++ b/wxPython/demo/IntCtrl.py @@ -0,0 +1,359 @@ +# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o intctrl needs the renamer applied. +# o intctrl needs new event binders. +# +# 12/08/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o All issues corrected +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxIntCtrl -> IntCtrl +# + +import wx +import wx.lib.intctrl + +#---------------------------------------------------------------------- + +class TestPanel( wx.Panel ): + def __init__( self, parent, log ): + + wx.Panel.__init__( self, parent, -1 ) + self.log = log + panel = wx.Panel( self, -1 ) + + self.set_min = wx.CheckBox( panel, -1, "Set minimum value:" ) + self.min = wx.lib.intctrl.IntCtrl( panel, size=( 50, -1 ) ) + self.min.Enable( False ) + + self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" ) + self.max = wx.lib.intctrl.IntCtrl( panel, size=( 50, -1 ) ) + self.max.Enable( False ) + + self.limit_target = wx.CheckBox( panel, -1, "Limit control" ) + self.allow_none = wx.CheckBox( panel, -1, "Allow empty control" ) + self.allow_long = wx.CheckBox( panel, -1, "Allow long integers" ) + + label = wx.StaticText( panel, -1, "Resulting integer control:" ) + self.target_ctl = wx.lib.intctrl.IntCtrl( panel ) + + grid = wx.FlexGridSizer( 0, 2, 0, 0 ) + grid.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid.Add( self.min, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid.Add(self.set_max, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid.Add( self.max, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid.Add( self.limit_target, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid.Add( self.allow_none, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid.Add( self.allow_long, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid.Add( self.target_ctl, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + outer_box = wx.BoxSizer( wx.VERTICAL ) + outer_box.AddSizer( grid, 0, wx.ALIGN_CENTRE|wx.ALL, 20 ) + + panel.SetAutoLayout( True ) + panel.SetSizer( outer_box ) + outer_box.Fit( panel ) + panel.Move( (50,50) ) + self.panel = panel + + self.Bind(wx.EVT_CHECKBOX, self.OnSetMin, self.set_min) + self.Bind(wx.EVT_CHECKBOX, self.OnSetMax, self.set_max) + self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target) + self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none) + self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowLong, self.allow_long) + + self.Bind(wx.lib.intctrl.EVT_INT, self.SetTargetMinMax, self.min) + self.Bind(wx.lib.intctrl.EVT_INT, self.SetTargetMinMax, self.max) + self.Bind(wx.lib.intctrl.EVT_INT, self.OnTargetChange, self.target_ctl) + + + def OnSetMin( self, event ): + self.min.Enable( self.set_min.GetValue() ) + self.SetTargetMinMax() + + def OnSetMax( self, event ): + self.max.Enable( self.set_max.GetValue() ) + self.SetTargetMinMax() + + + def SetTargetMinMax( self, event=None ): + min = max = None + self.target_ctl.SetLimited( self.limit_target.GetValue() ) + + if self.set_min.GetValue(): + min = self.min.GetValue() + + if self.set_max.GetValue(): + max = self.max.GetValue() + + cur_min, cur_max = self.target_ctl.GetBounds() + + if min != cur_min and not self.target_ctl.SetMin( min ): + self.log.write( "min (%d) > current max (%d) -- bound not set\n" % ( min, self.target_ctl.GetMax() ) ) + self.min.SetForegroundColour( wx.RED ) + else: + self.min.SetForegroundColour( wx.BLACK ) + + self.min.Refresh() + + if max != cur_max and not self.target_ctl.SetMax( max ): + self.log.write( "max (%d) < current min (%d) -- bound not set\n" % ( max, self.target_ctl.GetMin() ) ) + self.max.SetForegroundColour( wx.RED ) + else: + self.max.SetForegroundColour( wx.BLACK ) + + self.max.Refresh() + + if min != cur_min or max != cur_max: + new_min, new_max = self.target_ctl.GetBounds() + self.log.write( "current min, max: (%s, %s)\n" % ( str(new_min), str(new_max) ) ) + + + def OnSetAllowNone( self, event ): + self.target_ctl.SetNoneAllowed( self.allow_none.GetValue() ) + + + def OnSetAllowLong( self, event ): + self.target_ctl.SetLongAllowed( self.allow_long.GetValue() ) + + + def OnTargetChange( self, event ): + ctl = event.GetEventObject() + value = ctl.GetValue() + ib_str = [ " (out of bounds)", "" ] + self.log.write( "integer value = %s%s\n" % ( str(value), ib_str[ ctl.IsInBounds(value) ] ) ) + + +#---------------------------------------------------------------------- + +def runTest( frame, nb, log ): + win = TestPanel( nb, log ) + return win + +#---------------------------------------------------------------------- + +overview = """ +

+IntCtrl provides a control that takes and returns integers as +value, and provides bounds support and optional value limiting. +

+

+Here's the API for IntCtrl: +

+    IntCtrl(
+         parent, id = -1,
+         value = 0,
+         min = None,
+         max = None,
+         limited = False,
+         allow_none = False,
+         allow_long = False,
+         default_color = wxBLACK,
+         oob_color = wxRED,
+         pos = wxDefaultPosition,
+         size = wxDefaultSize,
+         style = 0,
+         name = "integer")
+
+ +
+
+
EVT_INT(win, id, func) +
Respond to a wxEVT_COMMAND_INT_UPDATED event, generated when the +value changes. Notice that this event will always be sent when the +control's contents changes - whether this is due to user input or +comes from the program itself (for example, if SetValue() is called.) +
+
+
SetValue(int) +
Sets the value of the control to the integer value specified. +The resulting actual value of the control may be altered to +conform with the bounds set on the control if limited, +or colored if not limited but the value is out-of-bounds. +A ValueError exception will be raised if an invalid value +is specified. +
+
GetValue() +
Retrieves the integer value from the control. The value +retrieved will be sized as an int if possible or a long, +if necessary. +
+
+
SetMin(min=None) +
Sets the expected minimum value, or lower bound, of the control. +(The lower bound will only be enforced if the control is +configured to limit its values to the set bounds.) +If a value of None is provided, then the control will have +no explicit lower bound. If the value specified is greater than +the current lower bound, then the function returns 0 and the +lower bound will not change from its current setting. On success, +the function returns 1. +
If successful and the current value is +lower than the new lower bound, if the control is limited, the +value will be automatically adjusted to the new minimum value; +if not limited, the value in the control will be colored with +the current out-of-bounds color. +
+
GetMin() +
Gets the current lower bound value for the control. +It will return None if no lower bound is currently specified. +
+
+
SetMax(max=None) +
Sets the expected maximum value, or upper bound, of the control. +(The upper bound will only be enforced if the control is +configured to limit its values to the set bounds.) +If a value of None is provided, then the control will +have no explicit upper bound. If the value specified is less +than the current lower bound, then the function returns 0 and +the maximum will not change from its current setting. On success, +the function returns 1. +
If successful and the current value +is greater than the new upper bound, if the control is limited +the value will be automatically adjusted to the new maximum value; +if not limited, the value in the control will be colored with the +current out-of-bounds color. +
+
GetMax() +
Gets the current upper bound value for the control. +It will return None if no upper bound is currently specified. +
+
+
SetBounds(min=None,max=None) +
This function is a convenience function for setting the min and max +values at the same time. The function only applies the maximum bound +if setting the minimum bound is successful, and returns True +only if both operations succeed. Note: leaving out an argument +will remove the corresponding bound. +
GetBounds() +
This function returns a two-tuple (min,max), indicating the +current bounds of the control. Each value can be None if +that bound is not set. +
+
+
IsInBounds(value=None) +
Returns True if no value is specified and the current value +of the control falls within the current bounds. This function can also +be called with a value to see if that value would fall within the current +bounds of the given control. +
+
+
SetLimited(bool) +
If called with a value of True, this function will cause the control +to limit the value to fall within the bounds currently specified. +If the control's value currently exceeds the bounds, it will then +be limited accordingly. +If called with a value of 0, this function will disable value +limiting, but coloring of out-of-bounds values will still take +place if bounds have been set for the control. +
IsLimited() +
Returns True if the control is currently limiting the +value to fall within the current bounds. +
+
+
SetNoneAllowed(bool) +
If called with a value of True, this function will cause the control +to allow the value to be empty, representing a value of None. +If called with a value of false, this function will prevent the value +from being None. If the value of the control is currently None, +ie. the control is empty, then the value will be changed to that +of the lower bound of the control, or 0 if no lower bound is set. +
IsNoneAllowed() +
Returns True if the control currently allows its +value to be None. +
+
+
SetLongAllowed(bool) +
If called with a value of True, this function will cause the +control to allow the value to be a long. If called with a value +of False, and the value of the control is currently a long value, +the value of the control will be adjusted to fall within the +size of an integer type, at either the sys.maxint or -sys.maxint-1, +for positive and negative values, respectively. +
IsLongAllowed() +
Returns True if the control currently allows its +value to be of type long. +
+
+
SetColors(default_color=wxBLACK, oob_color=wxRED) +
Tells the control what colors to use for normal and out-of-bounds +values. If the value currently exceeds the bounds, it will be +recolored accordingly. +
GetColors() +
Returns a tuple of (default_color, oob_color) indicating +the current color settings for the control. +
+
+
Cut() +
Will allow cuts to the clipboard of the text portion of the value, +leaving the value of zero if the entire contents are "cut." +
Paste() +
Will paste the contents of the clipboard to the selected portion +of the value; if the resulting string does not represent a legal +value, a ValueError will result. If the result is out-of bounds, +it will either be adjusted or colored as appropriate. +
+ +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/Joystick.py b/wxPython/demo/Joystick.py new file mode 100644 index 0000000000..2c4113adf0 --- /dev/null +++ b/wxPython/demo/Joystick.py @@ -0,0 +1,206 @@ + +#---------------------------------------------------------------------------- + +from wxPython.wx import * +from joystick_wdr import * + + +class JoystickTestPanel(wxPanel): + def __init__(self, parent, id, + pos = wxDefaultPosition, size = wxDefaultSize, + style = wxTAB_TRAVERSAL ): + wxPanel.__init__(self, parent, id, pos, size, style) + + MakeJoystickTestPanel( self, True ) + + try: + self.stick = wxJoystick() + self.stick.SetCapture(self) + EVT_JOYSTICK_EVENTS(self, self.OnJoystick) + self.UpdateFields() + except NotImplementedError, v: + wxMessageBox(str(v), "Exception Message") + + + def UpdateFields(self): + s = self.stick + self.GetXPositionCtrl().SetValue(str(s.GetPosition().x)) + self.GetYPositionCtrl().SetValue(str(s.GetPosition().y)) + self.GetZPositionCtrl().SetValue(str(s.GetZPosition())) + self.GetPovCtsPosCtrl().SetValue(str(s.GetPOVPosition())) + self.GetRudderPosCtrl().SetValue(str(s.GetRudderPosition())) + self.GetHasRudderCtrl().SetValue(str(s.HasRudder())) + self.GetHasZCtrl().SetValue(str(s.HasZ())) + self.GetHasPovCtrl().SetValue(str(s.HasPOV())) + self.GetHasPov4dirCtrl().SetValue(str(s.HasPOV4Dir())) + self.GetMfgIdCtrl().SetValue(str(s.GetManufacturerId())) + self.GetProdNameCtrl().SetValue(str(s.GetProductName())) + self.GetZMinCtrl().SetValue(str(s.GetZMin())) + self.GetXMaxCtrl().SetValue(str(s.GetXMax())) + self.GetNumButtonsCtrl().SetValue(str(s.GetNumberButtons())) + self.GetNumAxesCtrl().SetValue(str(s.GetNumberAxes())) + self.GetPollingMinCtrl().SetValue(str(s.GetPollingMin())) + self.GetPollingMaxCtrl().SetValue(str(s.GetPollingMax())) + self.GetUMinCtrl().SetValue(str(s.GetUMin())) + self.GetUMaxCtrl().SetValue(str(s.GetUMax())) + self.GetButtonStateCtrl().SetValue(str(s.GetButtonState())) + self.GetPovPositionCtrl().SetValue(str(s.GetPOVPosition())) + self.GetUPositionCtrl().SetValue(str(s.GetUPosition())) + self.GetVPositionCtrl().SetValue(str(s.GetVPosition())) + self.GetHasUCtrl().SetValue(str(s.HasU())) + self.GetHasVCtrl().SetValue(str(s.HasV())) + self.GetHasPovCtsCtrl().SetValue(str(s.HasPOVCTS())) + self.GetNumSticksCtrl().SetValue(str(s.GetNumberJoysticks())) + self.GetXMinCtrl().SetValue(str(s.GetXMin())) + self.GetYMinCtrl().SetValue(str(s.GetYMin())) + self.GetYMaxCtrl().SetValue(str(s.GetYMax())) + self.GetZMaxCtrl().SetValue(str(s.GetZMax())) + self.GetMaxButtonsCtrl().SetValue(str(s.GetMaxButtons())) + self.GetMaxAxesCtrl().SetValue(str(s.GetMaxAxes())) + self.GetRudderMinCtrl().SetValue(str(s.GetRudderMin())) + self.GetRudderMaxCtrl().SetValue(str(s.GetRudderMax())) + self.GetVMinCtrl().SetValue(str(s.GetVMin())) + self.GetVMaxCtrl().SetValue(str(s.GetVMax())) + + + def OnJoystick(self, evt): + self.UpdateFields() + + + # WDR: methods for JoystickTestPanel + + def GetYPositionCtrl(self): + return self.FindWindowById(ID_Y_Position_Ctrl) + + def GetXPositionCtrl(self): + return self.FindWindowById(ID_X_Position_Ctrl) + + + def GetVMaxCtrl(self): + return self.FindWindowById(ID_V_Max_Ctrl) + + def GetVMinCtrl(self): + return self.FindWindowById(ID_V_Min_Ctrl) + + def GetRudderMaxCtrl(self): + return self.FindWindowById(ID_Rudder_Max_Ctrl) + + def GetRudderMinCtrl(self): + return self.FindWindowById(ID_Rudder_Min_Ctrl) + + def GetMaxAxesCtrl(self): + return self.FindWindowById(ID_Max_Axes_Ctrl) + + def GetMaxButtonsCtrl(self): + return self.FindWindowById(ID_Max_Buttons_Ctrl) + + def GetZMaxCtrl(self): + return self.FindWindowById(ID_Z_Max_Ctrl) + + def GetYMaxCtrl(self): + return self.FindWindowById(ID_Y_Max_Ctrl) + + def GetYMinCtrl(self): + return self.FindWindowById(ID_Y_Min_Ctrl) + + def GetXMinCtrl(self): + return self.FindWindowById(ID_X_Min_Ctrl) + + def GetNumSticksCtrl(self): + return self.FindWindowById(ID_Num_Sticks_Ctrl) + + def GetHasPovCtsCtrl(self): + return self.FindWindowById(ID_Has_POV_CTS_Ctrl) + + def GetHasVCtrl(self): + return self.FindWindowById(ID_Has_V_Ctrl) + + def GetHasUCtrl(self): + return self.FindWindowById(ID_Has_U_Ctrl) + + def GetVPositionCtrl(self): + return self.FindWindowById(ID_V_Position_Ctrl) + + def GetUPositionCtrl(self): + return self.FindWindowById(ID_U_Position_Ctrl) + + def GetPovPositionCtrl(self): + return self.FindWindowById(ID_POV_Position_Ctrl) + + def GetButtonStateCtrl(self): + return self.FindWindowById(ID_Button_State_Ctrl) + + def GetUMaxCtrl(self): + return self.FindWindowById(ID_U_Max_Ctrl) + + def GetUMinCtrl(self): + return self.FindWindowById(ID_U_Min_Ctrl) + + def GetPollingMaxCtrl(self): + return self.FindWindowById(ID_Polling_Max_Ctrl) + + def GetPollingMinCtrl(self): + return self.FindWindowById(ID_Polling_Min_Ctrl) + + def GetNumAxesCtrl(self): + return self.FindWindowById(ID_Num_Axes_Ctrl) + + def GetNumButtonsCtrl(self): + return self.FindWindowById(ID_Num_Buttons_Ctrl) + + def GetXMaxCtrl(self): + return self.FindWindowById(ID_X_Max_Ctrl) + + def GetZMinCtrl(self): + return self.FindWindowById(ID_Z_Min_Ctrl) + + def GetProdNameCtrl(self): + return self.FindWindowById(ID_Prod_Name_Ctrl) + + def GetMfgIdCtrl(self): + return self.FindWindowById(ID_Mfg_ID_Ctrl) + + def GetHasPov4dirCtrl(self): + return self.FindWindowById(ID_Has_POV_4DIR_Ctrl) + + def GetHasPovCtrl(self): + return self.FindWindowById(ID_Has_POV_Ctrl) + + def GetHasZCtrl(self): + return self.FindWindowById(ID_Has_Z_Ctrl) + + def GetHasRudderCtrl(self): + return self.FindWindowById(ID_Has_Rudder_Ctrl) + + def GetRudderPosCtrl(self): + return self.FindWindowById(ID_Rudder_Pos_Ctrl) + + def GetPovCtsPosCtrl(self): + return self.FindWindowById(ID_POV_CTS_Pos_Ctrl) + + def GetZPositionCtrl(self): + return self.FindWindowById(ID_Z_Position_Ctrl) + + # WDR: handler implementations for JoysticktestPanel + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = JoystickTestPanel(nb, -1) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/KeyEvents.py b/wxPython/demo/KeyEvents.py new file mode 100644 index 0000000000..c992865219 --- /dev/null +++ b/wxPython/demo/KeyEvents.py @@ -0,0 +1,357 @@ +# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o lib.mixins.listctrl needs wx renamer applied. +# +# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin +# + +import wx +import wx.lib.mixins.listctrl as listmix + +#---------------------------------------------------------------------- + +keyMap = { + wx.WXK_BACK : "wx.WXK_BACK", + wx.WXK_TAB : "wx.WXK_TAB", + wx.WXK_RETURN : "wx.WXK_RETURN", + wx.WXK_ESCAPE : "wx.WXK_ESCAPE", + wx.WXK_SPACE : "wx.WXK_SPACE", + wx.WXK_DELETE : "wx.WXK_DELETE", + wx.WXK_START : "wx.WXK_START", + wx.WXK_LBUTTON : "wx.WXK_LBUTTON", + wx.WXK_RBUTTON : "wx.WXK_RBUTTON", + wx.WXK_CANCEL : "wx.WXK_CANCEL", + wx.WXK_MBUTTON : "wx.WXK_MBUTTON", + wx.WXK_CLEAR : "wx.WXK_CLEAR", + wx.WXK_SHIFT : "wx.WXK_SHIFT", + wx.WXK_ALT : "wx.WXK_ALT", + wx.WXK_CONTROL : "wx.WXK_CONTROL", + wx.WXK_MENU : "wx.WXK_MENU", + wx.WXK_PAUSE : "wx.WXK_PAUSE", + wx.WXK_CAPITAL : "wx.WXK_CAPITAL", + wx.WXK_PRIOR : "wx.WXK_PRIOR", + wx.WXK_NEXT : "wx.WXK_NEXT", + wx.WXK_END : "wx.WXK_END", + wx.WXK_HOME : "wx.WXK_HOME", + wx.WXK_LEFT : "wx.WXK_LEFT", + wx.WXK_UP : "wx.WXK_UP", + wx.WXK_RIGHT : "wx.WXK_RIGHT", + wx.WXK_DOWN : "wx.WXK_DOWN", + wx.WXK_SELECT : "wx.WXK_SELECT", + wx.WXK_PRINT : "wx.WXK_PRINT", + wx.WXK_EXECUTE : "wx.WXK_EXECUTE", + wx.WXK_SNAPSHOT : "wx.WXK_SNAPSHOT", + wx.WXK_INSERT : "wx.WXK_INSERT", + wx.WXK_HELP : "wx.WXK_HELP", + wx.WXK_NUMPAD0 : "wx.WXK_NUMPAD0", + wx.WXK_NUMPAD1 : "wx.WXK_NUMPAD1", + wx.WXK_NUMPAD2 : "wx.WXK_NUMPAD2", + wx.WXK_NUMPAD3 : "wx.WXK_NUMPAD3", + wx.WXK_NUMPAD4 : "wx.WXK_NUMPAD4", + wx.WXK_NUMPAD5 : "wx.WXK_NUMPAD5", + wx.WXK_NUMPAD6 : "wx.WXK_NUMPAD6", + wx.WXK_NUMPAD7 : "wx.WXK_NUMPAD7", + wx.WXK_NUMPAD8 : "wx.WXK_NUMPAD8", + wx.WXK_NUMPAD9 : "wx.WXK_NUMPAD9", + wx.WXK_MULTIPLY : "wx.WXK_MULTIPLY", + wx.WXK_ADD : "wx.WXK_ADD", + wx.WXK_SEPARATOR : "wx.WXK_SEPARATOR", + wx.WXK_SUBTRACT : "wx.WXK_SUBTRACT", + wx.WXK_DECIMAL : "wx.WXK_DECIMAL", + wx.WXK_DIVIDE : "wx.WXK_DIVIDE", + wx.WXK_F1 : "wx.WXK_F1", + wx.WXK_F2 : "wx.WXK_F2", + wx.WXK_F3 : "wx.WXK_F3", + wx.WXK_F4 : "wx.WXK_F4", + wx.WXK_F5 : "wx.WXK_F5", + wx.WXK_F6 : "wx.WXK_F6", + wx.WXK_F7 : "wx.WXK_F7", + wx.WXK_F8 : "wx.WXK_F8", + wx.WXK_F9 : "wx.WXK_F9", + wx.WXK_F10 : "wx.WXK_F10", + wx.WXK_F11 : "wx.WXK_F11", + wx.WXK_F12 : "wx.WXK_F12", + wx.WXK_F13 : "wx.WXK_F13", + wx.WXK_F14 : "wx.WXK_F14", + wx.WXK_F15 : "wx.WXK_F15", + wx.WXK_F16 : "wx.WXK_F16", + wx.WXK_F17 : "wx.WXK_F17", + wx.WXK_F18 : "wx.WXK_F18", + wx.WXK_F19 : "wx.WXK_F19", + wx.WXK_F20 : "wx.WXK_F20", + wx.WXK_F21 : "wx.WXK_F21", + wx.WXK_F22 : "wx.WXK_F22", + wx.WXK_F23 : "wx.WXK_F23", + wx.WXK_F24 : "wx.WXK_F24", + wx.WXK_NUMLOCK : "wx.WXK_NUMLOCK", + wx.WXK_SCROLL : "wx.WXK_SCROLL", + wx.WXK_PAGEUP : "wx.WXK_PAGEUP", + wx.WXK_PAGEDOWN : "wx.WXK_PAGEDOWN", + wx.WXK_NUMPAD_SPACE : "wx.WXK_NUMPAD_SPACE", + wx.WXK_NUMPAD_TAB : "wx.WXK_NUMPAD_TAB", + wx.WXK_NUMPAD_ENTER : "wx.WXK_NUMPAD_ENTER", + wx.WXK_NUMPAD_F1 : "wx.WXK_NUMPAD_F1", + wx.WXK_NUMPAD_F2 : "wx.WXK_NUMPAD_F2", + wx.WXK_NUMPAD_F3 : "wx.WXK_NUMPAD_F3", + wx.WXK_NUMPAD_F4 : "wx.WXK_NUMPAD_F4", + wx.WXK_NUMPAD_HOME : "wx.WXK_NUMPAD_HOME", + wx.WXK_NUMPAD_LEFT : "wx.WXK_NUMPAD_LEFT", + wx.WXK_NUMPAD_UP : "wx.WXK_NUMPAD_UP", + wx.WXK_NUMPAD_RIGHT : "wx.WXK_NUMPAD_RIGHT", + wx.WXK_NUMPAD_DOWN : "wx.WXK_NUMPAD_DOWN", + wx.WXK_NUMPAD_PRIOR : "wx.WXK_NUMPAD_PRIOR", + wx.WXK_NUMPAD_PAGEUP : "wx.WXK_NUMPAD_PAGEUP", + wx.WXK_NUMPAD_NEXT : "wx.WXK_NUMPAD_NEXT", + wx.WXK_NUMPAD_PAGEDOWN : "wx.WXK_NUMPAD_PAGEDOWN", + wx.WXK_NUMPAD_END : "wx.WXK_NUMPAD_END", + wx.WXK_NUMPAD_BEGIN : "wx.WXK_NUMPAD_BEGIN", + wx.WXK_NUMPAD_INSERT : "wx.WXK_NUMPAD_INSERT", + wx.WXK_NUMPAD_DELETE : "wx.WXK_NUMPAD_DELETE", + wx.WXK_NUMPAD_EQUAL : "wx.WXK_NUMPAD_EQUAL", + wx.WXK_NUMPAD_MULTIPLY : "wx.WXK_NUMPAD_MULTIPLY", + wx.WXK_NUMPAD_ADD : "wx.WXK_NUMPAD_ADD", + wx.WXK_NUMPAD_SEPARATOR : "wx.WXK_NUMPAD_SEPARATOR", + wx.WXK_NUMPAD_SUBTRACT : "wx.WXK_NUMPAD_SUBTRACT", + wx.WXK_NUMPAD_DECIMAL : "wx.WXK_NUMPAD_DECIMAL", + wx.WXK_NUMPAD_DIVIDE : "wx.WXK_NUMPAD_DIVIDE", +} + + +#---------------------------------------------------------------------- + +class KeySink(wx.Window): + def __init__(self, parent): + wx.Window.__init__(self, parent, -1, style=wx.WANTS_CHARS + #| wx.RAISED_BORDER + #| wx.SUNKEN_BORDER + ) + + self.SetBackgroundColour(wx.BLUE) + self.haveFocus = False + self.callSkip = False + self.logKeyDn = True + self.logKeyUp = True + self.logChar = True + + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) + self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) + self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse) + + self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) + self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) + self.Bind(wx.EVT_CHAR, self.OnChar) + + + def SetCallSkip(self, skip): + self.callSkip = skip + + def SetLogKeyUp(self, val): + self.logKeyUp = val + + def SetLogKeyDn(self, val): + self.logKeyDn = val + + def SetLogChar(self, val): + self.logChar = val + + + def OnPaint(self, evt): + dc = wx.PaintDC(self) + rect = self.GetClientRect() + dc.SetTextForeground(wx.WHITE) + dc.DrawLabel("Click here and then press some keys", + rect, wx.ALIGN_CENTER | wx.ALIGN_TOP) + if self.haveFocus: + dc.SetTextForeground(wx.GREEN) + dc.DrawLabel("Have Focus", rect, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) + else: + dc.SetTextForeground(wx.RED) + dc.DrawLabel("Need Focus!", rect, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) + + + def OnSetFocus(self, evt): + self.haveFocus = True + self.Refresh() + + def OnKillFocus(self, evt): + self.haveFocus = False + self.Refresh() + + def OnMouse(self, evt): + if evt.ButtonDown(): + self.SetFocus() + + + def OnKeyDown(self, evt): + if self.logKeyDn: + self.GetParent().keylog.LogKeyEvent("KeyDown", evt) + if self.callSkip: + evt.Skip() + + def OnKeyUp(self, evt): + if self.logKeyUp: + self.GetParent().keylog.LogKeyEvent("KeyUp", evt) + if self.callSkip: + evt.Skip() + + def OnChar(self, evt): + if self.logChar: + self.GetParent().keylog.LogKeyEvent("Char", evt) + + +#---------------------------------------------------------------------- + +class KeyLog(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin): + + def __init__(self, parent): + wx.ListCtrl.__init__(self, parent, -1, + style = wx.LC_REPORT|wx.LC_VRULES|wx.LC_HRULES) + listmix.ListCtrlAutoWidthMixin.__init__(self) + + self.InsertColumn(0, "Event Type") + self.InsertColumn(1, "Key Name") + self.InsertColumn(2, "Key Code") + self.InsertColumn(3, "Modifiers") + self.InsertColumn(4, "RawKeyCode") + self.InsertColumn(5, "RawKeyFlags") + self.InsertColumn(6, "") + + for x in range(6): + self.SetColumnWidth(x, wx.LIST_AUTOSIZE_USEHEADER) + + self.SetColumnWidth(1, 125) + + + def LogKeyEvent(self, evType, evt): + keycode = evt.GetKeyCode() + keyname = keyMap.get(keycode, None) + if keyname is None: + if keycode < 256: + if keycode == 0: + keyname = "NUL" + elif keycode < 27: + keyname = "Ctrl-%s" % chr(ord('A') + keycode-1) + else: + keyname = "\"%s\"" % chr(keycode) + else: + keyname = "unknown (%s)" % keycode + + modifiers = "" + for mod, ch in [(evt.ControlDown(), 'C'), + (evt.AltDown(), 'A'), + (evt.ShiftDown(), 'S'), + (evt.MetaDown(), 'M')]: + if mod: + modifiers += ch + else: + modifiers += '-' + + id = self.InsertStringItem(self.GetItemCount(), evType) + self.SetStringItem(id, 1, keyname) + self.SetStringItem(id, 2, str(keycode)) + self.SetStringItem(id, 3, modifiers) + self.SetStringItem(id, 4, str(evt.GetRawKeyCode())) + self.SetStringItem(id, 5, str(evt.GetRawKeyFlags())) + + #print ( id, evType, keyname, str(keycode), modifiers, str(evt.GetRawKeyCode()), str(evt.GetRawKeyFlags())) + + self.EnsureVisible(id) + + + def ClearLog(self): + self.DeleteAllItems() + + +#---------------------------------------------------------------------- + + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1, style=0) + self.keysink = KeySink(self) + self.keysink.SetSize((100, 65)) + self.keylog = KeyLog(self) + + btn = wx.Button(self, -1, "Clear Log") + self.Bind(wx.EVT_BUTTON, self.OnClearBtn, btn) + + cb1 = wx.CheckBox(self, -1, "Call evt.Skip for Key Up/Dn events") + self.Bind(wx.EVT_CHECKBOX, self.OnSkipCB, cb1) + + cb2 = wx.CheckBox(self, -1, "EVT_KEY_UP") + self.Bind(wx.EVT_CHECKBOX, self.OnKeyUpCB, cb2) + cb2.SetValue(True) + + cb3 = wx.CheckBox(self, -1, "EVT_KEY_DOWN") + self.Bind(wx.EVT_CHECKBOX, self.OnKeyDnCB, cb3) + cb3.SetValue(True) + + cb4 = wx.CheckBox(self, -1, "EVT_CHAR") + self.Bind(wx.EVT_CHECKBOX, self.OnCharCB, cb4) + cb4.SetValue(True) + + buttons = wx.BoxSizer(wx.HORIZONTAL) + buttons.Add(btn, 0, wx.ALL, 4) + buttons.Add(cb1, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 6) + buttons.Add(cb2, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 6) + buttons.Add(cb3, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 6) + buttons.Add(cb4, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 6) + + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(self.keysink, 0, wx.GROW) + sizer.Add(buttons) + sizer.Add(self.keylog, 1, wx.GROW) + + self.SetSizer(sizer) + + + def OnClearBtn(self, evt): + self.keylog.ClearLog() + + def OnSkipCB(self, evt): + self.keysink.SetCallSkip(evt.GetInt()) + + def OnKeyUpCB(self, evt): + self.keysink.SetLogKeyUp(evt.GetInt()) + + def OnKeyDnCB(self, evt): + self.keysink.SetLogKeyDn(evt.GetInt()) + + def OnCharCB(self, evt): + self.keysink.SetLogChar(evt.GetInt()) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wxKeyEvents

+ +This demo simply catches all key events and prints info about them. +It is meant to be used as a compatibility test for cross platform work. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/LEDNumberCtrl.py b/wxPython/demo/LEDNumberCtrl.py new file mode 100644 index 0000000000..7bb46e1647 --- /dev/null +++ b/wxPython/demo/LEDNumberCtrl.py @@ -0,0 +1,116 @@ +# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import time + +import wx +import wx.gizmos as gizmos + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + led = gizmos.LEDNumberCtrl(self, -1, (25,25), (280, 50)) + led.SetValue("01234") + + led = gizmos.LEDNumberCtrl(self, -1, (25,100), (280, 50)) + led.SetValue("56789") + led.SetAlignment(gizmos.LED_ALIGN_RIGHT) + led.SetDrawFaded(False) + + led = gizmos.LEDNumberCtrl(self, -1, (25,175), (280, 50), + gizmos.LED_ALIGN_CENTER)# | gizmos.LED_DRAW_FADED) + self.clock = led + self.OnTimer(None) + + self.timer = wx.Timer(self) + self.timer.Start(1000) + self.Bind(wx.EVT_TIMER, self.OnTimer) + + + def OnTimer(self, evt): + t = time.localtime(time.time()) + st = time.strftime("%I-%M-%S", t) + self.clock.SetValue(st) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + +overview = """\ + + +The following was gleaned as best I could from the wxWindows +source, which was a bit reluctant to reveal its secrets. My appologies if +I missed anything - jmg +

+wxLEDNumberCtrl( parent, id=-1, pos=wx.DefaultPosition, +size=wx.DefaultSize, style=LED_ALIGN_LEFT | LED_DRAW_FADED) + +

This is a control that simulates an LED clock display. It only accepts +numeric input. + +

Styles + +

+
LED_ALIGN_LEFT +
Align to the left. + +
LED_ALIGN_RIGHT +
Align to the right. + +
LED_ALIGN_CENTER +
Center on display. + +
LED_DRAW_FADED +
Not implemented. + +
+ +

Methods (and best guesses at what they do) + +

+
GetAlignment() +
Returns the alignment attribute for the control. + +
GetDrawFaded() +
Returns the DrawFaded attribute for the control. + +
GetValue() +
Returns the current value of the control. + +
SetAlignment(alignment) +
Set the alignment attribute for the control. + +
SetDrawFaded(value) +
Set the DrawFaded attribute for the control. + +
SetValue(number) +
Set the value for the control. Only numeric values are accepted. + +
+ +

Additionally, several methods of wx.Window are available as well. + + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/LayoutConstraints.py b/wxPython/demo/LayoutConstraints.py new file mode 100644 index 0000000000..29ffeaf080 --- /dev/null +++ b/wxPython/demo/LayoutConstraints.py @@ -0,0 +1,152 @@ +# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class TestLayoutConstraints(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent, -1) + self.SetAutoLayout(True) + self.Bind(wx.EVT_BUTTON, self.OnButton, id=100) + + self.SetBackgroundColour(wx.NamedColour("MEDIUM ORCHID")) + + self.panelA = wx.Window(self, -1, style=wx.SIMPLE_BORDER) + self.panelA.SetBackgroundColour(wx.BLUE) + + txt = wx.StaticText( + self.panelA, -1, + "Resize the window and see\n" + "what happens... Notice that\n" + "there is no OnSize handler.", + (5,5), (-1, 50) + ) + + txt.SetBackgroundColour(wx.BLUE) + txt.SetForegroundColour(wx.WHITE) + + lc = wx.LayoutConstraints() + lc.top.SameAs(self, wx.Top, 10) + lc.left.SameAs(self, wx.Left, 10) + lc.bottom.SameAs(self, wx.Bottom, 10) + lc.right.PercentOf(self, wx.Right, 50) + self.panelA.SetConstraints(lc) + + self.panelB = wx.Window(self, -1, style=wx.SIMPLE_BORDER) + self.panelB.SetBackgroundColour(wx.RED) + lc = wx.LayoutConstraints() + lc.top.SameAs(self, wx.Top, 10) + lc.right.SameAs(self, wx.Right, 10) + lc.bottom.PercentOf(self, wx.Bottom, 30) + lc.left.RightOf(self.panelA, 10) + self.panelB.SetConstraints(lc) + + self.panelC = wx.Window(self, -1, style=wx.SIMPLE_BORDER) + self.panelC.SetBackgroundColour(wx.WHITE) + lc = wx.LayoutConstraints() + lc.top.Below(self.panelB, 10) + lc.right.SameAs(self, wx.Right, 10) + lc.bottom.SameAs(self, wx.Bottom, 10) + lc.left.RightOf(self.panelA, 10) + self.panelC.SetConstraints(lc) + + b = wx.Button(self.panelA, 100, ' Panel A ') + lc = wx.LayoutConstraints() + lc.centreX.SameAs (self.panelA, wx.CentreX) + lc.centreY.SameAs (self.panelA, wx.CentreY) + lc.height.AsIs () + lc.width.PercentOf (self.panelA, wx.Width, 50) + b.SetConstraints(lc); + + b = wx.Button(self.panelB, 100, ' Panel B ') + lc = wx.LayoutConstraints() + lc.top.SameAs (self.panelB, wx.Top, 2) + lc.right.SameAs (self.panelB, wx.Right, 4) + lc.height.AsIs () + lc.width.AsIs () + b.SetConstraints(lc); + + self.panelD = wx.Window(self.panelC, -1, style=wx.SIMPLE_BORDER) + self.panelD.SetBackgroundColour(wx.GREEN) + wx.StaticText( + self.panelD, -1, "Panel D", (4, 4) + ).SetBackgroundColour(wx.GREEN) + + b = wx.Button(self.panelC, 100, ' Panel C ') + lc = wx.LayoutConstraints() + lc.top.Below (self.panelD) + lc.left.RightOf (self.panelD) + lc.height.AsIs () + lc.width.AsIs () + b.SetConstraints(lc); + + lc = wx.LayoutConstraints() + lc.bottom.PercentOf (self.panelC, wx.Height, 50) + lc.right.PercentOf (self.panelC, wx.Width, 50) + lc.height.SameAs (b, wx.Height) + lc.width.SameAs (b, wx.Width) + self.panelD.SetConstraints(lc); + + + def OnButton(self, event): + wx.Bell() + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestLayoutConstraints(nb) + return win + +#--------------------------------------------------------------------------- + + + +overview = """\ + +Objects of this class can be associated with a window to define its +layout constraints, with respect to siblings or its parent. + +

The class consists of the following eight constraints of class +wxIndividualLayoutConstraint, some or all of which should be accessed +directly to set the appropriate constraints. + +

+

Most constraints are initially set to have the relationship +wxUnconstrained, which means that their values should be calculated by +looking at known constraints. The exceptions are width and height, +which are set to wxAsIs to ensure that if the user does not specify a +constraint, the existing width and height will be used, to be +compatible with panel items which often have take a default size. If +the constraint is wxAsIs, the dimension will not be changed. + +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/ListBox.py b/wxPython/demo/ListBox.py new file mode 100644 index 0000000000..c3a69d6919 --- /dev/null +++ b/wxPython/demo/ListBox.py @@ -0,0 +1,162 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +# This listbox subclass lets you type the starting letters of what you want to +# select, and scrolls the list to the match if it is found. +class FindPrefixListBox(wx.ListBox): + def __init__(self, parent, id, pos=wx.DefaultPosition, size=wx.DefaultSize, + choices=[], style=0, validator=wx.DefaultValidator): + wx.ListBox.__init__(self, parent, id, pos, size, choices, style, validator) + self.typedText = '' + self.log = parent.log + self.Bind(wx.EVT_KEY_DOWN, self.OnKey) + + + def FindPrefix(self, prefix): + self.log.WriteText('Looking for prefix: %s\n' % prefix) + + if prefix: + prefix = prefix.lower() + length = len(prefix) + + # Changed in 2.5 because ListBox.Number() is no longer supported. + # ListBox.GetCount() is now the appropriate way to go. + for x in range(self.GetCount()): + text = self.GetString(x) + text = text.lower() + + if text[:length] == prefix: + self.log.WriteText('Prefix %s is found.\n' % prefix) + return x + + self.log.WriteText('Prefix %s is not found.\n' % prefix) + return -1 + + + def OnKey(self, evt): + key = evt.GetKeyCode() + + if key >= 32 and key <= 127: + self.typedText = self.typedText + chr(key) + item = self.FindPrefix(self.typedText) + + if item != -1: + self.SetSelection(item) + + elif key == wx.WXK_BACK: # backspace removes one character and backs up + self.typedText = self.typedText[:-1] + + if not self.typedText: + self.SetSelection(0) + else: + item = self.FindPrefix(self.typedText) + + if item != -1: + self.SetSelection(item) + else: + self.typedText = '' + evt.Skip() + + def OnKeyDown(self, evt): + pass + + +#--------------------------------------------------------------------------- + +class TestListBox(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', + 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', + 'twelve', 'thirteen', 'fourteen'] + + wx.StaticText(self, -1, "This example uses the wxListBox control.", (45, 10)) + wx.StaticText(self, -1, "Select one:", (15, 50), (65, 18)) + self.lb1 = wx.ListBox(self, 60, (80, 50), (80, 120), sampleList, wx.LB_SINGLE) + self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.lb1) + self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.lb1) + self.lb1.Bind(wx.EVT_RIGHT_UP, self.EvtRightButton) + self.lb1.SetSelection(3) + self.lb1.Append("with data", "This one has data"); + self.lb1.SetClientData(2, "This one has data"); + + + wx.StaticText(self, -1, "Select many:", (200, 50), (65, 18)) + self.lb2 = wx.ListBox(self, 70, (280, 50), (80, 120), sampleList, wx.LB_EXTENDED) + self.Bind(wx.EVT_LISTBOX, self.EvtMultiListBox, self.lb2) + self.lb2.Bind(wx.EVT_RIGHT_UP, self.EvtRightButton) + self.lb2.SetSelection(0) + + sampleList = sampleList + ['test a', 'test aa', 'test aab', + 'test ab', 'test abc', 'test abcc', + 'test abcd' ] + sampleList.sort() + wx.StaticText(self, -1, "Find Prefix:", (15, 250)) + fp = FindPrefixListBox(self, -1, (80, 250), (80, 120), sampleList, wx.LB_SINGLE) + fp.SetSelection(0) + + + def EvtListBox(self, event): + self.log.WriteText('EvtListBox: %s, %s, %s\n' % + (event.GetString(), event.IsSelection(), event.GetSelection())) + + lb = event.GetEventObject() + data = lb.GetClientData(lb.GetSelection()) + + if data is not None: + self.log.WriteText('\tdata: %s\n' % data) + + + def EvtListBoxDClick(self, event): + self.log.WriteText('EvtListBoxDClick: %s\n' % self.lb1.GetSelection()) + self.lb1.Delete(self.lb1.GetSelection()) + + def EvtMultiListBox(self, event): + self.log.WriteText('EvtMultiListBox: %s\n' % str(self.lb2.GetSelections())) + + def EvtRightButton(self, event): + self.log.WriteText('EvtRightButton: %s\n' % event.GetPosition()) + + if event.GetEventObject().GetId() == 70: + selections = list(self.lb2.GetSelections()) + selections.reverse() + + for index in selections: + self.lb2.Delete(index) + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestListBox(nb, log) + return win + +#--------------------------------------------------------------------------- + + + + +overview = """ +A listbox is used to select one or more of a list of +strings. The strings are displayed in a scrolling box, with the +selected string(s) marked in reverse video. A listbox can be single +selection (if an item is selected, the previous selection is removed) +or multiple selection (clicking an item toggles the item on or off +independently of other selections). + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/ListCtrl.py b/wxPython/demo/ListCtrl.py new file mode 100644 index 0000000000..879bc1baa0 --- /dev/null +++ b/wxPython/demo/ListCtrl.py @@ -0,0 +1,516 @@ +#---------------------------------------------------------------------------- +# Name: ListCtrl.py +# Purpose: Testing lots of stuff, controls, window types, etc. +# +# Author: Robin Dunn & Gary Dumer +# +# Created: +# RCS-ID: $Id$ +# Copyright: (c) 1998 by Total Control Software +# Licence: wxWindows license +#---------------------------------------------------------------------------- +# +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o listctrl mixin needs wx renamer. +# o wx.ListItem.GetText() returns a wxString pointer, not the text. +# +# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o ColumnSorterMixin implementation was broke - added event.Skip() +# to column click event to allow event to fall through to mixin. +# +# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxColumnSorterMixin -> ColumnSorterMixin +# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin +# + +import wx +import wx.lib.mixins.listctrl as listmix + +import images + +#--------------------------------------------------------------------------- + +musicdata = { +1 : ("Bad English", "The Price Of Love", "Rock"), +2 : ("DNA featuring Suzanne Vega", "Tom's Diner", "Rock"), +3 : ("George Michael", "Praying For Time", "Rock"), +4 : ("Gloria Estefan", "Here We Are", "Rock"), +5 : ("Linda Ronstadt", "Don't Know Much", "Rock"), +6 : ("Michael Bolton", "How Am I Supposed To Live Without You", "Blues"), +7 : ("Paul Young", "Oh Girl", "Rock"), +8 : ("Paula Abdul", "Opposites Attract", "Rock"), +9 : ("Richard Marx", "Should've Known Better", "Rock"), +10: ("Rod Stewart", "Forever Young", "Rock"), +11: ("Roxette", "Dangerous", "Rock"), +12: ("Sheena Easton", "The Lover In Me", "Rock"), +13: ("Sinead O'Connor", "Nothing Compares 2 U", "Rock"), +14: ("Stevie B.", "Because I Love You", "Rock"), +15: ("Taylor Dayne", "Love Will Lead You Back", "Rock"), +16: ("The Bangles", "Eternal Flame", "Rock"), +17: ("Wilson Phillips", "Release Me", "Rock"), +18: ("Billy Joel", "Blonde Over Blue", "Rock"), +19: ("Billy Joel", "Famous Last Words", "Rock"), +20: ("Billy Joel", "Lullabye (Goodnight, My Angel)", "Rock"), +21: ("Billy Joel", "The River Of Dreams", "Rock"), +22: ("Billy Joel", "Two Thousand Years", "Rock"), +23: ("Janet Jackson", "Alright", "Rock"), +24: ("Janet Jackson", "Black Cat", "Rock"), +25: ("Janet Jackson", "Come Back To Me", "Rock"), +26: ("Janet Jackson", "Escapade", "Rock"), +27: ("Janet Jackson", "Love Will Never Do (Without You)", "Rock"), +28: ("Janet Jackson", "Miss You Much", "Rock"), +29: ("Janet Jackson", "Rhythm Nation", "Rock"), +30: ("Janet Jackson", "State Of The World", "Rock"), +31: ("Janet Jackson", "The Knowledge", "Rock"), +32: ("Spyro Gyra", "End of Romanticism", "Jazz"), +33: ("Spyro Gyra", "Heliopolis", "Jazz"), +34: ("Spyro Gyra", "Jubilee", "Jazz"), +35: ("Spyro Gyra", "Little Linda", "Jazz"), +36: ("Spyro Gyra", "Morning Dance", "Jazz"), +37: ("Spyro Gyra", "Song for Lorraine", "Jazz"), +38: ("Yes", "Owner Of A Lonely Heart", "Rock"), +39: ("Yes", "Rhythm Of Love", "Rock"), +40: ("Cusco", "Dream Catcher", "New Age"), +41: ("Cusco", "Geronimos Laughter", "New Age"), +42: ("Cusco", "Ghost Dance", "New Age"), +43: ("Blue Man Group", "Drumbone", "New Age"), +44: ("Blue Man Group", "Endless Column", "New Age"), +45: ("Blue Man Group", "Klein Mandelbrot", "New Age"), +46: ("Kenny G", "Silhouette", "Jazz"), +47: ("Sade", "Smooth Operator", "Jazz"), +48: ("David Arkenstone", "Papillon (On The Wings Of The Butterfly)", "New Age"), +49: ("David Arkenstone", "Stepping Stars", "New Age"), +50: ("David Arkenstone", "Carnation Lily Lily Rose", "New Age"), +51: ("David Lanz", "Behind The Waterfall", "New Age"), +52: ("David Lanz", "Cristofori's Dream", "New Age"), +53: ("David Lanz", "Heartsounds", "New Age"), +54: ("David Lanz", "Leaves on the Seine", "New Age"), +} + +#--------------------------------------------------------------------------- + +class TestListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin): + def __init__(self, parent, ID, pos=wx.DefaultPosition, + size=wx.DefaultSize, style=0): + wx.ListCtrl.__init__(self, parent, ID, pos, size, style) + listmix.ListCtrlAutoWidthMixin.__init__(self) + + +class TestListCtrlPanel(wx.Panel, listmix.ColumnSorterMixin): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) + + self.log = log + tID = wx.NewId() + + self.il = wx.ImageList(16, 16) + + self.idx1 = self.il.Add(images.getSmilesBitmap()) + self.sm_up = self.il.Add(images.getSmallUpArrowBitmap()) + self.sm_dn = self.il.Add(images.getSmallDnArrowBitmap()) + + self.list = TestListCtrl(self, tID, + style=wx.LC_REPORT + | wx.SUNKEN_BORDER + | wx.LC_EDIT_LABELS + #| wxLC_NO_HEADER + #| wxLC_VRULES | wxLC_HRULES + ) + + self.list.SetImageList(self.il, wx.IMAGE_LIST_SMALL) + + self.PopulateList() + + # Now that the list exists we can init the other base class, + # see wxPython/lib/mixins/listctrl.py + self.itemDataMap = musicdata + listmix.ColumnSorterMixin.__init__(self, 3) + #self.SortListItems(0, True) + + self.Bind(wx.EVT_SIZE, self.OnSize) + + self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.list) + self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected, self.list) + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.list) + self.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnItemDelete, self.list) + self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list) + self.Bind(wx.EVT_LIST_COL_RIGHT_CLICK, self.OnColRightClick, self.list) + self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.OnColBeginDrag, self.list) + self.Bind(wx.EVT_LIST_COL_DRAGGING, self.OnColDragging, self.list) + self.Bind(wx.EVT_LIST_COL_END_DRAG, self.OnColEndDrag, self.list) + self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list) + + self.list.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick) + self.list.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) + + # for wxMSW + self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick) + + # for wxGTK + self.list.Bind(wx.EVT_RIGHT_UP, self.OnRightClick) + + + def PopulateList(self): + if 0: + # for normal, simple columns, you can add them like this: + self.list.InsertColumn(0, "Artist") + self.list.InsertColumn(1, "Title", wx.LIST_FORMAT_RIGHT) + self.list.InsertColumn(2, "Genre") + else: + # but since we want images on the column header we have to do it the hard way: + info = wx.ListItem() + info.m_mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT + info.m_image = -1 + info.m_format = 0 + info.m_text = "Artist" + self.list.InsertColumnInfo(0, info) + + info.m_format = wx.LIST_FORMAT_RIGHT + info.m_text = "Title" + self.list.InsertColumnInfo(1, info) + + info.m_format = 0 + info.m_text = "Genre" + self.list.InsertColumnInfo(2, info) + + items = musicdata.items() + for x in range(len(items)): + key, data = items[x] + self.list.InsertImageStringItem(x, data[0], self.idx1) + self.list.SetStringItem(x, 1, data[1]) + self.list.SetStringItem(x, 2, data[2]) + self.list.SetItemData(x, key) + + self.list.SetColumnWidth(0, wx.LIST_AUTOSIZE) + self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE) + self.list.SetColumnWidth(2, 100) + + # show how to select an item + self.list.SetItemState(5, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) + + # show how to change the colour of a couple items + item = self.list.GetItem(1) + item.SetTextColour(wx.BLUE) + self.list.SetItem(item) + item = self.list.GetItem(4) + item.SetTextColour(wx.RED) + self.list.SetItem(item) + + self.currentItem = 0 + + + # Used by the ColumnSorterMixin, see wxPython/lib/mixins/listctrl.py + def GetListCtrl(self): + return self.list + + # Used by the ColumnSorterMixin, see wxPython/lib/mixins/listctrl.py + def GetSortImages(self): + return (self.sm_dn, self.sm_up) + + + def OnRightDown(self, event): + self.x = event.GetX() + self.y = event.GetY() + self.log.WriteText("x, y = %s\n" % str((self.x, self.y))) + item, flags = self.list.HitTest((self.x, self.y)) + + if flags & wx.LIST_HITTEST_ONITEM: + self.list.Select(item) + + event.Skip() + + + def getColumnText(self, index, col): + item = self.list.GetItem(index, col) + return item.GetText() + + + def OnItemSelected(self, event): + ##print event.GetItem().GetTextColour() + self.currentItem = event.m_itemIndex + self.log.WriteText("OnItemSelected: %s, %s, %s, %s\n" % + (self.currentItem, + self.list.GetItemText(self.currentItem), + self.getColumnText(self.currentItem, 1), + self.getColumnText(self.currentItem, 2))) + + if self.currentItem == 10: + self.log.WriteText("OnItemSelected: Veto'd selection\n") + #event.Veto() # doesn't work + # this does + self.list.SetItemState(10, 0, wx.LIST_STATE_SELECTED) + + event.Skip() + + + def OnItemDeselected(self, evt): + item = evt.GetItem() + self.log.WriteText("OnItemDeselected: %d" % evt.m_itemIndex) + + # Show how to reselect something we don't want deselected + if evt.m_itemIndex == 11: + wx.CallAfter(self.list.SetItemState, 11, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) + + + def OnItemActivated(self, event): + self.currentItem = event.m_itemIndex + self.log.WriteText("OnItemActivated: %s\nTopItem: %s" % + (self.list.GetItemText(self.currentItem), self.list.GetTopItem())) + + def OnBeginEdit(self, event): + self.log.WriteText("OnBeginEdit") + event.Allow() + + def OnItemDelete(self, event): + self.log.WriteText("OnItemDelete\n") + + def OnColClick(self, event): + self.log.WriteText("OnColClick: %d\n" % event.GetColumn()) + event.Skip() + + def OnColRightClick(self, event): + 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") + ## Show how to not allow a column to be resized + #if event.GetColumn() == 0: + # event.Veto() + + + def OnColDragging(self, event): + self.log.WriteText("OnColDragging\n") + + def OnColEndDrag(self, event): + self.log.WriteText("OnColEndDrag\n") + + def OnDoubleClick(self, event): + self.log.WriteText("OnDoubleClick item %s\n" % self.list.GetItemText(self.currentItem)) + event.Skip() + + def OnRightClick(self, event): + self.log.WriteText("OnRightClick %s\n" % self.list.GetItemText(self.currentItem)) + + # only do this part the first time so the events are only bound once + if not hasattr(self, "popupID1"): + 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.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) + + # make a menu + menu = wx.Menu() + # add some items + menu.Append(self.popupID1, "FindItem tests") + menu.Append(self.popupID2, "Iterate Selected") + menu.Append(self.popupID3, "ClearAll and repopulate") + menu.Append(self.popupID4, "DeleteAllItems") + menu.Append(self.popupID5, "GetItem") + menu.Append(self.popupID6, "Edit") + + # Popup the menu. If an item is selected then its handler + # will be called before PopupMenu returns. + self.PopupMenu(menu, (self.x, self.y)) + menu.Destroy() + + + def OnPopupOne(self, event): + self.log.WriteText("Popup one\n") + print "FindItem:", self.list.FindItem(-1, "Roxette") + print "FindItemData:", self.list.FindItemData(-1, 11) + + def OnPopupTwo(self, event): + self.log.WriteText("Selected items:\n") + index = self.list.GetFirstSelected() + + while index != -1: + self.log.WriteText(" %s: %s\n" % (self.list.GetItemText(index), self.getColumnText(index, 1))) + index = self.list.GetNextSelected(index) + + def OnPopupThree(self, event): + self.log.WriteText("Popup three\n") + self.list.ClearAll() + wx.CallAfter(self.PopulateList) + + def OnPopupFour(self, event): + self.list.DeleteAllItems() + + def OnPopupFive(self, event): + item = self.list.GetItem(self.currentItem) + print item.m_text, item.m_itemId, self.list.GetItemData(self.currentItem) + + def OnPopupSix(self, event): + self.list.EditLabel(self.currentItem) + + + def OnSize(self, event): + w,h = self.GetClientSizeTuple() + self.list.SetDimensions(0, 0, w, h) + + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestListCtrlPanel(nb, log) + return win + +#--------------------------------------------------------------------------- + + +overview = """\ + + +A list control presents lists in a number of formats: list view, report view, +icon view and small icon view. In any case, elements are numbered from zero. +For all these modes (but not for virtual list controls), the items are stored +in the control and must be added to it using InsertItem method. + +

To intercept events from a list control, use the event table macros described in +wxListEvent. + +

Mix-ins

+This example demonstrates how to use mixins. The following mixins are available. + +

ColumnSorterMixin

+ +ColumnSorterMixin(numColumns) + +

A mixin class that handles sorting of a wxListCtrl in REPORT mode when the column +header is clicked on. + +

There are a few requirments needed in order for this to work genericly: +

    +
  1. The combined class must have a GetListCtrl method that returns + the ListCtrl to be sorted, and the list control must exist at the time the + ColumnSorterMixin.__init__()method is called because it uses + GetListCtrl. + +
  2. Items in the list control must have a unique data value set with + list.SetItemData. + +
  3. The combined class must have an attribute named itemDataMap + that is a dictionary mapping the data values to a sequence of objects + representing the values in each column. These valuesare compared in + the column sorter to determine sort order. +
+ +

Interesting methods to override are GetColumnSorter, +GetSecondarySortValues, and GetSortImages. + +

Methods
+
+
SetColumnCount(newNumColumns) +
Informs the mixin as to the number of columns in the control. When it is +set, it also sets up an event handler for EVT_LIST_COL_CLICK events. + +
SortListItems(col=-1, ascending=1) +
Sort the list on demand. Can also be used to set the sort column and order. + +
GetColumnWidths() +
Returns a list of column widths. Can be used to help restore the current +view later. + +
GetSortImages() +
Returns a tuple of image list indexes the indexes in the image list for an +image to be put on the column header when sorting in descending order + +
GetColumnSorter() +
Returns a callable object to be used for comparing column values when sorting. + +
GetSecondarySortValues(col, key1, key2) +
Returns a tuple of 2 values to use for secondary sort values when the +items in the selected column match equal. The default just returns the +item data values. + +
+ +

ListCtrlAutoWidthMixin

+ +ListCtrlAutoWidthMixin() + +

A mix-in class that automatically resizes the last column to take up the +remaining width of the ListCtrl. + +

This causes the ListCtrl to automatically take up the full width of the list, +without either a horizontal scroll bar (unless absolutely necessary) or empty +space to the right of the last column. + +

NOTE: This only works for report-style lists. + +

WARNING: If you override the EVT_SIZE event in your ListCtrl, +make sure you call event.Skip() to ensure that the mixin's _OnResize method is +called. + +

This mix-in class was written by Erik Westra + +

Methods
+
+ +
resizeLastColumn(minWidth) +
Resize the last column appropriately. If the list's columns are too wide to +fit within the window, we use a horizontal scrollbar. Otherwise, we expand the +right-most column to take up the remaining free space in the list. This method is +called automatically when the ListCtrl is resized; you can also call it yourself +whenever you want the last column to be resized appropriately (eg, when adding, +removing or resizing columns). 'minWidth' is the preferred minimum width for +the last column. + +
+ + +

ListCtrlSelectionManagerMix

+ +ListCtrlSelectionManagerMix() + +

Mixin that defines a platform independent selection policy + +

As selection single and multi-select list return the item index or a +list of item indexes respectively. + +

Methods
+
+ +
getPopupMenu() +
Override to implement dynamic menus (create) + +
setPopupMenu(menu) +
Must be set for default behaviour. + +
afterPopupMenu() +
Override to implement dynamic menus (destroy). + +
getSelection() +
Returns the current selection (or selections as a Python list if extended +selection is enabled) + + + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/ListCtrl_virtual.py b/wxPython/demo/ListCtrl_virtual.py new file mode 100644 index 0000000000..75f5d97573 --- /dev/null +++ b/wxPython/demo/ListCtrl_virtual.py @@ -0,0 +1,117 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wx.ListItem.GetText() returns a wxString pointer, not the text. +# + +import wx +import images + +#---------------------------------------------------------------------- + +class TestVirtualList(wx.ListCtrl): + def __init__(self, parent, log): + wx.ListCtrl.__init__( + self, parent, -1, + style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES + ) + + self.log = log + + self.il = wx.ImageList(16, 16) + self.idx1 = self.il.Add(images.getSmilesBitmap()) + self.SetImageList(self.il, wx.IMAGE_LIST_SMALL) + + + self.InsertColumn(0, "First") + self.InsertColumn(1, "Second") + self.InsertColumn(2, "Third") + self.SetColumnWidth(0, 175) + self.SetColumnWidth(1, 175) + self.SetColumnWidth(2, 175) + + self.SetItemCount(1000000) + + self.attr1 = wx.ListItemAttr() + self.attr1.SetBackgroundColour("yellow") + + self.attr2 = wx.ListItemAttr() + self.attr2.SetBackgroundColour("light blue") + + self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected) + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) + self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected) + + + def OnItemSelected(self, event): + self.currentItem = event.m_itemIndex + self.log.WriteText('OnItemSelected: "%s", "%s", "%s", "%s"\n' % + (self.currentItem, + self.GetItemText(self.currentItem), + self.getColumnText(self.currentItem, 1), + self.getColumnText(self.currentItem, 2))) + + def OnItemActivated(self, event): + self.currentItem = event.m_itemIndex + self.log.WriteText("OnItemActivated: %s\nTopItem: %s\n" % + (self.GetItemText(self.currentItem), self.GetTopItem())) + + def getColumnText(self, index, col): + item = self.GetItem(index, col) + return item.GetText() + + def OnItemDeselected(self, evt): + self.log.WriteText("OnItemDeselected: %s" % evt.m_itemIndex) + + + #--------------------------------------------------- + # These methods are callbacks for implementing the + # "virtualness" of the list... Normally you would + # determine the text, attributes and/or image based + # on values from some external data source, but for + # this demo we'll just calculate them + def OnGetItemText(self, item, col): + return "Item %d, column %d" % (item, col) + + def OnGetItemImage(self, item): + if item % 3 == 0: + return self.idx1 + else: + return -1 + + def OnGetItemAttr(self, item): + if item % 3 == 1: + return self.attr1 + elif item % 3 == 2: + return self.attr2 + else: + return None + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestVirtualList(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +This example demonstrates the ListCtrl's Virtual List features. A Virtual list +can contain any number of cells, but data is not loaded into the control itself. +It is loaded on demand via virtual methods OnGetItemText(), OnGetItemImage(), +and OnGetItemAttr(). This greatly reduces the amount of memory required +without limiting what can be done with the list control itself. +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Listbook.py b/wxPython/demo/Listbook.py new file mode 100644 index 0000000000..2186205cb3 --- /dev/null +++ b/wxPython/demo/Listbook.py @@ -0,0 +1,129 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Bunches of imports that might need to go away for the final roll-out. +# + +import sys + +import wx + +import images + +import ColorPanel + +colourList = [ "Aquamarine", "Black", "Blue", "Blue Violet", "Brown", "Cadet Blue", + "Coral", "Cornflower Blue", "Cyan", "Dark Grey", "Dark Green", + "Dark Olive Green", "Dark Orchid", "Dark Slate Blue", + "Dark Slate Grey", "Dark Turquoise", "Dim Grey", "Firebrick", + "Forest Green", "Gold", "Goldenrod", "Grey", "Green", "Green Yellow", + "Indian Red", "Khaki", "Light Blue", "Light Grey", "Light Steel Blue", + "Lime Green", "Magenta", "Maroon", "Medium Aquamarine", "Medium Blue", + "Medium Forest Green", "Medium Goldenrod", "Medium Orchid", + "Medium Sea Green", "Medium Slate Blue", "Medium Spring Green", + "Medium Turquoise", "Medium Violet Red", "Midnight Blue", "Navy", + "Orange", "Orange Red", "Orchid", "Pale Green", "Pink", "Plum", + "Purple", "Red", "Salmon", "Sea Green", "Sienna", "Sky Blue", + "Slate Blue", "Spring Green", "Steel Blue", "Tan", "Thistle", + "Turquoise", "Violet", "Violet Red", "Wheat", "White", "Yellow", + "Yellow Green" + ] + +#---------------------------------------------------------------------------- + +class TestLB(wx.Listbook): + def __init__(self, parent, id, log): + wx.Listbook.__init__(self, parent, id, style= + wx.LB_DEFAULT + #wxLB_TOP + #wxLB_BOTTOM + #wxLB_LEFT + #wxLB_RIGHT + ) + self.log = log + + + # make an image list using the BlomXX images + il = wx.ImageList(32, 32) + for x in range(1, 15): + f = getattr(images, 'getBlom%02dBitmap' % x) + bmp = f() + il.Add(bmp) + self.AssignImageList(il) + + # Now make a bunch of panels for the list book + first = True + imID = 0 + for colour in colourList: + win = self.makeColorPanel(colour) + self.AddPage(win, colour, imageId=imID) + imID += 1 + if imID == il.GetImageCount(): imID = 0 + if first: + st = wx.StaticText(win.win, -1, + "You can put nearly any type of window here,\n" + "and the list can be on any side of the Listbook", + wx.Point(10, 10)) + #st.SetForegroundColour(wxWHITE) + #st.SetBackgroundColour(wxBLUE) + first = False + + + + wx.EVT_LISTBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged) + wx.EVT_LISTBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging) + + + def makeColorPanel(self, color): + p = wx.Panel(self, -1) + win = ColorPanel.ColoredPanel(p, color) + p.win = win + def OnCPSize(evt, win=win): + win.SetSize(evt.GetSize()) + p.Bind(wx.EVT_SIZE, OnCPSize) + return p + + + def OnPageChanged(self, event): + old = event.GetOldSelection() + new = event.GetSelection() + sel = self.GetSelection() + self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) + event.Skip() + + def OnPageChanging(self, event): + old = event.GetOldSelection() + new = event.GetSelection() + sel = self.GetSelection() + self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) + event.Skip() + +#---------------------------------------------------------------------------- + +def runTest(frame, nb, log): + testWin = TestLB(nb, -1, log) + return testWin + +#---------------------------------------------------------------------------- + + +overview = """\ + +

wxListbook

+

+This class is a control similar to a notebook control, but with a +wxListCtrl instead of a set of tabs. + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + diff --git a/wxPython/demo/MDIDemo.py b/wxPython/demo/MDIDemo.py index ad86693e55..190b5a4a5e 100644 --- a/wxPython/demo/MDIDemo.py +++ b/wxPython/demo/MDIDemo.py @@ -8,9 +8,9 @@ import wx -# Importing wxScrolledWindow demo to make use of the MyCanvas +# Importing ScrolledWindow demo to make use of the MyCanvas # class defined within. -import wxScrolledWindow +import ScrolledWindow import images SHOW_BACKGROUND = 1 @@ -53,7 +53,7 @@ class MyParentFrame(wx.MDIParentFrame): def OnNewWindow(self, evt): self.winCount = self.winCount + 1 win = wx.MDIChildFrame(self, -1, "Child Window: %d" % self.winCount) - canvas = wxScrolledWindow.MyCanvas(win) + canvas = ScrolledWindow.MyCanvas(win) win.Show(True) diff --git a/wxPython/demo/MDISashDemo.py b/wxPython/demo/MDISashDemo.py index 00cdc3d684..99faae0913 100644 --- a/wxPython/demo/MDISashDemo.py +++ b/wxPython/demo/MDISashDemo.py @@ -7,7 +7,7 @@ import wx -import wxScrolledWindow +import ScrolledWindow #---------------------------------------------------------------------- # There are better ways to do IDs, but this demo requires that the window @@ -135,7 +135,7 @@ class MyParentFrame(wx.MDIParentFrame): def OnNewWindow(self, evt): self.winCount = self.winCount + 1 win = wx.MDIChildFrame(self, -1, "Child Window: %d" % self.winCount) - canvas = wxScrolledWindow.MyCanvas(win) + canvas = ScrolledWindow.MyCanvas(win) win.Show(True) diff --git a/wxPython/demo/MDIWindows.py b/wxPython/demo/MDIWindows.py new file mode 100644 index 0000000000..a28390a674 --- /dev/null +++ b/wxPython/demo/MDIWindows.py @@ -0,0 +1,66 @@ +# 11/12/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +import MDIDemo +import MDISashDemo + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + b1 = wx.Button(self, -1, "MDI demo") + self.Bind(wx.EVT_BUTTON, self.ShowMDIDemo, b1) + + b2 = wx.Button(self, -1, "MDI with SashWindows demo") + self.Bind(wx.EVT_BUTTON, self.ShowMDISashDemo, b2) + + box = wx.BoxSizer(wx.VERTICAL) + box.Add((20, 30)) + box.Add(b1, 0, wx.ALIGN_CENTER|wx.ALL, 15) + box.Add(b2, 0, wx.ALIGN_CENTER|wx.ALL, 15) + self.SetAutoLayout(True) + self.SetSizer(box) + + + def ShowMDIDemo(self, evt): + frame = MDIDemo.MyParentFrame() + frame.Show() + + def ShowMDISashDemo(self, evt): + frame = MDISashDemo.MyParentFrame() + frame.Show() + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

Multiple Document Interface

+ +Although Microsoft has deprecated the MDI model, wxWindows still supports +it. Here are a couple samples of how to use it - one straightforward, the other +showing how the MDI interface can be integrated into a SashWindow interface. + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/MVCTree.py b/wxPython/demo/MVCTree.py new file mode 100644 index 0000000000..79ad083a85 --- /dev/null +++ b/wxPython/demo/MVCTree.py @@ -0,0 +1,90 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Library must be updated for this to run. +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxMVCTree -> MVCTree +# + +import os +import sys + +import wx +import wx.lib.mvctree as tree + +logger = None +def selchanging(evt): + logger.write("SelChanging!\n") + +def selchanged(evt): + logger.write("SelChange!\n") + logger.write(str(evt.node)) +def expanded(evt): + logger.write("Expanded\n") +def closed(evt): + logger.write("Closed!\n") +def key(evt): + logger.write("Key\n") +def add(evt): + logger.write("Add\n") +def delitem(evt): + logger.write("Delete\n") + +def runTest(frame, nb, log): + #f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500)) + global logger + logger = log + p = tree.MVCTree(nb, -1) + #f = wx.Frame(frame, -1, "MVCTree") + #p = tree.MVCTree(f, -1) + p.SetAssumeChildren(True) + p.SetModel(tree.LateFSTreeModel(os.path.normpath(os.getcwd() + os.sep +'..'))) + + #Uncomment this to enable live filename editing! +# p.AddEditor(FileEditor(p)) + + p.SetMultiSelect(True) + tree.EVT_MVCTREE_SEL_CHANGING(p, p.GetId(), selchanging) + tree.EVT_MVCTREE_SEL_CHANGED(p, p.GetId(), selchanged) + tree.EVT_MVCTREE_ITEM_EXPANDED(p, p.GetId(), expanded) + tree.EVT_MVCTREE_ITEM_COLLAPSED(p, p.GetId(), closed) + tree.EVT_MVCTREE_ADD_ITEM(p, p.GetId(), add) + tree.EVT_MVCTREE_DELETE_ITEM(p, p.GetId(), delitem) + tree.EVT_MVCTREE_KEY_DOWN(p, p.GetId(), key) + + return p + #frame.otherWin = f + #f.Show(True) + #return None + + +overview = """\ + +MVCTree is a control which handles hierarchical data. It is +constructed in model-view-controller architecture, so the display of +that data, and the content of the data can be changed greatly without +affecting the other parts. + +Multiple selections are possible by holding down the Ctrl key. + +This demo shows the wxPython directory structure. The interesting part +is that the tree model is late-bound to the filesystem, so the +filenames are not retrieved until the directory is expanded. In +mvctree.py are models for generic data, and both the early and +late-bound filesystem models. + +There is also support for editing, though it's not enabled in this +demo, to avoid accidentally renaming files! + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index bd75b35f5b..b6c623007a 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -29,154 +29,154 @@ import images _treeList = [ # new stuff ('Recent Additions', [ - 'wxVListBox', - 'wxListbook', - 'wxMaskedNumCtrl', + 'VListBox', + 'Listbook', + 'MaskedNumCtrl', 'FloatCanvas', - 'wxXmlResourceSubclass', - 'wxGridBagSizer', + 'XmlResourceSubclass', + 'GridBagSizer', 'Cursor', 'PyPlot', ]), # managed windows == things with a (optional) caption you can close ('Base Frames and Dialogs', [ - 'wxDialog', - 'wxFrame', - 'wxMDIWindows', - 'wxMiniFrame', - 'wxWizard', + 'Dialog', + 'Frame', + 'MDIWindows', + 'MiniFrame', + 'Wizard', ]), # the common dialogs ('Common Dialogs', [ - 'wxColourDialog', - 'wxDirDialog', - 'wxFileDialog', - 'wxFileDialog_Save', - 'wxFindReplaceDialog', - 'wxFontDialog', - 'wxMessageDialog', - 'wxPageSetupDialog', - 'wxPrintDialog', - 'wxProgressDialog', - 'wxSingleChoiceDialog', - 'wxTextEntryDialog', + 'ColourDialog', + 'DirDialog', + 'FileDialog', + 'FileDialog_Save', + 'FindReplaceDialog', + 'FontDialog', + 'MessageDialog', + 'PageSetupDialog', + 'PrintDialog', + 'ProgressDialog', + 'SingleChoiceDialog', + 'TextEntryDialog', ]), # dialogs from libraries ('More Dialogs', [ 'ErrorDialogs', 'ImageBrowser', - 'wxMultipleChoiceDialog', - 'wxScrolledMessageDialog', + 'MultipleChoiceDialog', + 'ScrolledMessageDialog', ]), # core controls ('Core Windows/Controls', [ + 'Button', + 'CheckBox', + 'CheckListBox', + 'Choice', + 'ComboBox', + 'Gauge', + 'Grid', + 'Grid_MegaExample', + 'ListBox', + 'ListCtrl', + 'ListCtrl_virtual', + 'Listbook', + 'Menu', + 'Notebook', 'PopupMenu', - 'wxButton', - 'wxCheckBox', - 'wxCheckListBox', - 'wxChoice', - 'wxComboBox', - 'wxGauge', - 'wxGrid', - 'wxGrid_MegaExample', - 'wxListbook', - 'wxListBox', - 'wxListCtrl', - 'wxListCtrl_virtual', - 'wxMenu', - 'wxNotebook', - 'wxPopupWindow', - 'wxRadioBox', - 'wxRadioButton', - 'wxSashWindow', - 'wxScrolledWindow', - 'wxSlider', - 'wxSpinButton', - 'wxSpinCtrl', - 'wxSplitterWindow', - 'wxStaticBitmap', - 'wxStaticText', - 'wxStatusBar', - 'wxTextCtrl', - 'wxToggleButton', - 'wxToolBar', - 'wxTreeCtrl', - 'wxValidator', + 'PopupWindow', + 'RadioBox', + 'RadioButton', + 'SashWindow', + 'ScrolledWindow', + 'Slider', + 'SpinButton', + 'SpinCtrl', + 'SplitterWindow', + 'StaticBitmap', + 'StaticText', + 'StatusBar', + 'TextCtrl', + 'ToggleButton', + 'ToolBar', + 'TreeCtrl', + 'Validator', ]), ('Custom Controls', [ 'AnalogClockWindow', 'ColourSelect', + 'Editor', 'GenericButtons', - 'wxEditor', - 'wxGenericDirCtrl', - 'wxLEDNumberCtrl', - 'wxMultiSash', - 'wxPopupControl', - 'wxPyColourChooser', - 'wxTreeListCtrl', + 'GenericDirCtrl', + 'LEDNumberCtrl', + 'MultiSash', + 'PopupControl', + 'PyColourChooser', + 'TreeListCtrl', ]), # controls coming from other libraries ('More Windows/Controls', [ - #'wxFloatBar', deprecated - #'wxMVCTree', deprecated - #'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now. + #'RightTextCtrl', deprecated as we have wxTE_RIGHT now. + 'Calendar', + 'CalendarCtrl', 'ContextHelp', + 'DynamicSashWindow', + 'EditableListBox', 'FancyText', - 'FloatCanvas', 'FileBrowseButton', + 'FloatBar', + 'FloatCanvas', + 'HtmlWindow', + 'IEHtmlWin', + 'IntCtrl', + 'MVCTree', 'MaskedEditControls', - 'PyShell', + 'MaskedNumCtrl', + 'MimeTypesManager', 'PyCrust', 'PyPlot', + 'PyShell', + 'ScrolledPanel', 'SplitTree', + 'StyledTextCtrl_1', + 'StyledTextCtrl_2', 'TablePrint', 'Throbber', - 'wxCalendar', - 'wxCalendarCtrl', - 'wxDynamicSashWindow', - 'wxEditableListBox', - 'wxHtmlWindow', - 'wxIEHtmlWin', - 'wxIntCtrl', - 'wxMimeTypesManager', - 'wxMaskedNumCtrl', - 'wxScrolledPanel', - 'wxStyledTextCtrl_1', - 'wxStyledTextCtrl_2', - 'wxTimeCtrl', - 'wxVListBox', + 'TimeCtrl', + 'VListBox', ]), # How to lay out the controls in a frame/dialog ('Window Layout', [ + 'GridBagSizer', 'LayoutAnchors', + 'LayoutConstraints', 'Layoutf', 'RowColSizer', + 'ScrolledPanel', 'Sizers', - 'wxGridBagSizer', - 'wxLayoutConstraints', - 'wxScrolledPanel', - 'wxXmlResource', - 'wxXmlResourceHandler', - 'wxXmlResourceSubclass', + 'XmlResource', + 'XmlResourceHandler', + 'XmlResourceSubclass', ]), # ditto ('Process and Events', [ 'EventManager', - 'infoframe', + 'KeyEvents', 'OOR', + 'Process', 'PythonEvents', 'Threads', - 'wxKeyEvents', - 'wxProcess', - 'wxTimer', + 'Timer', + 'infoframe', ]), # Clipboard and DnD @@ -188,13 +188,13 @@ _treeList = [ # Images ('Using Images', [ + 'ArtProvider', 'Cursor', + 'DragImage', + 'Image', + 'ImageFromStream', + 'Mask', 'Throbber', - 'wxArtProvider', - 'wxDragImage', - 'wxImage', - 'wxImageFromStream', - 'wxMask', ]), # Other stuff @@ -202,24 +202,24 @@ _treeList = [ 'ColourDB', 'DialogUnits', 'DrawXXXList', + 'FileHistory', 'FontEnumerator', + 'Joystick', 'NewNamespace', + 'OGL', 'PrintFramework', 'ShapedWindow', 'Throbber', 'Unicode', - 'wxFileHistory', - 'wxJoystick', - 'wxOGL', - 'wxWave', + 'Wave', ]), # need libs not coming with the demo ('Objects using an external library', [ 'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE', - 'wxGLCanvas', - #'wxPlotCanvas', # deprecated, use PyPlot + 'GLCanvas', + #'PlotCanvas', # deprecated, use PyPlot ]), @@ -253,14 +253,14 @@ class MyTP(wx.PyTipProvider): #--------------------------------------------------------------------------- # A class to be used to display source code in the demo. Try using the -# wxSTC in the wxStyledTextCtrl_2 sample first, fall back to wxTextCtrl +# wxSTC in the StyledTextCtrl_2 sample first, fall back to wxTextCtrl # if there is an error, such as the stc module not being present. # try: ##raise ImportError from wx import stc - from wxStyledTextCtrl_2 import PythonSTC + from StyledTextCtrl_2 import PythonSTC class DemoCodeViewer(PythonSTC): def __init__(self, parent, ID): PythonSTC.__init__(self, parent, ID) diff --git a/wxPython/demo/Mask.py b/wxPython/demo/Mask.py new file mode 100644 index 0000000000..8d5a43c58b --- /dev/null +++ b/wxPython/demo/Mask.py @@ -0,0 +1,135 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +logicList = [ + ('wx.AND', wx.AND), + ('wx.AND_INVERT', wx.AND_INVERT), + ('wx.AND_REVERSE', wx.AND_REVERSE), + ('wx.CLEAR', wx.CLEAR), + ('wx.COPY', wx.COPY), + ('wx.EQUIV', wx.EQUIV), + ('wx.INVERT', wx.INVERT), + ('wx.NAND', wx.NAND), + + # this one causes an assert on wxGTK, and doesn't seem to + # do much on MSW anyway, so I'll just take it out.... + #('wxNOR', wxNOR), + + ('wx.NO_OP', wx.NO_OP), + ('wx.OR', wx.OR), + ('wx.OR_INVERT', wx.OR_INVERT), + ('wx.OR_REVERSE', wx.OR_REVERSE), + ('wx.SET', wx.SET), + ('wx.SRC_INVERT', wx.SRC_INVERT), + ('wx.XOR', wx.XOR), +] + +import images + +class TestMaskWindow(wx.ScrolledWindow): + def __init__(self, parent): + wx.ScrolledWindow.__init__(self, parent, -1) + self.SetBackgroundColour(wx.Colour(0,128,0)) + + # A reference bitmap that we won't mask + self.bmp_nomask = images.getTestStar2Bitmap() + + # One that we will + self.bmp_withmask = images.getTestStar2Bitmap() + + # this mask comes from a monochrome bitmap + self.bmp_themask = wx.BitmapFromImage(images.getTestMaskImage(), 1) + mask = wx.Mask(self.bmp_themask) + + # set the mask on our bitmap + self.bmp_withmask.SetMask(mask) + + # Now we'll create a mask in a bit of an easier way, by picking a + # colour in the image that is to be the transparent colour. + self.bmp_withcolourmask = images.getTestStar2Bitmap() + mask = wx.MaskColour(self.bmp_withcolourmask, wx.WHITE) + self.bmp_withcolourmask.SetMask(mask) + + self.SetScrollbars(20, 20, 700/20, 460/20) + + self.Bind(wx.EVT_PAINT, self.OnPaint) + + + def OnPaint (self, e): + dc = wx.PaintDC(self) + self.PrepareDC(dc) + dc.SetTextForeground(wx.WHITE) + + # make an interesting background... + dc.SetPen(wx.MEDIUM_GREY_PEN) + for i in range(100): + dc.DrawLine((0,i*10), (i*10,0)) + + # draw raw image, mask, and masked images + dc.DrawText('original image', (0,0)) + dc.DrawBitmap(self.bmp_nomask, (0,20), 0) + dc.DrawText('with colour mask', (0,100)) + dc.DrawBitmap(self.bmp_withcolourmask, (0,120), 1) + dc.DrawText('the mask image', (0,200)) + dc.DrawBitmap(self.bmp_themask, (0,220), 0) + dc.DrawText('masked image', (0,300)) + dc.DrawBitmap(self.bmp_withmask, (0,320), 1) + + cx,cy = self.bmp_themask.GetWidth(), self.bmp_themask.GetHeight() + + # draw array of assorted blit operations + mdc = wx.MemoryDC() + i = 0 + + for text, code in logicList: + x,y = 120+150*(i%4), 20+100*(i/4) + dc.DrawText(text, (x, y-20)) + mdc.SelectObject(self.bmp_withcolourmask) + dc.Blit((x,y), (cx,cy), mdc, (0,0), code, True) + i = i + 1 + + +# On wxGTK there needs to be a panel under wx.ScrolledWindows if they are +# going to be in a wxNotebook... +class TestPanel(wx.Panel): + def __init__(self, parent, ID): + wx.Panel.__init__(self, parent, ID) + self.win = TestMaskWindow(self) + self.Bind(wx.EVT_SIZE, self.OnSize) + + def OnSize(self, evt): + self.win.SetSize(evt.GetSize()) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, -1) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +This class encapsulates a monochrome mask bitmap, where the masked area is black +and the unmasked area is white. When associated with a bitmap and drawn in a device +context, the unmasked area of the bitmap will be drawn, and the masked area will +not be drawn. + +This example shows not only how to create a Mask, but the effects of the Device +Context (dc) Blit() method's logic codes. +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/MaskedNumCtrl.py b/wxPython/demo/MaskedNumCtrl.py new file mode 100644 index 0000000000..855726b100 --- /dev/null +++ b/wxPython/demo/MaskedNumCtrl.py @@ -0,0 +1,346 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wx.lib.maskednumctrl needs hit up with the renamer and new binders +# +# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Issues with lib corrected. +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxMaskedNumCtrl -> MaskedNumCtrl +# + +import string +import sys +import traceback + +import wx +import wx.lib.maskednumctrl as mnum +#---------------------------------------------------------------------- + +class TestPanel( wx.Panel ): + def __init__( self, parent, log ): + + wx.Panel.__init__( self, parent, -1 ) + self.log = log + panel = wx.Panel( self, -1 ) + + header = wx.StaticText(panel, -1, """\ +This shows the various options for MaskedNumCtrl. +The controls at the top reconfigure the resulting control at the bottom. +""") + header.SetForegroundColour( "Blue" ) + + intlabel = wx.StaticText( panel, -1, "Integer width:" ) + self.integerwidth = mnum.MaskedNumCtrl( + panel, value=10, integerWidth=2, allowNegative=False + ) + + fraclabel = wx.StaticText( panel, -1, "Fraction width:" ) + self.fractionwidth = mnum.MaskedNumCtrl( + panel, value=0, integerWidth=2, allowNegative=False + ) + + groupcharlabel = wx.StaticText( panel,-1, "Grouping char:" ) + self.groupchar = mnum.MaskedTextCtrl( + panel, -1, value=',', mask='&', excludeChars = '-()', + formatcodes='F', emptyInvalid=True, validRequired=True + ) + + decimalcharlabel = wx.StaticText( panel,-1, "Decimal char:" ) + self.decimalchar = mnum.MaskedTextCtrl( + panel, -1, value='.', mask='&', excludeChars = '-()', + formatcodes='F', emptyInvalid=True, validRequired=True + ) + + self.set_min = wx.CheckBox( panel, -1, "Set minimum value:" ) + # Create this MaskedNumCtrl using factory, to show how: + self.min = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 ) + self.min.Enable( False ) + + self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" ) + self.max = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 ) + self.max.Enable( False ) + + + self.limit_target = wx.CheckBox( panel, -1, "Limit control" ) + self.allow_none = wx.CheckBox( panel, -1, "Allow empty control" ) + self.group_digits = wx.CheckBox( panel, -1, "Group digits" ) + self.group_digits.SetValue( True ) + self.allow_negative = wx.CheckBox( panel, -1, "Allow negative values" ) + self.allow_negative.SetValue( True ) + self.use_parens = wx.CheckBox( panel, -1, "Use parentheses" ) + self.select_on_entry = wx.CheckBox( panel, -1, "Select on entry" ) + self.select_on_entry.SetValue( True ) + + label = wx.StaticText( panel, -1, "Resulting numeric control:" ) + font = label.GetFont() + font.SetWeight(wx.BOLD) + label.SetFont(font) + + self.target_ctl = mnum.MaskedNumCtrl( panel, -1, name="target control" ) + + label_numselect = wx.StaticText( panel, -1, """\ +Programmatically set the above +value entry ctrl:""") + self.numselect = wx.ComboBox(panel, -1, choices = [ '0', '111', '222.22', '-3', '54321.666666666', '-1353.978', + '1234567', '-1234567', '123456789', '-123456789.1', + '1234567890.', '-9876543210.9' ]) + + grid1 = wx.FlexGridSizer( 0, 4, 0, 0 ) + grid1.Add( intlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + grid1.Add( self.integerwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid1.Add( groupcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + grid1.Add( self.groupchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid1.Add( fraclabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid1.Add( self.fractionwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid1.Add( decimalcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) + grid1.Add( self.decimalchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid1.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid1.Add( self.min, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + + grid1.Add( self.set_max, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid1.Add( self.max, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + + + grid1.Add( self.limit_target, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid1.Add( self.allow_none, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + hbox1 = wx.BoxSizer( wx.HORIZONTAL ) + hbox1.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + hbox1.Add( self.group_digits, 0, wx.ALIGN_LEFT|wx.LEFT, 5 ) + grid1.Add( hbox1, 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + + grid1.Add( self.allow_negative, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid1.Add( self.use_parens, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + hbox2 = wx.BoxSizer( wx.HORIZONTAL ) + hbox2.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + hbox2.Add( self.select_on_entry, 0, wx.ALIGN_LEFT|wx.LEFT, 5 ) + grid1.Add( hbox2, 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + + + grid2 = wx.FlexGridSizer( 0, 2, 0, 0 ) + grid2.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid2.Add( self.target_ctl, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid2.Add( label_numselect, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid2.Add( self.numselect, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) + grid2.AddGrowableCol(1) + + self.outer_box = wx.BoxSizer( wx.VERTICAL ) + self.outer_box.Add(header, 0, wx.ALIGN_LEFT|wx.TOP|wx.LEFT, 20) + self.outer_box.Add( grid1, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.BOTTOM|wx.RIGHT, 20 ) + self.outer_box.Add( grid2, 0, wx.ALIGN_LEFT|wx.ALL, 20 ) + self.grid2 = grid2 + + panel.SetAutoLayout( True ) + panel.SetSizer( self.outer_box ) + self.outer_box.Fit( panel ) + panel.Move( (50,10) ) + self.panel = panel + + self.Bind(mnum.EVT_MASKEDNUM, self.OnSetIntWidth, self.integerwidth ) + self.Bind(mnum.EVT_MASKEDNUM, self.OnSetFractionWidth, self.fractionwidth ) + self.Bind(wx.EVT_TEXT, self.OnSetGroupChar, self.groupchar ) + self.Bind(wx.EVT_TEXT, self.OnSetDecimalChar, self.decimalchar ) + + self.Bind(wx.EVT_CHECKBOX, self.OnSetMin, self.set_min ) + self.Bind(wx.EVT_CHECKBOX, self.OnSetMax, self.set_max ) + self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.min ) + self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.max ) + + self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target ) + self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none ) + self.Bind(wx.EVT_CHECKBOX, self.OnSetGroupDigits, self.group_digits ) + self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNegative, self.allow_negative ) + self.Bind(wx.EVT_CHECKBOX, self.OnSetUseParens, self.use_parens ) + self.Bind(wx.EVT_CHECKBOX, self.OnSetSelectOnEntry, self.select_on_entry ) + + self.Bind(mnum.EVT_MASKEDNUM, self.OnTargetChange, self.target_ctl ) + self.Bind(wx.EVT_COMBOBOX, self.OnNumberSelect, self.numselect ) + + + def OnSetIntWidth(self, event ): + width = self.integerwidth.GetValue() + + if width < 1: + self.log.write("integer width must be positive\n") + self.integerwidth.SetForegroundColour(wx.RED) + else: + self.integerwidth.SetForegroundColour(wx.BLACK) + self.log.write("setting integer width to %d\n" % width) + self.target_ctl.SetParameters( integerWidth = width) + # Now resize and fit the dialog as appropriate: + self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) + self.outer_box.Fit( self.panel ) + self.outer_box.SetSizeHints( self.panel ) + + + def OnSetFractionWidth(self, event ): + width = self.fractionwidth.GetValue() + self.log.write("setting fraction width to %d\n" % width) + self.target_ctl.SetParameters( fractionWidth = width) + # Now resize and fit the dialog as appropriate: + self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) + self.outer_box.Fit( self.panel ) + self.outer_box.SetSizeHints( self.panel ) + + + def OnSetGroupChar( self, event ): + char = self.groupchar.GetValue() + if self.target_ctl.GetDecimalChar() == char: + self.log.write("group and decimal chars must be different\n") + self.groupchar.SetForegroundColour(wx.RED) + else: + self.groupchar.SetForegroundColour(wx.BLACK) + self.log.write("setting group char to %s\n" % char) + self.target_ctl.SetGroupChar( char ) + + def OnSetDecimalChar( self, event ): + char = self.decimalchar.GetValue() + if self.target_ctl.GetGroupChar() == char: + self.log.write("group and decimal chars must be different\n") + self.decimalchar.SetForegroundColour(wx.RED) + else: + self.decimalchar.SetForegroundColour(wx.BLACK) + self.log.write("setting decimal char to %s\n" % char) + self.target_ctl.SetDecimalChar( char ) + + + def OnSetMin( self, event ): + self.min.Enable( self.set_min.GetValue() ) + self.SetTargetMinMax() + + def OnSetMax( self, event ): + self.max.Enable( self.set_max.GetValue() ) + self.SetTargetMinMax() + + + def SetTargetMinMax( self, event=None ): + min = max = None + self.target_ctl.SetLimited( self.limit_target.GetValue() ) + + if self.set_min.GetValue(): + min = self.min.GetValue() + if self.set_max.GetValue(): + max = self.max.GetValue() + + cur_min, cur_max = self.target_ctl.GetBounds() + + if min != cur_min and not self.target_ctl.SetMin( min ): + if self.target_ctl.GetMax() is None and cur_max > min: + self.log.write( "min (%d) won't fit in control -- bound not set\n" % min ) + else: + self.log.write( "min (%d) > current max (%d) -- bound not set\n" % ( min, self.target_ctl.GetMax() ) ) + self.min.SetParameters( signedForegroundColour=wx.RED, foregroundColour=wx.RED ) + else: + self.min.SetParameters( signedForegroundColour=wx.BLACK, foregroundColour=wx.BLACK ) + self.min.Refresh() + + if max != cur_max and not self.target_ctl.SetMax( max ): + if self.target_ctl.GetMax() is None and cur_min < max: + self.log.write( "max (%d) won't fit in control -- bound not set\n" % max ) + else: + self.log.write( "max (%d) < current min (%d) -- bound not set\n" % ( max, self.target_ctl.GetMin() ) ) + self.max.SetParameters( signedForegroundColour=wx.RED, foregroundColour=wx.RED ) + else: + self.max.SetParameters( signedForegroundColour=wx.BLACK, foregroundColour=wx.BLACK ) + self.max.Refresh() + + if min != cur_min or max != cur_max: + new_min, new_max = self.target_ctl.GetBounds() + self.log.write( "current min, max: (%s, %s)\n" % ( str(new_min), str(new_max) ) ) + + + def OnSetAllowNone( self, event ): + self.target_ctl.SetAllowNone( self.allow_none.GetValue() ) + + + def OnSetGroupDigits( self, event ): + self.target_ctl.SetGroupDigits( self.group_digits.GetValue() ) + # Now resize and fit the dialog as appropriate: + self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) + self.outer_box.Fit( self.panel ) + self.outer_box.SetSizeHints( self.panel ) + + + def OnSetAllowNegative( self, event ): + if self.allow_negative.GetValue(): + self.use_parens.Enable(True) + self.target_ctl.SetParameters(allowNegative=True, + useParensForNegatives = self.use_parens.GetValue()) + else: + self.target_ctl.SetAllowNegative(False) + # Now resize and fit the dialog as appropriate: + self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) + self.outer_box.Fit( self.panel ) + self.outer_box.SetSizeHints( self.panel ) + + + def OnSetUseParens( self, event ): + self.target_ctl.SetUseParensForNegatives( self.use_parens.GetValue() ) + # Now resize and fit the dialog as appropriate: + self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) + self.outer_box.Fit( self.panel ) + self.outer_box.SetSizeHints( self.panel ) + + + def OnSetSelectOnEntry( self, event ): + self.target_ctl.SetSelectOnEntry( self.select_on_entry.GetValue() ) + + + def OnTargetChange( self, event ): + ctl = event.GetEventObject() + value = ctl.GetValue() + ib_str = [ " (out of bounds)", "" ] + self.log.write( "value = %s (%s)%s\n" % ( repr(value), repr(type(value)), ib_str[ ctl.IsInBounds(value) ] ) ) + + + def OnNumberSelect( self, event ): + value = event.GetString() + if value: + if value.find('.') != -1: + numvalue = float(value) + else: + numvalue = long(value) + else: + numvalue = value # try to clear the value again + + try: + self.target_ctl.SetValue(numvalue) + except: + type, value, tb = sys.exc_info() + for line in traceback.format_exception_only(type, value): + self.log.write(line) + + +#---------------------------------------------------------------------- + +def runTest( frame, nb, log ): + win = TestPanel( nb, log ) + return win + +#---------------------------------------------------------------------- +overview = mnum.__doc__ + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/Menu.py b/wxPython/demo/Menu.py new file mode 100644 index 0000000000..516241efcf --- /dev/null +++ b/wxPython/demo/Menu.py @@ -0,0 +1,300 @@ +#------------------------------------------------------------------- +# essaimenu.py +# +# menus in wxPython 2.3.3 +# +#------------------------------------------------------------------- +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import time +import wx +import images + +#------------------------------------------------------------------- + +class MyFrame(wx.Frame): + + def __init__(self, parent, id, log): + wx.Frame.__init__(self, parent, id, 'Playing with menus', size=(400, 200)) + self.log = log + self.CenterOnScreen() + + self.CreateStatusBar() + self.SetStatusText("This is the statusbar") + + tc = wx.TextCtrl(self, -1, """ +A bunch of bogus menus have been created for this frame. You +can play around with them to see how they behave and then +check the source for this sample to see how to implement them. +""", style=wx.TE_READONLY|wx.TE_MULTILINE) + + # Prepare the menu bar + menuBar = wx.MenuBar() + + # 1st menu from left + menu1 = wx.Menu() + 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, "&Close", "Close this frame") + # Add menu to the menu bar + menuBar.Append(menu1, "&Planets") + + # 2nd menu from left + menu2 = wx.Menu() + menu2.Append(201, "Hydrogen") + menu2.Append(202, "Helium") + # a submenu in the 2nd menu + submenu = wx.Menu() + 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 = wx.Menu() + # Radio items + menu3.Append(301, "IDLE", "a Python shell using tcl/tk as GUI", wx.ITEM_RADIO) + menu3.Append(302, "PyCrust", "a Python shell using wxPython as GUI", wx.ITEM_RADIO) + menu3.Append(303, "psi", "a simple Python shell using wxPython as GUI", wx.ITEM_RADIO) + menu3.AppendSeparator() + menu3.Append(304, "project1", "", wx.ITEM_NORMAL) + menu3.Append(305, "project2", "", wx.ITEM_NORMAL) + menuBar.Append(menu3, "&Shells") + + menu4 = wx.Menu() + # Check menu items + menu4.Append(401, "letters", "abcde...", wx.ITEM_CHECK) + menu4.Append(402, "digits", "123...", wx.ITEM_CHECK) + menu4.Append(403, "letters and digits", "abcd... + 123...", wx.ITEM_CHECK) + menuBar.Append(menu4, "Chec&k") + + menu5 = wx.Menu() + # Show how to put an icon in the menu + item = wx.MenuItem(menu5, 500, "&Smile!\tCtrl+S", "This one has an icon") + item.SetBitmap(images.getSmilesBitmap()) + menu5.AppendItem(item) + + # Shortcuts + menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!") + menu5.AppendSeparator() + menu5.Append(502, "Hello\tShift+H") + menu5.AppendSeparator() + menu5.Append(503, "remove the submenu") + menu6 = wx.Menu() + menu6.Append(601, "Submenu Item") + menu5.AppendMenu(504, "submenu", menu6) + menu5.Append(505, "remove this menu") + menu5.Append(506, "this is updated") + menu5.Append(507, "insert after this...") + menu5.Append(508, "...and before this") + menuBar.Append(menu5, "&Fun") + + self.SetMenuBar(menuBar) + + # Menu events + self.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight) + + self.Bind(wx.EVT_MENU, self.Menu101, id=101) + self.Bind(wx.EVT_MENU, self.Menu102, id=102) + self.Bind(wx.EVT_MENU, self.Menu103, id=103) + self.Bind(wx.EVT_MENU, self.CloseWindow, id=104) + + self.Bind(wx.EVT_MENU, self.Menu201, id=201) + self.Bind(wx.EVT_MENU, self.Menu202, id=202) + self.Bind(wx.EVT_MENU, self.Menu2031, id=2031) + self.Bind(wx.EVT_MENU, self.Menu2032, id=2032) + self.Bind(wx.EVT_MENU, self.Menu2033, id=2033) + + self.Bind(wx.EVT_MENU, self.Menu301To303, id=301) + self.Bind(wx.EVT_MENU, self.Menu301To303, id=302) + self.Bind(wx.EVT_MENU, self.Menu301To303, id=303) + self.Bind(wx.EVT_MENU, self.Menu304, id=304) + self.Bind(wx.EVT_MENU, self.Menu305, id=305) + + # Range of menu items + self.Bind(wx.EVT_MENU_RANGE, self.Menu401To403, id=401, id2=403) + + self.Bind(wx.EVT_MENU, self.Menu500, id=500) + self.Bind(wx.EVT_MENU, self.Menu501, id=501) + self.Bind(wx.EVT_MENU, self.Menu502, id=502) + self.Bind(wx.EVT_MENU, self.TestRemove, id=503) + self.Bind(wx.EVT_MENU, self.TestRemove2, id=505) + self.Bind(wx.EVT_MENU, self.TestInsert, id=507) + self.Bind(wx.EVT_MENU, self.TestInsert, id=508) + + wx.GetApp().Bind(wx.EVT_UPDATE_UI, self.TestUpdateUI, id=506) + + # Methods + + def OnMenuHighlight(self, event): + # Show how to get menu item imfo from this event handler + id = event.GetMenuId() + item = self.GetMenuBar().FindItemById(id) + text = item.GetText() + help = item.GetHelp() + + #print text, help + # but in this case just call Skip so the default is done + event.Skip() + + + 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 CloseWindow(self, event): + self.Close() + + 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 Menu500(self, event): + self.log.write('Have a happy day!\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 TestRemove(self, evt): + mb = self.GetMenuBar() + submenuItem = mb.FindItemById(601) + + if not submenuItem: + return + + submenu = submenuItem.GetMenu() + menu = submenu.GetParent() + + # This works + #menu.Remove(504) + + # this also works + menu.RemoveItem(mb.FindItemById(504)) + + # This doesn't work, as expected since submenuItem is not on menu + #menu.RemoveItem(submenuItem) + + + def TestRemove2(self, evt): + mb = self.GetMenuBar() + mb.Remove(4) + + + def TestUpdateUI(self, evt): + text = time.ctime() + evt.SetText(text) + + + def TestInsert(self, evt): + theID = 508 + # get the menu + mb = self.GetMenuBar() + menuItem = mb.FindItemById(theID) + menu = menuItem.GetMenu() + + # figure out the position to insert at + pos = 0 + + for i in menu.GetMenuItems(): + if i.GetId() == theID: + break + + pos += 1 + + # now insert the new item + ID = wx.NewId() + ##menu.Insert(pos, ID, "NewItem " + str(ID)) + item = wx.MenuItem(menu) + item.SetId(ID) + item.SetText("NewItem " + str(ID)) + menu.InsertItem(pos, item) + + +#------------------------------------------------------------------- + +wx.RegisterId(10000) + +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. + +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 +used to construct either menu bars or popup menus. + +A menu item has an integer ID associated with it which can be used to identify +the selection, or to change the menu item in some way. A menu item with a special +identifier -1 is a separator item and doesn't have an associated command but just +makes a separator line appear in the menu. + +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 +be retrieved using either IsChecked method of wxMenu or wxMenuBar 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 +in the same radio group are unchecked when a radio item is checked. The radio group +is formed by a contiguous range of radio items, i.e. it starts at the first item of +this kind and ends with the first item of a different kind (or the end of the menu). +Notice that because the radio groups are defined in terms of the item positions +inserting or removing the items in the menu containing the radio items risks to not +work correctly. Finally note that the radio items are only supported under Windows +and GTK+ currently. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/MessageDialog.py b/wxPython/demo/MessageDialog.py new file mode 100644 index 0000000000..009c30fb11 --- /dev/null +++ b/wxPython/demo/MessageDialog.py @@ -0,0 +1,39 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + dlg = wx.MessageDialog(frame, 'Hello from Python and wxPython!', + 'A Message Box', wx.OK | wx.ICON_INFORMATION) + #wxYES_NO | wxNO_DEFAULT | wxCANCEL | wxICON_INFORMATION) + dlg.ShowModal() + dlg.Destroy() + +#--------------------------------------------------------------------------- + + + +overview = """\ +This class represents a dialog that shows a single or multi-line message, with a +choice of OK, Yes, No and Cancel buttons. + +Additionally, various style flags can determine whether an icon is displayed, +and, if so, what kind. + +The dialog can be modal or not; of modal, the user's response is in the return +code of ShowModal(). If not, the response can be taken from GetReturnCode() (inherited +from the wxDialog super class). If not modal and the return code is required, it +must be retrieved before the dialog is destroyed. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/MimeTypesManager.py b/wxPython/demo/MimeTypesManager.py new file mode 100644 index 0000000000..b3c6b970a6 --- /dev/null +++ b/wxPython/demo/MimeTypesManager.py @@ -0,0 +1,355 @@ +#---------------------------------------------------------------------- +# Name: wxMimeTypesManager +# Purpose: Demonstrate use of wx.MimeTypesManager, wx.FileType +# +# Author: Jeff Grimmett (grimmtoo@softhome.net), adapted from original +# .wdr-derived demo +# +# Created: 12/31/03 +# RCS-ID: $Id$ +# Copyright: +# Licence: wxWindows license +#---------------------------------------------------------------------- +# + + +import pprint +import wx +import images + +#---------------------------------------------------------------------------- + +# A convenient wrapper around wx.TextCtrl to give it a spiffy label. +class ExtStr(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent, -1) + sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Extension'), wx.HORIZONTAL) + self.ctl = wx.TextCtrl(self, -1, value="wav", style = wx.TE_PROCESS_ENTER ) + sizer.Add(self.ctl, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 3) + self.Enable(True) + + self.SetSizer(sizer) + sizer.Fit(self) + + def Enable(self, value): + self.ctl.Enable(value) + + def SetValue(self, value): + self.ctl.SetValue(value) + + def GetValue(self): + return(self.ctl.GetValue()) + + +class MimeTypesDemoPanel(wx.Panel): + def __init__(self, parent, log): + + self.log = log + + wx.Panel.__init__(self, parent, -1) + + # Contains everything + tsizer = wx.BoxSizer(wx.VERTICAL) + + # Contains upper controls + usizer = wx.BoxSizer(wx.HORIZONTAL) + + # A little fancy stuff to make things align right. + self.ext = ExtStr(self) + usizer.Add(self.ext, 0, wx.ALL | wx.ALIGN_TOP, 4) + self.ext.Bind(wx.EVT_TEXT_ENTER, self.OnLookup) + + # Select how to look it up + self.how = wx.RadioBox( + self, -1, "Lookup method", choices=['By extension', 'By MIME type'], + majorDimension=2, style=wx.RA_SPECIFY_COLS + ) + usizer.Add(self.how, 0, wx.ALL | wx.ALIGN_TOP, 4) + self.how.SetSelection(0) + + # Trigger a lookup (hitting ENTER in the text ctrl will do the same thing) + self.go = wx.Button(self, -1, "Go get it!") + usizer.Add(self.go, 0, wx.ALL | wx.ALIGN_CENTER, 4) + self.Bind(wx.EVT_BUTTON, self.OnLookup, self.go) + + # StaticBox with larger label than usual + lbox = wx.StaticBox(self, -1, 'wx.FileType') + lbox.SetFont( + wx.Font( + self.GetFont().GetPointSize() * 2, + self.GetFont().GetFamily(), + self.GetFont().GetStyle(), + wx.BOLD + )) + + lsizer = wx.StaticBoxSizer(lbox, wx.HORIZONTAL) + + # Contains the wx.FileType info + llsizer = wx.GridBagSizer(2, 2) + llsizer.AddGrowableCol(2) + + # This will be used for all of the labels that follow (bold label) + bfont = wx.Font( + self.GetFont().GetPointSize(), + self.GetFont().GetFamily(), + self.GetFont().GetStyle(), + wx.BOLD + ) + + #------- Icon info + + t = wx.StaticText(self, -1, 'GetIconInfo: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (0, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.icon = wx.StaticBitmap(self, -1, images.getNoIconBitmap()) + llsizer.Add(self.icon, (0, 1), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.iconsource = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) + llsizer.Add(self.iconsource, (0, 2), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.iconoffset = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) + llsizer.Add(self.iconoffset, (0, 3), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + #------- MIME Type + + t = wx.StaticText(self, -1, 'GetMimeType: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (1, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.mimetype = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) + llsizer.Add(self.mimetype, (1, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + #------- MIME Types + + t = wx.StaticText(self, -1, 'GetMimeTypes: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (2, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.mimetypes = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) + llsizer.Add(self.mimetypes, (2, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + #------- Extensions + + t = wx.StaticText(self, -1, 'GetExtensions: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (3, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.extensions = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) + llsizer.Add(self.extensions, (3, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + #------- Description + + t = wx.StaticText(self, -1, 'GetDescription: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (4, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.description = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY) + llsizer.Add(self.description, (4, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + #------- Open command + + t = wx.StaticText(self, -1, 'GetOpenCommand: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (5, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.opencommand = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) + llsizer.Add(self.opencommand, (5, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + #------- Print command + + t = wx.StaticText(self, -1, 'GetPrintCommand: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (6, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.printcommand = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) + llsizer.Add(self.printcommand, (6, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + #------- All commands + + t = wx.StaticText(self, -1, 'GetAllCommands: ', style = wx.ALIGN_RIGHT ) + t.SetFont(bfont) + llsizer.Add(t, (7, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) + + self.allcommands = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY | wx.TE_DONTWRAP | wx.TE_MULTILINE ) + + # Set the default height to be smaller than normal (for + # multi-line) so the sizer can then expand it to whatever + # space is available + self.allcommands.SetSize((-1, 20)) + + llsizer.Add(self.allcommands, (7, 1), (1, 3), wx.ALL | wx.GROW | wx.ALIGN_CENTER, 2) + + # Tell the sizer to expand this row as needed + llsizer.AddGrowableRow(7) + + #---------------------------------------------------------------------------- + + lrsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Known MIME types'), wx.HORIZONTAL) + + #------- List box with known MIME types + self.mimelist = wx.ListBox(self, -1, choices=[], style = wx.LB_SINGLE | wx.LB_SORT) + lrsizer.Add(self.mimelist, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) + self.Bind(wx.EVT_LISTBOX, self.OnListbox, self.mimelist) + + #---------------------------------------------------------------------------- + + lsizer.Add(llsizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) + lsizer.Add(lrsizer, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) + + #---------------------------------------------------------------------------- + + tsizer.Add(usizer, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) + tsizer.Add(lsizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) + + #---------------------------------------------------------------------------- + + self.SetSizer(tsizer) + tsizer.Fit(self) + + # Populate the Known MIME types list with what is in the database + mtypes = wx.TheMimeTypesManager.EnumAllFileTypes() + for mt in mtypes: + self.mimelist.Append(mt) + + # Do a lookup of *.wav for a starting position + self.OnLookup() + + # Grab the selection from the listbox, push that into + # the text box at top, select 'MIME', and then look it up. + def OnListbox(self, event): + mimetype = event.GetString() + self.ext.SetValue(mimetype) + self.how.SetSelection(1) + self.OnLookup() + + # Look up a given file extension or MIME type. + def OnLookup(self, event=None): + txt = self.ext.GetValue() + + # For MIME lookups + if self.how.GetSelection() == 1: + fileType = wx.TheMimeTypesManager.GetFileTypeFromMimeType(txt) + msg = "Mime type" + + # Select the entered value in the list + if fileType: + if self.mimelist.FindString(txt) != -1: + self.mimelist.SetSelection(self.mimelist.FindString(txt)) + + # Must be an extension lookup + else: + fileType = wx.TheMimeTypesManager.GetFileTypeFromExtension(txt) + msg = "File extension" + + # Select the entered value in the list + if fileType: + if self.mimelist.FindString(str(fileType.GetMimeType())) != -1: + # Using CallAfter to ensure that GUI is ready before trying to + # select it (otherwise, it's selected but not visible) + wx.CallAfter(self.mimelist.SetSelection, self.mimelist.FindString(str(fileType.GetMimeType()))) + + + if fileType is None: + wx.MessageBox(msg + " not found.", "Oops!") + else: + self.Update(fileType) + + # Populate the wx.FileType fields with actual values. + def Update(self, ft): + + #------- Icon info + info = ft.GetIconInfo() + + if info is None: + bmp = images.getNoIconBitmap() + self.icon.SetBitmap(bmp) + self.iconsource.SetValue("") + self.iconoffset.SetValue("") + else: + icon, file, idx = info + if icon.Ok(): + self.icon.SetIcon(icon) + else: + bmp = images.getNoIconBitmap() + self.icon.SetBitmap(bmp) + self.iconsource.SetValue(file) + self.iconoffset.SetValue(str(idx)) + + #------- MIME type + self.mimetype.SetValue(str(ft.GetMimeType())) + #------- MIME types + self.mimetypes.SetValue(str(ft.GetMimeTypes())) + #------- Associated extensions + self.extensions.SetValue(str(ft.GetExtensions())) + #------- Description of file type + self.description.SetValue(str(ft.GetDescription())) + + #------- Prep a fake command line command + extList = ft.GetExtensions() + + if extList: + ext = extList[0] + if ext[0] == ".": ext = ext[1:] + else: + ext = "" + + filename = "SPAM" + "." + ext + mime = ft.GetMimeType() or "" + + #------- OPEN command + cmd = ft.GetOpenCommand(filename, mime) + self.opencommand.SetValue(str(cmd)) + + #------- PRINT command + cmd = ft.GetPrintCommand(filename, mime) + self.printcommand.SetValue(str(cmd)) + + #------- All commands + all = ft.GetAllCommands(filename, mime) + + if all is None: + self.allcommands.SetValue("") + else: + verbs, commands = all + text = pprint.pformat(map(None, verbs, commands)) + self.allcommands.SetValue(text) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = MimeTypesDemoPanel(nb, log) + return win + +#---------------------------------------------------------------------- + +overview = """\ + +The wx.MimeTypesManager class allows the application to retrieve the +information about all known MIME types from a system-specific location and the +filename extensions to the MIME types and vice versa. After initialization the +methods GetFileTypeFromMimeType() and GetFileTypeFromExtension() +may be called: they will return a wx.FileType object which may be further +queried for file description, icon and other attributes. + +A global instance of wx.MimeTypesManager is always available as +wx.TheMimeTypesManager. It is recommended to use this instance instead +of creating your own because gathering MIME information may take quite a long +on Unix systems. + +This demo shows how to use wx.TheMimeTypesManager to list all known MIME types +and retrieve that information as a wx.FileType from either an extension or +MIME type. + +For further information please consult the wxWindows documentation for +wx.MimeTypesManager and wx.FileType. + +""" + +#---------------------------------------------------------------------- + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/MiniFrame.py b/wxPython/demo/MiniFrame.py new file mode 100644 index 0000000000..42e237ae4f --- /dev/null +++ b/wxPython/demo/MiniFrame.py @@ -0,0 +1,55 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- +class MyMiniFrame(wx.MiniFrame): + def __init__( + self, parent, title, pos=wx.DefaultPosition, size=wx.DefaultSize, + style=wx.DEFAULT_FRAME_STYLE + ): + + wx.MiniFrame.__init__(self, parent, -1, title, pos, size, style) + panel = wx.Panel(self, -1) + + button = wx.Button(panel, -1, "Close Me") + button.SetPosition((15, 15)) + self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + + def OnCloseMe(self, event): + self.Close(True) + + def OnCloseWindow(self, event): + print "OnCloseWindow" + self.Destroy() + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = MyMiniFrame(frame, "This is a wxMiniFrame", + #pos=(250,250), size=(200,200), + style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ) + win.SetSize((200, 200)) + win.CenterOnParent(wx.BOTH) + frame.otherWin = win + win.Show(True) + + +#--------------------------------------------------------------------------- + + +overview = """\ +A miniframe is a frame with a small title bar. It is suitable for floating +toolbars that must not take up too much screen area. In other respects, it's the +same as a wxFrame. +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/MultiSash.py b/wxPython/demo/MultiSash.py new file mode 100644 index 0000000000..ce95868047 --- /dev/null +++ b/wxPython/demo/MultiSash.py @@ -0,0 +1,112 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wx renamer needs to be applied to multisash lib. +# o There appears to be a problem with the image that +# the library is trying to use for the alternate cursor +# +# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o renamer issue shelved. +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxMultiSash -> MultiSash +# + +import wx +import wx.lib.multisash as sash +import wx.stc as stc + +#--------------------------------------------------------------------------- + +sampleText="""\ +You can drag the little tab on the vertical sash left to create another view, +or you can drag the tab on the horizontal sash to the top to create another +horizontal view. + +The red blocks on the sashes will destroy the view (bottom,left) this block +belongs to. + +A yellow rectangle also highlights the current selected view. + +By calling GetSaveData on the multiSash control the control will return its +contents and the positions of each sash as a dictionary. +Calling SetSaveData with such a dictionary will restore the control to the +state it was in when it was saved. + +If the class, that is used as a view, has GetSaveData/SetSaveData implemented, +these will also be called to save/restore their state. Any object can be +returned by GetSaveData, as it is just another object in the dictionary. +""" + +#--------------------------------------------------------------------------- + +class TestWindow(stc.StyledTextCtrl): + + # shared document reference + doc = None + + def __init__(self, parent): + stc.StyledTextCtrl.__init__(self, parent, -1, style=wx.NO_BORDER) + self.SetMarginWidth(1,0) + + if wx.Platform == '__WXMSW__': + fSize = 10 + else: + fSize = 12 + + self.StyleSetFont( + stc.STC_STYLE_DEFAULT, + wx.Font(fSize, wx.MODERN, wx.NORMAL, wx.NORMAL) + ) + + if self.doc: + self.SetDocPointer(self.doc) + else: + self.SetText(sampleText) + TestWindow.doc = self.GetDocPointer() + + + def SutdownDemo(self): + # Reset doc reference in case this demo is run again + TestWindow.doc = None + + +#--------------------------------------------------------------------------- + + +def runTest(frame, nb, log): + multi = sash.MultiSash(nb, -1, pos = (0,0), size = (640,480)) + + # Use this method to set the default class that will be created when + # a new sash is created. The class's constructor needs 1 parameter + # which is the parent of the window + multi.SetDefaultChildClass(TestWindow) + + return multi + +#---------------------------------------------------------------------- + + + +overview = """ +

MultiSash

+ +MultiSash allows the user to split a window any number of times +either horizontally or vertically, and to close the split off windows +when desired. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/MultipleChoiceDialog.py b/wxPython/demo/MultipleChoiceDialog.py new file mode 100644 index 0000000000..e354d28070 --- /dev/null +++ b/wxPython/demo/MultipleChoiceDialog.py @@ -0,0 +1,92 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wx renamer not applied to lib. +# +# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxMultipleChoiceDialog -> MultipleChoiceDialog +# + +import wx +import wx.lib.dialogs + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange', + 'etc', 'etc..', 'etc...' ] + + dlg = wx.lib.dialogs.MultipleChoiceDialog( + frame, + "Pick some from\n this list\nblah blah...", + "m.s.d.", lst) + + if (dlg.ShowModal() == wx.ID_OK): + print "Selection:", dlg.GetValue(), " -> ", dlg.GetValueString() + +#--------------------------------------------------------------------------- + + + +overview = """\ + + + +This is a Python implementation of a dialog that is not yet implemented in wxWindows +proper, so don't let the wxWindows documentation mislead you. + +

MultipleChoiceDialog(self, parent, msg, title, lst, +pos = wx.wxDefaultPosition, size = (200,200), style = wx.wxDEFAULT_DIALOG_STYLE) + + +

+
parent +
The parent window + +
msg +
The message that will be displayed above the list + +
title +
The text that will appear on the title bar + +
lst +
A Python list of choices that will appear in the dialog. + +
pos +
The position of the dialog + +
size +
The size of the dialog + +
style +
The style for the dialog. Only styles normally available to wxDialog are +available. + +
+ +Methods + +
+
GetValue +
Returns a tuple containing the indices of the selected items + +
GetValueString +
Returns a tuple containing the text of the selected items + +
+ +Additionally, MultipleChoiceDialog.lbox is a standard wx.ListBox which supports all +methods applicable to that class. + + + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/Notebook.py b/wxPython/demo/Notebook.py new file mode 100644 index 0000000000..c9740ce678 --- /dev/null +++ b/wxPython/demo/Notebook.py @@ -0,0 +1,139 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import sys + +import wx + +import ColorPanel +import GridSimple +import ListCtrl +import ScrolledWindow +import images + +#---------------------------------------------------------------------------- + +class TestNB(wx.Notebook): + def __init__(self, parent, id, log): + wx.Notebook.__init__(self, parent, id, style= + #wxNB_TOP + wx.NB_BOTTOM + #wxNB_LEFT + #wxNB_RIGHT + ) + self.log = log + + win = self.makeColorPanel(wx.BLUE) + self.AddPage(win, "Blue") + st = wx.StaticText(win.win, -1, + "You can put nearly any type of window here,\n" + "and if the platform supports it then the\n" + "tabs can be on any side of the notebook.", + (10, 10)) + + st.SetForegroundColour(wx.WHITE) + st.SetBackgroundColour(wx.BLUE) + + # Show how to put an image on one of the notebook tabs, + # first make the image list: + il = wx.ImageList(16, 16) + idx1 = il.Add(images.getSmilesBitmap()) + self.AssignImageList(il) + + # now put an image on the first tab we just created: + self.SetPageImage(0, idx1) + + + win = self.makeColorPanel(wx.RED) + self.AddPage(win, "Red") + + win = ScrolledWindow.MyCanvas(self) + self.AddPage(win, 'ScrolledWindow') + + win = self.makeColorPanel(wx.GREEN) + self.AddPage(win, "Green") + + win = GridSimple.SimpleGrid(self, log) + self.AddPage(win, "Grid") + + win = ListCtrl.TestListCtrlPanel(self, log) + self.AddPage(win, 'List') + + win = self.makeColorPanel(wx.CYAN) + self.AddPage(win, "Cyan") + +# win = self.makeColorPanel(wxWHITE) +# self.AddPage(win, "White") + +# win = self.makeColorPanel(wxBLACK) +# self.AddPage(win, "Black") + + win = self.makeColorPanel(wx.NamedColour('MIDNIGHT BLUE')) + self.AddPage(win, "MIDNIGHT BLUE") + + win = self.makeColorPanel(wx.NamedColour('INDIAN RED')) + self.AddPage(win, "INDIAN RED") + + self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged) + self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging) + + + def makeColorPanel(self, color): + p = wx.Panel(self, -1) + win = ColorPanel.ColoredPanel(p, color) + p.win = win + + def OnCPSize(evt, win=win): + win.SetSize(evt.GetSize()) + + p.Bind(wx.EVT_SIZE, OnCPSize) + return p + + def OnPageChanged(self, event): + old = event.GetOldSelection() + new = event.GetSelection() + sel = self.GetSelection() + self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) + event.Skip() + + def OnPageChanging(self, event): + old = event.GetOldSelection() + new = event.GetSelection() + sel = self.GetSelection() + self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) + event.Skip() + +#---------------------------------------------------------------------------- + +def runTest(frame, nb, log): + testWin = TestNB(nb, -1, log) + return testWin + +#---------------------------------------------------------------------------- + + +overview = """\ + +

wxNotebook

+

+This class represents a notebook control, which manages multiple +windows with associated tabs. +

+To use the class, create a wxNotebook object and call AddPage or +InsertPage, passing a window to be used as the page. Do not explicitly +delete the window for a page that is currently managed by wxNotebook. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + + + + diff --git a/wxPython/demo/OGL.py b/wxPython/demo/OGL.py new file mode 100644 index 0000000000..eb7cea9c83 --- /dev/null +++ b/wxPython/demo/OGL.py @@ -0,0 +1,330 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o OGL's busted bigtime. Can't even use OGLInitialize() without a +# program error on w2k. +# + +import wx +import wx.ogl as ogl + +import images + +##wx.Trap() + +#---------------------------------------------------------------------- +# This creates some pens and brushes that the OGL library uses. + +ogl.OGLInitialize() + +#---------------------------------------------------------------------- + +class DiamondShape(ogl.PolygonShape): + def __init__(self, w=0.0, h=0.0): + ogl.PolygonShape.__init__(self) + if w == 0.0: + w = 60.0 + if h == 0.0: + h = 60.0 + + # Either ogl.RealPoints or 2-tuples of floats works. + + #points = [ ogl.RealPoint(0.0, -h/2.0), + # ogl.RealPoint(w/2.0, 0.0), + # ogl.RealPoint(0.0, h/2.0), + # ogl.RealPoint(-w/2.0, 0.0), + # ] + points = [ (0.0, -h/2.0), + (w/2.0, 0.0), + (0.0, h/2.0), + (-w/2.0, 0.0), + ] + + self.Create(points) + + +#---------------------------------------------------------------------- + +class RoundedRectangleShape(ogl.RectangleShape): + def __init__(self, w=0.0, h=0.0): + ogl.RectangleShape.__init__(self, w, h) + self.SetCornerRadius(-0.3) + + +#---------------------------------------------------------------------- + +class DividedShape(ogl.DividedShape): + def __init__(self, width, height, canvas): + ogl.DividedShape.__init__(self, width, height) + + region1 = ogl.ShapeRegion() + region1.SetText('DividedShape') + region1.SetProportions(0.0, 0.2) + region1.SetFormatMode(ogl.FORMAT_CENTRE_HORIZ) + self.AddRegion(region1) + + region2 = ogl.ShapeRegion() + region2.SetText('This is Region number two.') + region2.SetProportions(0.0, 0.3) + region2.SetFormatMode(ogl.FORMAT_CENTRE_HORIZ|ogl.FORMAT_CENTRE_VERT) + self.AddRegion(region2) + + region3 = ogl.ShapeRegion() + region3.SetText('Region 3\nwith embedded\nline breaks') + region3.SetProportions(0.0, 0.5) + region3.SetFormatMode(ogl.FORMAT_NONE) + self.AddRegion(region3) + + self.SetRegionSizes() + self.ReformatRegions(canvas) + + + def ReformatRegions(self, canvas=None): + rnum = 0 + + if canvas is None: + canvas = self.GetCanvas() + + dc = wx.ClientDC(canvas) # used for measuring + + for region in self.GetRegions(): + text = region.GetText() + self.FormatText(dc, text, rnum) + rnum += 1 + + + def OnSizingEndDragLeft(self, pt, x, y, keys, attch): + print "***", self + self.base_OnSizingEndDragLeft(pt, x, y, keys, attch) + self.SetRegionSizes() + self.ReformatRegions() + self.GetCanvas().Refresh() + + +#---------------------------------------------------------------------- + +class MyEvtHandler(ogl.ShapeEvtHandler): + def __init__(self, log, frame): + ogl.ShapeEvtHandler.__init__(self) + self.log = log + self.statbarFrame = frame + + def UpdateStatusBar(self, shape): + x,y = shape.GetX(), shape.GetY() + width, height = shape.GetBoundingBoxMax() + self.statbarFrame.SetStatusText("Pos: (%d,%d) Size: (%d, %d)" % + (x, y, width, height)) + + + def OnLeftClick(self, x, y, keys = 0, attachment = 0): + shape = self.GetShape() + print shape.__class__, shape.GetClassName() + canvas = shape.GetCanvas() + dc = wx.ClientDC(canvas) + canvas.PrepareDC(dc) + + if shape.Selected(): + shape.Select(False, dc) + canvas.Redraw(dc) + else: + redraw = False + shapeList = canvas.GetDiagram().GetShapeList() + toUnselect = [] + + for s in shapeList: + if s.Selected(): + # If we unselect it now then some of the objects in + # shapeList will become invalid (the control points are + # shapes too!) and bad things will happen... + toUnselect.append(s) + + shape.Select(True, dc) + + if toUnselect: + for s in toUnselect: + s.Select(False, dc) + + canvas.Redraw(dc) + + self.UpdateStatusBar(shape) + + + def OnEndDragLeft(self, x, y, keys = 0, attachment = 0): + shape = self.GetShape() + self.base_OnEndDragLeft(x, y, keys, attachment) + + if not shape.Selected(): + self.OnLeftClick(x, y, keys, attachment) + + self.UpdateStatusBar(shape) + + + def OnSizingEndDragLeft(self, pt, x, y, keys, attch): + self.base_OnSizingEndDragLeft(pt, x, y, keys, attch) + self.UpdateStatusBar(self.GetShape()) + + + def OnMovePost(self, dc, x, y, oldX, oldY, display): + self.base_OnMovePost(dc, x, y, oldX, oldY, display) + self.UpdateStatusBar(self.GetShape()) + + + def OnRightClick(self, *dontcare): + self.log.WriteText("%s\n" % self.GetShape()) + + +#---------------------------------------------------------------------- + +class TestWindow(ogl.ShapeCanvas): + def __init__(self, parent, log, frame): + ogl.ShapeCanvas.__init__(self, parent) + + maxWidth = 1000 + maxHeight = 1000 + self.SetScrollbars(20, 20, maxWidth/20, maxHeight/20) + + self.log = log + self.frame = frame + self.SetBackgroundColour("LIGHT BLUE") #wx.WHITE) + self.diagram = ogl.Diagram() + self.SetDiagram(self.diagram) + self.diagram.SetCanvas(self) + self.shapes = [] + self.save_gdi = [] + + rRectBrush = wx.Brush("MEDIUM TURQUOISE", wx.SOLID) + dsBrush = wx.Brush("WHEAT", wx.SOLID) + + self.MyAddShape( + ogl.CircleShape(80), + 100, 100, wx.Pen(wx.BLUE, 3), wx.GREEN_BRUSH, "Circle" + ) + + self.MyAddShape( + ogl.RectangleShape(85, 50), + 305, 60, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "Rectangle" + ) + + ds = self.MyAddShape( + DividedShape(140, 150, self), + 495, 145, wx.BLACK_PEN, dsBrush, '' + ) + + self.MyAddShape( + DiamondShape(90, 90), + 345, 235, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon" + ) + + self.MyAddShape( + RoundedRectangleShape(95,70), + 140, 255, wx.Pen(wx.RED, 2), rRectBrush, "Rounded Rect" + ) + + bmp = images.getTest2Bitmap() + mask = wx.MaskColour(bmp, wx.BLUE) + bmp.SetMask(mask) + + s = ogl.BitmapShape() + s.SetBitmap(bmp) + self.MyAddShape(s, 225, 150, None, None, "Bitmap") + + dc = wx.ClientDC(self) + self.PrepareDC(dc) + + for x in range(len(self.shapes)): + fromShape = self.shapes[x] + if x+1 == len(self.shapes): + toShape = self.shapes[0] + else: + toShape = self.shapes[x+1] + + line = ogl.LineShape() + line.SetCanvas(self) + line.SetPen(wx.BLACK_PEN) + line.SetBrush(wx.BLACK_BRUSH) + line.AddArrow(ogl.ARROW_ARROW) + line.MakeLineControlPoints(2) + fromShape.AddLine(line, toShape) + self.diagram.AddShape(line) + line.Show(True) + + # for some reason, the shapes have to be moved for the line to show up... + fromShape.Move(dc, fromShape.GetX(), fromShape.GetY()) + + wx.EVT_WINDOW_DESTROY(self, self.OnDestroy) + + + def MyAddShape(self, shape, x, y, pen, brush, text): + shape.SetDraggable(True, True) + shape.SetCanvas(self) + shape.SetX(x) + shape.SetY(y) + if pen: shape.SetPen(pen) + if brush: shape.SetBrush(brush) + if text: shape.AddText(text) + #shape.SetShadowMode(ogl.SHADOW_RIGHT) + self.diagram.AddShape(shape) + shape.Show(True) + + evthandler = MyEvtHandler(self.log, self.frame) + evthandler.SetShape(shape) + evthandler.SetPreviousHandler(shape.GetEventHandler()) + shape.SetEventHandler(evthandler) + + self.shapes.append(shape) + return shape + + + def OnDestroy(self, evt): + # Do some cleanup + for shape in self.diagram.GetShapeList(): + if shape.GetParent() == None: + shape.SetCanvas(None) + shape.Destroy() + + self.diagram.Destroy() + + + def OnBeginDragLeft(self, x, y, keys): + self.log.write("OnBeginDragLeft: %s, %s, %s\n" % (x, y, keys)) + + def OnEndDragLeft(self, x, y, keys): + self.log.write("OnEndDragLeft: %s, %s, %s\n" % (x, y, keys)) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + # This creates some pens and brushes that the OGL library uses. + # It should be called after the app object has been created, but + # before OGL is used. + ogl.OGLInitialize() + + win = TestWindow(nb, log, frame) + return win + +#---------------------------------------------------------------------- + +class __Cleanup: + cleanup = ogl.OGLCleanUp + def __del__(self): + self.cleanup() + +# when this module gets cleaned up then wxOGLCleanUp() will get called +__cu = __Cleanup() + + +overview = """\ +The Object Graphics Library is a library supporting the creation and +manipulation of simple and complex graphic images on a canvas. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/PageSetupDialog.py b/wxPython/demo/PageSetupDialog.py new file mode 100644 index 0000000000..a4e7e4e215 --- /dev/null +++ b/wxPython/demo/PageSetupDialog.py @@ -0,0 +1,55 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + data = wx.PageSetupDialogData() + data.SetMarginTopLeft( (15, 15) ) + data.SetMarginBottomRight( (15, 15) ) + #data.SetDefaultMinMargins(True) + data.SetPaperId(wx.PAPER_LETTER) + + dlg = wx.PageSetupDialog(frame, data) + + if dlg.ShowModal() == wx.ID_OK: + data = dlg.GetPageSetupData() + tl = data.GetMarginTopLeft() + br = data.GetMarginBottomRight() + log.WriteText('Margins are: %s %s\n' % (str(tl), str(br))) + + dlg.Destroy() + +#--------------------------------------------------------------------------- + + +overview = """\ +This class represents the page setup common dialog. The page setup dialog is standard +from Windows 95 on, replacing the print setup dialog (which is retained in Windows +and wxWindows for backward compatibility). On Windows 95 and NT 4.0 and above, +the page setup dialog is native to the windowing system, otherwise it is emulated. + +The page setup dialog contains controls for paper size (A4, A5 etc.), orientation +(landscape or portrait), and controls for setting left, top, right and bottom margin +sizes in millimetres. + +When the dialog has been closed, you need to query the wxPageSetupDialogData object +associated with the dialog. + +Note that the OK and Cancel buttons do not destroy the dialog; this must be done by +the application. As with other dialogs, do not destroy the dialog until you are done +with the data, and, conversely, do not use the wxPageSetupDialogData after the +dialog is destroyed. + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/PlotCanvas.py b/wxPython/demo/PlotCanvas.py new file mode 100644 index 0000000000..4311942af3 --- /dev/null +++ b/wxPython/demo/PlotCanvas.py @@ -0,0 +1,56 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxPlotCanvas must be updated with new draw mechanics (tuples) before +# it can be used with 2.5. +# + +import wx +import wx.lib.wxPlotCanvas as plot + +import Numeric + +#--------------------------------------------------------------------------- + +def _InitObjects(): + # 100 points sin function, plotted as green circles + data1 = 2.*Numeric.pi*Numeric.arange(200)/200. + data1.shape = (100, 2) + data1[:,1] = Numeric.sin(data1[:,0]) + markers1 = plot.PolyMarker(data1, color='green', marker='circle',size=1) + + # 50 points cos function, plotted as red line + data1 = 2.*Numeric.pi*Numeric.arange(100)/100. + data1.shape = (50,2) + data1[:,1] = Numeric.cos(data1[:,0]) + lines = plot.PolyLine(data1, color='red') + + # A few more points... + pi = Numeric.pi + markers2 = plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), + (3.*pi/4., -1)], color='blue', + fillcolor='green', marker='cross') + + return plot.PlotGraphics([markers1, lines, markers2]) + + +#--------------------------------------------------------------------------- + + +def runTest(frame, nb, log): + win = plot.PlotCanvas(nb) + win.draw(_InitObjects(),'automatic','automatic'); + return win + +overview = plot.__doc__ + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/PopupControl.py b/wxPython/demo/PopupControl.py new file mode 100644 index 0000000000..d312a9319c --- /dev/null +++ b/wxPython/demo/PopupControl.py @@ -0,0 +1,107 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Is it just me or are the graphics for the control not lining up right? +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxPopupControl -> PopupControl +# + +import wx +import wx.lib.popupctl as pop +import wx.calendar as cal + +class TestDateControl(pop.PopupControl): + def __init__(self,*_args,**_kwargs): + apply(pop.PopupControl.__init__,(self,) + _args,_kwargs) + + self.win = wx.Window(self,-1,pos = (0,0),style = 0) + self.cal = cal.CalendarCtrl(self.win,-1,pos = (0,0)) + + bz = self.cal.GetBestSize() + self.win.SetSize(bz) + + # This method is needed to set the contents that will be displayed + # in the popup + self.SetPopupContent(self.win) + + # Event registration for date selection + self.cal.Bind(cal.EVT_CALENDAR_DAY, self.OnCalSelected) + + # Method called when a day is selected in the calendar + def OnCalSelected(self,evt): + self.PopDown() + date = self.cal.GetDate() + + # Format the date that was selected for the text part of the control + self.SetValue('%02d/%02d/%04d' % (date.GetDay(), + date.GetMonth()+1, + date.GetYear())) + evt.Skip() + + # Method overridden from PopupControl + # This method is called just before the popup is displayed + # Use this method to format any controls in the popup + def FormatContent(self): + # I parse the value in the text part to resemble the correct date in + # the calendar control + txtValue = self.GetValue() + dmy = txtValue.split('/') + didSet = False + + if len(dmy) == 3: + date = self.cal.GetDate() + d = int(dmy[0]) + m = int(dmy[1]) - 1 + y = int(dmy[2]) + + if d > 0 and d < 31: + if m >= 0 and m < 12: + if y > 1000: + self.cal.SetDate(wx.DateTimeFromDMY(d,m,y)) + didSet = True + + if not didSet: + self.cal.SetDate(wx.DateTime_Today()) + + +#--------------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + date = TestDateControl(self, -1, pos = (30,30), size = (100,22)) + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + +overview = """ +

PopupControl

+ +PopupControl is a class that can display a value and has a button +that will popup another window similar to how a wxComboBox works. The +popup window can contain whatever is needed to edit the value. This +example uses a wxCalendarCtrl. + +

Currently a wxDialog is used for the popup. Eventually a +wxPopupWindow should be used... + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/PopupWindow.py b/wxPython/demo/PopupWindow.py new file mode 100644 index 0000000000..cc4d71b83f --- /dev/null +++ b/wxPython/demo/PopupWindow.py @@ -0,0 +1,218 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Some issues with the listbox example; I tried correcting +# it but it's still not working the way it should. Commented +# out for now but will be revisited. +# o The math in determining the popup window's position is +# a bit off. +# + +import wx + +havePopupWindow = 1 +try: + wx.PopupWindow +except NameError: + havePopupWindow = 0 + wx.PopupWindow = wx.PopupTransientWindow = wx.Window + +#--------------------------------------------------------------------------- + +class TestPopup(wx.PopupWindow): + """Adds a bit of text and mouse movement to the wxPopupWindow""" + def __init__(self, parent, style): + wx.PopupWindow.__init__(self, parent, style) + self.SetBackgroundColour("CADET BLUE") + + st = wx.StaticText(self, -1, + "This is a special kind of top level\n" + "window that can be used for\n" + "popup menus, combobox popups\n" + "and such.\n\n" + "Try positioning the demo near\n" + "the bottom of the screen and \n" + "hit the button again.\n\n" + "In this demo this window can\n" + "be dragged with the left button\n" + "and closed with the right." + , + pos=(10,10)) + + sz = st.GetBestSize() + self.SetSize( (sz.width+20, sz.height+20) ) + + self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) + self.Bind(wx.EVT_MOTION, self.OnMouseMotion) + self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) + self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) + + st.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) + st.Bind(wx.EVT_MOTION, self.OnMouseMotion) + st.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) + st.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) + + def OnMouseLeftDown(self, evt): + self.ldPos = evt.GetEventObject().ClientToScreen(evt.GetPosition()) + self.wPos = self.ClientToScreen((0,0)) + self.CaptureMouse() + + def OnMouseMotion(self, evt): + if evt.Dragging() and evt.LeftIsDown(): + dPos = evt.GetEventObject().ClientToScreen(evt.GetPosition()) + nPos = (self.wPos.x + (dPos.x - self.ldPos.x), + self.wPos.y + (dPos.y - self.ldPos.y)) + self.Move(nPos) + + def OnMouseLeftUp(self, evt): + self.ReleaseMouse() + + def OnRightUp(self, evt): + self.Show(False) + self.Destroy() + + +class TestTransientPopup(wx.PopupTransientWindow): + """Adds a bit of text and mouse movement to the wxPopupWindow""" + def __init__(self, parent, style, log): + wx.PopupTransientWindow.__init__(self, parent, style) + self.log = log + panel = wx.Panel(self, -1) + panel.SetBackgroundColour("#FFB6C1") + st = wx.StaticText(panel, -1, + "wxPopupTransientWindow is a\n" + "wxPopupWindow which disappears\n" + "automatically when the user\n" + "clicks the mouse outside it or if it\n" + "(or its first child) loses focus in \n" + "any other way." + , + pos=(10,10)) + sz = st.GetBestSize() + panel.SetSize( (sz.width+20, sz.height+20) ) + self.SetSize(panel.GetSize()) + + def ProcessLeftDown(self, evt): + self.log.write("ProcessLeftDown\n") + return False + + def OnDismiss(self): + self.log.write("OnDismiss\n") + + + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + b = wx.Button(self, -1, "Show wxPopupWindow", (25, 50)) + self.Bind(wx.EVT_BUTTON, self.OnShowPopup, b) + + b = wx.Button(self, -1, "Show wxPopupTransientWindow", (25, 95)) + self.Bind(wx.EVT_BUTTON, self.OnShowPopupTransient, b) + + # This isn't working so well, not sure why. Commented out for + # now. + +# b = wx.Button(self, -1, "Show wxPopupWindow with listbox", (25, 140)) +# self.Bind(wx.EVT_BUTTON, self.OnShowPopupListbox, b) + + + def OnShowPopup(self, evt): + win = TestPopup(self, wx.SIMPLE_BORDER) + + # Show the popup right below or above the button + # depending on available screen space... + btn = evt.GetEventObject() + pos = btn.ClientToScreen( (0,0) ) + sz = btn.GetSize() + win.Position(pos, (0, sz[1])) + + win.Show(True) + + + def OnShowPopupTransient(self, evt): + win = TestTransientPopup(self, wx.SIMPLE_BORDER, self.log) + + # Show the popup right below or above the button + # depending on available screen space... + btn = evt.GetEventObject() + pos = btn.ClientToScreen( (0,0) ) + sz = btn.GetSize() + win.Position(pos, (0, sz[1])) + + win.Popup() + + + def OnShowPopupListbox(self, evt): + win = TestPopupWithListbox(self, wx.NO_BORDER, self.log) + + # Show the popup right below or above the button + # depending on available screen space... + btn = evt.GetEventObject() + pos = btn.ClientToScreen( (0,0) ) + sz = btn.GetSize() + win.Position(pos, (0, sz[1])) + + win.Show(True) + +class TestPopupWithListbox(wx.PopupWindow): + def __init__(self, parent, style, log): + wx.PopupWindow.__init__(self, parent, style) + + import keyword + + self.lb = wx.ListBox(self, -1, choices = keyword.kwlist) + #sz = self.lb.GetBestSize() + self.SetSize((150, 75)) #sz) + self.lb.SetSize(self.GetClientSize()) + self.lb.SetFocus() + self.Bind(wx.EVT_LISTBOX, self.OnListBox) + self.lb.Bind(wx.EVT_LEFT_DOWN, self.OnLeft) + + def OnLeft(self, evt): + obj = evt.GetEventObject() + print "OnLeft", obj + print 'Selected: %s' % obj.GetStringSelection() + obj.Show(False) + evt.Skip() + + def OnListBox(self, evt): + obj = evt.GetEventObject() + print "OnListBox", obj + print 'Selected: %s' % obj.GetString() + evt.Skip() + + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + if havePopupWindow: + win = TestPanel(nb, log) + return win + else: + dlg = wx.MessageDialog( + frame, 'wxPopupWindow is not available on this platform.', + 'Sorry', wx.OK | wx.ICON_INFORMATION + ) + + dlg.ShowModal() + dlg.Destroy() + +#--------------------------------------------------------------------------- + + +overview = """\ +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/PrintDialog.py b/wxPython/demo/PrintDialog.py new file mode 100644 index 0000000000..981f0ea965 --- /dev/null +++ b/wxPython/demo/PrintDialog.py @@ -0,0 +1,45 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + data = wx.PrintDialogData() + + data.EnableSelection(True) + data.EnablePrintToFile(True) + data.EnablePageNumbers(True) + data.SetMinPage(1) + data.SetMaxPage(5) + data.SetAllPages(True) + + dlg = wx.PrintDialog(frame, data) + + if dlg.ShowModal() == wx.ID_OK: + data = dlg.GetPrintDialogData() + log.WriteText('GetAllPages: %d\n' % data.GetAllPages()) + + dlg.Destroy() + +#--------------------------------------------------------------------------- + + +overview = """\ +This class represents the print and print setup common dialogs. You may obtain +a wxPrinterDC device context from a successfully dismissed print dialog. + +User information is stored in a wxPrintDialogData object that is passed to the +dialog at creation time, and it is filled in by the user. As with other dialogs, +do not use this data once the dialog is dismissed, and do not destroy the dialog +until you have everything you need from it. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/PrintFramework.py b/wxPython/demo/PrintFramework.py index ce6c1ff603..ac9d3a1c57 100644 --- a/wxPython/demo/PrintFramework.py +++ b/wxPython/demo/PrintFramework.py @@ -6,7 +6,7 @@ # import wx -import wxScrolledWindow +import ScrolledWindow #---------------------------------------------------------------------- @@ -108,7 +108,7 @@ class TestPrintPanel(wx.Panel): self.printData.SetPaperId(wx.PAPER_LETTER) self.box = wx.BoxSizer(wx.VERTICAL) - self.canvas = wxScrolledWindow.MyCanvas(self) + self.canvas = ScrolledWindow.MyCanvas(self) self.box.Add(self.canvas, 1, wx.GROW) subbox = wx.BoxSizer(wx.HORIZONTAL) diff --git a/wxPython/demo/Process.py b/wxPython/demo/Process.py new file mode 100644 index 0000000000..42c46c2cd6 --- /dev/null +++ b/wxPython/demo/Process.py @@ -0,0 +1,165 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, ID, log): + wx.Panel.__init__(self, parent, ID) + self.log = log + + self.process = None + self.Bind(wx.EVT_IDLE, self.OnIdle) + + # We can either derive from wxProcess and override OnTerminate + # or we can let wxProcess send this window an event that is + # caught in the normal way... + self.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded) + + + # Make the controls + prompt = wx.StaticText(self, -1, 'Command line:') + self.cmd = wx.TextCtrl(self, -1, 'python -u data/echo.py') + self.exBtn = wx.Button(self, -1, 'Execute') + + self.out = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE|wx.TE_READONLY) + + self.inp = wx.TextCtrl(self, -1, '', style=wx.TE_PROCESS_ENTER) + self.sndBtn = wx.Button(self, -1, 'Send') + self.termBtn = wx.Button(self, -1, 'Close Stream') + self.inp.Enable(False) + self.sndBtn.Enable(False) + self.termBtn.Enable(False) + + # Hook up the events + self.Bind(wx.EVT_BUTTON, self.OnExecuteBtn, self.exBtn) + self.Bind(wx.EVT_BUTTON, self.OnSendText, self.sndBtn) + self.Bind(wx.EVT_BUTTON, self.OnCloseStream, self.termBtn) + self.Bind(wx.EVT_TEXT_ENTER, self.OnSendText, self.inp) + + + # Do the layout + box1 = wx.BoxSizer(wx.HORIZONTAL) + box1.Add(prompt, 0, wx.ALIGN_CENTER) + box1.Add(self.cmd, 1, wx.ALIGN_CENTER|wx.LEFT|wx.RIGHT, 5) + box1.Add(self.exBtn, 0) + + box2 = wx.BoxSizer(wx.HORIZONTAL) + box2.Add(self.inp, 1, wx.ALIGN_CENTER) + box2.Add(self.sndBtn, 0, wx.LEFT, 5) + box2.Add(self.termBtn, 0, wx.LEFT, 5) + + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(box1, 0, wx.EXPAND|wx.ALL, 10) + sizer.Add(self.out, 1, wx.EXPAND|wx.ALL, 10) + sizer.Add(box2, 0, wx.EXPAND|wx.ALL, 10) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + + + def __del__(self): + if self.process is not None: + self.process.Detach() + self.process.CloseOutput() + self.process = None + + + def OnExecuteBtn(self, evt): + cmd = self.cmd.GetValue() + + self.process = wx.Process(self) + self.process.Redirect(); + pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) + self.log.write('OnExecuteBtn: "%s" pid: %s\n' % (cmd, pid)) + + self.inp.Enable(True) + self.sndBtn.Enable(True) + self.termBtn.Enable(True) + self.cmd.Enable(False) + self.exBtn.Enable(False) + self.inp.SetFocus() + + + def OnSendText(self, evt): + text = self.inp.GetValue() + self.inp.SetValue('') + self.log.write('OnSendText: "%s"\n' % text) + self.process.GetOutputStream().write(text + '\n') + self.inp.SetFocus() + + + def OnCloseStream(self, evt): + self.log.write('OnCloseStream\n') + #print "b4 CloseOutput" + self.process.CloseOutput() + #print "after CloseOutput" + + def OnIdle(self, evt): + if self.process is not None: + stream = self.process.GetInputStream() + + if stream.CanRead(): + text = stream.read() + self.out.AppendText(text) + + + def OnProcessEnded(self, evt): + self.log.write('OnProcessEnded, pid:%s, exitCode: %s\n' % + (evt.GetPid(), evt.GetExitCode())) + + stream = self.process.GetInputStream() + + if stream.CanRead(): + text = stream.read() + self.out.AppendText(text) + + self.process.Destroy() + self.process = None + self.inp.Enable(False) + self.sndBtn.Enable(False) + self.termBtn.Enable(False) + self.cmd.Enable(True) + self.exBtn.Enable(True) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, -1, log) + return win + + +#---------------------------------------------------------------------- + + +overview = """\ + +

wxProcess

+ +wxProcess lets you get notified when an asyncronous child process +started by wxExecute terminates, and also to get input/output streams +for the child process's stdout, stderr and stdin. + +

+This demo launches a simple python script that echos back on stdout +lines that it reads from stdin. You can send text to the echo +process' stdin by typing in the lower textctrl and clicking Send. + +

+Clicking the Close Stream button will close the demo's end of the +stdin pipe to the child process. In our case that will cause the +child process to exit its main loop. + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/ProgressDialog.py b/wxPython/demo/ProgressDialog.py new file mode 100644 index 0000000000..9144175976 --- /dev/null +++ b/wxPython/demo/ProgressDialog.py @@ -0,0 +1,61 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wx.ProgressDialog appears to be broken. No abort button +# and it's not possible to dismiss it otherwise. +# + +import wx + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + max = 20 + + dlg = wx.ProgressDialog("Progress dialog example", + "An informative message", + maximum = max, + parent=frame, + style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL) + + keepGoing = True + count = 0 + + while keepGoing and count < max: + count = count + 1 + #print count + wx.Sleep(1) + + if count == max / 2: + keepGoing = dlg.Update(count, "Half-time!") + else: + keepGoing = dlg.Update(count) + + dlg.Destroy() + + +#--------------------------------------------------------------------------- + + +overview = """\ +This class represents a dialog that shows a short message and a progress bar. +Optionally, it can display an ABORT button + +This dialog indicates the progress of some event that takes a while to accomplish, +usually, such as file copy progress, download progress, and so on. The display +is completely under control of the program; you must update the dialog from +within the program creating it. + +When the dialog closes, you must check to see if the user aborted the process or +not, and act accordingly -- that is, if the PD_CAN_ABORT style flag is set. +If not then you may progress blissfully onward. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/PyColourChooser.py b/wxPython/demo/PyColourChooser.py new file mode 100644 index 0000000000..b31fe51326 --- /dev/null +++ b/wxPython/demo/PyColourChooser.py @@ -0,0 +1,72 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated URL for SF link in overview. +# +# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxPyColorChooser -> PyColorChooser +# o wxPyColourChooser -> PyColourChooser +# + +import wx +import wx.lib.colourchooser as cc + +#--------------------------------------------------------------- + +class TestColourChooser(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + chooser = cc.PyColourChooser(self, -1) + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(chooser, 0, wx.ALL, 25) + + self.SetAutoLayout(True) + self.SetSizer(sizer) + +#--------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestColourChooser(nb, log) + return win + +#--------------------------------------------------------------- + +overview = """ +The PyColourChooser component creates a colour chooser window +that is similar to the Microsoft Windows colour chooser dialog. +This dialog component is drawn in a panel, and thus can be +embedded inside any widget (although it cannot be resized). +This colour chooser may also be substituted for the colour +chooser on any platform that might have an ugly one :) + +How to use it +------------------------------ + +The demo (demo/PyColourChooser.py code shows how to display +a colour chooser and retrieve its options. + +Contact and Author Info +------------------------------ + +PyColourChooser was written and is maintained by: + + Michael Gilfix + +You can find the latest PyColourChooser code at +http://sourceforge.net/projects/wxcolourchooser/. If you have +any suggestions or want to submit a patch, please send +it my way at: mgilfix@eecs.tufts.edu +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/RadioBox.py b/wxPython/demo/RadioBox.py new file mode 100644 index 0000000000..cd583a3378 --- /dev/null +++ b/wxPython/demo/RadioBox.py @@ -0,0 +1,73 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class TestRadioBox(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + #self.SetBackgroundColour(wx.BLUE) + + sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', + 'six', 'seven', 'eight'] + + sizer = wx.BoxSizer(wx.VERTICAL) + + rb = wx.RadioBox( + self, -1, "wx.RadioBox", wx.DefaultPosition, wx.DefaultSize, + sampleList, 2, wx.RA_SPECIFY_COLS + ) + + self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, rb) + #rb.SetBackgroundColour(wx.BLUE) + rb.SetToolTip(wx.ToolTip("This is a ToolTip!")) + #rb.SetLabel("wxRadioBox") + + sizer.Add(rb, 0, wx.ALL, 20) + + rb = wx.RadioBox( + self, -1, "", wx.DefaultPosition, wx.DefaultSize, + sampleList, 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER + ) + + self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, rb) + rb.SetToolTip(wx.ToolTip("This box has no label")) + + sizer.Add(rb, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 20) + + self.SetSizer(sizer) + + + def EvtRadioBox(self, event): + self.log.WriteText('EvtRadioBox: %d\n' % event.GetInt()) + +# Doesn't appear to be used for anything. +# def EvtRadioButton(self, event): +# self.log.write('EvtRadioButton:%d\n' % event.GetId()) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestRadioBox(nb, log) + return win + + + +overview = """\ +A radio box item is used to select one of number of mutually exclusive +choices. It is displayed as a vertical column or horizontal row of +labelled buttons. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/RadioButton.py b/wxPython/demo/RadioButton.py new file mode 100644 index 0000000000..ad4ee8ce7c --- /dev/null +++ b/wxPython/demo/RadioButton.py @@ -0,0 +1,130 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel( wx.Panel ): + def __init__( self, parent, log ): + + wx.Panel.__init__( self, parent, -1 ) + self.log = log + panel = wx.Panel( self, -1 ) + + # 1st group of controls: + self.group1_ctrls = [] + radio1 = wx.RadioButton( panel, -1, " Radio1 ", style = wx.RB_GROUP ) + text1 = wx.TextCtrl( panel, -1, "" ) + radio2 = wx.RadioButton( panel, -1, " Radio2 " ) + text2 = wx.TextCtrl( panel, -1, "" ) + radio3 = wx.RadioButton( panel, -1, " Radio3 " ) + text3 = wx.TextCtrl( panel, -1, "" ) + self.group1_ctrls.append((radio1, text1)) + self.group1_ctrls.append((radio2, text2)) + self.group1_ctrls.append((radio3, text3)) + + # 2nd group of controls: + self.group2_ctrls = [] + radio4 = wx.RadioButton( panel, -1, " Radio1 ", style = wx.RB_GROUP ) + text4 = wx.TextCtrl( panel, -1, "" ) + radio5 = wx.RadioButton( panel, -1, " Radio2 " ) + text5 = wx.TextCtrl( panel, -1, "" ) + radio6 = wx.RadioButton( panel, -1, " Radio3 " ) + text6 = wx.TextCtrl( panel, -1, "" ) + self.group2_ctrls.append((radio4, text4)) + self.group2_ctrls.append((radio5, text5)) + self.group2_ctrls.append((radio6, text6)) + + # Layout controls on panel: + vs = wx.BoxSizer( wx.VERTICAL ) + + box1_title = wx.StaticBox( panel, -1, "Group 1" ) + box1 = wx.StaticBoxSizer( box1_title, wx.VERTICAL ) + grid1 = wx.FlexGridSizer( 0, 2, 0, 0 ) + + for radio, text in self.group1_ctrls: + grid1.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) + grid1.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) + + box1.AddSizer( grid1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) + vs.AddSizer( box1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) + + box2_title = wx.StaticBox( panel, -1, "Group 2" ) + box2 = wx.StaticBoxSizer( box2_title, wx.VERTICAL ) + grid2 = wx.FlexGridSizer( 0, 2, 0, 0 ) + + for radio, text in self.group2_ctrls: + grid2.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) + grid2.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) + + box2.AddSizer( grid2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) + vs.AddSizer( box2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) + + panel.SetSizer( vs ) + vs.Fit( panel ) + panel.Move( (50,50) ) + self.panel = panel + + # Setup event handling and initial state for controls: + for radio, text in self.group1_ctrls: + self.Bind(wx.EVT_RADIOBUTTON, self.OnGroup1Select, radio ) + + for radio, text in self.group2_ctrls: + self.Bind(wx.EVT_RADIOBUTTON, self.OnGroup2Select, radio ) + + for radio, text in self.group1_ctrls + self.group2_ctrls: + radio.SetValue(0) + text.Enable(False) + + def OnGroup1Select( self, event ): + radio_selected = event.GetEventObject() + self.log.write('Group1 %s selected\n' % radio_selected.GetLabel() ) + + for radio, text in self.group1_ctrls: + if radio is radio_selected: + text.Enable(True) + else: + text.Enable(False) + + def OnGroup2Select( self, event ): + radio_selected = event.GetEventObject() + self.log.write('Group2 %s selected\n' % radio_selected.GetLabel() ) + + for radio, text in self.group2_ctrls: + if radio is radio_selected: + text.Enable(True) + else: + text.Enable(False) + +#---------------------------------------------------------------------- + +def runTest( frame, nb, log ): + win = TestPanel( nb, log ) + return win + +#---------------------------------------------------------------------- + + +overview = """\ + +

+This demo shows how individual radio buttons can be used to build +more complicated selection mechanisms... +

+It uses 2 groups of wxRadioButtons, where the groups are defined by +instantiation. When a wxRadioButton is created with the wxRB_GROUP +style, all subsequent wxRadioButtons created without it are implicitly +added to that group by the framework. + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/RightTextCtrl.py b/wxPython/demo/RightTextCtrl.py new file mode 100644 index 0000000000..9d28c46c79 --- /dev/null +++ b/wxPython/demo/RightTextCtrl.py @@ -0,0 +1,79 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o The rightalign library needs converted for this to work correctly. +# +# 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o All issues resolved. +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxRightTextCtrl -> RightTextCtrl +# + +############################################################################\ +# Note: this demo has been converted, but the control is deprecated because | +# wx.TextCtrl now supports the wx.TE_RIGHT style flag, which makes this | +# control completely superfluous. | +############################################################################/ + +import wx +import wx.lib.rightalign as right + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent, -1) + + fgs = wx.FlexGridSizer(cols=2, vgap=5, hgap=5) + + txt = wx.StaticText( + self, -1, + "These text controls will align their contents to\n" + "the right (on wxMSW) when they don't have focus.", + style=wx.ALIGN_RIGHT + ) + + fgs.Add(txt) + fgs.Add(right.RightTextCtrl(self, -1, "", size=(75, -1))) + + fgs.Add((10,10)) + fgs.Add(right.RightTextCtrl(self, -1, "123.45", size=(75, -1))) + + fgs.Add((10,10)) + fgs.Add(right.RightTextCtrl(self, -1, "234.56", size=(75, -1))) + + fgs.Add((10,10)) + fgs.Add(right.RightTextCtrl(self, -1, "345.67", size=(75, -1))) + + fgs.Add((10,10)) + fgs.Add(right.RightTextCtrl(self, -1, "456.78", size=(75, -1))) + + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(fgs, 0, wx.ALL, 25) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb) + return win + +#---------------------------------------------------------------------- + +overview = right.__doc__ + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/SashWindow.py b/wxPython/demo/SashWindow.py new file mode 100644 index 0000000000..b70a3ee7a1 --- /dev/null +++ b/wxPython/demo/SashWindow.py @@ -0,0 +1,151 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o Should be renamed to wxSashLayoutWindow.py +# + +import wx + +#--------------------------------------------------------------------------- + +class TestSashWindow(wx.Panel): + ID_WINDOW_TOP = 5100 + ID_WINDOW_LEFT1 = 5101 + ID_WINDOW_LEFT2 = 5102 + ID_WINDOW_BOTTOM = 5103 + + + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + + self.log = log + + # will occupy the space not used by the Layout Algorithm + self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER) + + self.Bind( + wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag, + id=self.ID_WINDOW_TOP, id2=self.ID_WINDOW_BOTTOM, + ) + + self.Bind(wx.EVT_SIZE, self.OnSize) + + + # Create some layout windows + # A window like a toolbar + win = wx.SashLayoutWindow( + self, self.ID_WINDOW_TOP, wx.DefaultPosition, (200, 30), + wx.NO_BORDER|wx.SW_3D + ) + + win.SetDefaultSize((1000, 30)) + win.SetOrientation(wx.LAYOUT_HORIZONTAL) + win.SetAlignment(wx.LAYOUT_TOP) + win.SetBackgroundColour(wx.Colour(255, 0, 0)) + win.SetSashVisible(wx.SASH_BOTTOM, True) + + self.topWindow = win + + + # A window like a statusbar + win = wx.SashLayoutWindow( + self, self.ID_WINDOW_BOTTOM, wx.DefaultPosition, (200, 30), + wx.NO_BORDER|wx.SW_3D + ) + + win.SetDefaultSize((1000, 30)) + win.SetOrientation(wx.LAYOUT_HORIZONTAL) + win.SetAlignment(wx.LAYOUT_BOTTOM) + win.SetBackgroundColour(wx.Colour(0, 0, 255)) + win.SetSashVisible(wx.SASH_TOP, True) + + self.bottomWindow = win + + # A window to the left of the client window + win = wx.SashLayoutWindow( + self, self.ID_WINDOW_LEFT1, wx.DefaultPosition, (200, 30), + wx.NO_BORDER|wx.SW_3D + ) + + win.SetDefaultSize((120, 1000)) + win.SetOrientation(wx.LAYOUT_VERTICAL) + win.SetAlignment(wx.LAYOUT_LEFT) + win.SetBackgroundColour(wx.Colour(0, 255, 0)) + win.SetSashVisible(wx.SASH_RIGHT, True) + win.SetExtraBorderSize(10) + textWindow = wx.TextCtrl( + win, -1, "", wx.DefaultPosition, wx.DefaultSize, + wx.TE_MULTILINE|wx.SUNKEN_BORDER + ) + + textWindow.SetValue("A sub window") + + self.leftWindow1 = win + + + # Another window to the left of the client window + win = wx.SashLayoutWindow( + self, self.ID_WINDOW_LEFT2, wx.DefaultPosition, (200, 30), + wx.NO_BORDER|wx.SW_3D + ) + + win.SetDefaultSize((120, 1000)) + win.SetOrientation(wx.LAYOUT_VERTICAL) + win.SetAlignment(wx.LAYOUT_LEFT) + win.SetBackgroundColour(wx.Colour(0, 255, 255)) + win.SetSashVisible(wx.SASH_RIGHT, True) + + self.leftWindow2 = win + + + def OnSashDrag(self, event): + if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: + return + + eID = event.GetId() + + if eID == self.ID_WINDOW_TOP: + self.topWindow.SetDefaultSize((1000, event.GetDragRect().height)) + + elif eID == self.ID_WINDOW_LEFT1: + self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000)) + + + elif eID == self.ID_WINDOW_LEFT2: + self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000)) + + elif eID == self.ID_WINDOW_BOTTOM: + self.bottomWindow.SetDefaultSize((1000, event.GetDragRect().height)) + + wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) + self.remainingSpace.Refresh() + + def OnSize(self, event): + wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestSashWindow(nb, log) + return win + +#--------------------------------------------------------------------------- + + +overview = """\ +wxSashLayoutWindow responds to OnCalculateLayout events generated by +wxLayoutAlgorithm. It allows the application to use simple accessors to +specify how the window should be laid out, rather than having to respond +to events. The fact that the class derives from wxSashWindow allows sashes +to be used if required, to allow the windows to be user-resizable. + +The documentation for wxLayoutAlgorithm explains the purpose of this class +in more detail. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/ScrolledMessageDialog.py b/wxPython/demo/ScrolledMessageDialog.py new file mode 100644 index 0000000000..03158917af --- /dev/null +++ b/wxPython/demo/ScrolledMessageDialog.py @@ -0,0 +1,51 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o dialogs library needs updated to wx +# +# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o dialogs library converted. All is well. +# +# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxScrolledMessageDialog -> ScrolledMessageDialog +# + +import wx +import wx.lib.dialogs + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + f = open("Main.py", "r") + msg = f.read() + f.close() + + dlg = wx.lib.dialogs.ScrolledMessageDialog(frame, msg, "message test") + dlg.ShowModal() + +#--------------------------------------------------------------------------- + + + +overview = """\ + +ScrolledMessageDialog(parent, msg, caption, pos=wx.DefaultPosition, size=(500,300)) + +This class represents a message dialog that uses a wxTextCtrl to display the +message. This allows more flexible information display without having to be +as much concerned with layout requirements. A text file can simply be used + +This dialog offers no special attributes or methods beyond those supported +by wxDialog. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/ScrolledPanel.py b/wxPython/demo/ScrolledPanel.py new file mode 100644 index 0000000000..947051cf1a --- /dev/null +++ b/wxPython/demo/ScrolledPanel.py @@ -0,0 +1,131 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o scrolledpanel lib needs wx update +# +# 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o lib updated, all is well. +# +# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxScrolledPanel -> ScrolledPanel +# + +import wx +import wx.lib.scrolledpanel as scrolled + +#---------------------------------------------------------------------- + +text = "one two buckle my shoe three four shut the door five six pick up sticks seven eight lay them straight nine ten big fat hen" + + +class TestPanel(scrolled.ScrolledPanel): + def __init__(self, parent, log): + self.log = log + scrolled.ScrolledPanel.__init__(self, parent, -1) + + vbox = wx.BoxSizer(wx.VERTICAL) + desc = wx.StaticText(self, -1, + "ScrolledPanel extends wx.ScrolledWindow, adding all " + "the necessary bits to set up scroll handling for you.\n\n" + "Here are three fixed size examples of its use. The " + "demo panel for this sample is also using it -- the \nwxStaticLine" + "below is intentionally made too long so a scrollbar will be " + "activated." + ) + desc.SetForegroundColour("Blue") + vbox.Add(desc, 0, wx.ALIGN_LEFT|wx.ALL, 5) + vbox.Add(wx.StaticLine(self, -1, size=(1024,-1)), 0, wx.ALL, 5) + vbox.Add((20,20)) + + words = text.split() + + panel1 = scrolled.ScrolledPanel(self, -1, size=(120,300), + style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER ) + fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4) + + for word in words: + label = wx.StaticText(panel1, -1, word+":") + tc = wx.TextCtrl(panel1, -1, word, size=(50,-1)) + fgs1.Add(label, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) + fgs1.Add(tc, flag=wx.EXPAND|wx.RIGHT, border=25) + + panel1.SetSizer( fgs1 ) + panel1.SetAutoLayout(1) + panel1.SetupScrolling( scroll_x=False ) + + panel2 = scrolled.ScrolledPanel(self, -1, size=(350, 40), + style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) + panel3 = scrolled.ScrolledPanel(self, -1, size=(200,100), + style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) + + fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4) + fgs3 = wx.FlexGridSizer(cols=5, vgap=4, hgap=4) + + for i in range(len(words)): + word = words[i] + if i % 5 != 4: + label2 = wx.StaticText(panel2, -1, word) + fgs2.Add(label2, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) + label3 = wx.StaticText(panel3, -1, word) + fgs3.Add(label3, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) + else: + tc2 = wx.TextCtrl(panel2, -1, word, size=(50,-1)) + fgs2.Add(tc2, flag=wx.LEFT, border=5) + tc3 = wx.TextCtrl(panel3, -1, word ) + fgs3.Add(tc3, flag=wx.LEFT, border=5) + + panel2.SetSizer( fgs2 ) + panel2.SetAutoLayout(1) + panel2.SetupScrolling(scroll_y = False) + + panel3.SetSizer( fgs3 ) + panel3.SetAutoLayout(1) + panel3.SetupScrolling() + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add((20,20)) + hbox.Add(panel1, 0) + hbox.Add((40, 10)) + + vbox2 = wx.BoxSizer(wx.VERTICAL) + vbox2.Add(panel2, 0) + vbox2.Add((20, 50)) + + vbox2.Add(panel3, 0) + vbox2.Add((20, 10)) + hbox.Add(vbox2) + + vbox.AddSizer(hbox, 0) + self.SetSizer(vbox) + self.SetAutoLayout(1) + self.SetupScrolling() + + +#---------------------------------------------------------------------- + + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +ScrolledPanel fills a "hole" in the implementation of wx.ScrolledWindow, +providing automatic scrollbar and scrolling behavior and the tab traversal +mangement that wx.ScrolledWindow lacks. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/ScrolledWindow.py b/wxPython/demo/ScrolledWindow.py new file mode 100644 index 0000000000..411d73aee7 --- /dev/null +++ b/wxPython/demo/ScrolledWindow.py @@ -0,0 +1,248 @@ +# 11/12/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o Rudimentary overview doc added. +# + +import wx + +import images + +BUFFERED = 1 + +#--------------------------------------------------------------------------- + +class MyCanvas(wx.ScrolledWindow): + def __init__(self, parent, id = -1, size = wx.DefaultSize): + wx.ScrolledWindow.__init__(self, parent, id, (0, 0), size=size, style=wx.SUNKEN_BORDER) + + self.lines = [] + self.maxWidth = 1000 + self.maxHeight = 1000 + self.x = self.y = 0 + self.curLine = [] + self.drawing = False + + self.SetBackgroundColour("WHITE") + self.SetCursor(wx.StockCursor(wx.CURSOR_PENCIL)) + bmp = images.getTest2Bitmap() + mask = wx.MaskColour(bmp, wx.BLUE) + bmp.SetMask(mask) + self.bmp = bmp + + self.SetScrollbars(20, 20, self.maxWidth/20, self.maxHeight/20) + + if BUFFERED: + # Initialize the buffer bitmap. No real DC is needed at this point. + self.buffer = wx.EmptyBitmap(self.maxWidth, self.maxHeight) + dc = wx.BufferedDC(None, self.buffer) + dc.SetBackground(wx.Brush(self.GetBackgroundColour())) + dc.Clear() + self.DoDrawing(dc) + + self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftButtonEvent) + self.Bind(wx.EVT_LEFT_UP, self.OnLeftButtonEvent) + self.Bind(wx.EVT_MOTION, self.OnLeftButtonEvent) + self.Bind(wx.EVT_PAINT, self.OnPaint) + + + def getWidth(self): + return self.maxWidth + + def getHeight(self): + return self.maxHeight + + + def OnPaint(self, event): + if BUFFERED: + # Create a buffered paint DC. It will create the real + # wx.PaintDC and then blit the bitmap to it when dc is + # deleted. Since we don't need to draw anything else + # here that's all there is to it. + dc = wx.BufferedPaintDC(self, self.buffer) + else: + dc = wx.PaintDC(self) + self.PrepareDC(dc) + # since we're not buffering in this case, we have to + # paint the whole window, potentially very time consuming. + self.DoDrawing(dc) + + + def DoDrawing(self, dc, printing=False): + dc.BeginDrawing() + dc.SetPen(wx.Pen('RED')) + dc.DrawRectangle((5, 5), (50, 50)) + + dc.SetBrush(wx.LIGHT_GREY_BRUSH) + dc.SetPen(wx.Pen('BLUE', 4)) + dc.DrawRectangle((15, 15), (50, 50)) + + dc.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL)) + dc.SetTextForeground(wx.Colour(0xFF, 0x20, 0xFF)) + te = dc.GetTextExtent("Hello World") + dc.DrawText("Hello World", (60, 65)) + + dc.SetPen(wx.Pen('VIOLET', 4)) + dc.DrawLine((5, 65+te[1]), (60+te[0], 65+te[1])) + + lst = [(100,110), (150,110), (150,160), (100,160)] + dc.DrawLines(lst, -60) + dc.SetPen(wx.GREY_PEN) + dc.DrawPolygon(lst, 75) + dc.SetPen(wx.GREEN_PEN) + dc.DrawSpline(lst+[(100,100)]) + + dc.DrawBitmap(self.bmp, (200, 20), True) + dc.SetTextForeground(wx.Colour(0, 0xFF, 0x80)) + dc.DrawText("a bitmap", (200, 85)) + +## dc.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL)) +## dc.SetTextForeground("BLACK") +## dc.DrawText("TEST this STRING", (10, 200)) +## print dc.GetFullTextExtent("TEST this STRING") + + font = wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL) + dc.SetFont(font) + dc.SetTextForeground(wx.BLACK) + + for a in range(0, 360, 45): + dc.DrawRotatedText("Rotated text...", (300, 300), a) + + dc.SetPen(wx.TRANSPARENT_PEN) + dc.SetBrush(wx.BLUE_BRUSH) + dc.DrawRectangle((50,500),(50,50)) + dc.DrawRectangle((100,500),(50,50)) + + dc.SetPen(wx.Pen('RED')) + dc.DrawEllipticArc((200, 500), (50, 75), 0, 90) + + if not printing: + # This has troubles when used on a print preview in wxGTK, + # probably something to do with the pen styles and the scaling + # it does... + y = 20 + + for style in [wx.DOT, wx.LONG_DASH, wx.SHORT_DASH, wx.DOT_DASH, wx.USER_DASH]: + pen = wx.Pen("DARK ORCHID", 1, style) + if style == wx.USER_DASH: + pen.SetCap(wx.CAP_BUTT) + pen.SetDashes([1,2]) + pen.SetColour("RED") + dc.SetPen(pen) + dc.DrawLine((300, y), (400, y)) + y = y + 10 + + dc.SetBrush(wx.TRANSPARENT_BRUSH) + dc.SetPen(wx.Pen(wx.Colour(0xFF, 0x20, 0xFF), 1, wx.SOLID)) + dc.DrawRectangle((450, 50), (100, 100)) + old_pen = dc.GetPen() + new_pen = wx.Pen("BLACK", 5) + dc.SetPen(new_pen) + dc.DrawRectangle((470, 70), (60, 60)) + dc.SetPen(old_pen) + dc.DrawRectangle((490, 90), (20, 20)) + + self.DrawSavedLines(dc) + dc.EndDrawing() + + + def DrawSavedLines(self, dc): + dc.SetPen(wx.Pen('MEDIUM FOREST GREEN', 4)) + + for line in self.lines: + for coords in line: + apply(dc.DrawLine, coords) + + + def SetXY(self, event): + self.x, self.y = self.ConvertEventCoords(event) + + def ConvertEventCoords(self, event): + xView, yView = self.GetViewStart() + xDelta, yDelta = self.GetScrollPixelsPerUnit() + return (event.GetX() + (xView * xDelta), + event.GetY() + (yView * yDelta)) + + def OnLeftButtonEvent(self, event): + if event.LeftDown(): + self.SetFocus() + self.SetXY(event) + self.curLine = [] + self.CaptureMouse() + self.drawing = True + + elif event.Dragging() and self.drawing: + if BUFFERED: + # If doing buffered drawing, create the buffered DC, giving it + # it a real DC to blit to when done. + cdc = wx.ClientDC(self) + self.PrepareDC(cdc) + dc = wx.BufferedDC(cdc, self.buffer) + else: + dc = wx.ClientDC(self) + self.PrepareDC(dc) + + dc.BeginDrawing() + dc.SetPen(wx.Pen('MEDIUM FOREST GREEN', 4)) + coords = [(self.x, self.y) , self.ConvertEventCoords(event)] + self.curLine.append(coords) + apply(dc.DrawLine, coords) + self.SetXY(event) + dc.EndDrawing() + + + elif event.LeftUp() and self.drawing: + self.lines.append(self.curLine) + self.curLine = [] + self.ReleaseMouse() + self.drawing = False + + +## This is an example of what to do for the EVT_MOUSEWHEEL event, +## but since wx.ScrolledWindow does this already it's not +## necessary to do it ourselves. You would need to add an event table +## entry to __init__() to direct wheelmouse events to this handler. + +## wheelScroll = 0 +## def OnWheel(self, evt): +## delta = evt.GetWheelDelta() +## rot = evt.GetWheelRotation() +## linesPer = evt.GetLinesPerAction() +## print delta, rot, linesPer +## ws = self.wheelScroll +## ws = ws + rot +## lines = ws / delta +## ws = ws - lines * delta +## self.wheelScroll = ws +## if lines != 0: +## lines = lines * linesPer +## vsx, vsy = self.GetViewStart() +## scrollTo = vsy - lines +## self.Scroll(-1, scrollTo) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = MyCanvas(nb) + return win + +#--------------------------------------------------------------------------- + + + +overview = """ + + +The wx.ScrolledWindow class manages scrolling for its client area, transforming the +coordinates according to the scrollbar positions, and setting the scroll positions, +thumb sizes and ranges according to the area in view. + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/SingleChoiceDialog.py b/wxPython/demo/SingleChoiceDialog.py new file mode 100644 index 0000000000..34c6f50b5f --- /dev/null +++ b/wxPython/demo/SingleChoiceDialog.py @@ -0,0 +1,42 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + dlg = wx.SingleChoiceDialog( + frame, 'Test Single Choice', 'The Caption', + ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'], + wx.CHOICEDLG_STYLE + ) + + if dlg.ShowModal() == wx.ID_OK: + log.WriteText('You selected: %s\n' % dlg.GetStringSelection()) + + dlg.Destroy() + +#--------------------------------------------------------------------------- + + + + +overview = """\ +This class represents a dialog that shows a list of strings, and allows the user +to select one. Double-clicking on a list item is equivalent to single-clicking +and then pressing OK. + +As with all dialogs, be sure to retrieve the information you need BEFORE you +destroy the dialog. +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Slider.py b/wxPython/demo/Slider.py new file mode 100644 index 0000000000..11284aa86a --- /dev/null +++ b/wxPython/demo/Slider.py @@ -0,0 +1,52 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + self.count = 0 + + wx.StaticText(self, -1, "This is a wxSlider.", (45, 15)) + + slider = wx.Slider( + self, 100, 25, 1, 100, (30, 60), (250, -1), + wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS + ) + + slider.SetTickFreq(5, 1) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + + +overview = """\ +A slider is a control with a handle which can be pulled back and forth to +change the value. + +In Windows versions below Windows 95, a scrollbar is used to simulate the slider. +In Windows 95, the track bar control is used. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/SpinButton.py b/wxPython/demo/SpinButton.py new file mode 100644 index 0000000000..acbe912fb1 --- /dev/null +++ b/wxPython/demo/SpinButton.py @@ -0,0 +1,61 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o EVT_SPIN events (or something about them) freezes up the app. +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + self.count = 0 + + wx.StaticText(self, -1, "This example uses the wxSpinButton control.", (45, 15)) + + self.text = wx.TextCtrl(self, -1, "1", (30, 50), (60, -1)) + h = self.text.GetSize().height + + self.spin = wx.SpinButton(self, -1, (92, 50), (h, h), wx.SP_VERTICAL) + self.spin.SetRange(1, 100) + self.spin.SetValue(1) + + self.Bind(wx.EVT_SPIN, self.OnSpin, self.spin) + + + def OnSpin(self, event): + self.text.SetValue(str(event.GetPosition())) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +A wxSpinButton has two small up and down (or left and right) arrow buttons. +It is often used next to a text control for increment and decrementing a value. +Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not +implemented for all platforms (Win32 and GTK only currently). + +NB: the range supported by this control (and wxSpinCtrl) depends on the platform +but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version +of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit +range is supported. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/SpinCtrl.py b/wxPython/demo/SpinCtrl.py new file mode 100644 index 0000000000..427be32326 --- /dev/null +++ b/wxPython/demo/SpinCtrl.py @@ -0,0 +1,50 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + self.count = 0 + + wx.StaticText(self, -1, "This example uses the wxSpinCtrl control.", (45, 15)) + sc = wx.SpinCtrl(self, -1, "", (30, 50), (80, -1)) + sc.SetRange(1,100) + sc.SetValue(5) + #sc.Enable(False) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +wxSpinCtrl combines wxTextCtrl and wxSpinButton in one control. + +Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not +implemented for all platforms (Win32 and GTK only currently). + +NB: the range supported by this control depends on the platform +but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version +of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit +range is supported. + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/SplitterWindow.py b/wxPython/demo/SplitterWindow.py new file mode 100644 index 0000000000..d25e626923 --- /dev/null +++ b/wxPython/demo/SplitterWindow.py @@ -0,0 +1,60 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +class MySplitter(wx.SplitterWindow): + def __init__(self, parent, ID, log): + wx.SplitterWindow.__init__(self, parent, ID) + self.log = log + + self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged) + self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging) + + def OnSashChanged(self, evt): + self.log.WriteText("sash changed to %s\n" % str(evt.GetSashPosition())) + # uncomment this to not allow the change + #evt.SetSashPosition(-1) + + def OnSashChanging(self, evt): + self.log.WriteText("sash changing to %s\n" % str(evt.GetSashPosition())) + # uncomment this to not allow the change + #evt.SetSashPosition(-1) + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + splitter = MySplitter(nb, -1, log) + + p1 = wx.Window(splitter, -1) + p1.SetBackgroundColour(wx.RED) + wx.StaticText(p1, -1, "Panel One", (5,5)).SetBackgroundColour(wx.RED) + + p2 = wx.Window(splitter, -1) + p2.SetBackgroundColour(wx.BLUE) + wx.StaticText(p2, -1, "Panel Two", (5,5)).SetBackgroundColour(wx.BLUE) + + splitter.SetMinimumPaneSize(20) + splitter.SplitVertically(p1, p2, 100) + + return splitter + + +#--------------------------------------------------------------------------- + + +overview = """\ +This class manages up to two subwindows. The current view can be split +into two programmatically (perhaps from a menu command), and unsplit +either programmatically or via the wxSplitterWindow user interface. +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/StaticBitmap.py b/wxPython/demo/StaticBitmap.py new file mode 100644 index 0000000000..2bfecf0433 --- /dev/null +++ b/wxPython/demo/StaticBitmap.py @@ -0,0 +1,51 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import images + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + self.count = 0 + + wx.StaticText(self, -1, "This is a wxStaticBitmap.", (45, 15)) + + bmp = images.getTest2Bitmap() + mask = wx.MaskColour(bmp, wx.BLUE) + bmp.SetMask(mask) + wx.StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight())) + + bmp = images.getRobinBitmap() + wx.StaticBitmap(self, -1, bmp, (80, 150)) + + wx.StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175)) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + +overview = """\ +A static bitmap control displays a bitmap. + +The bitmap to be displayed should have a small number of colours, such as 16, +to avoid palette problems. + +A bitmap can be derived from most image formats using the wxImage class. + +""" + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/StaticText.py b/wxPython/demo/StaticText.py new file mode 100644 index 0000000000..22874ef480 --- /dev/null +++ b/wxPython/demo/StaticText.py @@ -0,0 +1,61 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o Removed the USE_GENERIC code because it doesn't work unless you use +# the 'from wx import *' methodology. +# + +import wx + +#--------------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent, -1) + + wx.StaticText(self, -1, "This is an example of static text", (20, 10)) + wx.StaticText(self, -1, "using the wxStaticText Control.", (20, 30)) + + wx.StaticText( + self, -1, "Is this yellow?", (20, 70), (90, -1) + ).SetBackgroundColour('Yellow') + + wx.StaticText( + self, -1, "align center", (120, 70), (90, -1), wx.ALIGN_CENTER + ).SetBackgroundColour('Yellow') + + wx.StaticText( + self, -1, "align right", (220, 70), (90, -1), wx.ALIGN_RIGHT + ).SetBackgroundColour('Yellow') + + str = "This is a different font." + text = wx.StaticText(self, -1, str, (20, 100)) + font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL) + text.SetFont(font) + #text.SetSize(text.GetBestSize()) + + wx.StaticText(self, -1, "Multi-line wxStaticText\nline 2\nline 3\n\nafter empty line", (20,150)) + wx.StaticText(self, -1, "Align right multi-line\nline 2\nline 3\n\nafter empty line", (220,150), style=wx.ALIGN_RIGHT) + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + panel = TestPanel(nb) + return panel + + +#--------------------------------------------------------------------------- + + +overview = '''\ +A static text control displays one or more lines of read-only text. + +''' + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/StatusBar.py b/wxPython/demo/StatusBar.py new file mode 100644 index 0000000000..0d1cd90880 --- /dev/null +++ b/wxPython/demo/StatusBar.py @@ -0,0 +1,124 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import time +import wx + +#--------------------------------------------------------------------------- + +class CustomStatusBar(wx.StatusBar): + def __init__(self, parent, log): + wx.StatusBar.__init__(self, parent, -1) + + # This status bar has three fields + self.SetFieldsCount(3) + self.log = log + self.sizeChanged = False + self.Bind(wx.EVT_SIZE, self.OnSize) + self.Bind(wx.EVT_IDLE, self.OnIdle) + + # Field 0 ... just text + self.SetStatusText("A Custom StatusBar...", 0) + + # This will fall into field 1 (the second field) + self.cb = wx.CheckBox(self, 1001, "toggle clock") + self.Bind(wx.EVT_CHECKBOX, self.OnToggleClock, self.cb) + self.cb.SetValue(True) + + # set the initial position of the checkbox + self.Reposition() + + # We're going to use a timer to drive a 'clock' in the last + # field. + self.timer = wx.PyTimer(self.Notify) + self.timer.Start(1000) + self.Notify() + + + # Handles events from the timer we started in __init__(). + # We're using it to drive a 'clock' in field 2 (the third field). + def Notify(self): + t = time.localtime(time.time()) + st = time.strftime("%d-%b-%Y %I:%M:%S", t) + self.SetStatusText(st, 2) + self.log.WriteText("tick...\n") + + + # the checkbox was clicked + def OnToggleClock(self, event): + if self.cb.GetValue(): + self.timer.Start(1000) + self.Notify() + else: + self.timer.Stop() + + + def OnSize(self, evt): + self.Reposition() # for normal size events + + # Set a flag so the idle time handler will also do the repositioning. + # It is done this way to get around a buglet where GetFieldRect is not + # accurate during the EVT_SIZE resulting from a frame maximize. + self.sizeChanged = True + + + def OnIdle(self, evt): + if self.sizeChanged: + self.Reposition() + + + # reposition the checkbox + def Reposition(self): + rect = self.GetFieldRect(1) + self.cb.SetPosition((rect.x+2, rect.y+2)) + self.cb.SetSize((rect.width-4, rect.height-4)) + self.sizeChanged = False + + + +class TestCustomStatusBar(wx.Frame): + def __init__(self, parent, log): + wx.Frame.__init__(self, parent, -1, 'Test Custom StatusBar') + + self.sb = CustomStatusBar(self, log) + self.SetStatusBar(self.sb) + tc = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE) + + self.SetSize((500, 300)) + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + + def OnCloseWindow(self, event): + self.sb.timer.Stop() + del self.sb.timer + self.Destroy() + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestCustomStatusBar(frame, log) + frame.otherWin = win + win.Show(True) + +#--------------------------------------------------------------------------- + + +overview = """\ +A status bar is a narrow window that can be placed along the bottom of +a frame to give small amounts of status information. It can contain +one or more fields, one or more of which can be variable length +according to the size of the window. + +This example demonstrates how to create a custom status bar with actual +gadgets embedded in it. In this case, the first field is just plain text, +The second one has a checkbox that enables the timer, and the third +field has a clock that shows the current time when it is enabled. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/StyledTextCtrl_1.py b/wxPython/demo/StyledTextCtrl_1.py new file mode 100644 index 0000000000..5eff81c883 --- /dev/null +++ b/wxPython/demo/StyledTextCtrl_1.py @@ -0,0 +1,300 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o EVT_STC_DRAG_OVER event GetdragResult() is not an int +# o wx.TheClipboard.Flush() generates an error on program exit. +# + +import wx +import wx.stc as stc + +import images + +#---------------------------------------------------------------------- + +debug = 1 + + +demoText = """\ + +This editor is provided by a class named wxStyledTextCtrl. As +the name suggests, you can define styles that can be applied to +sections of text. This will typically be used for things like +syntax highlighting code editors, but I'm sure that there are other +applications as well. A style is a combination of font, point size, +foreground and background colours. The editor can handle +proportional fonts just as easily as monospaced fonts, and various +styles can use different sized fonts. + +There are a few canned language lexers and colourizers included, +(see the next demo) or you can handle the colourization yourself. +If you do you can simply register an event handler and the editor +will let you know when the visible portion of the text needs +styling. + +wxStyledTextEditor also supports setting markers in the margin... + + + + +...and indicators within the text. You can use these for whatever +you want in your application. Cut, Copy, Paste, Drag and Drop of +text works, as well as virtually unlimited Undo and Redo +capabilities, (right click to try it out.) +""" + +if wx.Platform == '__WXMSW__': + face1 = 'Arial' + face2 = 'Times New Roman' + face3 = 'Courier New' + pb = 10 +else: + face1 = 'Helvetica' + face2 = 'Times' + face3 = 'Courier' + pb = 10 + + +#---------------------------------------------------------------------- +# This shows how to catch the Modified event from the wxStyledTextCtrl + +class MySTC(stc.StyledTextCtrl): + def __init__(self, parent, ID, log): + stc.StyledTextCtrl.__init__(self, parent, ID) + self.log = log + + self.Bind(stc.EVT_STC_DO_DROP, self.OnDoDrop) + self.Bind(stc.EVT_STC_DRAG_OVER, self.OnDragOver) + self.Bind(stc.EVT_STC_START_DRAG, self.OnStartDrag) + self.Bind(stc.EVT_STC_MODIFIED, self.OnModified) + + self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) + + def OnDestroy(self, evt): + # This is how the clipboard contents can be preserved after + # the app has exited. + wx.TheClipboard.Flush() + evt.Skip() + + + def OnStartDrag(self, evt): + self.log.write("OnStartDrag: %d, %s\n" + % (evt.GetDragAllowMove(), evt.GetDragText())) + + if debug and evt.GetPosition() < 250: + evt.SetDragAllowMove(False) # you can prevent moving of text (only copy) + evt.SetDragText("DRAGGED TEXT") # you can change what is dragged + #evt.SetDragText("") # or prevent the drag with empty text + + + def OnDragOver(self, evt): + #Todo: evt.GetdragResult() response is not an int + + self.log.write( + "OnDragOver: x,y=(%d, %d) pos: %d DragResult: %d\n" + % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult()) + ) + + if debug and evt.GetPosition() < 250: + evt.SetDragResult(wx.DragNone) # prevent dropping at the beginning of the buffer + + + def OnDoDrop(self, evt): + self.log.write("OnDoDrop: x,y=(%d, %d) pos: %d DragResult: %d\n" + "\ttext: %s\n" + % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult(), + evt.GetDragText())) + + if debug and evt.GetPosition() < 500: + evt.SetDragText("DROPPED TEXT") # Can change text if needed + #evt.SetDragResult(wx.DragNone) # Can also change the drag operation, but it + # is probably better to do it in OnDragOver so + # there is visual feedback + + #evt.SetPosition(25) # Can also change position, but I'm not sure why + # you would want to... + + + + + def OnModified(self, evt): + self.log.write("""OnModified + Mod type: %s + At position: %d + Lines added: %d + Text Length: %d + Text: %s\n""" % ( self.transModType(evt.GetModificationType()), + evt.GetPosition(), + evt.GetLinesAdded(), + evt.GetLength(), + repr(evt.GetText()) )) + + + def transModType(self, modType): + st = "" + table = [(stc.STC_MOD_INSERTTEXT, "InsertText"), + (stc.STC_MOD_DELETETEXT, "DeleteText"), + (stc.STC_MOD_CHANGESTYLE, "ChangeStyle"), + (stc.STC_MOD_CHANGEFOLD, "ChangeFold"), + (stc.STC_PERFORMED_USER, "UserFlag"), + (stc.STC_PERFORMED_UNDO, "Undo"), + (stc.STC_PERFORMED_REDO, "Redo"), + (stc.STC_LASTSTEPINUNDOREDO, "Last-Undo/Redo"), + (stc.STC_MOD_CHANGEMARKER, "ChangeMarker"), + (stc.STC_MOD_BEFOREINSERT, "B4-Insert"), + (stc.STC_MOD_BEFOREDELETE, "B4-Delete") + ] + + for flag,text in table: + if flag & modType: + st = st + text + " " + + if not st: + st = 'UNKNOWN' + + return st + + + + +#---------------------------------------------------------------------- + +_USE_PANEL = 1 + +def runTest(frame, nb, log): + if not _USE_PANEL: + ed = p = MySTC(nb, -1, log) + + else: + p = wx.Panel(nb, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) + ed = MySTC(p, -1, log) + s = wx.BoxSizer(wx.HORIZONTAL) + s.Add(ed, 1, wx.EXPAND) + p.SetSizer(s) + p.SetAutoLayout(True) + + + #ed.SetBufferedDraw(False) + #ed.StyleClearAll() + #ed.SetScrollWidth(800) + #ed.SetWrapMode(True) + + ed.SetText(demoText) + + if wx.USE_UNICODE: + import codecs + decode = codecs.lookup("utf-8")[1] + + ed.GotoPos(ed.GetLength()) + ed.AddText("\n\nwxStyledTextCtrl can also do Unicode:\n") + unitext, l = decode('\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd - ' + '\xd0\xbb\xd1\x83\xd1\x87\xd1\x88\xd0\xb8\xd0\xb9 ' + '\xd1\x8f\xd0\xb7\xd1\x8b\xd0\xba \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f!\n\n') + ed.AddText('\tRussian: ') + ed.AddText(unitext) + ed.GotoPos(0) + + ed.EmptyUndoBuffer() + + # make some styles + ed.StyleSetSpec(stc.STC_STYLE_DEFAULT, "size:%d,face:%s" % (pb, face3)) + ed.StyleSetSpec(1, "size:%d,bold,face:%s,fore:#0000FF" % (pb+2, face1)) + ed.StyleSetSpec(2, "face:%s,italic,fore:#FF0000,size:%d" % (face2, pb)) + ed.StyleSetSpec(3, "face:%s,bold,size:%d" % (face2, pb+2)) + ed.StyleSetSpec(4, "face:%s,size:%d" % (face1, pb-1)) + + # Now set some text to those styles... Normally this would be + # done in an event handler that happens when text needs displayed. + ed.StartStyling(98, 0xff) + ed.SetStyling(6, 1) # set style for 6 characters using style 1 + + ed.StartStyling(190, 0xff) + ed.SetStyling(20, 2) + + ed.StartStyling(310, 0xff) + ed.SetStyling(4, 3) + ed.SetStyling(2, 0) + ed.SetStyling(10, 4) + + + # line numbers in the margin + ed.SetMarginType(0, stc.STC_MARGIN_NUMBER) + ed.SetMarginWidth(0, 22) + ed.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "size:%d,face:%s" % (pb, face1)) + + # setup some markers + ed.SetMarginType(1, stc.STC_MARGIN_SYMBOL) + ed.MarkerDefine(0, stc.STC_MARK_ROUNDRECT, "#CCFF00", "RED") + #ed.MarkerDefine(1, stc.STC_MARK_CIRCLE, "FOREST GREEN", "SIENNA") + ed.MarkerDefineBitmap(1, images.getFolder1Bitmap()) + ed.MarkerDefine(2, stc.STC_MARK_SHORTARROW, "blue", "blue") + ed.MarkerDefine(3, stc.STC_MARK_ARROW, "#00FF00", "#00FF00") + + # put some markers on some lines + ed.MarkerAdd(17, 0) + ed.MarkerAdd(18, 1) + ed.MarkerAdd(19, 2) + ed.MarkerAdd(20, 3) + ed.MarkerAdd(20, 0) + + + # and finally, an indicator or two + ed.IndicatorSetStyle(0, stc.STC_INDIC_SQUIGGLE) + ed.IndicatorSetForeground(0, wx.RED) + ed.IndicatorSetStyle(1, stc.STC_INDIC_DIAGONAL) + ed.IndicatorSetForeground(1, wx.BLUE) + ed.IndicatorSetStyle(2, stc.STC_INDIC_STRIKE) + ed.IndicatorSetForeground(2, wx.RED) + + ed.StartStyling(836, stc.STC_INDICS_MASK) + ed.SetStyling(10, stc.STC_INDIC0_MASK) + ed.SetStyling(10, stc.STC_INDIC1_MASK) + ed.SetStyling(10, stc.STC_INDIC2_MASK | stc.STC_INDIC1_MASK) + + + # some test stuff... + if debug: + print "GetTextLength(): ", ed.GetTextLength(), len(ed.GetText()) + print "GetText(): ", repr(ed.GetText()) + print + print "GetStyledText(98, 104): ", repr(ed.GetStyledText(98, 104)), len(ed.GetStyledText(98, 104)) + print + print "GetCurLine(): ", repr(ed.GetCurLine()) + ed.GotoPos(5) + print "GetCurLine(): ", repr(ed.GetCurLine()) + print + print "GetLine(1): ", repr(ed.GetLine(1)) + print + ed.SetSelection(25, 35) + print "GetSelectedText(): ", repr(ed.GetSelectedText()) + print "GetTextRange(25, 35): ", repr(ed.GetTextRange(25, 35)) + print "FindText(0, max, 'indicators'): ", + print ed.FindText(0, ed.GetTextLength(), "indicators") + + ed.GotoPos(0) + + + return p + + + +#---------------------------------------------------------------------- + + +overview = """\ + +Once again, no docs yet. Sorry. But this +and this should +be helpful. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/StyledTextCtrl_2.py b/wxPython/demo/StyledTextCtrl_2.py new file mode 100644 index 0000000000..f9514cf521 --- /dev/null +++ b/wxPython/demo/StyledTextCtrl_2.py @@ -0,0 +1,400 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import keyword + +import wx +import wx.stc as stc + +import images + +#---------------------------------------------------------------------- + +demoText = """\ +## This version of the editor has been set up to edit Python source +## code. Here is a copy of wxPython/demo/Main.py to play with. + + +""" + +#---------------------------------------------------------------------- + + +if wx.Platform == '__WXMSW__': + faces = { 'times': 'Times New Roman', + 'mono' : 'Courier New', + 'helv' : 'Arial', + 'other': 'Comic Sans MS', + 'size' : 10, + 'size2': 8, + } +else: + faces = { 'times': 'Times', + 'mono' : 'Courier', + 'helv' : 'Helvetica', + 'other': 'new century schoolbook', + 'size' : 12, + 'size2': 10, + } + + +#---------------------------------------------------------------------- + +class PythonSTC(stc.StyledTextCtrl): + + fold_symbols = 2 + + def __init__(self, parent, ID): + stc.StyledTextCtrl.__init__(self, parent, ID, + style = wx.NO_FULL_REPAINT_ON_RESIZE) + + self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) + self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT) + + self.SetLexer(stc.STC_LEX_PYTHON) + self.SetKeyWords(0, " ".join(keyword.kwlist)) + + self.SetProperty("fold", "1") + self.SetProperty("tab.timmy.whinge.level", "1") + self.SetMargins(0,0) + + self.SetViewWhiteSpace(False) + #self.SetBufferedDraw(False) + #self.SetViewEOL(True) + + self.SetEdgeMode(stc.STC_EDGE_BACKGROUND) + self.SetEdgeColumn(78) + + # Setup a margin to hold fold markers + #self.SetFoldFlags(16) ### WHAT IS THIS VALUE? WHAT ARE THE OTHER FLAGS? DOES IT MATTER? + self.SetMarginType(2, stc.STC_MARGIN_SYMBOL) + self.SetMarginMask(2, stc.STC_MASK_FOLDERS) + self.SetMarginSensitive(2, True) + self.SetMarginWidth(2, 12) + + if self.fold_symbols == 0: + # Arrow pointing right for contracted folders, arrow pointing down for expanded + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_ARROWDOWN, "black", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_ARROW, "black", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "black", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "black", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black"); + + elif self.fold_symbols == 1: + # Plus for contracted folders, minus for expanded + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_MINUS, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_PLUS, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black"); + + elif self.fold_symbols == 2: + # Like a flattened tree control using circular headers and curved joins + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_CIRCLEMINUS, "white", "#404040"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_CIRCLEPLUS, "white", "#404040"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#404040"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNERCURVE, "white", "#404040"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_CIRCLEPLUSCONNECTED, "white", "#404040"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_CIRCLEMINUSCONNECTED, "white", "#404040"); + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNERCURVE, "white", "#404040"); + + elif self.fold_symbols == 3: + # Like a flattened tree control using square headers + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_BOXMINUS, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_BOXPLUS, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNER, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_BOXPLUSCONNECTED, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_BOXMINUSCONNECTED, "white", "#808080") + self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNER, "white", "#808080") + + + self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI) + self.Bind(stc.EVT_STC_MARGINCLICK, self.OnMarginClick) + self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed) + + # Make some styles, The lexer defines what each style is used for, we + # just have to define what each style looks like. This set is adapted from + # Scintilla sample property files. + + # Global default styles for all languages + self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % faces) + self.StyleClearAll() # Reset all to be like the default + + # Global default styles for all languages + self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % faces) + self.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces) + self.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR, "face:%(other)s" % faces) + self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, "fore:#FFFFFF,back:#0000FF,bold") + self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold") + + # Python styles + # Default + self.StyleSetSpec(stc.STC_P_DEFAULT, "fore:#000000,face:%(helv)s,size:%(size)d" % faces) + # Comments + self.StyleSetSpec(stc.STC_P_COMMENTLINE, "fore:#007F00,face:%(other)s,size:%(size)d" % faces) + # Number + self.StyleSetSpec(stc.STC_P_NUMBER, "fore:#007F7F,size:%(size)d" % faces) + # String + self.StyleSetSpec(stc.STC_P_STRING, "fore:#7F007F,face:%(helv)s,size:%(size)d" % faces) + # Single quoted string + self.StyleSetSpec(stc.STC_P_CHARACTER, "fore:#7F007F,face:%(helv)s,size:%(size)d" % faces) + # Keyword + self.StyleSetSpec(stc.STC_P_WORD, "fore:#00007F,bold,size:%(size)d" % faces) + # Triple quotes + self.StyleSetSpec(stc.STC_P_TRIPLE, "fore:#7F0000,size:%(size)d" % faces) + # Triple double quotes + self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE, "fore:#7F0000,size:%(size)d" % faces) + # Class name definition + self.StyleSetSpec(stc.STC_P_CLASSNAME, "fore:#0000FF,bold,underline,size:%(size)d" % faces) + # Function or method name definition + self.StyleSetSpec(stc.STC_P_DEFNAME, "fore:#007F7F,bold,size:%(size)d" % faces) + # Operators + self.StyleSetSpec(stc.STC_P_OPERATOR, "bold,size:%(size)d" % faces) + # Identifiers + self.StyleSetSpec(stc.STC_P_IDENTIFIER, "fore:#000000,face:%(helv)s,size:%(size)d" % faces) + # Comment-blocks + self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, "fore:#7F7F7F,size:%(size)d" % faces) + # End of line where string is not closed + self.StyleSetSpec(stc.STC_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % faces) + + self.SetCaretForeground("BLUE") + + + # register some images for use in the AutoComplete box. + self.RegisterImage(1, images.getSmilesBitmap()) + self.RegisterImage(2, images.getFile1Bitmap()) + self.RegisterImage(3, images.getCopy2Bitmap()) + + + def OnKeyPressed(self, event): + if self.CallTipActive(): + self.CallTipCancel() + key = event.KeyCode() + + if key == 32 and event.ControlDown(): + pos = self.GetCurrentPos() + + # Tips + if event.ShiftDown(): + self.CallTipSetBackground("yellow") + self.CallTipShow(pos, 'lots of of text: blah, blah, blah\n\n' + 'show some suff, maybe parameters..\n\n' + 'fubar(param1, param2)') + # Code completion + else: + #lst = [] + #for x in range(50000): + # lst.append('%05d' % x) + #st = " ".join(lst) + #print len(st) + #self.AutoCompShow(0, st) + + kw = keyword.kwlist[:] + kw.append("zzzzzz?2") + kw.append("aaaaa?2") + kw.append("__init__?3") + kw.append("zzaaaaa?2") + kw.append("zzbaaaa?2") + kw.append("this_is_a_longer_value") + #kw.append("this_is_a_much_much_much_much_much_much_much_longer_value") + + kw.sort() # Python sorts are case sensitive + self.AutoCompSetIgnoreCase(False) # so this needs to match + + # Images are specified with a appended "?type" + for i in range(len(kw)): + if kw[i] in keyword.kwlist: + kw[i] = kw[i] + "?1" + + self.AutoCompShow(0, " ".join(kw)) + else: + event.Skip() + + + def OnUpdateUI(self, evt): + # check for matching braces + braceAtCaret = -1 + braceOpposite = -1 + charBefore = None + caretPos = self.GetCurrentPos() + + if caretPos > 0: + charBefore = self.GetCharAt(caretPos - 1) + styleBefore = self.GetStyleAt(caretPos - 1) + + # check before + if charBefore and chr(charBefore) in "[]{}()" and styleBefore == stc.STC_P_OPERATOR: + braceAtCaret = caretPos - 1 + + # check after + if braceAtCaret < 0: + charAfter = self.GetCharAt(caretPos) + styleAfter = self.GetStyleAt(caretPos) + + if charAfter and chr(charAfter) in "[]{}()" and styleAfter == stc.STC_P_OPERATOR: + braceAtCaret = caretPos + + if braceAtCaret >= 0: + braceOpposite = self.BraceMatch(braceAtCaret) + + if braceAtCaret != -1 and braceOpposite == -1: + self.BraceBadLight(braceAtCaret) + else: + self.BraceHighlight(braceAtCaret, braceOpposite) + #pt = self.PointFromPosition(braceOpposite) + #self.Refresh(True, wxRect(pt.x, pt.y, 5,5)) + #print pt + #self.Refresh(False) + + + def OnMarginClick(self, evt): + # fold and unfold as needed + if evt.GetMargin() == 2: + if evt.GetShift() and evt.GetControl(): + self.FoldAll() + else: + lineClicked = self.LineFromPosition(evt.GetPosition()) + + if self.GetFoldLevel(lineClicked) & stc.STC_FOLDLEVELHEADERFLAG: + if evt.GetShift(): + self.SetFoldExpanded(lineClicked, True) + self.Expand(lineClicked, True, True, 1) + elif evt.GetControl(): + if self.GetFoldExpanded(lineClicked): + self.SetFoldExpanded(lineClicked, False) + self.Expand(lineClicked, False, True, 0) + else: + self.SetFoldExpanded(lineClicked, True) + self.Expand(lineClicked, True, True, 100) + else: + self.ToggleFold(lineClicked) + + + def FoldAll(self): + lineCount = self.GetLineCount() + expanding = True + + # find out if we are folding or unfolding + for lineNum in range(lineCount): + if self.GetFoldLevel(lineNum) & stc.STC_FOLDLEVELHEADERFLAG: + expanding = not self.GetFoldExpanded(lineNum) + break; + + lineNum = 0 + + while lineNum < lineCount: + level = self.GetFoldLevel(lineNum) + if level & stc.STC_FOLDLEVELHEADERFLAG and \ + (level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE: + + if expanding: + self.SetFoldExpanded(lineNum, True) + lineNum = self.Expand(lineNum, True) + lineNum = lineNum - 1 + else: + lastChild = self.GetLastChild(lineNum, -1) + self.SetFoldExpanded(lineNum, False) + + if lastChild > lineNum: + self.HideLines(lineNum+1, lastChild) + + lineNum = lineNum + 1 + + + + def Expand(self, line, doExpand, force=False, visLevels=0, level=-1): + lastChild = self.GetLastChild(line, level) + line = line + 1 + + while line <= lastChild: + if force: + if visLevels > 0: + self.ShowLines(line, line) + else: + self.HideLines(line, line) + else: + if doExpand: + self.ShowLines(line, line) + + if level == -1: + level = self.GetFoldLevel(line) + + if level & stc.STC_FOLDLEVELHEADERFLAG: + if force: + if visLevels > 1: + self.SetFoldExpanded(line, True) + else: + self.SetFoldExpanded(line, False) + + line = self.Expand(line, doExpand, force, visLevels-1) + + else: + if doExpand and self.GetFoldExpanded(line): + line = self.Expand(line, True, force, visLevels-1) + else: + line = self.Expand(line, False, force, visLevels-1) + else: + line = line + 1; + + return line + + +#---------------------------------------------------------------------- + +_USE_PANEL = 1 + +def runTest(frame, nb, log): + if not _USE_PANEL: + ed = p = PythonSTC(nb, -1) + else: + p = wx.Panel(nb, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE) + ed = PythonSTC(p, -1) + s = wx.BoxSizer(wx.HORIZONTAL) + s.Add(ed, 1, wx.EXPAND) + p.SetSizer(s) + p.SetAutoLayout(True) + + + ed.SetText(demoText + open('Main.py').read()) + ed.EmptyUndoBuffer() + ed.Colourise(0, -1) + + # line numbers in the margin + ed.SetMarginType(1, stc.STC_MARGIN_NUMBER) + ed.SetMarginWidth(1, 25) + + return p + + + +#---------------------------------------------------------------------- + + +overview = """\ + +Once again, no docs yet. Sorry. But this +and this should +be helpful. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + + + + + +#---------------------------------------------------------------------- +#---------------------------------------------------------------------- + diff --git a/wxPython/demo/TextCtrl.py b/wxPython/demo/TextCtrl.py new file mode 100644 index 0000000000..8c954a43b1 --- /dev/null +++ b/wxPython/demo/TextCtrl.py @@ -0,0 +1,176 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import sys +import wx + +#--------------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def OnSetFocus(self, evt): + print "OnSetFocus" + evt.Skip() + def OnKillFocus(self, evt): + print "OnKillFocus" + evt.Skip() + def OnWindowDestroy(self, evt): + print "OnWindowDestroy" + evt.Skip() + + + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + l1 = wx.StaticText(self, -1, "wx.TextCtrl") + t1 = wx.TextCtrl(self, -1, "Test it out and see", size=(125, -1)) + t1.SetInsertionPoint(0) + self.tc1 = t1 + + self.Bind(wx.EVT_TEXT, self.EvtText, t1) + t1.Bind(wx.EVT_CHAR, self.EvtChar) + t1.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) + t1.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) + t1.Bind(wx.EVT_WINDOW_DESTROY, self.OnWindowDestroy) + + l2 = wx.StaticText(self, -1, "Password") + t2 = wx.TextCtrl(self, -1, "", size=(125, -1), style=wx.TE_PASSWORD) + self.Bind(wx.EVT_TEXT, self.EvtText, t2) + + l3 = wx.StaticText(self, -1, "Multi-line") + t3 = wx.TextCtrl(self, -1, + "Here is a looooooooooooooong line of text set in the control.\n\n" + "The quick brown fox jumped over the lazy dog...", + size=(200, 100), style=wx.TE_MULTILINE) + + t3.SetInsertionPoint(0) + self.Bind(wx.EVT_TEXT, self.EvtText, t3) + b = wx.Button(self, -1, "Test Replace") + self.Bind(wx.EVT_BUTTON, self.OnTestReplace, b) + b2 = wx.Button(self, -1, "Test GetSelection") + self.Bind(wx.EVT_BUTTON, self.OnTestGetSelection, b2) + b3 = wx.Button(self, -1, "Test WriteText") + self.Bind(wx.EVT_BUTTON, self.OnTestWriteText, b3) + self.tc = t3 + + + l4 = wx.StaticText(self, -1, "Rich Text") + t4 = wx.TextCtrl(self, -1, "If supported by the native control, this is red, and this is a different font.", + size=(200, 100), style=wx.TE_MULTILINE|wx.TE_RICH2) + t4.SetInsertionPoint(0) + t4.SetStyle(44, 47, wx.TextAttr("RED", "YELLOW")) + points = t4.GetFont().GetPointSize() # get the current size + f = wx.Font(points+3, wx.ROMAN, wx.ITALIC, wx.BOLD, True) + t4.SetStyle(63, 77, wx.TextAttr("BLUE", wx.NullColour, f)) + + l5 = wx.StaticText(self, -1, "Test Positions") + t5 = wx.TextCtrl(self, -1, "0123456789\n" * 5, size=(200, 100), + style = wx.TE_MULTILINE + #| wx.TE_RICH + | wx.TE_RICH2 + ) + t5.Bind(wx.EVT_LEFT_DOWN, self.OnT5LeftDown) + self.t5 = t5 + + bsizer = wx.BoxSizer(wx.VERTICAL) + bsizer.Add(b, 0, wx.GROW|wx.ALL, 4) + bsizer.Add(b2, 0, wx.GROW|wx.ALL, 4) + bsizer.Add(b3, 0, wx.GROW|wx.ALL, 4) + + sizer = wx.FlexGridSizer(cols=3, hgap=6, vgap=6) + sizer.AddMany([ l1, t1, (0,0), + l2, t2, (0,0), + l3, t3, bsizer, + l4, t4, (0,0), + l5, t5, (0,0), + ]) + border = wx.BoxSizer(wx.VERTICAL) + border.Add(sizer, 0, wx.ALL, 25) + self.SetSizer(border) + self.SetAutoLayout(True) + + + def EvtText(self, event): + self.log.WriteText('EvtText: %s\n' % event.GetString()) + + + def EvtChar(self, event): + self.log.WriteText('EvtChar: %d\n' % event.GetKeyCode()) + event.Skip() + + + def OnTestReplace(self, evt): + self.tc.Replace(5, 9, "IS A") + #self.tc.Remove(5, 9) + + def OnTestWriteText(self, evt): + self.tc.WriteText("TEXT") + + def OnTestGetSelection(self, evt): + start, end = self.tc.GetSelection() + text = self.tc.GetValue() + if wx.Platform == "__WXMSW__": # This is why GetStringSelection was added + text = text.replace('\n', '\r\n') + + self.log.write("multi-line GetSelection(): (%d, %d)\n" + "\tGetStringSelection(): %s\n" + "\tSelectedText: %s\n" % + (start, end, + self.tc.GetStringSelection(), + repr(text[start:end]))) + + start, end = self.tc1.GetSelection() + text = self.tc1.GetValue() + + if wx.Platform == "__WXMSW__": # This is why GetStringSelection was added + text = text.replace('\n', '\r\n') + + self.log.write("single-line GetSelection(): (%d, %d)\n" + "\tGetStringSelection(): %s\n" + "\tSelectedText: %s\n" % + (start, end, + self.tc1.GetStringSelection(), + repr(text[start:end]))) + + + def OnT5LeftDown(self, evt): + evt.Skip() + wx.CallAfter(self.LogT5Position, evt) + + def LogT5Position(self, evt): + text = self.t5.GetValue() + ip = self.t5.GetInsertionPoint() + lp = self.t5.GetLastPosition() + self.log.write("LogT5Position:\n" + "\tGetInsertionPoint:\t%d\n" + "\ttext[insertionpoint]:\t%s\n" + "\tGetLastPosition:\t%d\n" + "\tlen(text):\t\t%d\n" + % (ip, text[ip], lp, len(text))) + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#--------------------------------------------------------------------------- + + +overview = """\ +A text control allows text to be displayed and (possibly) edited. It may be single +line or multi-line, support styles or not, be read-only or not, and even supports +text masking for such things as passwords. + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/TextEntryDialog.py b/wxPython/demo/TextEntryDialog.py new file mode 100644 index 0000000000..3083749bd1 --- /dev/null +++ b/wxPython/demo/TextEntryDialog.py @@ -0,0 +1,42 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + dlg = wx.TextEntryDialog( + frame, 'What is your favorite programming language?', + 'Duh??', 'Python') + + dlg.SetValue("Python is the best!") + + if dlg.ShowModal() == wx.ID_OK: + log.WriteText('You entered: %s\n' % dlg.GetValue()) + + dlg.Destroy() + + +#--------------------------------------------------------------------------- + + + +overview = """\ +This class represents a dialog that requests a one-line text string from the user. +It is implemented as a generic wxWindows dialog. Along with the usual wxDialog +style flags, all of the wxTextCtrl TE_* style flags are accepted, so, for example, +wx.TE_PASSWORD could be used to create a password dialog. + +As with other dialogs of this type, the user input must be retrieved prior to +destroying the dialog. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/TimeCtrl.py b/wxPython/demo/TimeCtrl.py new file mode 100644 index 0000000000..aa5cf52762 --- /dev/null +++ b/wxPython/demo/TimeCtrl.py @@ -0,0 +1,250 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wx renamer needed for timectrl lib +# o presense of spin control causing probs (see spin ctrl demo for details) +# +# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o New binders applied. Issues still exist. +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxTimeCtrl -> TimeCtrl +# o wxScrolledPanel -> ScrolledPanel +# + +import wx +import wx.lib.timectrl as timectl +import wx.lib.scrolledpanel as scrolled + +#---------------------------------------------------------------------- + +class TestPanel( scrolled.ScrolledPanel ): + def __init__( self, parent, log ): + + scrolled.ScrolledPanel.__init__( self, parent, -1 ) + self.log = log + + + text1 = wx.StaticText( self, -1, "12-hour format:") + self.time12 = timectl.TimeCtrl( self, -1, name="12 hour control" ) + spin1 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,20), 0 ) + self.time12.BindSpinButton( spin1 ) + + text2 = wx.StaticText( self, -1, "24-hour format:") + spin2 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,20), 0 ) + self.time24 = timectl.TimeCtrl( + self, -1, name="24 hour control", fmt24hr=True, + spinButton = spin2 + ) + + text3 = wx.StaticText( self, -1, "No seconds\nor spin button:") + self.spinless_ctrl = timectl.TimeCtrl( + self, -1, name="spinless control", + display_seconds = False + ) + + grid = wx.FlexGridSizer( 0, 2, 10, 5 ) + grid.Add( text1, 0, wx.ALIGN_RIGHT ) + hbox1 = wx.BoxSizer( wx.HORIZONTAL ) + hbox1.Add( self.time12, 0, wx.ALIGN_CENTRE ) + hbox1.Add( spin1, 0, wx.ALIGN_CENTRE ) + grid.Add( hbox1, 0, wx.LEFT ) + + grid.Add( text2, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM ) + hbox2 = wx.BoxSizer( wx.HORIZONTAL ) + hbox2.Add( self.time24, 0, wx.ALIGN_CENTRE ) + hbox2.Add( spin2, 0, wx.ALIGN_CENTRE ) + grid.Add( hbox2, 0, wx.LEFT ) + + grid.Add( text3, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM ) + grid.Add( self.spinless_ctrl, 0, wx.LEFT ) + + + buttonChange = wx.Button( self, -1, "Change Controls") + self.radio12to24 = wx.RadioButton( + self, -1, "Copy 12-hour time to 24-hour control", + wx.DefaultPosition, wx.DefaultSize, wx.RB_GROUP + ) + + self.radio24to12 = wx.RadioButton( + self, -1, "Copy 24-hour time to 12-hour control" + ) + + self.radioWx = wx.RadioButton( self, -1, "Set controls to 'now' using wxDateTime") + self.radioMx = wx.RadioButton( self, -1, "Set controls to 'now' using mxDateTime") + + radio_vbox = wx.BoxSizer( wx.VERTICAL ) + radio_vbox.Add( self.radio12to24, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + radio_vbox.Add( self.radio24to12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + radio_vbox.Add( self.radioWx, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + radio_vbox.Add( self.radioMx, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + box_label = wx.StaticBox( self, -1, "Change Controls through API" ) + buttonbox = wx.StaticBoxSizer( box_label, wx.HORIZONTAL ) + buttonbox.Add( buttonChange, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) + buttonbox.Add( radio_vbox, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) + + hbox = wx.BoxSizer( wx.HORIZONTAL ) + hbox.Add( grid, 0, wx.ALIGN_LEFT|wx.ALL, 15 ) + hbox.Add( buttonbox, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 20 ) + + + box_label = wx.StaticBox( self, -1, "Bounds Control" ) + boundsbox = wx.StaticBoxSizer( box_label, wx.HORIZONTAL ) + self.set_bounds = wx.CheckBox( self, -1, "Set time bounds:" ) + + minlabel = wx.StaticText( self, -1, "minimum time:" ) + self.min = timectl.TimeCtrl( self, -1, name="min", display_seconds = False ) + self.min.Enable( False ) + + maxlabel = wx.StaticText( self, -1, "maximum time:" ) + self.max = timectl.TimeCtrl( self, -1, name="max", display_seconds = False ) + self.max.Enable( False ) + + self.limit_check = wx.CheckBox( self, -1, "Limit control" ) + + label = wx.StaticText( self, -1, "Resulting time control:" ) + self.target_ctrl = timectl.TimeCtrl( self, -1, name="new" ) + + grid2 = wx.FlexGridSizer( 0, 2, 0, 0 ) + grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid2.Add( self.set_bounds, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid3 = wx.FlexGridSizer( 0, 2, 5, 5 ) + grid3.Add(minlabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL ) + grid3.Add( self.min, 0, wx.ALIGN_LEFT ) + grid3.Add(maxlabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL ) + grid3.Add( self.max, 0, wx.ALIGN_LEFT ) + grid2.Add(grid3, 0, wx.ALIGN_LEFT ) + + grid2.Add( self.limit_check, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + grid2.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + grid2.Add( self.target_ctrl, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + boundsbox.Add(grid2, 0, wx.ALIGN_CENTER|wx.EXPAND|wx.ALL, 5) + + vbox = wx.BoxSizer( wx.VERTICAL ) + vbox.Add( (20, 20) ) + vbox.Add( hbox, 0, wx.ALIGN_LEFT|wx.ALL, 5) + vbox.Add( boundsbox, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) + + + outer_box = wx.BoxSizer( wx.VERTICAL ) + outer_box.Add( vbox, 0, wx.ALIGN_LEFT|wx.ALL, 5) + + + # Turn on mxDateTime option only if we can import the module: + try: + from mx import DateTime + except ImportError: + self.radioMx.Enable( False ) + + + self.SetAutoLayout( True ) + self.SetSizer( outer_box ) + outer_box.Fit( self ) + self.SetupScrolling() + + self.Bind(wx.EVT_BUTTON, self.OnButtonClick, buttonChange ) + self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time12 ) + self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time24 ) + self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.spinless_ctrl ) + self.Bind(wx.EVT_CHECKBOX, self.OnBoundsCheck, self.set_bounds ) + self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_check ) + self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.min ) + self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.max ) + self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.target_ctrl ) + + + def OnTimeChange( self, event ): + timectrl = self.FindWindowById( event.GetId() ) + ib_str = [ " (out of bounds)", "" ] + + self.log.write('%s time = %s%s\n' % ( timectrl.GetName(), timectrl.GetValue(), ib_str[ timectrl.IsInBounds() ] ) ) + + + def OnButtonClick( self, event ): + if self.radio12to24.GetValue(): + self.time24.SetValue( self.time12.GetValue() ) + + elif self.radio24to12.GetValue(): + self.time12.SetValue( self.time24.GetValue() ) + + elif self.radioWx.GetValue(): + now = wx.DateTime_Now() + self.time12.SetValue( now ) + # (demonstrates that G/SetValue returns/takes a wxDateTime) + self.time24.SetValue( self.time12.GetValue(as_wxDateTime=True) ) + + # (demonstrates that G/SetValue returns/takes a wxTimeSpan) + self.spinless_ctrl.SetValue( self.time12.GetValue(as_wxTimeSpan=True) ) + + elif self.radioMx.GetValue(): + from mx import DateTime + now = DateTime.now() + self.time12.SetValue( now ) + + # (demonstrates that G/SetValue returns/takes a DateTime) + self.time24.SetValue( self.time12.GetValue(as_mxDateTime=True) ) + + # (demonstrates that G/SetValue returns/takes a DateTimeDelta) + self.spinless_ctrl.SetValue( self.time12.GetValue(as_mxDateTimeDelta=True) ) + + + def OnBoundsCheck( self, event ): + self.min.Enable( self.set_bounds.GetValue() ) + self.max.Enable( self.set_bounds.GetValue() ) + self.SetTargetMinMax() + + + def SetTargetMinMax( self, event=None ): + min = None + max = None + + if self.set_bounds.GetValue(): + min = self.min.GetWxDateTime() + max = self.max.GetWxDateTime() + else: + min, max = None, None + + cur_min, cur_max = self.target_ctrl.GetBounds() + + # jmg - A little expirimental change to ensure that min + # or max contain valid values before we use them + if min and (min != cur_min): self.target_ctrl.SetMin( min ) + if max and (max != cur_max): self.target_ctrl.SetMax( max ) + + self.target_ctrl.SetLimited( self.limit_check.GetValue() ) + + if min != cur_min or max != cur_max: + new_min, new_max = self.target_ctrl.GetBounds() + + if new_min and new_max: + self.log.write( "current min, max: (%s, %s)\n" % ( new_min.FormatTime(), new_max.FormatTime() ) ) + else: + self.log.write( "current min, max: (None, None)\n" ) + +#---------------------------------------------------------------------- + +def runTest( frame, nb, log ): + win = TestPanel( nb, log ) + return win + +#---------------------------------------------------------------------- + +overview = timectl.__doc__ + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Timer.py b/wxPython/demo/Timer.py new file mode 100644 index 0000000000..7f71b1f442 --- /dev/null +++ b/wxPython/demo/Timer.py @@ -0,0 +1,89 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import time +import wx + +#--------------------------------------------------------------------------- + +## For your convenience; an example of creating your own timer class. +## +## class TestTimer(wxTimer): +## def __init__(self, log = None): +## wxTimer.__init__(self) +## self.log = log +## def Notify(self): +## wxBell() +## if self.log: +## self.log.WriteText('beep!\n') + +#--------------------------------------------------------------------------- + +ID_Start = wx.NewId() +ID_Stop = wx.NewId() +ID_Timer = wx.NewId() +ID_Timer2 = wx.NewId() + +class TestTimerWin(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + wx.StaticText(self, -1, "This is a timer example", (15, 30)) + wx.Button(self, ID_Start, ' Start ', (15, 75), wx.DefaultSize) + wx.Button(self, ID_Stop, ' Stop ', (115, 75), wx.DefaultSize) + + self.timer = wx.Timer(self, # object to send the event to + ID_Timer) # event id to use + + self.timer2 = wx.Timer(self, # object to send the event to + ID_Timer2) # event id to use + + self.Bind(wx.EVT_BUTTON, self.OnStart, id=ID_Start) + self.Bind(wx.EVT_BUTTON, self.OnStop, id=ID_Stop) + self.Bind(wx.EVT_TIMER, self.OnTimer, id=ID_Timer) + self.Bind(wx.EVT_TIMER, self.OnTimer2, id=ID_Timer2) + + def OnStart(self, event): + self.timer.Start(1000) + self.timer2.Start(1500) + + def OnStop(self, event): + self.timer.Stop() + self.timer2.Stop() + + def OnTimer(self, event): + wx.Bell() + if self.log: + self.log.WriteText('beep!\n') + + def OnTimer2(self, event): + wx.Bell() + if self.log: + self.log.WriteText('beep 2!\n') + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestTimerWin(nb, log) + return win + +#--------------------------------------------------------------------------- + + + +overview = """\ +The wxTimer class allows you to execute code at specified intervals from +within the wxPython event loop. Timers can be one-shot or repeating. + +""" + + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/ToggleButton.py b/wxPython/demo/ToggleButton.py new file mode 100644 index 0000000000..7beec9983a --- /dev/null +++ b/wxPython/demo/ToggleButton.py @@ -0,0 +1,67 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +haveToggleBtn = 1 + +try: + wx.ToggleButton +except NameError: + haveToggleBtn = 0 + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + panel = wx.Panel(self, -1) + buttons = wx.BoxSizer(wx.HORIZONTAL) + + for word in "These are toggle buttons".split(): + b = wx.ToggleButton(panel, -1, word) + self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b) + buttons.Add(b, flag=wx.ALL, border=5) + + panel.SetAutoLayout(True) + panel.SetSizer(buttons) + buttons.Fit(panel) + panel.Move((50,50)) + + def OnToggle(self, evt): + self.log.write("Button %d toggled\n" % evt.GetId()) + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + if haveToggleBtn: + win = TestPanel(nb, log) + return win + else: + dlg = wx.MessageDialog(frame, 'wxToggleButton is not available on this platform.', + 'Sorry', wx.OK | wx.ICON_INFORMATION) + dlg.ShowModal() + dlg.Destroy() + + +#---------------------------------------------------------------------- + + +overview = """\ +wxToggleButton is a button that stays pressed when clicked by the user. +In other words, it is similar to wxCheckBox in functionality but looks like a +wxButton. + +This class is only available under wxMSW and wxGTK currently. + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/ToolBar.py b/wxPython/demo/ToolBar.py new file mode 100644 index 0000000000..b609061504 --- /dev/null +++ b/wxPython/demo/ToolBar.py @@ -0,0 +1,143 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import images + +#--------------------------------------------------------------------------- + +class TestToolBar(wx.Frame): + def __init__(self, parent, log): + wx.Frame.__init__(self, parent, -1, 'Test ToolBar', size=(500, 300)) + self.log = log + self.timer = None + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + + wx.Window(self, -1).SetBackgroundColour(wx.NamedColour("WHITE")) + + # Use the wxFrame internals to create the toolbar and associate it all + # in one tidy method call. + tb = self.CreateToolBar( wx.TB_HORIZONTAL + | wx.NO_BORDER + | wx.TB_FLAT + | wx.TB_TEXT + ) + + # Here's a 'simple' toolbar example, and how to bind it using SetToolBar() + #tb = wx.ToolBarSimple(self, -1, wx.DefaultPosition, wx.DefaultSize, + # wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT) + #self.SetToolBar(tb) + # But we're doing it a different way here. + + log.write("Default toolbar tool size: %s\n" % tb.GetToolBitmapSize()) + + self.CreateStatusBar() + + tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'") + #tb.AddLabelTool(10, "New", images.getNewBitmap(), shortHelp="New", longHelp="Long help for 'New'") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10) + + tb.AddSimpleTool(20, images.getOpenBitmap(), "Open", "Long help for 'Open'") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20) + + tb.AddSeparator() + tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy", "Long help for 'Copy'") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30) + + tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste", "Long help for 'Paste'") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40) + + tb.AddSeparator() + + tool = tb.AddCheckTool(50, images.getTog1Bitmap(), + shortHelp="Toggle this") + self.Bind(wx.EVT_TOOL, self.OnToolClick, id=50) + +## tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap(), +## shortHelp="Toggle with 2 bitmaps") +## self.Bind(EVT_TOOL, self.OnToolClick, id=60) + + self.Bind(wx.EVT_TOOL_ENTER, self.OnToolEnter) + self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick) # Match all + self.Bind(wx.EVT_TIMER, self.OnClearSB) + + tb.AddSeparator() + cbID = wx.NewId() + + tb.AddControl( + wx.ComboBox( + tb, cbID, "", choices=["", "This", "is a", "wxComboBox"], + size=(150,-1), style=wx.CB_DROPDOWN + )) + + self.Bind(wx.EVT_COMBOBOX, self.OnCombo, id=cbID) + tb.AddControl(wx.TextCtrl(tb, -1, "Toolbar controls!!", size=(150, -1))) + + # Final thing to do for a toolbar is call the Realize() method. This + # causes it to render (more or less, that is). + tb.Realize() + + + def OnToolClick(self, event): + self.log.WriteText("tool %s clicked\n" % event.GetId()) + tb = self.GetToolBar() + tb.EnableTool(10, not tb.GetToolEnabled(10)) + + def OnToolRClick(self, event): + self.log.WriteText("tool %s right-clicked\n" % event.GetId()) + + def OnCombo(self, event): + self.log.WriteText("combobox item selected: %s\n" % event.GetString()) + + def OnToolEnter(self, event): + self.log.WriteText('OnToolEnter: %s, %s\n' % (event.GetId(), event.GetInt())) + + if self.timer is None: + self.timer = wx.Timer(self) + + if self.timer.IsRunning(): + self.timer.Stop() + + self.timer.Start(2000) + event.Skip() + + + def OnClearSB(self, event): # called for the timer event handler + self.SetStatusText("") + self.timer.Stop() + self.timer = None + + + def OnCloseWindow(self, event): + if self.timer is not None: + self.timer.Stop() + self.timer = None + self.Destroy() + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestToolBar(frame, log) + frame.otherWin = win + win.Show(True) + +#--------------------------------------------------------------------------- + + + +overview = """\ + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/TreeCtrl.py b/wxPython/demo/TreeCtrl.py new file mode 100644 index 0000000000..547d05c87c --- /dev/null +++ b/wxPython/demo/TreeCtrl.py @@ -0,0 +1,206 @@ +# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import string +import wx +import images + +#--------------------------------------------------------------------------- + +class MyTreeCtrl(wx.TreeCtrl): + def __init__(self, parent, id, pos, size, style, log): + wx.TreeCtrl.__init__(self, parent, id, pos, size, style) + self.log = log + + def OnCompareItems(self, item1, item2): + t1 = self.GetItemText(item1) + t2 = self.GetItemText(item2) + self.log.WriteText('compare: ' + t1 + ' <> ' + t2 + '\n') + if t1 < t2: return -1 + if t1 == t2: return 0 + return 1 + +#--------------------------------------------------------------------------- + +class TestTreeCtrlPanel(wx.Panel): + def __init__(self, parent, log): + # Use the WANTS_CHARS style so the panel doesn't eat the Return key. + wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) + self.Bind(wx.EVT_SIZE, self.OnSize) + + self.log = log + tID = wx.NewId() + + self.tree = MyTreeCtrl(self, tID, wx.DefaultPosition, wx.DefaultSize, + wx.TR_HAS_BUTTONS + | wx.TR_EDIT_LABELS + #| wx.TR_MULTIPLE + #| wx.TR_HIDE_ROOT + , self.log) + + isz = (16,16) + il = wx.ImageList(isz[0], isz[1]) + fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) + fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) + fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz)) + smileidx = il.Add(images.getSmilesBitmap()) + + self.tree.SetImageList(il) + self.il = il + + # NOTE: For some reason tree items have to have a data object in + # order to be sorted. Since our compare just uses the labels + # we don't need any real data, so we'll just use None below for + # the item data. + + self.root = self.tree.AddRoot("The Root Item") + self.tree.SetPyData(self.root, None) + self.tree.SetItemImage(self.root, fldridx, wx.TreeItemIcon_Normal) + self.tree.SetItemImage(self.root, fldropenidx, wx.TreeItemIcon_Expanded) + + + for x in range(15): + child = self.tree.AppendItem(self.root, "Item %d" % x) + self.tree.SetPyData(child, None) + self.tree.SetItemImage(child, fldridx, wx.TreeItemIcon_Normal) + self.tree.SetItemImage(child, fldropenidx, wx.TreeItemIcon_Expanded) + + for y in range(5): + last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y))) + self.tree.SetPyData(last, None) + self.tree.SetItemImage(last, fldridx, wx.TreeItemIcon_Normal) + self.tree.SetItemImage(last, fldropenidx, wx.TreeItemIcon_Expanded) + + for z in range(5): + item = self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z)) + self.tree.SetPyData(item, None) + self.tree.SetItemImage(item, fileidx, wx.TreeItemIcon_Normal) + self.tree.SetItemImage(item, smileidx, wx.TreeItemIcon_Selected) + + self.tree.Expand(self.root) + self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded, self.tree) + self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, self.tree) + self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree) + self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.tree) + self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndEdit, self.tree) + self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate, self.tree) + + self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) + self.tree.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick) + self.tree.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) + + + + def OnRightClick(self, event): + pt = event.GetPosition(); + item, flags = self.tree.HitTest(pt) + self.log.WriteText("OnRightClick: %s, %s, %s\n" % + (self.tree.GetItemText(item), type(item), item.__class__)) + self.tree.SelectItem(item) + + + def OnRightUp(self, event): + pt = event.GetPosition(); + item, flags = self.tree.HitTest(pt) + self.log.WriteText("OnRightUp: %s (manually starting label edit)\n" + % self.tree.GetItemText(item)) + self.tree.EditLabel(item) + + + + def OnBeginEdit(self, event): + self.log.WriteText("OnBeginEdit\n") + # show how to prevent edit... + if self.tree.GetItemText(event.GetItem()) == "The Root Item": + wx.Bell() + self.log.WriteText("You can't edit this one...\n") + + # Lets just see what's visible of its children + cookie = 0 + root = event.GetItem() + (child, cookie) = self.tree.GetFirstChild(root, cookie) + + while child.IsOk(): + self.log.WriteText("Child [%s] visible = %d" % + (self.tree.GetItemText(child), + self.tree.IsVisible(child))) + (child, cookie) = self.tree.GetNextChild(root, cookie) + + event.Veto() + + + def OnEndEdit(self, event): + self.log.WriteText("OnEndEdit\n") + # show how to reject edit, we'll not allow any digits + for x in event.GetLabel(): + if x in string.digits: + self.log.WriteText("You can't enter digits...\n") + event.Veto() + return + + + def OnLeftDClick(self, event): + pt = event.GetPosition(); + item, flags = self.tree.HitTest(pt) + self.log.WriteText("OnLeftDClick: %s\n" % self.tree.GetItemText(item)) + parent = self.tree.GetItemParent(item) + self.tree.SortChildren(parent) + event.Skip() + + + def OnSize(self, event): + w,h = self.GetClientSizeTuple() + self.tree.SetDimensions(0, 0, w, h) + + + def OnItemExpanded(self, event): + item = event.GetItem() + self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item)) + + def OnItemCollapsed(self, event): + item = event.GetItem() + self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item)) + + def OnSelChanged(self, event): + self.item = event.GetItem() + self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(self.item)) + if wx.Platform == '__WXMSW__': + self.log.WriteText("BoundingRect: %s\n" % + self.tree.GetBoundingRect(self.item, True)) + #items = self.tree.GetSelections() + #print map(self.tree.GetItemText, items) + event.Skip() + + + def OnActivate(self, event): + self.log.WriteText("OnActivate: %s\n" % self.tree.GetItemText(self.item)) + + +#--------------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestTreeCtrlPanel(nb, log) + return win + +#--------------------------------------------------------------------------- + + + + + +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])]) + diff --git a/wxPython/demo/TreeListCtrl.py b/wxPython/demo/TreeListCtrl.py new file mode 100644 index 0000000000..4015c0665f --- /dev/null +++ b/wxPython/demo/TreeListCtrl.py @@ -0,0 +1,121 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import wx.gizmos as gizmos + +import images + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + self.Bind(wx.EVT_SIZE, self.OnSize) + + self.tree = gizmos.TreeListCtrl(self, -1, style = wx.TR_DEFAULT_STYLE + #| wx.TR_ROW_LINES + #| wx.TR_NO_LINES + #| wx.TR_TWIST_BUTTONS + ) + isz = (16,16) + il = wx.ImageList(isz[0], isz[1]) + fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) + fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) + fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz)) + smileidx = il.Add(images.getSmilesBitmap()) + + self.tree.SetImageList(il) + self.il = il + + # create some columns + self.tree.AddColumn("Main column") + self.tree.AddColumn("Column 1") + self.tree.AddColumn("Column 2") + self.tree.SetMainColumn(0) # the one with the tree in it... + self.tree.SetColumnWidth(0, 175) + + + self.root = self.tree.AddRoot("The Root Item") + self.tree.SetItemText(self.root, "col 1 root", 1) + self.tree.SetItemText(self.root, "col 2 root", 2) + self.tree.SetItemImage(self.root, fldridx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(self.root, fldropenidx, which = wx.TreeItemIcon_Expanded) + + + for x in range(15): + txt = "Item %d" % x + child = self.tree.AppendItem(self.root, txt) + self.tree.SetItemText(child, txt + "(c1)", 1) + self.tree.SetItemText(child, txt + "(c2)", 2) + self.tree.SetItemImage(child, fldridx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(child, fldropenidx, which = wx.TreeItemIcon_Expanded) + + for y in range(5): + txt = "item %d-%s" % (x, chr(ord("a")+y)) + last = self.tree.AppendItem(child, txt) + self.tree.SetItemText(last, txt + "(c1)", 1) + self.tree.SetItemText(last, txt + "(c2)", 2) + self.tree.SetItemImage(last, fldridx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(last, fldropenidx, which = wx.TreeItemIcon_Expanded) + + for z in range(5): + txt = "item %d-%s-%d" % (x, chr(ord("a")+y), z) + item = self.tree.AppendItem(last, txt) + self.tree.SetItemText(item, txt + "(c1)", 1) + self.tree.SetItemText(item, txt + "(c2)", 2) + self.tree.SetItemImage(item, fileidx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(item, smileidx, which = wx.TreeItemIcon_Selected) + + + self.tree.Expand(self.root) + + self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) + + + def OnRightUp(self, evt): + # Convert the position from being relative to the subwindow to + # being relative to the outer treelist window so HitTest will + # have the point it is expecting. + pos = evt.GetPosition() + pos = self.tree.GetMainWindow().ClientToScreen(pos) + pos = self.tree.ScreenToClient(pos) + item, flags, col = self.tree.HitTest(pos) + + if item: + print flags, col, self.tree.GetItemText(item, col) + + + def OnSize(self, evt): + self.tree.SetSize(self.GetSize()) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wxTreeListCtrl

+ +The wx.TreeListCtrl is essentially a wx.TreeCtrl with extra columns, +such that the look is similar to a wx.ListCtrl. + + +""" + + +if __name__ == '__main__': + #raw_input("Press enter...") + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/VListBox.py b/wxPython/demo/VListBox.py new file mode 100644 index 0000000000..cbe7707698 --- /dev/null +++ b/wxPython/demo/VListBox.py @@ -0,0 +1,135 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +#---------------------------------------------------------------------- + +# The wxVListBox is much like a regular wxListBox except you draw the +# items yourself and the items can vary in height. +class MyVListBox(wx.VListBox): + + # This method must be overridden. When called it should draw the + # n'th item on the dc within the rect. How it is drawn, and what + # is drawn is entirely up to you. + def OnDrawItem(self, dc, rect, n): + if self.GetSelection() == n: + c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT) + else: + c = self.GetForegroundColour()#wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT) + dc.SetTextForeground(c) + dc.DrawLabel(self._getItemText(n), rect, + wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) + + # This method must be overridden. It should return the height + # required to draw the n'th item. + def OnMeasureItem(self, n): + height = 0 + + for line in self._getItemText(n).split('\n'): + w, h = self.GetTextExtent(line) + height += h + + return height + 5 + + + # These are also overridable: + # + # OnDrawSeparator(dc, rect, n) + # Draw a separator between items. Note that rect may be reduced + # in size if desired so OnDrawItem gets a smaller rect. + # + # OnDrawBackground(dc, rect, n) + # Draw the background and maybe a border if desired. + + + def _getItemText(self, item): + if item % 2 == 0: + return "This is item# %d" % item + else: + return "This is item# %d\n with an extra line" % item + +#---------------------------------------------------------------------- + +# The wx.HtmlListBox derives from wx.VListBox, but draws each item +# itself as a wx.HtmlCell. +class MyHtmlListBox(wx.HtmlListBox): + + def OnGetItem(self, n): + if n % 2 == 0: + return "This is item# %d" % n + else: + return "This is item# %d
Any HTML is okay." % n + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + spacer = 50 + + vlb = MyVListBox(self, -1, size=(150, 250), style=wx.BORDER_SUNKEN) + vlb.SetItemCount(50) + vlb.SetSelection(0) + vlb.SetFocus() + vlbSizer = wx.BoxSizer(wx.VERTICAL) + vlbSizer.Add((spacer, spacer)) + vlbSizer.Add(wx.StaticText(self, -1, "wx.VListBox"), 0, 5, wx.ALL) + vlbSizer.Add(vlb) + + hlb = MyHtmlListBox(self, -1, size=(150, 250), style=wx.BORDER_SUNKEN) + hlb.SetItemCount(50) + hlb.SetSelection(0) + hlbSizer = wx.BoxSizer(wx.VERTICAL) + hlbSizer.Add((spacer, spacer)) + hlbSizer.Add(wx.StaticText(self, -1, "wx.HtmlListBox"), 0, 5, wx.ALL) + hlbSizer.Add(hlb) + + sizer = wx.BoxSizer(wx.HORIZONTAL) + sizer.Add((spacer, spacer)) + sizer.Add(vlbSizer) + sizer.Add((spacer, spacer)) + sizer.Add((spacer, spacer)) + sizer.Add(hlbSizer) + + self.SetSizer(sizer) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wxVListBox and wxHtmlListBox

+
+ +The "V" in wxVListBox stands for both "virtual" because it can have an +unlimited number of items since it doesn't store them itself, and +"variable" since items can vary in height. It has much the same +interface as wxListBox and also emits the same events so you can use +the same EVT_LISTBOX function to connect a handler. +

+ +The wxHtmlListBox derives from wxVListBox, but draws each item itself +as a wxHtmlCell. This means that you just need to provide a snippet +of HTML for each item when requested. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Validator.py b/wxPython/demo/Validator.py new file mode 100644 index 0000000000..b31b56b8f3 --- /dev/null +++ b/wxPython/demo/Validator.py @@ -0,0 +1,244 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import string +import wx + + +#---------------------------------------------------------------------- + +ALPHA_ONLY = 1 +DIGIT_ONLY = 2 + +class MyValidator(wx.PyValidator): + def __init__(self, flag=None, pyVar=None): + wx.PyValidator.__init__(self) + self.flag = flag + self.Bind(wx.EVT_CHAR, self.OnChar) + + def Clone(self): + return MyValidator(self.flag) + + def Validate(self, win): + tc = self.GetWindow() + val = tc.GetValue() + + if self.flag == ALPHA_ONLY: + for x in val: + if x not in string.letters: + return False + + elif self.flag == DIGIT_ONLY: + for x in val: + if x not in string.digits: + return False + + return True + + + def OnChar(self, event): + key = event.KeyCode() + + if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255: + event.Skip() + return + + if self.flag == ALPHA_ONLY and chr(key) in string.letters: + event.Skip() + return + + if self.flag == DIGIT_ONLY and chr(key) in string.digits: + event.Skip() + return + + if not wx.Validator_IsSilent(): + wx.Bell() + + # Returning without calling even.Skip eats the event before it + # gets to the text control + return + +#---------------------------------------------------------------------- + +class TestValidatorPanel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent, -1) + self.SetAutoLayout(True) + VSPACE = 10 + + fgs = wx.FlexGridSizer(0, 2) + + fgs.Add((1,1)) + fgs.Add(wx.StaticText(self, -1, "These controls have validators that limit\n" + "the type of characters that can be entered.")) + + fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) + + label = wx.StaticText(self, -1, "Alpha Only: ") + fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) + + fgs.Add(wx.TextCtrl(self, -1, "", validator = MyValidator(ALPHA_ONLY))) + + fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) + + label = wx.StaticText(self, -1, "Digits Only: ") + fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) + fgs.Add(wx.TextCtrl(self, -1, "", validator = MyValidator(DIGIT_ONLY))) + + fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) + fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) + fgs.Add((0,0)) + b = wx.Button(self, -1, "Test Dialog Validation") + self.Bind(wx.EVT_BUTTON, self.OnDoDialog, b) + fgs.Add(b) + + border = wx.BoxSizer() + border.Add(fgs, 1, wx.GROW|wx.ALL, 25) + self.SetSizer(border) + self.Layout() + + def OnDoDialog(self, evt): + dlg = TestValidateDialog(self) + dlg.ShowModal() + dlg.Destroy() + + +#---------------------------------------------------------------------- + +class TextObjectValidator(wx.PyValidator): + """ This validator is used to ensure that the user has entered something + into the text object editor dialog's text field. + """ + def __init__(self): + """ Standard constructor. + """ + wx.PyValidator.__init__(self) + + + + def Clone(self): + """ Standard cloner. + + Note that every validator must implement the Clone() method. + """ + return TextObjectValidator() + + + def Validate(self, win): + """ Validate the contents of the given text control. + """ + textCtrl = self.GetWindow() + text = textCtrl.GetValue() + + if len(text) == 0: + wx.MessageBox("A text object must contain some text!", "Error") + textCtrl.SetBackgroundColour("pink") + textCtrl.SetFocus() + textCtrl.Refresh() + return False + else: + textCtrl.SetBackgroundColour( + wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) + textCtrl.Refresh() + return True + + + def TransferToWindow(self): + """ Transfer data from validator to window. + + The default implementation returns False, indicating that an error + occurred. We simply return True, as we don't do any data transfer. + """ + return True # Prevent wxDialog from complaining. + + + def TransferFromWindow(self): + """ Transfer data from window to validator. + + The default implementation returns False, indicating that an error + occurred. We simply return True, as we don't do any data transfer. + """ + return True # Prevent wxDialog from complaining. + +#---------------------------------------------------------------------- + +class TestValidateDialog(wx.Dialog): + def __init__(self, parent): + wx.Dialog.__init__(self, parent, -1, "Validated Dialog") + + self.SetAutoLayout(True) + VSPACE = 10 + + fgs = wx.FlexGridSizer(0, 2) + + fgs.Add((1,1)); + fgs.Add(wx.StaticText(self, -1, + "These controls must have text entered into them. Each\n" + "one has a validator that is checked when the Okay\n" + "button is clicked.")) + + fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) + + label = wx.StaticText(self, -1, "First: ") + fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) + + fgs.Add(wx.TextCtrl(self, -1, "", validator = TextObjectValidator())) + + fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) + + label = wx.StaticText(self, -1, "Second: ") + fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) + fgs.Add(wx.TextCtrl(self, -1, "", validator = TextObjectValidator())) + + + buttons = wx.BoxSizer(wx.HORIZONTAL) + b = wx.Button(self, wx.ID_OK, "Okay") + b.SetDefault() + buttons.Add(b, 0, wx.ALL, 10) + buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 0, wx.ALL, 10) + + border = wx.BoxSizer(wx.VERTICAL) + border.Add(fgs, 1, wx.GROW|wx.ALL, 25) + border.Add(buttons) + self.SetSizer(border) + border.Fit(self) + self.Layout() + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestValidatorPanel(nb) + return win + +#---------------------------------------------------------------------- + + + +overview = """\ + + +wxValidator is the base class for a family of validator classes that mediate +between a class of control, and application data. + +

A validator has three major roles: + +

    +
  1. to transfer data from a C++ variable or own storage to and from a control; +
  2. to validate data in a control, and show an appropriate error message; +
  3. to filter events (such as keystrokes), thereby changing the behaviour of the associated control. +
+

Validators can be plugged into controls dynamically. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/Wave.py b/wxPython/demo/Wave.py new file mode 100644 index 0000000000..b84e62148b --- /dev/null +++ b/wxPython/demo/Wave.py @@ -0,0 +1,61 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx + +from Main import opj + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent, -1) + + b = wx.Button(self, -1, "Play Sound 1", (25, 25)) + self.Bind(wx.EVT_BUTTON, self.OnButton1, b) + + b = wx.Button(self, -1, "Play Sound 2", (25, 65)) + self.Bind(wx.EVT_BUTTON, self.OnButton2, b) + + + def OnButton1(self, evt): + try: + wave = wx.Wave(opj('data/anykey.wav')) + wave.Play() + except NotImplementedError, v: + wx.MessageBox(str(v), "Exception Message") + + + def OnButton2(self, evt): + try: + wave = wx.Wave(opj('data/plan.wav')) + wave.Play() + except NotImplementedError, v: + wx.MessageBox(str(v), "Exception Message") + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb) + return win + +#---------------------------------------------------------------------- + + +overview = """\ +This class represents a short wave file, in Windows WAV format, that can +be stored in memory and played. Currently this class is implemented on Windows +and GTK (Linux) only. + +This demo offers two examples, both driven by buttons, but obviously the event +that drives the playing of the sound can come from anywhere. + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/Wizard.py b/wxPython/demo/Wizard.py new file mode 100644 index 0000000000..7c7d5d80f6 --- /dev/null +++ b/wxPython/demo/Wizard.py @@ -0,0 +1,253 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/3-/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o WizardPage* doesn't support GetId() +# + +import wx +import wx.wizard as wiz +import images + +#---------------------------------------------------------------------- + +def makePageTitle(wizPg, title): + sizer = wx.BoxSizer(wx.VERTICAL) + wizPg.SetSizer(sizer) + title = wx.StaticText(wizPg, -1, title) + title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) + sizer.AddWindow(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) + sizer.AddWindow(wx.StaticLine(wizPg, -1), 0, wx.EXPAND|wx.ALL, 5) + return sizer + +#---------------------------------------------------------------------- + +class TitledPage(wiz.WizardPageSimple): + def __init__(self, parent, title): + wiz.WizardPageSimple.__init__(self, parent) + self.sizer = makePageTitle(self, title) + + +#---------------------------------------------------------------------- + +class SkipNextPage(wiz.PyWizardPage): + def __init__(self, parent, title): + wiz.PyWizardPage.__init__(self, parent) + self.next = self.prev = None + self.sizer = makePageTitle(self, title) + + self.cb = wx.CheckBox(self, -1, "Skip next page") + self.sizer.Add(self.cb, 0, wx.ALL, 5) + + def SetNext(self, next): + self.next = next + + def SetPrev(self, prev): + self.prev = prev + + + # Classes derived from wxPyWizardPanel must override + # GetNext and GetPrev, and may also override GetBitmap + # as well as all those methods overridable by + # wx.PyWindow. + + def GetNext(self): + """If the checkbox is set then return the next page's next page""" + next = self.next + if self.cb.GetValue(): + next = next.GetNext() + return next + + def GetPrev(self): + return self.prev + +#---------------------------------------------------------------------- + +class UseAltBitmapPage(wiz.PyWizardPage): + def __init__(self, parent, title): + wiz.PyWizardPage.__init__(self, parent) + self.next = self.prev = None + self.sizer = makePageTitle(self, title) + + self.sizer.Add(wx.StaticText(self, -1, "This page uses a different bitmap"), + 0, wx.ALL, 5) + + def SetNext(self, next): + self.next = next + + def SetPrev(self, prev): + self.prev = prev + + def GetNext(self): + return self.next + + def GetPrev(self): + return self.prev + + def GetBitmap(self): + # You usually wouldn't need to override this method + # since you can set a non-default bitmap in the + # wxWizardPageSimple constructor, but if you need to + # dynamically change the bitmap based on the + # contents of the wizard, or need to also change the + # next/prev order then it can be done by overriding + # GetBitmap. + return images.getWizTest2Bitmap() + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + ID_wiz = wx.NewId() + + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + b = wx.Button(self, -1, "Run Simple Wizard", pos=(50, 50)) + self.Bind(wx.EVT_BUTTON, self.OnRunSimpleWizard, b) + + b = wx.Button(self, -1, "Run Dynamic Wizard", pos=(50, 100)) + self.Bind(wx.EVT_BUTTON, self.OnRunDynamicWizard, b) + + wiz.EVT_WIZARD_PAGE_CHANGED(self, self.ID_wiz, self.OnWizPageChanged) + wiz.EVT_WIZARD_PAGE_CHANGING(self, self.ID_wiz, self.OnWizPageChanging) + wiz.EVT_WIZARD_CANCEL(self, self.ID_wiz, self.OnWizCancel) + + + def OnWizPageChanged(self, evt): + if evt.GetDirection(): + dir = "forward" + else: + dir = "backward" + + page = evt.GetPage() + self.log.write("OnWizPageChanged: %s, %s\n" % (dir, page.__class__)) + + + def OnWizPageChanging(self, evt): + if evt.GetDirection(): + dir = "forward" + else: + dir = "backward" + + page = evt.GetPage() + self.log.write("OnWizPageChanging: %s, %s\n" % (dir, page.__class__)) + + + def OnWizCancel(self, evt): + page = evt.GetPage() + self.log.write("OnWizCancel: %s\n" % page.__class__) + + # Show how to prevent cancelling of the wizard. The + # other events can be Veto'd too. + if page is self.page1: + wx.MessageBox("Cancelling on the first page has been prevented.", "Sorry") + evt.Veto() + + def OnWizFinished(self, evt): + self.log.write("OnWizFinished\n") + + + def OnRunSimpleWizard(self, evt): + # Create the wizard and the pages + wizard = wiz.Wizard(self, self.ID_wiz, "Simple Wizard", + images.getWizTest1Bitmap()) + page1 = TitledPage(wizard, "Page 1") + page2 = TitledPage(wizard, "Page 2") + page3 = TitledPage(wizard, "Page 3") + page4 = TitledPage(wizard, "Page 4") + self.page1 = page1 + + page1.sizer.Add(wx.StaticText(page1, -1, """ +This wizard is totally useless, but is meant to show how to +chain simple wizard pages together in a non-dynamic manner. +IOW, the order of the pages never changes, and so the +wxWizardPageSimple class can easily be used for the pages.""")) + wizard.FitToPage(page1) + page4.sizer.Add(wx.StaticText(page4, -1, "\nThis is the last page.")) + + # Use the convenience Chain function to connect the pages + wiz.WizardPageSimple_Chain(page1, page2) + wiz.WizardPageSimple_Chain(page2, page3) + wiz.WizardPageSimple_Chain(page3, page4) + + if wizard.RunWizard(page1): + wx.MessageBox("Wizard completed successfully", "That's all folks!") + else: + wx.MessageBox("Wizard was cancelled", "That's all folks!") + + + + def OnRunDynamicWizard(self, evt): + # Create the wizard and the pages + #wizard = wx.PreWizard() + #wizard.SetExtraStyle(wx.WIZARD_EX_HELPBUTTON) + #wizard.Create(self, self.ID_wiz, "Simple Wizard", + # images.getWizTest1Bitmap()) + wizard = wiz.Wizard(self, self.ID_wiz, "Simple Wizard", + images.getWizTest1Bitmap()) + + page1 = TitledPage(wizard, "Page 1") + page2 = SkipNextPage(wizard, "Page 2") + page3 = TitledPage(wizard, "Page 3") + page4 = UseAltBitmapPage(wizard, "Page 4") + page5 = TitledPage(wizard, "Page 5") + self.page1 = page1 + + page1.sizer.Add(wx.StaticText(page1, -1, """ +This wizard shows the ability to choose at runtime the order +of the pages and also which bitmap is shown. +""")) + wizard.FitToPage(page1) + page5.sizer.Add(wx.StaticText(page5, -1, "\nThis is the last page.")) + + # Set the initial order of the pages + page1.SetNext(page2) + page2.SetPrev(page1) + page2.SetNext(page3) + page3.SetPrev(page2) + page3.SetNext(page4) + page4.SetPrev(page3) + page4.SetNext(page5) + page5.SetPrev(page4) + + + if wizard.RunWizard(page1): + wx.MessageBox("Wizard completed successfully", "That's all folks!") + else: + wx.MessageBox("Wizard was cancelled", "That's all folks!") + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wxWizard

+ +wxWizard is the central class for implementing 'wizard-like' +dialogs. These dialogs are mostly familiar to Windows users and are +nothing else but a sequence of 'pages' each of them displayed inside a +dialog which has the buttons to pass to the next (and previous) pages. +

+The wizards are typically used to decompose a complex dialog into +several simple steps and are mainly useful to the novice users, hence +it is important to keep them as simple as possible. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/XmlResource.py b/wxPython/demo/XmlResource.py new file mode 100644 index 0000000000..208e229eac --- /dev/null +++ b/wxPython/demo/XmlResource.py @@ -0,0 +1,80 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import wx.xrc as xrc + +from Main import opj + +#---------------------------------------------------------------------- + +RESFILE = opj("data/resource_wdr.xrc") + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + wx.Panel.__init__(self, parent, -1) + self.log = log + + # make the components + label = wx.StaticText(self, -1, "The lower panel was built from this XML:") + label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)) + + resourceText = open(RESFILE).read() + text = wx.TextCtrl(self, -1, resourceText, + style=wx.TE_READONLY|wx.TE_MULTILINE) + text.SetInsertionPoint(0) + + line = wx.StaticLine(self, -1) + + # This shows a few different ways to load XML Resources + if 0: + # XML Resources can be loaded from a file like this: + res = xrc.XmlResource(RESFILE) + + elif 1: + # or from a Virtual FileSystem: + wx.FileSystem_AddHandler(wx.MemoryFSHandler()) + wx.MemoryFSHandler_AddFile("XRC_Resources/data_file", resourceText) + res = xrc.XmlResource("memory:XRC_Resources/data_file") + + else: + # or from a string, like this: + res = xrc.EmptyXmlResource() + res.LoadFromString(resourceText) + + + # Now create a panel from the resource data + panel = res.LoadPanel(self, "MyPanel") + + # and do the layout + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(label, 0, wx.EXPAND|wx.TOP|wx.LEFT, 5) + sizer.Add(text, 1, wx.EXPAND|wx.ALL, 5) + sizer.Add(line, 0, wx.EXPAND) + sizer.Add(panel, 1, wx.EXPAND|wx.ALL, 5) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/XmlResourceHandler.py b/wxPython/demo/XmlResourceHandler.py new file mode 100644 index 0000000000..2098c5da41 --- /dev/null +++ b/wxPython/demo/XmlResourceHandler.py @@ -0,0 +1,195 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# o There are issues using the wx namespace within the xrc code. +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Error report: "Error: No handler found for XML node 'object', +# class 'wx.StaticText'!"; no text shows on panel. +# + +import wx +import wx.xrc as xrc + +#---------------------------------------------------------------------- + +resourceText = r''' + + + + + + 200,100 + + + 10,10 + + + +''' + +#---------------------------------------------------------------------- + +class MyBluePanel(wx.Panel): + def __init__(self, parent, id, pos, size, style, name): + wx.Panel.__init__(self, parent, id, pos, size, style, name) + + # This is the little bit of customization that we do for this + # silly example. It could just as easily have been done in + # the resource. + self.SetBackgroundColour("BLUE") + self.SetForegroundColour("WHITE") + + +# To do it the more complex way, (see below) we need to write the +# class a little differently... This could obviously be done with a +# single class, but I wanted to make separate ones to make clear what +# the different requirements are. +class PreMyBluePanel(wx.Panel): + def __init__(self): + p = wx.PrePanel() + self.PostCreate(p) + + def Create(self, parent, id, pos, size, style, name): + wx.Panel.Create(self, parent, id, pos, size, style, name) + self.SetBackgroundColour("BLUE") + self.SetForegroundColour("WHITE") + + +#---------------------------------------------------------------------- + +class MyBluePanelXmlHandler(xrc.XmlResourceHandler): + def __init__(self): + xrc.XmlResourceHandler.__init__(self) + # Specify the styles recognized by objects of this type + self.AddStyle("wx.NO_3D", wx.NO_3D); + self.AddStyle("wx.TAB_TRAVERSAL", wx.TAB_TRAVERSAL); + self.AddStyle("wx.WS_EX_VALIDATE_RECURSIVELY", wx.WS_EX_VALIDATE_RECURSIVELY); + self.AddStyle("wx.CLIP_CHILDREN", wx.CLIP_CHILDREN); + self.AddWindowStyles(); + + # This method and the next one are required for XmlResourceHandlers + def CanHandle(self, node): + return self.IsOfClass(node, "MyBluePanel") + + def DoCreateResource(self): + # NOTE: wxWindows can be created in either a single-phase or + # in a two-phase way. Single phase is what you normally do, + # and two-phase creates the instnace first, and then later + # creates the actual window when the Create method is called. + # (In wxPython the first phase is done using the wxPre* + # function, for example, wxPreFrame, wxPrePanel, etc.) + # + # wxXmlResource supports either method, a premade instance can + # be created and populated by xrc using the appropriate + # LoadOn* method (such as LoadOnPanel) or xrc can create the + # instance too, using the Load* method. However this makes + # the handlers a bit more complex. If you can be sure that a + # particular class will never be loaded using a pre-existing + # instance, then you can make the handle much simpler. I'll + # show both methods below. + + if 1: + # The simple method assumes that there is no existing + # instance. Be sure of that with an assert. + assert self.GetInstance() is None + + # Now create the object + panel = MyBluePanel(self.GetParentAsWindow(), + self.GetID(), + self.GetPosition(), + self.GetSize(), + self.GetStyle("style", wx.TAB_TRAVERSAL), + self.GetName() + ) + else: + # When using the more complex (but more flexible) method + # the instance may already have been created, check for it + panel = self.GetInstance() + if panel is None: + # if not, then create the instance (but not the window) + panel = PreMyBluePanel() + + # Now call the panel's Create method to actually create the window + panel.Create(self.GetParentAsWindow(), + self.GetID(), + self.GetPosition(), + self.GetSize(), + self.GetStyle("style", wx.TAB_TRAVERSAL), + self.GetName() + ) + + # These two things should be done in either case: + # Set standard window attributes + self.SetupWindow(panel) + # Create any child windows of this node + self.CreateChildren(panel) + + return panel + + +#---------------------------------------------------------------------- + + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + # make the components + label = wx.StaticText(self, -1, "The lower panel was built from this XML:") + label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)) + + text = wx.TextCtrl(self, -1, resourceText, + style=wx.TE_READONLY|wx.TE_MULTILINE) + text.SetInsertionPoint(0) + + line = wx.StaticLine(self, -1) + + # Load the resource + res = xrc.EmptyXmlResource() + res.InsertHandler(MyBluePanelXmlHandler()) + res.LoadFromString(resourceText) + + # Now create a panel from the resource data + panel = res.LoadObject(self, "MyPanel", "MyBluePanel") + + # and do the layout + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(label, 0, wx.EXPAND|wx.TOP|wx.LEFT, 5) + sizer.Add(text, 1, wx.EXPAND|wx.ALL, 5) + sizer.Add(line, 0, wx.EXPAND) + sizer.Add(panel, 1, wx.EXPAND|wx.ALL, 5) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wxXmlResourceHandler

+ +Deriving a class from wxXmlResourceHandler allows you to specify your +own classes in XRC resources, and your handler class will then be used +to create instances of that class when the resource is loaded. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/XmlResourceSubclass.py b/wxPython/demo/XmlResourceSubclass.py new file mode 100644 index 0000000000..4fc5a275c4 --- /dev/null +++ b/wxPython/demo/XmlResourceSubclass.py @@ -0,0 +1,108 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# + +import wx +import wx.xrc as xrc + +#---------------------------------------------------------------------- + +resourceText = r''' + + + + + + 200,100 + + + 10,10 + + + +''' + +#---------------------------------------------------------------------- + +class MyBluePanel(wx.Panel): + def __init__(self): + p = wx.PrePanel() + # the Create step is done by XRC. + self.PostCreate(p) + self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate) + + def OnCreate(self, evt): + # This is the little bit of customization that we do for this + # silly example. It could just as easily have been done in + # the resource. We do it in the EVT_WINDOW_CREATE handler + # because the window doesn't really exist yet in the __init__. + self.SetBackgroundColour("BLUE") + self.SetForegroundColour("WHITE") + +#---------------------------------------------------------------------- + + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + # make the components + label = wx.StaticText(self, -1, "The lower panel was built from this XML:") + label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)) + + text = wx.TextCtrl(self, -1, resourceText, + style=wx.TE_READONLY|wx.TE_MULTILINE) + text.SetInsertionPoint(0) + + line = wx.StaticLine(self, -1) + + # Load the resource + res = xrc.EmptyXmlResource() + res.LoadFromString(resourceText) + + # Now create a panel from the resource data + panel = res.LoadPanel(self, "MyPanel") + + # and do the layout + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(label, 0, wx.EXPAND|wx.TOP|wx.LEFT, 5) + sizer.Add(text, 1, wx.EXPAND|wx.ALL, 5) + sizer.Add(line, 0, wx.EXPAND) + sizer.Add(panel, 1, wx.EXPAND|wx.ALL, 5) + + self.SetSizer(sizer) + self.SetAutoLayout(True) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wxXmlResourceSubclass

+ +Sometimes it is necessary to use custom classes, but you still want +them to be created from XRC. The subclass XRC attribute allows you to +do that. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) + diff --git a/wxPython/demo/pyfiles.tgz b/wxPython/demo/pyfiles.tgz new file mode 100644 index 0000000000..3ce3fd61ff Binary files /dev/null and b/wxPython/demo/pyfiles.tgz differ diff --git a/wxPython/demo/wxArtProvider.py b/wxPython/demo/wxArtProvider.py deleted file mode 100644 index 02b326680e..0000000000 --- a/wxPython/demo/wxArtProvider.py +++ /dev/null @@ -1,859 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import cStringIO -import wx - -#---------------------------------------------------------------------- - -ArtClients = [ "wx.ART_TOOLBAR", - "wx.ART_MENU", - "wx.ART_FRAME_ICON", - "wx.ART_CMN_DIALOG", - "wx.ART_HELP_BROWSER", - "wx.ART_MESSAGE_BOX", - "wx.ART_OTHER", - ] - -ArtIDs = [ "wx.ART_ADD_BOOKMARK", - "wx.ART_DEL_BOOKMARK", - "wx.ART_HELP_SIDE_PANEL", - "wx.ART_HELP_SETTINGS", - "wx.ART_HELP_BOOK", - "wx.ART_HELP_FOLDER", - "wx.ART_HELP_PAGE", - "wx.ART_GO_BACK", - "wx.ART_GO_FORWARD", - "wx.ART_GO_UP", - "wx.ART_GO_DOWN", - "wx.ART_GO_TO_PARENT", - "wx.ART_GO_HOME", - "wx.ART_FILE_OPEN", - "wx.ART_PRINT", - "wx.ART_HELP", - "wx.ART_TIP", - "wx.ART_REPORT_VIEW", - "wx.ART_LIST_VIEW", - "wx.ART_NEW_DIR", - "wx.ART_FOLDER", - "wx.ART_GO_DIR_UP", - "wx.ART_EXECUTABLE_FILE", - "wx.ART_NORMAL_FILE", - "wx.ART_TICK_MARK", - "wx.ART_CROSS_MARK", - "wx.ART_ERROR", - "wx.ART_QUESTION", - "wx.ART_WARNING", - "wx.ART_INFORMATION", - ] - - -#---------------------------------------------------------------------- - -class MyArtProvider(wx.ArtProvider): - def __init__(self, log): - wx.ArtProvider.__init__(self) - self.log = log - - def CreateBitmap(self, artid, client, size): - # You can do anything here you want, such as using the same - # image for any size, any client, etc., or using specific - # images for specific sizes, whatever... - - # See end of file for the image data - - bmp = wx.NullBitmap - # use this one for all 48x48 images - if size.width == 48: - bmp = makeBitmap(smile48_png) - - # but be more specific for these - elif size.width == 16 and artid == wx.ART_ADD_BOOKMARK: - bmp = makeBitmap(smile16_png) - elif size.width == 32 and artid == wx.ART_ADD_BOOKMARK: - bmp = makeBitmap(smile32_png) - - # and just ignore the size for these - elif artid == wx.ART_GO_BACK: - bmp = makeBitmap(left_png) - elif artid == wx.ART_GO_FORWARD: - bmp = makeBitmap(right_png) - elif artid == wx.ART_GO_UP: - bmp = makeBitmap(up_png) - elif artid == wx.ART_GO_DOWN: - bmp = makeBitmap(down_png) - elif artid == wx.ART_GO_TO_PARENT: - bmp = makeBitmap(back_png) - - elif artid == wx.ART_CROSS_MARK: - bmp = makeBitmap(cross_png) - elif artid == wx.ART_TICK_MARK: - bmp = makeBitmap(tick_png) - - if bmp.Ok(): - self.log.write("MyArtProvider: providing %s:%s at %s\n" %(artid, client, size)) - return bmp - - - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - sizer = wx.BoxSizer(wx.VERTICAL) - - title = wx.StaticText(self, -1, "ArtProvider") - title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) - sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) - sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - - fgs = wx.FlexGridSizer(0, 3, 10, 10) - - combo = wx.ComboBox(self, -1, "", choices = ArtClients, - style = wx.CB_DROPDOWN|wx.CB_READONLY) - fgs.Add(combo, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - self.Bind(wx.EVT_COMBOBOX, self.OnSelectClient, combo) - combo.Select(0) - - combo = wx.ComboBox(self, -1, "", choices = ArtIDs, - style = wx.CB_DROPDOWN|wx.CB_READONLY) - fgs.Add(combo, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - self.Bind(wx.EVT_COMBOBOX, self.OnSelectID, combo) - combo.Select(0) - - cb = wx.CheckBox(self, -1, "Use custom provider") - fgs.Add(cb, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - self.Bind(wx.EVT_CHECKBOX, self.OnUseCustom, cb) - - fgs.Add((10, 10), 0, wx.ALIGN_CENTRE|wx.ALL, 5) - fgs.Add((10, 10), 0, wx.ALIGN_CENTRE|wx.ALL, 5) - fgs.Add((10, 10), 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - box = wx.BoxSizer(wx.VERTICAL) - bmp = wx.EmptyBitmap(16,16) - self.bmp16 = wx.StaticBitmap(self, -1, bmp) - box.Add(self.bmp16, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - text = wx.StaticText(self, -1, "16x16") - box.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - fgs.Add(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - box = wx.BoxSizer(wx.VERTICAL) - bmp = wx.EmptyBitmap(32,32) - self.bmp32 = wx.StaticBitmap(self, -1, bmp) - box.Add(self.bmp32, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - text = wx.StaticText(self, -1, "32x32") - box.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - fgs.Add(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - box = wx.BoxSizer(wx.VERTICAL) - bmp = wx.EmptyBitmap(48,48) - self.bmp48 = wx.StaticBitmap(self, -1, bmp) - box.Add(self.bmp48, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - text = wx.StaticText(self, -1, "48x48") - box.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - fgs.AddSizer(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - sizer.Add(fgs, 0, wx.ALL, 5) - self.SetSizer(sizer) - - self.client = eval(ArtClients[0]) - self.artid = eval(ArtIDs[0]) - self.getArt() - - - def OnSelectClient(self, evt): - self.log.write("OnSelectClient\n") - self.client = eval(evt.GetString()) - self.getArt() - - - def OnSelectID(self, evt): - self.log.write("OnSelectID\n") - self.artid = eval(evt.GetString()) - self.getArt() - - - def OnUseCustom(self, evt): - if evt.IsChecked(): - self.log.write("Images will now be provided by MyArtProvider\n") - wx.ArtProvider_PushProvider( MyArtProvider(self.log) ) - else: - self.log.write("MyArtProvider deactivated\n") - wx.ArtProvider_PopProvider() - self.getArt() - - - def getArt(self): - self.log.write("Getting art for %s:%s\n" % (self.client, self.artid)) - - bmp = wx.ArtProvider_GetBitmap(self.artid, self.client, (16,16)) - - if not bmp.Ok(): - bmp = wxEmptyBitmap(16,16) - - self.bmp16.SetBitmap(bmp) - - bmp = wx.ArtProvider_GetBitmap(self.artid, self.client, (32,32)) - - if not bmp.Ok(): - bmp = wxEmptyBitmap(32,32) - - self.bmp32.SetBitmap(bmp) - - bmp = wx.ArtProvider_GetBitmap(self.artid, self.client, (48,48)) - - if not bmp.Ok(): - bmp = wxEmptyBitmap(48,48) - - self.bmp48.SetBitmap(bmp) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """ -

wxArtProvider

- -wxArtProvider class can be used to customize the look of wxWindows -applications. When wxWindows internal classes need to display an icon -or a bitmap (e.g. in the standard file dialog), it does not use a -hard-coded resource but asks wxArtProvider for it instead. This way -the users can plug in their own wxArtProvider class and easily replace -standard art with his/her own version. It is easy thing to do: all -that is needed is to derive a class from wxArtProvider, override it's -CreateBitmap method and register the provider with -wxArtProvider_PushProvider. -

- -This class can also be used to get the platform native icons as -provided by wxArtProvider_GetBitmap or wxArtProvider_GetIcon methods. - - -""" - - -#---------------------------------------------------------------------- -# Image data - - -def makeBitmap(data): - stream = cStringIO.StringIO(data) - return wx.BitmapFromImage(wx.ImageFromStream(stream)) - - -back_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ -\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x07YID\ -ATx\x9c\xa5\x97Ml\x9dG\x15\x86\x9fsf\xbe\xef^\xfb:\xaeS\xd7\xa9\x1d;!IK)\xfd\ -A\x05\x95BQ\xc5\xdf\x02\xb1(\x12\x0b\x10\x8b\x8a\x05]Vl\xd8\xb2`\xcb\x92\xee\ -Q\x85\xd8U\xaa\xba\x03\tD+@j\x91J\x11\x8aT\xd14\xfd\xa7\xf9q\x9a\xc6\x8e\xe3\ -\xd8\xb1\xefwg\xcea1s\xaf\x13;\xaa*1\xd2h4su\xe7=\xe7\xcc{\xdes>\x99\x9b\x9b\ -\x03\xe0\xf9\x17\xff\xe2[\xb6B;u\'\x86`\x19\x9299Ar\xc8\x19\xb29\xd9 \xe5\ -\xb2O\x069\x97\xb3\x03{\x1b\xff\xa7\x9c\xa5zf\xe6,\x1e\xda\xe0\xe1\xe5U\xe6g\ -\xb6\x91\xb9\xb99~\xf7\xc2i\x1f\xcc-3\xdd\x8f\xe5r\x83Q\x86\x94\xa0K\x05p\ -\xbc\x1f\xe5\xba\xff?\xcf{\xb1\xe3;_x\x17\xf9\xd3\xcb\xaf\xbb\xce>\xc2\xcctd\ -\x94*x\xca\\\xdb\xd8\xe2Fg\x98\x0b\x96\x95l\xc2\xc8 \xbb\xe0Y\xc8&\xd5+!eadB\ -JBv\xa9`R\xef\x12FYH\x19\xcc\x84.\xcb\xc4\xb0\xa5\xd9k\xc4-[f\xb1_\xc0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97\xce(\x9e\xbck\x8d\x85\x99M\xce_\xbdc\ -\x12\x85\x11\xb1\xf6\xed%2f`\xa9#\xe5\x8e\x9c\x129\x15\x02y\x1eb\xb5\xa8\x94\ -\x0e\xa7+\nge?>/kWz\x00\xebp7<\x0f9yr\x19\xfd\xc9\x8f\x9e\x94o}\xfe=\xee]\ -\xf8\x04%\x17A\x1aW\xc7}_\xb5\xd9J+\xfd\xa9\xc3\r\xb7\\V\xb7\xc9\xea\x9e\x8b\ -b\xba!\x18G\x97\xe6\xf9\xc1\xb7\x97\xf9\x1f\x92tznH\x8fy\x14\x00\x00\x00\x00\ -IEND\xaeB`\x82' - -down_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ -\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x042ID\ -ATx\x9c\xa5\xd5Ko\x1bU\x14\xc0\xf1\xff\x8c\xe7\xe1g\xe2\xa6\x84\xa8\xa8\x82\ -\xd0\x88E\xabJ\x08\t\x8a*\xb1@\x02v\xec@l`\x87\xf8\x1e\x91\xf8\x06 \x90\xd8\ -\xb3\xe2S\xb0aS\x1ej\x8bhIe\xd2\xa8i\xa8\x13\xc7\x8f\xda\xe3\x99\xb93\xf7\ -\xcee1\x1e\xc7\xae\xed\xc4c\x16Wc\xddk\xfbw\xce\xf1\xf1\xb9\xc6\x0fw\xb5\xfe\ -h\x1b\x02\t\x91\x02\xa1 N&^+\x88\x12\x08%\x08\x99\xeeE\xa3\xf3l\t\x05~\x9c>\ -\xc3\xd1^(\'>7:\x7fqOH0\x13\r\x00\xa6\x91\xae\x82\x01F\xba5~\xca\x04\x94\x86\ -db\xa9\xd1\x92I\x1a|\x16t<\x91\x84\x18%\x15\xc4g\x81\x87Y\xa2\x12\x94R\x98J\ -\x8f\x0e\'\xb2\x11\nNzC\xfex\xb0\x8f\x17\xeb\xf4|"\xfb\xec\xfdB\x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\xd1\xf1\xfd\x87\x8cJ\xda\ -<\xae<\xe4\xf6\xe2\x1dV*5\\P`\xfed\x99s\xf3\x11\xfe\x1boq\xf3\xef\xbfp\x92\r\ -\xf3\x81T\x86\x1f\x0c/\x8a\x8fn\xb5\\r\x96\x97n\xb3\xbc\xf0\x0f\xbf\xcf\x9d\ -\xe4\xbb\xab\xdfr\xf1\xb3\x0f\x98?\xfd6[\x8f\xee\xf7\xda+\xbc\xf3\xbf9\xa7\ -\xed\xcb\xc5\'\xadvDQ\x08}\xf2N\x0b\'\xe9\xf8\x1a\xd8\xff\xb9\xf4*p\'\n\x95\ -\xa9\xc1\x93\x0f\xce\x81\xd7\x85\x0f\xdb\xef;\x07\x8e\x13w\xa2\xf0\x8f\x13G\ -\x14\xff\x03\xe8\x84\x1b+\xdf\xf26\x9e\x00\x00\x00\x00IEND\xaeB`\x82' - -right_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ -\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\nI\ -DATx\x9c\xc5\x96Ko\x1bU\x14\xc7\x7f\xf3\xb4=&\xd4mQ_H\xd0"\xdaD,\xda\x8aR\nB\ -\xa8\xb0a\x83\xc4\x82\r{>\x01_\x00\xa9;>\x04\x0b\xb6,\xd9\xb0fQ@\x08\x81BU\ -\x92\xaa\xa1\xa5\x0f\xbbQ\x12\'c{\xecy\xdf\x07\x8b\xf1\xb86u\x9c\xa4I\x95\ -\xd5\x9ds\xe6\xce\xfd\x9d9\xf7\x9c\xff\xbdF\xa3\xd1\xe0\xbb\xdf;:S \x15\xe4\ -\n\xa4\x06!Ah\x10C\x7f\xaa \x97O\xe7\x08]\xd8\xb9*\xe6\xc4\xa2\xb0\xb3\xe1\ -\xfbT\x0emY<\xc7\xa2\x18K;\x93\x90\x08\xb0\xbf\xf9\xa9\xa3/\x9dx\xea,\'\x8c\ -\x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\xd7\xe9\xfd\xfd\x1dWWW\ -\xda\xed\xb5`\x1d\x1d\x1dp\xbb\xdd\xb0\xdb\xed\xc2\x0f\xcbw\xac\xecB\x12\x89\ -D(\x1a\x8d\xe2\xe4\xe4\x04\xb9\\\x0e\x8c1X,\x16\xf8|>\xac\xae\xae\xea\x06\ -\x16\n\x00\x80\xdd\xdd]\xba\xbd\xbdE&\x93A{{;\xfa\xfb\xfb1;;\xab;\\(\xe0\'\ -\xed\xf7\xfd\x9c~\xb5\xbf\x8a\xf3q\xb2q\x86\xa0|\x00\x00\x00\x00IEND\xaeB`\ -\x82' - - -cross_png = \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ -\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x03\ -\x9fIDATx\x9c\xc5\x97OH*_\x14\xc7\xbfW~\x82\x8c\x19Sh\xc2\x80\x8b\xfe\x10\ -\x04A\x90P.\x84(r\x13ER\x14\x11\x18A\x11\x14\xba0\n\x83B\xa1\x90\\\x88\xa5\ -\x05\xe5B\x11%7\x89\x14B\x08\xc2\xac\xda\xb6\x88V\xd12\xb0M\xb4jWx\xde\xe2a<\ -_3\xe3(\xef\xf7\xde\x81\xb3P\xef9\xdf\xcf\x9d+\xdfs\x87\xf1<\x8f\x7f\x19\x9a\ -\x7f\xaa\xfe7\x01\x82\xc1 \xcd\xcf\xcfS<\x1e\xa7_\xbfg\xf5\x8e \x9dNSKK\x0bf\ -ffX3\xc2\xc9d\x92r\xb9\x1c\x8a\xc5"\xde\xde\xde044\x84\xbd\xbd=,--1Y\x80t:M\ -\x8c1\xdc\xde\xde\xe2\xea\xea\n\x13\x13\x13\x98\x9a\x9aj\x18\xe2\xf0\xf0\x90\ -\xe2\xf18\xee\xef\xefA\xf4s\xe3Z\xad\x16\xa3\xa3\xa3\xb0\xdb\xed\xb0\xdb\xed\ -\x00\xcf\xf35y||L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xbe\xaez\x16|]H.//\xe9\xe5\xe5\x05\x8f\x8f\x8f8::\x02\x00loo#\x1a\ -\x8d6\xf5F\xd40@5\xf2\xf9<\xdd\xdd\xdd\x01\x00\xacVk\xd3\xafdM\x03\xfc\xed\ -\xf8\x01\xe9\t\x94\x8c\xa7\xf9\xf9<\x00\x00\x00\x00IEND\xaeB`\x82' - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - - - diff --git a/wxPython/demo/wxButton.py b/wxPython/demo/wxButton.py deleted file mode 100644 index 039ff89e4b..0000000000 --- a/wxPython/demo/wxButton.py +++ /dev/null @@ -1,81 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import images - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1, - style=wx.NO_FULL_REPAINT_ON_RESIZE) - self.log = log - - b = wx.Button(self, 10, "Default Button", (20, 20)) - self.Bind(wx.EVT_BUTTON, self.OnClick, b) - b.SetDefault() - b.SetSize(b.GetBestSize()) - - b = wx.Button(self, 20, "HELLO AGAIN!", (20, 80), (120, 45)) - self.Bind(wx.EVT_BUTTON, self.OnClick, b) - b.SetToolTipString("This is a Hello button...") - - if 0: # a test case for catching wx.PyAssertionError - - #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS) - #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION) - #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG) - #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG) - - try: - bmp = wx.Bitmap("nosuchfile.bmp", wx.BITMAP_TYPE_BMP) - mask = wx.MaskColour(bmp, wx.BLUE) - except wx.PyAssertionError: - self.log.write("Caught wx.PyAssertionError! I will fix the problem.\n") - bmp = images.getTest2Bitmap() - mask = wx.MaskColour(bmp, wx.BLUE) - else: - bmp = images.getTest2Bitmap() - mask = wx.MaskColour(bmp, wx.BLUE) - - bmp.SetMask(mask) - wx.BitmapButton(self, 30, bmp, (160, 20), - (bmp.GetWidth()+10, bmp.GetHeight()+10)) - self.Bind(wx.EVT_BUTTON, self.OnClick, id=30) - - - def OnClick(self, event): - self.log.write("Click! (%d)\n" % event.GetId()) - ##wxLogDebug("debug message") - - -## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """ -

Button

- -A button is a control that contains a text string or a bitmap and can be -placed on nearly any kind of window. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxCalendar.py b/wxPython/demo/wxCalendar.py deleted file mode 100644 index d9134beb5d..0000000000 --- a/wxPython/demo/wxCalendar.py +++ /dev/null @@ -1,684 +0,0 @@ -#---------------------------------------------------------------------------- -# Name: wxCalendar.py -# Purpose: Calendar control display testing on panel for wxPython demo -# -# Author: Lorne White (email: lwhite1@planet.eon.net) -# -# Version 0.9 -# Date: Feb 26, 2001 -# Licence: wxWindows license -#---------------------------------------------------------------------------- -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Some updating of the library itself will be needed for this demo to work -# correctly. -# -# 11/26/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Problems have changed a little. The print dialog requires -# a wx.Size to work with the calendar library. wx.core doesn't -# approve, though, so we get deprecation warnings. -# o Ugh. AFter updating to the Bind() method, things lock up -# on various control clicks. Will have to debug. Only seems -# to happen on windows with calendar controls, though. -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Lockup issue clarification: it appears that the spinner is -# the culprit. -# -# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o New Bind() method now fully supported. -# -# 12/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxCalendar renamed to Calendar -# o Got rid of unneeded IDs where Bind() could figure it -# out for itself. -# - -import os - -import wx -import wx.lib.calendar - -import images - - -# highlighted days in month - -test_days ={ 0: [], - 1: [3, 7, 9, 21], - 2: [2, 10, 4, 9], - 3: [4, 20, 29], - 4: [1, 12, 22], - 5: [2, 10, 15], - 6: [4, 8, 17], - 7: [6, 7, 8], - 8: [5, 10, 20], - 9: [1, 2, 5, 29], - 10: [2, 4, 6, 22], - 11: [6, 9, 12, 28, 29], - 12: [8, 9, 10, 11, 20] } - -# test of full window calendar control functions - -def GetMonthList(): - - monthlist = [] - - for i in range(13): - name = wx.lib.calendar.Month[i] - - if name != None: - monthlist.append(name) - - return monthlist - -class TestPanel(wx.Panel): - def __init__(self, parent, log, frame): - wx.Panel.__init__(self, parent, -1) - - self.log = log - self.frame = frame - - self.calend = wx.lib.calendar.Calendar(self, -1, (100, 50), (200, 180)) - -# start_month = 2 # preselect the date for calendar -# start_year = 2001 - - start_month = self.calend.GetMonth() # get the current month & year - start_year = self.calend.GetYear() - - # month list from DateTime module - - monthlist = GetMonthList() - - self.date = wx.ComboBox(self, -1, "", - (100, 20), (90, -1), - monthlist, wx.CB_DROPDOWN) - - self.date.SetSelection(start_month-1) - self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, self.date) - - # set start month and year - - self.calend.SetMonth(start_month) - self.calend.SetYear(start_year) - - # set attributes of calendar - - self.calend.hide_title = True - self.calend.HideGrid() - self.calend.SetWeekColor('WHITE', 'BLACK') - - # display routine - - self.ResetDisplay() - - # mouse click event - self.Bind(wx.lib.calendar.EVT_CALENDAR, self.MouseClick, self.calend) - - # scroll bar for month selection - self.scroll = wx.ScrollBar(self, -1, (100, 240), (200, 20), wx.SB_HORIZONTAL) - self.scroll.SetScrollbar(start_month-1, 1, 12, 1, True) - self.Bind(wx.EVT_COMMAND_SCROLL, self.Scroll, self.scroll) - - # spin control for year selection - - self.dtext = wx.TextCtrl(self, -1, str(start_year), (200, 20), (60, -1)) - h = self.dtext.GetSize().height - - self.spin = wx.SpinButton(self, -1, (270, 20), (h*2, h)) - self.spin.SetRange(1980, 2010) - self.spin.SetValue(start_year) - self.Bind(wx.EVT_SPIN, self.OnSpin, self.spin) - - # button for calendar dialog test - - wx.StaticText(self, -1, "Test Calendar Dialog", (350, 50), (150, -1)) - - bmp = images.getCalendarBitmap() - self.but1 = wx.BitmapButton(self, -1, bmp, (380, 80)) - self.Bind(wx.EVT_BUTTON, self.TestDlg, self.but1) - - # button for calendar window test - - wx.StaticText(self, -1, "Test Calendar Window", (350, 150), (150, -1)) - - self.but2 = wx.BitmapButton(self, -1, bmp, (380, 180)) - self.Bind(wx.EVT_BUTTON, self.TestFrame, self.but2) - - wx.StaticText(self, -1, "Test Calendar Print", (350, 250), (150, -1)) - - self.but3 = wx.BitmapButton(self, -1, bmp, (380, 280)) - self.Bind(wx.EVT_BUTTON, self.OnPreview, self.but3) - - # calendar dialog - - def TestDlg(self, event): # test the date dialog - dlg = wx.lib.calendar.CalenDlg(self) - dlg.Centre() - - if dlg.ShowModal() == wx.ID_OK: - result = dlg.result - day = result[1] - month = result[2] - year = result[3] - new_date = str(month) + '/'+ str(day) + '/'+ str(year) - self.log.WriteText('Date Selected: %s\n' % new_date) - else: - self.log.WriteText('No Date Selected') - - # calendar window test - - def TestFrame(self, event): - frame = CalendFrame(self, -1, "Test Calendar", self.log) - frame.Show(True) - return True - - # calendar print preview - - def OnPreview(self, event): - month = self.calend.GetMonth() - year = self.calend.GetYear() - - prt = PrintCalend(self.frame, month, year) - prt.Preview() - - # month and year control events - - def OnSpin(self, event): - year = event.GetPosition() - self.dtext.SetValue(str(year)) - self.calend.SetYear(year) - self.calend.Refresh() - - def EvtComboBox(self, event): - name = event.GetString() - self.log.WriteText('EvtComboBox: %s\n' % name) - monthval = self.date.FindString(name) - self.scroll.SetScrollbar(monthval, 1, 12, 1, True) - - self.calend.SetMonth(monthval+1) - self.ResetDisplay() - - def Scroll(self, event): - value = self.scroll.GetThumbPosition() - monthval = int(value)+1 - self.calend.SetMonth(monthval) - self.ResetDisplay() - self.log.WriteText('Month: %s\n' % value) - - name = wx.lib.calendar.Month[monthval] - self.date.SetValue(name) - - # log mouse events - - def MouseClick(self, evt): - text = '%s CLICK %02d/%02d/%d' % (evt.click, evt.day, evt.month, evt.year) # format date - self.log.WriteText('Date Selected: ' + text + '\n') - - - # set the highlighted days for the calendar - - def ResetDisplay(self): - month = self.calend.GetMonth() - - try: - set_days = test_days[month] - except: - set_days = [1, 5, 12] - - self.calend.AddSelect([4, 11], 'BLUE', 'WHITE') - self.calend.SetSelDay(set_days) - self.calend.Refresh() - - # increment and decrement toolbar controls - - def OnIncYear(self, event): - self.calend.IncYear() - self.ResetDisplay() - - def OnDecYear(self, event): - self.calend.DecYear() - self.ResetDisplay() - - def OnIncMonth(self, event): - self.calend.IncMonth() - self.ResetDisplay() - - def OnDecMonth(self, event): - self.calend.DecMonth() - self.ResetDisplay() - - def OnCurrent(self, event): - self.calend.SetCurrentDay() - self.ResetDisplay() - -# test of full window calendar control functions - -class CalendFrame(wx.Frame): - def __init__(self, parent, id, title, log): - wx.Frame.__init__(self, parent, id, title, size=(400, 400), - style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE) - - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - - self.log = log - self.CreateStatusBar() - self.mainmenu = wx.MenuBar() - menu = wx.Menu() - - menu = self.MakeFileMenu() - self.mainmenu.Append(menu, '&File') - - self.MakeToolMenu() # toolbar - - self.SetMenuBar(self.mainmenu) - self.calend = wx.lib.calendar.Calendar(self, -1) - self.calend.SetCurrentDay() - self.calend.grid_color = 'BLUE' - self.calend.SetBusType() -# self.calend.ShowWeekEnd() - - self.ResetDisplay() - - self.Bind(wx.lib.calendar.EVT_CALENDAR, self.MouseClick, self.calend) - - def MouseClick(self, evt): - text = '%s CLICK %02d/%02d/%d' % (evt.click, evt.day, evt.month, evt.year) # format date - self.log.WriteText('Date Selected: ' + text + '\n') - - def OnCloseWindow(self, event): - self.Destroy() - - def ResetDisplay(self): - month = self.calend.GetMonth() - - try: - set_days = test_days[month] - except: - set_days = [1, 5, 12] - - self.calend.AddSelect([2, 16], 'GREEN', 'WHITE') - - self.calend.SetSelDay(set_days) - self.calend.Refresh() - - def OnIncYear(self, event): - self.calend.IncYear() - self.ResetDisplay() - - def OnDecYear(self, event): - self.calend.DecYear() - self.ResetDisplay() - - def OnIncMonth(self, event): - self.calend.IncMonth() - self.ResetDisplay() - - def OnDecMonth(self, event): - self.calend.DecMonth() - self.ResetDisplay() - - def OnCurrent(self, event): - self.calend.SetCurrentDay() - self.ResetDisplay() - - def MakeFileMenu(self): - menu = wx.Menu() - - mID = wx.NewId() - menu.Append(mID, 'Decrement', 'Next') - self.Bind(wx.EVT_MENU, self.OnDecMonth, id=mID) - - mID = wx.NewId() - menu.Append(mID, 'Increment', 'Dec') - self.Bind(wx.EVT_MENU, self.OnIncMonth, id=mID) - - menu.AppendSeparator() - - mID = wx.NewId() - menu.Append(mID, 'E&xit', 'Exit') - self.Bind(wx.EVT_MENU, self.OnCloseWindow, id=mID) - - return menu - - def MakeToolMenu(self): - tb = self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER) - - mID = wx.NewId() - SetToolPath(self, tb, mID, images.getDbDecBitmap(), 'Dec Year') - self.Bind(wx.EVT_TOOL, self.OnDecYear, id=mID) - - mID = wx.NewId() - SetToolPath(self, tb, mID, images.getDecBitmap(), 'Dec Month') - self.Bind(wx.EVT_TOOL, self.OnDecMonth, id=mID) - - mID = wx.NewId() - SetToolPath(self, tb, mID, images.getPtBitmap(), 'Current Month') - self.Bind(wx.EVT_TOOL, self.OnCurrent, id=mID) - - mID = wx.NewId() - SetToolPath(self, tb, mID, images.getIncBitmap(), 'Inc Month') - self.Bind(wx.EVT_TOOL, self.OnIncMonth, id=mID) - - mID = wx.NewId() - SetToolPath(self, tb, mID, images.getDbIncBitmap(), 'Inc Year') - self.Bind(wx.EVT_TOOL, self.OnIncYear, id=mID) - - tb.Realize() - -#--------------------------------------------------------------------------- - -# example class for printing/previewing calendars - -class PrintCalend: - def __init__(self, parent, month, year): - self.frame = parent - self.month = month - self.year = year - - self.SetParms() - self.SetCal() - self.printData = wx.PrintData() - - def SetCal(self): - self.grid_color = 'BLUE' - self.back_color = 'WHITE' - self.sel_color = 'RED' - self.high_color = 'LIGHT BLUE' - self.font = wx.SWISS - self.bold = wx.NORMAL - - self.sel_key = None # last used by - self.sel_lst = [] # highlighted selected days - - self.size = None - self.hide_title = False - self.hide_grid = False - self.set_day = None - - def SetParms(self): - self.ymax = 1 - self.xmax = 1 - self.page = 1 - self.total_pg = 1 - - self.preview = None - self.scale = 1.0 - - self.pagew = 8.5 - self.pageh = 11.0 - - self.txt_marg = 0.1 - self.lf_marg = 0 - self.top_marg = 0 - - self.page = 0 - - def SetDates(self, month, year): - self.month = month - self.year = year - - def SetStyleDef(self, desc): - self.style = desc - - def SetCopies(self, copies): # number of copies of label - self.copies = copies - - def SetStart(self, start): # start position of label - self.start = start - - def Preview(self): - printout = SetPrintout(self) - printout2 = SetPrintout(self) - self.preview = wx.PrintPreview(printout, printout2, self.printData) - - if not self.preview.Ok(): - wx.MessageBox("There was a problem printing!", "Printing", wx.OK) - return - - self.preview.SetZoom(60) # initial zoom value - - frame = wx.PreviewFrame(self.preview, self.frame, "Print preview") - - frame.Initialize() - frame.SetPosition(self.frame.GetPosition()) - frame.SetSize(self.frame.GetSize()) - frame.Show(True) - - def Print(self): - pdd = wx.PrintDialogData() - pdd.SetPrintData(self.printData) - printer = wx.Printer(pdd) - printout = SetPrintout(self) - frame = wx.Frame(None, -1, "Test") - - if not printer.Print(frame, printout): - wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK) - else: - self.printData = printer.GetPrintDialogData().GetPrintData() - - printout.Destroy() - - def DoDrawing(self, DC): - size = DC.GetSize() - DC.BeginDrawing() - - cal = wx.lib.calendar.PrtCalDraw(self) - - if self.preview is None: - cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh) - cal.SetPreview(False) - - else: - if self.preview == 1: - cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh) - else: - cal.SetPSize(self.pwidth, self.pheight) - - cal.SetPreview(self.preview) - - cal.hide_title = self.hide_title # set the calendar parameters - cal.hide_grid = self.hide_grid - - cal.grid_color = self.grid_color - cal.high_color = self.high_color - cal.back_color = self.back_color - cal.outer_border = False - cal.font = self.font - cal.bold = self.bold - - cal_size = (3.0, 3.0) - cal.SetSize(cal_size) - - year, month = self.year, self.month - - x = 0.5 - for i in range(2): - y = 0.5 - - for j in range(3): - cal.SetCal(year, month) # current month - cal.SetPos(x, y) - - try: - set_days = test_days[month] - except: - set_days = [1, 5, 12] - - cal.AddSelect([2, 16], 'GREEN', 'WHITE') - - cal.DrawCal(DC, set_days) - - year, month = self.IncMonth(year, month) - y = y + 3.5 - - x = x + 4.0 # next column - - DC.EndDrawing() - - self.ymax = DC.MaxY() - self.xmax = DC.MaxX() - - def IncMonth(self, year, month): # next month - month = month + 1 - - if month > 12: - month = 1 - year = year + 1 - - return year, month - - def GetTotalPages(self): - self.pg_cnt = 1 - return self.pg_cnt - - def SetPage(self, page): - self.page = page - - def SetPageSize(self, width, height): - self.pwidth, self.pheight = width, height - - def SetTotalSize(self, width, height): - self.ptwidth, self.ptheight = width, height - - def SetPreview(self, preview, scale): - self.preview = preview - self.scale = scale - - def SetTotalSize(self, width, height): - self.ptwidth = width - self.ptheight = height - -def SetToolPath(self, tb, id, bmp, title): - tb.AddSimpleTool(id, bmp, title, title) - -class SetPrintout(wx.Printout): - def __init__(self, canvas): - wx.Printout.__init__(self) - self.canvas = canvas - self.end_pg = 1 - - def OnBeginDocument(self, start, end): - return self.base_OnBeginDocument(start, end) - - def OnEndDocument(self): - self.base_OnEndDocument() - - def HasPage(self, page): - if page <= self.end_pg: - return True - else: - return False - - def GetPageInfo(self): - self.end_pg = self.canvas.GetTotalPages() - str_pg = 1 - - try: - end_pg = self.end_pg - except: - end_pg = 1 - - return (str_pg, end_pg, str_pg, end_pg) - - def OnPreparePrinting(self): - self.base_OnPreparePrinting() - - def OnBeginPrinting(self): - dc = self.GetDC() - - self.preview = self.IsPreview() - - if (self.preview): - self.pixelsPerInch = self.GetPPIScreen() - else: - self.pixelsPerInch = self.GetPPIPrinter() - - (w, h) = dc.GetSize() - scaleX = float(w) / 1000 - scaleY = float(h) / 1000 - self.printUserScale = min(scaleX, scaleY) - - self.base_OnBeginPrinting() - - def GetSize(self): - self.psizew, self.psizeh = self.GetPPIPrinter() - return self.psizew, self.psizeh - - def GetTotalSize(self): - self.ptsizew, self.ptsizeh = self.GetPageSizePixels() - return self.ptsizew, self.ptsizeh - - def OnPrintPage(self, page): - dc = self.GetDC() - (w, h) = dc.GetSize() - scaleX = float(w) / 1000 - scaleY = float(h) / 1000 - self.printUserScale = min(scaleX, scaleY) - dc.SetUserScale(self.printUserScale, self.printUserScale) - - self.preview = self.IsPreview() - - self.canvas.SetPreview(self.preview, self.printUserScale) - self.canvas.SetPage(page) - - self.ptsizew, self.ptsizeh = self.GetPageSizePixels() - self.canvas.SetTotalSize(self.ptsizew, self.ptsizeh) - - self.psizew, self.psizeh = self.GetPPIPrinter() - self.canvas.SetPageSize(self.psizew, self.psizeh) - - self.canvas.DoDrawing(dc) - return True - -class MyApp(wx.App): - def OnInit(self): - frame = CalendFrame(None, -1, "Test Calendar", log) - frame.Show(True) - self.SetTopWindow(frame) - return True - -#--------------------------------------------------------------------------- - -def MessageDlg(self, message, type = 'Message'): - dlg = wx.MessageDialog(self, message, type, wx.OK | wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log, frame) - return win - -#--------------------------------------------------------------------------- - - -overview = """\ -This control provides a Calendar control class for displaying and selecting dates. -In addition, the class is extended and can be used for printing/previewing. - -Additional features include weekend highlighting and business type Monday-Sunday -format. - -See example for various methods used to set display month, year, and highlighted -dates (different font and background colours). - -by Lorne White - -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxCalendarCtrl.py b/wxPython/demo/wxCalendarCtrl.py deleted file mode 100644 index 03fc569b4d..0000000000 --- a/wxPython/demo/wxCalendarCtrl.py +++ /dev/null @@ -1,73 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import wx.lib.calendar as calendar - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, ID, log): - wx.Panel.__init__(self, parent, ID) - self.log = log - - cal = calendar.CalendarCtrl(self, -1, wx.DateTime_Now(), pos = (25,50), - style = calendar.CAL_SHOW_HOLIDAYS - | calendar.CAL_SUNDAY_FIRST - | calendar.CAL_SEQUENTIAL_MONTH_SELECTION - ) - - self.Bind(calendar.EVT_CALENDAR, self.OnCalSelected, id=cal.GetId()) - - b = wx.Button(self, -1, "Destroy the Calendar", pos = (250, 50)) - self.Bind(wx.EVT_BUTTON, self.OnButton, id= b.GetId()) - self.cal = cal - - # Set up control to display a set of holidays: - self.Bind(calendar.EVT_CALENDAR_MONTH, self.OnChangeMonth, id=cal.GetId()) - self.holidays = [(1,1), (10,31), (12,25) ] # (these don't move around) - self.OnChangeMonth() - - def OnButton(self, evt): - self.cal.Destroy() - self.cal = None - - def OnCalSelected(self, evt): - self.log.write('OnCalSelected: %s\n' % evt.GetDate()) - - def OnChangeMonth(self, evt=None): - cur_month = self.cal.GetDate().GetMonth() + 1 # convert wxDateTime 0-11 => 1-12 - - for month, day in self.holidays: - if month == cur_month: - self.cal.SetHoliday(day) - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, -1, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ - -

wxCalendarCtrl

- -Yet another calendar control. This one is a wrapper around the C++ -version described in the docs. This one will probably be a bit more efficient -than the one in wxPython.lib.calendar, but I like a few things about it better, -so I think both will stay in wxPython. -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxCheckBox.py b/wxPython/demo/wxCheckBox.py deleted file mode 100644 index 41fb677987..0000000000 --- a/wxPython/demo/wxCheckBox.py +++ /dev/null @@ -1,53 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class TestCheckBox(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - wx.StaticText(self, -1, "This example uses the wxCheckBox control.", (10, 10)) - - cID = wx.NewId() - cb1 = wx.CheckBox(self, cID, " Apples", (65, 40), (150, 20), wx.NO_BORDER) - cb2 = wx.CheckBox(self, cID+1, " Oranges", (65, 60), (150, 20), wx.NO_BORDER) - cb2.SetValue(True) - cb3 = wx.CheckBox(self, cID+2, " Pears", (65, 80), (150, 20), wx.NO_BORDER) - - self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb1) - self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb2) - self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb3) - - def EvtCheckBox(self, event): - self.log.WriteText('EvtCheckBox: %d\n' % event.IsChecked()) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestCheckBox(nb, log) - return win - -#--------------------------------------------------------------------------- - - - - - -overview = """\ -A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark). - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxCheckListBox.py b/wxPython/demo/wxCheckListBox.py deleted file mode 100644 index ef80a7637b..0000000000 --- a/wxPython/demo/wxCheckListBox.py +++ /dev/null @@ -1,92 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Why is there a popup menu in this demo? -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', - 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', - 'twelve', 'thirteen', 'fourteen'] - - wx.StaticText(self, -1, "This example uses the wxCheckListBox control.", (45, 15)) - - lb = wx.CheckListBox(self, 60, (80, 50), (80, 120), sampleList) - self.Bind(wx.EVT_LISTBOX, self.EvtListBox, id=60) - self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, id=60) - lb.SetSelection(0) - self.lb = lb - - pos = lb.GetPosition().x + lb.GetSize().width + 25 - btn = wx.Button(self, -1, "Test SetString", (pos, 50)) - self.Bind(wx.EVT_BUTTON, self.OnTestButton, id=btn.GetId()) - self.Bind(wx.EVT_RIGHT_UP, self.OnDoPopup) - - def EvtListBox(self, event): - self.log.WriteText('EvtListBox: %s\n' % event.GetString()) - - def EvtListBoxDClick(self, event): - self.log.WriteText('EvtListBoxDClick:\n') - - def OnTestButton(self, evt): - self.lb.SetString(4, "FUBAR") - - - def OnDoPopup(self, evt): - menu = wx.Menu() - # Make this first item bold - item = wx.MenuItem(menu, wx.NewId(), "If supported, this is bold") - df = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) - - nf = wx.Font( - df.GetPointSize(), df.GetFamily(), df.GetStyle(), - wx.BOLD, False, df.GetFaceName() - ) - - item.SetFont(nf) - menu.AppendItem(item) - - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &1")) - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &2")) - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &3")) - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &4")) - - self.PopupMenu(menu, evt.GetPosition()) - menu.Destroy() - evt.Skip() - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -A checklistbox is like a Listbox, but allows items to be checked or unchecked rather -than relying on extended selection (e.g. shift-select) to select multiple items in -the list. - -This class is currently implemented under Windows and GTK. - -This demo shows the basic CheckListBox and how to use the SetString method to change -labels dynamically. -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxChoice.py b/wxPython/demo/wxChoice.py deleted file mode 100644 index 39e2db847a..0000000000 --- a/wxPython/demo/wxChoice.py +++ /dev/null @@ -1,60 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class TestChoice(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', - 'six', 'seven', 'eight'] - - wx.StaticText(self, -1, "This example uses the wxChoice control.", (15, 10)) - wx.StaticText(self, -1, "Select one:", (15, 50), (75, 20)) - self.ch = wx.Choice(self, -1, (80, 50), choices = sampleList) - self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch) - - - def EvtChoice(self, event): - self.log.WriteText('EvtChoice: %s\n' % event.GetString()) - self.ch.Append("A new item") - - if event.GetString() == 'one': - self.log.WriteText('Well done!\n') - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestChoice(nb, log) - return win - -#--------------------------------------------------------------------------- - -overview = """ -A Choice control is used to select one of a list of strings. Unlike a listbox, -only the current selection is visible until the user pulls down the menu of -choices. - -This demo illustrates how to set up the Choice control and how to extract the -selected choice once it is selected. - -Note that the syntax of the constructor is different than the C++ implementation. -The number of choices and the choice array are consilidated into one python -list. -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxColourDialog.py b/wxPython/demo/wxColourDialog.py deleted file mode 100644 index be0fc703d4..0000000000 --- a/wxPython/demo/wxColourDialog.py +++ /dev/null @@ -1,59 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - dlg = wx.ColourDialog(frame) - - # Ensure the full colour dialog is displayed, - # not the abbreviated version. - dlg.GetColourData().SetChooseFull(True) - - if dlg.ShowModal() == wx.ID_OK: - - # If the user selected OK, then the dialog's wx.ColourData will - # contain valid information. Fetch the data ... - data = dlg.GetColourData() - - # ... then do something with it. The actual colour data will be - # returned as a three-tuple (r, g, b) in this particular case. - log.WriteText('You selected: %s\n' % str(data.GetColour().Get())) - - # Once the dialog is destroyed, Mr. wx.ColourData is no longer your - # friend. Don't use it again! - dlg.Destroy() - -#--------------------------------------------------------------------------- - - -overview = """\ -This class represents the colour chooser dialog. - -Use of this dialog is a multi-stage process. - -The actual information about how to display the dialog and the colors in the -dialog's 'registers' are contained in a wx.ColourData instance that is created by -the dialog at init time. Before displaying the dialog, you may alter these settings -to suit your needs. In the example, we set the dialog up to show the extended colour -data selection pane. Otherwise, only the more compact and less extensive colour -dialog is shown. You may also preset the colour as well as other items. - -If the user selects something and selects OK, then the wxColourData instance contains -the colour data that the user selected. Before destroying the dialog, retrieve the data. -Do not try to retain the wx.ColourData instance. It will probably not be valid -after the dialog is destroyed. - -Along with he wxColourDialog documentation, see also the wx.ColourData documentation -for details. -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxComboBox.py b/wxPython/demo/wxComboBox.py deleted file mode 100644 index eb995d51a5..0000000000 --- a/wxPython/demo/wxComboBox.py +++ /dev/null @@ -1,115 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class TestComboBox(wx.Panel): - def OnSetFocus(self, evt): - print "OnSetFocus" - evt.Skip() - - def OnKillFocus(self, evt): - print "OnKillFocus" - evt.Skip() - - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', - #'this is a long item that needs a scrollbar...', - 'six', 'seven', 'eight'] - - wx.StaticText(self, -1, "This example uses the wxComboBox control.", (8, 10)) - wx.StaticText(self, -1, "Select one:", (15, 50), (75, 18)) - - # This combobox is created with a preset list of values. - cb = wx.ComboBox( - self, 500, "default value", (90, 50), - (95, -1), sampleList, wx.CB_DROPDOWN #|wxTE_PROCESS_ENTER - ) - - ##import win32api, win32con - ##win32api.SendMessage(cb.GetHandle(), - ## win32con.CB_SETHORIZONTALEXTENT, - ## 200, 0) - - self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, cb) - self.Bind(wx.EVT_TEXT, self.EvtText, cb) - self.Bind(wx.EVT_TEXT_ENTER, self.EvtTextEnter, cb) - cb.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) - cb.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) - - # Once the combobox is set up, we append some more data to it. - cb.Append("foo", "This is some client data for this item") - - # This combobox is created with no values initially. - cb = wx.ComboBox( - self, 501, "default value", (90, 80), (95, -1), [], wx.CB_SIMPLE) - - # Here we dynamically add our values to the second combobox. - for item in sampleList: - cb.Append(item, item.upper()) - - self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, cb) - self.Bind(wx.EVT_COMBOBOX, self.EvtText, cb) - - # The user selects something, we go here. - def EvtComboBox(self, evt): - cb = evt.GetEventObject() - data = cb.GetClientData(cb.GetSelection()) - self.log.WriteText('EvtComboBox: %s\nClientData: %s\n' % (evt.GetString(), data)) - - if evt.GetString() == 'one': - self.log.WriteText("You follow directions well!\n\n") - - # Capture events every time a user hits a key in the text entry field. - def EvtText(self, evt): - self.log.WriteText('EvtText: %s\n' % evt.GetString()) - - # Capture events when the user types something into the control then - # hits ENTER. - def EvtTextEnter(self, evt): - self.log.WriteText('EvtTextEnter: %s' % evt.GetString()) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestComboBox(nb, log) - return win - -#--------------------------------------------------------------------------- - - - -overview = """\ -A ComboBox is like a combination of an edit control and a listbox. It can be -displayed as static list with editable or read-only text field; or a drop-down -list with text field; or a drop-down list without a text field. - -This example shows both a preset ComboBox and one that is dynamically created -(that is, it is initially empty but then we 'grow' it out of program-supplied -data). The former is common for read-only controls. - -This example also shows the two form factors for the ComboBox. The first is more -common, and resembles a Choice control. The latter, although less common, shows -how all the values in the ComboBox can be visible, yet the functionality is the -same for both. - -Finally, this demo shows how event handling can differ. The first ComboBox is set -up to handle EVT_TEXT_ENTER events, in which text is typed in and then ENTER is -hit by the user. This allows the user to enter a line of text which can then be -processed by the program. EVT_TEXT can also be processed, but in that case the -event is generated every time that the user hits a key in the ComboBox entry field. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxDialog.py b/wxPython/demo/wxDialog.py deleted file mode 100644 index 263c2cfb50..0000000000 --- a/wxPython/demo/wxDialog.py +++ /dev/null @@ -1,137 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- -# Create and set a help provider. Normally you would do this in -# the app's OnInit as it must be done before any SetHelpText calls. -provider = wx.SimpleHelpProvider() -wx.HelpProvider_Set(provider) - -#--------------------------------------------------------------------------- - -class TestDialog(wx.Dialog): - def __init__( - self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition, - style=wx.DEFAULT_DIALOG_STYLE - ): - - # Instead of calling wxDialog.__init__ we precreate the dialog - # so we can set an extra style that must be set before - # creation, and then we create the GUI dialog using the Create - # method. - pre = wx.PreDialog() - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) - pre.Create(parent, ID, title, pos, size, style) - - # This next step is the most important, it turns this Python - # object into the real wrapper of the dialog (instead of pre) - # as far as the wxPython extension is concerned. - self.this = pre.this - - # Now continue with the normal construction of the dialog - # contents - sizer = wx.BoxSizer(wx.VERTICAL) - - label = wx.StaticText(self, -1, "This is a wxDialog") - label.SetHelpText("This is the help text for the label") - sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - box = wx.BoxSizer(wx.HORIZONTAL) - - label = wx.StaticText(self, -1, "Field #1:") - label.SetHelpText("This is the help text for the label") - box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - text = wx.TextCtrl(self, -1, "", size=(80,-1)) - text.SetHelpText("Here's some help text for field #1") - box.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL, 5) - - sizer.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - - box = wx.BoxSizer(wx.HORIZONTAL) - - label = wx.StaticText(self, -1, "Field #2:") - label.SetHelpText("This is the help text for the label") - box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - text = wx.TextCtrl(self, -1, "", size=(80,-1)) - text.SetHelpText("Here's some help text for field #2") - box.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL, 5) - - sizer.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - - line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) - sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) - - box = wx.BoxSizer(wx.HORIZONTAL) - - if wx.Platform != "__WXMSW__": - btn = wx.ContextHelpButton(self) - box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - btn = wx.Button(self, wx.ID_OK, " OK ") - btn.SetDefault() - btn.SetHelpText("The OK button completes the dialog") - box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - btn = wx.Button(self, wx.ID_CANCEL, " Cancel ") - btn.SetHelpText("The Cancel button cnacels the dialog. (Cool, huh?)") - box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - - sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - - self.SetSizer(sizer) - self.SetAutoLayout(True) - sizer.Fit(self) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestDialog(frame, -1, "This is a Dialog", size=(350, 200), - #style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME - style = wx.DEFAULT_DIALOG_STYLE - ) - win.CenterOnScreen() - val = win.ShowModal() - - if val == wx.ID_OK: - log.WriteText("You pressed OK\n") - else: - log.WriteText("You pressed Cancel\n") - - win.Destroy() - - - -#--------------------------------------------------------------------------- - - -overview = """\ -wxPython offers quite a few general purpose dialogs for useful data input from -the user; they are all based on the wx.Dialog class, which you can also subclass -to create custom dialogs to suit your needs. - -The Dialog class, in addition to dialog-like behaviors, also supports the full -wxWindows layout featureset, which means that you can incorporate sizers or -layout constraints as needed to achieve the look and feel desired. It even supports -context-sensitive help, which is illustrated in this example. - -The example is very simple; in real world situations, a dialog that had input -fields such as this would no doubt be required to deliver those values back to -the calling function. The Dialog class supports data retrieval in this manner. -However, the data must be retrieved prior to the dialog being destroyed. -The example shown here is modal; non-modal dialogs are possible as well. - -See the documentation for the Dialog class for more details. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxDirDialog.py b/wxPython/demo/wxDirDialog.py deleted file mode 100644 index dc936d2272..0000000000 --- a/wxPython/demo/wxDirDialog.py +++ /dev/null @@ -1,40 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - - # In this case we include a "New directory" button. - dlg = wx.DirDialog(frame, "Choose a directory:", - style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON) - - # If the user selects OK, then we process the dialog's data. - # This is done by getting the path data from the dialog - BEFORE - # we destroy it. - if dlg.ShowModal() == wx.ID_OK: - log.WriteText('You selected: %s\n' % dlg.GetPath()) - - # Only destroy a dialog after you're done with it. - dlg.Destroy() - -#--------------------------------------------------------------------------- - - - -overview = """\ -This class represents the directory chooser dialog. It is used when all you -need from the user is the name of a directory. Data is retrieved via utility -methods; see the DirDialog documentation for specifics. -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxDragImage.py b/wxPython/demo/wxDragImage.py deleted file mode 100644 index ad8f880a5d..0000000000 --- a/wxPython/demo/wxDragImage.py +++ /dev/null @@ -1,345 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import images - -#---------------------------------------------------------------------- - -class DragShape: - def __init__(self, bmp): - self.bmp = bmp - self.pos = (0,0) - self.shown = True - self.text = None - self.fullscreen = False - - def HitTest(self, pt): - rect = self.GetRect() - return rect.InsideXY(pt.x, pt.y) - - def GetRect(self): - return wx.Rect(self.pos[0], self.pos[1], - self.bmp.GetWidth(), self.bmp.GetHeight()) - - def Draw(self, dc, op = wx.COPY): - if self.bmp.Ok(): - memDC = wx.MemoryDC() - memDC.SelectObject(self.bmp) - - dc.Blit((self.pos[0], self.pos[1]), - (self.bmp.GetWidth(), self.bmp.GetHeight()), - memDC, (0, 0), op, True) - - return True - else: - return False - - - -#---------------------------------------------------------------------- - -class DragCanvas(wx.ScrolledWindow): - def __init__(self, parent, ID): - wx.ScrolledWindow.__init__(self, parent, ID) - self.shapes = [] - self.dragImage = None - self.dragShape = None - self.hiliteShape = None - - self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) - self.bg_bmp = images.getBackgroundBitmap() - - # Make a shape from an image and mask. This one will demo - # dragging outside the window - bmp = images.getTestStarBitmap() - shape = DragShape(bmp) - shape.pos = (5, 5) - shape.fullscreen = True - self.shapes.append(shape) - - # Make a shape from some text - text = "Some Text" - bg_colour = wx.Colour(57, 115, 57) # matches the bg image - font = wx.Font(15, wx.ROMAN, wx.NORMAL, wx.BOLD) - textExtent = self.GetFullTextExtent(text, font) - - # create a bitmap the same size as our text - bmp = wx.EmptyBitmap(textExtent[0], textExtent[1]) - - # 'draw' the text onto the bitmap - dc = wx.MemoryDC() - dc.SelectObject(bmp) - dc.SetBackground(wx.Brush(bg_colour, wx.SOLID)) - dc.Clear() - dc.SetTextForeground(wx.RED) - dc.SetFont(font) - dc.DrawText(text, (0, 0)) - dc.SelectObject(wx.NullBitmap) - mask = wx.MaskColour(bmp, bg_colour) - bmp.SetMask(mask) - shape = DragShape(bmp) - shape.pos = (5, 100) - shape.text = "Some dragging text" - self.shapes.append(shape) - - - # Make some shapes from some playing card images. - x = 200 - - for card in ['_01c_', '_12h_', '_13d_', '_10s_']: - bmpFunc = getattr(images, "get%sBitmap" % card) - bmp = bmpFunc() - shape = DragShape(bmp) - shape.pos = (x, 5) - self.shapes.append(shape) - x = x + 80 - - - self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) - self.Bind(wx.EVT_PAINT, self.OnPaint) - self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) - self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) - self.Bind(wx.EVT_MOTION, self.OnMotion) - self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) - - - # We're not doing anything here, but you might have reason to. - # for example, if you were dragging something, you might elect to - # 'drop it' when the cursor left the window. - def OnLeaveWindow(self, evt): - pass - - - # tile the background bitmap - def TileBackground(self, dc): - sz = self.GetClientSize() - w = self.bg_bmp.GetWidth() - h = self.bg_bmp.GetHeight() - - x = 0 - - while x < sz.width: - y = 0 - - while y < sz.height: - dc.DrawBitmap(self.bg_bmp, (x, y)) - y = y + h - - x = x + w - - - # Go through our list of shapes and draw them in whatever place they are. - def DrawShapes(self, dc): - for shape in self.shapes: - if shape.shown: - shape.Draw(dc) - - # This is actually a sophisticated 'hit test', but in this - # case we're also determining which shape, if any, was 'hit'. - def FindShape(self, pt): - for shape in self.shapes: - if shape.HitTest(pt): - return shape - return None - - # Remove a shape from the display - def EraseShape(self, shape, dc): - r = shape.GetRect() - dc.SetClippingRect(r) - self.TileBackground(dc) - self.DrawShapes(dc) - dc.DestroyClippingRegion() - - # Clears the background, then redraws it. If the DC is passed, then - # we only do so in the area so designated. Otherwise, it's the whole thing. - def OnEraseBackground(self, evt): - dc = evt.GetDC() - - if not dc: - dc = wxClientDC(self) - rect = self.GetUpdateRegion().GetBox() - dc.SetClippingRect(rect) - self.TileBackground(dc) - - # Fired whenever a paint event occurs - def OnPaint(self, evt): - dc = wx.PaintDC(self) - self.PrepareDC(dc) - self.DrawShapes(dc) - - # Left mouse button is down. - def OnLeftDown(self, evt): - # Did the mouse go down on one of our shapes? - shape = self.FindShape(evt.GetPosition()) - - # If a shape was 'hit', then set that as the shape we're going to - # drag around. Get our start position. Dragging has not yet started. - # That will happen once the mouse moves, OR the mouse is released. - if shape: - self.dragShape = shape - self.dragStartPos = evt.GetPosition() - - # Left mouse button up. - def OnLeftUp(self, evt): - if not self.dragImage or not self.dragShape: - self.dragImage = None - self.dragShape = None - return - - # Hide the image, end dragging, and nuke out the drag image. - self.dragImage.Hide() - self.dragImage.EndDrag() - self.dragImage = None - - dc = wx.ClientDC(self) - - if self.hiliteShape: - self.hiliteShape.Draw(dc) - self.hiliteShape = None - - # reposition and draw the shape - - # Note by jmg 11/28/03 - # Here's the original: - # - # self.dragShape.pos = self.dragShape.pos + evt.GetPosition() - self.dragStartPos - # - # So if there are any problems associated with this, use that as - # a starting place in your investigation. I've tried to simulate the - # wx.Point __add__ method here -- it won't work for tuples as we - # have now from the various methods - # - # There must be a better way to do this :-) - # - - self.dragShape.pos = ( - self.dragShape.pos[0] + evt.GetPosition()[0] - self.dragStartPos[0], - self.dragShape.pos[1] + evt.GetPosition()[1] - self.dragStartPos[1] - ) - - self.dragShape.shown = True - self.dragShape.Draw(dc) - self.dragShape = None - - # The mouse is moving - def OnMotion(self, evt): - # Ignore mouse movement if we're not dragging. - if not self.dragShape or not evt.Dragging() or not evt.LeftIsDown(): - return - - # if we have a shape, but haven't started dragging yet - if self.dragShape and not self.dragImage: - - # only start the drag after having moved a couple pixels - tolerance = 2 - pt = evt.GetPosition() - dx = abs(pt.x - self.dragStartPos.x) - dy = abs(pt.y - self.dragStartPos.y) - if dx <= tolerance and dy <= tolerance: - return - - # erase the shape since it will be drawn independently now - dc = wx.ClientDC(self) - self.dragShape.shown = False - self.EraseShape(self.dragShape, dc) - - - if self.dragShape.text: - self.dragImage = wx.DragString(self.dragShape.text, - wx.StockCursor(wx.CURSOR_HAND)) - else: - self.dragImage = wx.DragImage(self.dragShape.bmp, - wx.StockCursor(wx.CURSOR_HAND)) - - hotspot = self.dragStartPos - self.dragShape.pos - self.dragImage.BeginDrag(hotspot, self, self.dragShape.fullscreen) - - self.dragImage.Move(pt) - self.dragImage.Show() - - - # if we have shape and image then move it, posibly highlighting another shape. - elif self.dragShape and self.dragImage: - onShape = self.FindShape(evt.GetPosition()) - unhiliteOld = False - hiliteNew = False - - # figure out what to hilite and what to unhilite - if self.hiliteShape: - if onShape is None or self.hiliteShape is not onShape: - unhiliteOld = True - - if onShape and onShape is not self.hiliteShape and onShape.shown: - hiliteNew = True - - # if needed, hide the drag image so we can update the window - if unhiliteOld or hiliteNew: - self.dragImage.Hide() - - if unhiliteOld: - dc = wx.ClientDC(self) - self.hiliteShape.Draw(dc) - self.hiliteShape = None - - if hiliteNew: - dc = wx.ClientDC(self) - self.hiliteShape = onShape - self.hiliteShape.Draw(dc, wx.INVERT) - - # now move it and show it again if needed - self.dragImage.Move(evt.GetPosition()) - if unhiliteOld or hiliteNew: - self.dragImage.Show() - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - - win = wx.Panel(nb, -1) - canvas = DragCanvas(win, -1) - - def onSize(evt, panel=win, canvas=canvas): - canvas.SetSize(panel.GetSize()) - - win.Bind(wx.EVT_SIZE, onSize) - return win - -#---------------------------------------------------------------------- - - - -overview = """\ -DragImage is used when you wish to drag an object on the screen, and a simple -cursor is not enough. - -On Windows, the WIN32 API is used to do achieve smooth dragging. On other -platforms, GenericDragImage is used. Applications may also prefer to use -GenericDragImage on Windows, too. - -wxPython note: wxPython uses GenericDragImage on all -platforms, but uses the DragImage name. - -To use this class, when you wish to start dragging an image, create a -DragImage object and store it somewhere you can access it as the -drag progresses. Call BeginDrag to start, and EndDrag to stop the drag. To move -the image, initially call Show and then Move. If you wish to update the screen -contents during the drag (for example, highlight an item as in the example), first -call Hide, update the screen, call Move, and then call Show. - -You can drag within one window, or you can use full-screen dragging either across -the whole screen, or just restricted to one area of the screen to save resources. -If you want the user to drag between two windows, then you will need to use -full-screen dragging. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxDynamicSashWindow.py b/wxPython/demo/wxDynamicSashWindow.py deleted file mode 100644 index 8deeceb0d7..0000000000 --- a/wxPython/demo/wxDynamicSashWindow.py +++ /dev/null @@ -1,168 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import wx.gizmos as gizmos -import wx.stc as stc - -#---------------------------------------------------------------------- -# This is an example of the complex view that manages its own scrollbars -# as described in the overview below. - -class TestView(stc.StyledTextCtrl): - def __init__(self, parent, ID, log): - stc.StyledTextCtrl.__init__(self, parent, ID, style=wx.NO_BORDER) - self.dyn_sash = parent - self.log = log - self.SetupScrollBars() - self.SetMarginWidth(1,0) - - self.StyleSetFont(stc.STC_STYLE_DEFAULT, - wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) - - self.Bind(gizmos.EVT_DYNAMIC_SASH_SPLIT, self.OnSplit) - self.Bind(gizmos.EVT_DYNAMIC_SASH_UNIFY, self.OnUnify) - #self.SetScrollWidth(500) - - def SetupScrollBars(self): - # hook the scrollbars provided by the wxDynamicSashWindow - # to this view - v_bar = self.dyn_sash.GetVScrollBar(self) - h_bar = self.dyn_sash.GetHScrollBar(self) - v_bar.Bind(wx.EVT_SCROLL, self.OnSBScroll) - h_bar.Bind(wx.EVT_SCROLL, self.OnSBScroll) - v_bar.Bind(wx.EVT_SET_FOCUS, self.OnSBFocus) - h_bar.Bind(wx.EVT_SET_FOCUS, self.OnSBFocus) - - # And set the wxStyledText to use these scrollbars instead - # of its built-in ones. - self.SetVScrollBar(v_bar) - self.SetHScrollBar(h_bar) - - - def __del__(self): - self.log.write("TestView.__del__\n") - - def OnSplit(self, evt): - self.log.write("TestView.OnSplit\n"); - newview = TestView(self.dyn_sash, -1, self.log) - newview.SetDocPointer(self.GetDocPointer()) # use the same document - self.SetupScrollBars() - - - def OnUnify(self, evt): - self.log.write("TestView.OnUnify\n"); - self.SetupScrollBars() - - - def OnSBScroll(self, evt): - # redirect the scroll events from the dyn_sash's scrollbars to the STC - self.GetEventHandler().ProcessEvent(evt) - - def OnSBFocus(self, evt): - # when the scrollbar gets the focus move it back to the STC - self.SetFocus() - - -sampleText="""\ -You can drag the little tabs above the vertical scrollbar, or to the -left of the horizontal scrollbar to split this view, and you can -continue splitting the new views as much as you like. Try it and see. - -In this case the views also share the same document so changes in one -are instantly seen in the others. This is a feature of the -StyledTextCtrl that is used for the view class in this sample. -""" - -#---------------------------------------------------------------------- -# This one is simpler, but doesn't do anything with the scrollbars -# except the default wxDynamicSashWindow behaviour - -class SimpleView(wx.Panel): - def __init__(self, parent, ID, log): - wx.Panel.__init__(self, parent, ID) - self.dyn_sash = parent - self.log = log - self.SetBackgroundColour("LIGHT BLUE") - self.Bind(gizmos.EVT_DYNAMIC_SASH_SPLIT, self.OnSplit) - - def OnSplit(self, evt): - v = SimpleView(self.dyn_sash, -1, self.log) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - if wx.Platform == "__WXMAC__": - wx.MessageBox("This demo currently fails on the Mac. The problem is being looked into...", "Sorry") - return - - if 1: - win = gizmos.DynamicSashWindow(nb, -1, style = wx.CLIP_CHILDREN - #| wxDS_MANAGE_SCROLLBARS - #| wxDS_DRAG_CORNER - ) - - win.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) - view = TestView(win, -1, log) - view.SetText(sampleText) - else: - win = wx.DynamicSashWindow(nb, -1) - view = SimpleView(win, -1, log) - return win - -#---------------------------------------------------------------------- - -overview = """\ - -

DynamicSashWindow

-

-wxDynamicSashWindow widgets manages the way other widgets are viewed. -When a wxDynamicSashWindow is first shown, it will contain one child -view, a viewport for that child, and a pair of scrollbars to allow the -user to navigate the child view area. Next to each scrollbar is a small -tab. By clicking on either tab and dragging to the appropriate spot, a -user can split the view area into two smaller views separated by a -draggable sash. Later, when the user wishes to reunify the two subviews, -the user simply drags the sash to the side of the window. -wxDynamicSashWindow will automatically reparent the appropriate child -view back up the window hierarchy, and the wxDynamicSashWindow will have -only one child view once again. -

-As an application developer, you will simply create a wxDynamicSashWindow -using either the Create() function or the more complex constructor -provided below, and then create a view window whose parent is the -wxDynamicSashWindow. The child should respond to -wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by -constructing a new view window whose parent is also the -wxDynamicSashWindow. That's it! Now your users can dynamically split -and reunify the view you provided. -

-If you wish to handle the scrollbar events for your view, rather than -allowing wxDynamicSashWindow to do it for you, things are a bit more -complex. (You might want to handle scrollbar events yourself, if, -for instance, you wish to scroll a subwindow of the view you add to -your wxDynamicSashWindow object, rather than scrolling the whole view.) -In this case, you will need to construct your wxDynamicSashWindow without -the wxDS_MANAGE_SCROLLBARS style and you will need to use the -GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar -controls and call SetEventHanler() on them to redirect the scrolling -events whenever your window is reparented by wxDyanmicSashWindow. -You will need to set the scrollbars' event handler at three times: -

-

    -
  • When your view is created -
  • When your view receives a wxDynamicSashSplitEvent -
  • When your view receives a wxDynamicSashUnifyEvent -
- -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxEditableListBox.py b/wxPython/demo/wxEditableListBox.py deleted file mode 100644 index 6d10604a54..0000000000 --- a/wxPython/demo/wxEditableListBox.py +++ /dev/null @@ -1,102 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Added overview text based on source code delving. -# - -import wx -import wx.gizmos as gizmos - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - self.elb = gizmos.EditableListBox( - self, -1, "List of Stuff", (50,50), (250, 250) - ) - #style=wx.EL_ALLOW_NEW | wx.EL_ALLOW_EDIT | wx.EL_ALLOW_DELETE) - - self.elb.SetStrings(["This is a nifty ListBox widget", - "that is editable by the user.", - "", - "Use the buttons above to", - "manipulate items in the list", - "Or to add new ones.", - ]) - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """\ - - -This class provides a composite control that lets the user easily enter and edit -a list of strings. - -

Styles supported:

- -

    -
  • EL_ALLOW_NEW - Allow user to create new items. -
  • EL_ALLOW_EDIT - Allow user to edit text in the control. -
  • EL_ALLOW_DELETE - Allow user to delete text from the control. -
- -

Init: -

- EditableListBox(wxWindow *parent, wxWindowID id=-1,
-                 const wxString& label,
-                 const wxPoint& pos = wxDefaultPosition,
-                 const wxSize& size = wxDefaultSize,
-                 long style = EL_ALLOW_NEW | EL_ALLOW_EDIT | EL_ALLOW_DELETE,
-                 const wxString& name = "editableListBox")
-
- -

Methods: -

    -
  • SetStrings(const wxArrayString& strings) - Set an array of strings - into the control. Note: The wxPython method accepts a Python list instead - of an array of strings. - -
  • void GetStrings(wxArrayString& strings) - Retrieves an array - of strings from the control. The wxPython version returns a list of strings. - -
  • GetListCtrl() - Retrieves a reference to the actual list control - portion of the custom control. - -
  • GetDelButton() - Retrieves a reference to the BitmapButton that is used - as the 'delete' button in the control. - -
  • GetNewButton() - Retrieves a reference to the BitmapButton that is used - as the 'new' button in the control. - -
  • GetUpButton() - Retrieves a reference to the BitmapButton that is used - as the 'up' button in the control. - -
  • GetDownButton() - Retrieves a reference to the BitmapButton that is used - as the 'down' button in the control. - -
  • GetEditButton() - Retrieves a reference to the BitmapButton that is used - as the 'edit' button in the control. -
- - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxEditor.py b/wxPython/demo/wxEditor.py deleted file mode 100644 index 904dc3f144..0000000000 --- a/wxPython/demo/wxEditor.py +++ /dev/null @@ -1,81 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o editor lib hasn't been hit by the renamer yet. -# -# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxEditor -> Editor -# - -import wx -import wx.lib.editor as editor - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = wx.Panel(nb, -1) - ed = editor.Editor(win, -1, style=wx.SUNKEN_BORDER) - box = wx.BoxSizer(wx.VERTICAL) - box.Add(ed, 1, wx.ALL|wx.GROW, 1) - win.SetSizer(box) - win.SetAutoLayout(True) - - ed.SetText(["", - "This is a simple text editor, the class name is", - "Editor. Type a few lines and try it out.", - "", - "It uses Windows-style key commands that can be overridden by subclassing.", - "Mouse select works. Here are the key commands:", - "", - "Cursor movement: Arrow keys or mouse", - "Beginning of line: Home", - "End of line: End", - "Beginning of buffer: Control-Home", - "End of the buffer: Control-End", - "Select text: Hold down Shift while moving the cursor", - "Copy: Control-Insert, Control-C", - "Cut: Shift-Delete, Control-X", - "Paste: Shift-Insert, Control-V", - ""]) - - return win - -#---------------------------------------------------------------------- - - -overview = """ -The Editor class implements a simple text editor using wxPython. You -can create a custom editor by subclassing Editor. Even though much of -the editor is implemented in Python, it runs surprisingly smoothly on -normal hardware with small files. - -How to use it -------------- -The demo code (demo/Editor.py) shows how to use Editor as a simple text -box. Use the SetText() and GetText() methods to set or get text from -the component; these both use a list of strings. - -The samples/FrogEdit directory has an example of a simple text editor -application that uses the Editor component. - -Subclassing ------------ -To add or change functionality, you can subclass this -component. One example of this might be to change the key -Alt key commands. In that case you would (for example) override the -SetAltFuncs() method. - -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxFileDialog.py b/wxPython/demo/wxFileDialog.py deleted file mode 100644 index 0d42aa54e6..0000000000 --- a/wxPython/demo/wxFileDialog.py +++ /dev/null @@ -1,70 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import os -import wx - -#--------------------------------------------------------------------------- - -# This is how you pre-establish a file filter so that the dialog -# only shows the extention(s) you want it to. -wildcard = "Python source (*.py)|*.py|" \ - "Compiled Python (*.pyc)|*.pyc|" \ - "All files (*.*)|*.*" - -def runTest(frame, nb, log): - log.WriteText("CWD: %s\n" % os.getcwd()) - - # Create the dialog. In this case the current directory is forced as the starting - # directory for the dialog, and no default file name is forced. This can easilly - # be changed in your program. This is an 'open' dialog, and allows multitple - # file selection to boot. - # - # Finally, of the directory is changed in the process of getting files, this - # dialog is set up to change the current working directory to the path chosen. - dlg = wx.FileDialog( - frame, message="Choose a file", defaultDir=os.getcwd(), - defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR - ) - - # Show the dialog and retrieve the user response. If it is the OK response, - # process the data. - if dlg.ShowModal() == wx.ID_OK: - # This returns a Python list of files that were selected. - paths = dlg.GetPaths() - - log.WriteText('You selected %d files:' % len(paths)) - - for path in paths: - log.WriteText(' %s\n' % path) - - # Compare this with the debug above; did we change working dirs? - log.WriteText("CWD: %s\n" % os.getcwd()) - - # Destroy the dialog. Don't do this until you are done with it! - # BAD things can happen otherwise! - dlg.Destroy() - -#--------------------------------------------------------------------------- - - -overview = """\ -This class provides the file selection dialog. It incorporates OS-native features -depending on the OS in use, and can be used both for open and save operations. -The files displayed can be filtered by setting up a wildcard filter, multiple files -can be selected (open only), and files can be forced in a read-only mode. - -There are two ways to get the results back from the dialog. GetFiles() returns only -the file names themselves, in a Python list. GetPaths() returns the full path and -filenames combined as a Python list. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxFileDialog_Save.py b/wxPython/demo/wxFileDialog_Save.py deleted file mode 100644 index 55fdae0596..0000000000 --- a/wxPython/demo/wxFileDialog_Save.py +++ /dev/null @@ -1,91 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import os -import wx - -#--------------------------------------------------------------------------- - -# This is how you pre-establish a file filter so that the dialog -# only shows the extention(s) you want it to. -wildcard = "Python source (*.py)|*.py|" \ - "Compiled Python (*.pyc)|*.pyc|" \ - "SPAM files (*.spam)|*.spam|" \ - "Egg file (*.egg)|*.egg|" \ - "All files (*.*)|*.*" - -def runTest(frame, nb, log): - log.WriteText("CWD: %s\n" % os.getcwd()) - - # Create the dialog. In this case the current directory is forced as the starting - # directory for the dialog, and no default file name is forced. This can easilly - # be changed in your program. This is an 'save' dialog. - # - # Unlike the 'open dialog' example found elsewhere, this example does NOT - # force the current working directory to change if the user chooses a different - # directory than the one initially set. - dlg = wx.FileDialog( - frame, message="Save file as ...", defaultDir=os.getcwd(), - defaultFile="", wildcard=wildcard, style=wx.SAVE - ) - - # This sets the default filter that the user will initially see. Otherwise, - # the first filter in the list will be used by default. - dlg.SetFilterIndex(2) - - # Show the dialog and retrieve the user response. If it is the OK response, - # process the data. - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - log.WriteText('You selected "%s"' % path) - - # Normally, at this point you would save your data using the file and path - # data that the user provided to you, but since we didn't actually start - # with any data to work with, that would be difficult. - # - # The code to do so would be similar to this, assuming 'data' contains - # the data you want to save: - # - # fp = file(path, 'w') # Create file anew - # fp.write(data) - # fp.close() - # - # You might want to add some error checking :-) - # - - # Note that the current working dir didn't change. This is good since - # that's the way we set it up. - log.WriteText("CWD: %s\n" % os.getcwd()) - - # Destroy the dialog. Don't do this until you are done with it! - # BAD things can happen otherwise! - dlg.Destroy() - -#--------------------------------------------------------------------------- - - -overview = """\ -This class provides the file selection dialog. It incorporates OS-native features -depending on the OS in use, and can be used both for open and save operations. -The files displayed can be filtered by setting up a wildcard filter, multiple files -can be selected (open only), and files can be forced in a read-only mode. - -There are two ways to get the results back from the dialog. GetFiles() returns only -the file names themselves, in a Python list. GetPaths() returns the full path and -filenames combined as a Python list. - -One important thing to note: if you use the file extention filters, then files saved -with the filter set to something will automatically get that extention appended to them -if it is not already there. For example, suppose the dialog was displaying the 'egg' -extention and you entered a file name of 'fried'. It would be saved as 'fried.egg.' -Yum! -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxFileHistory.py b/wxPython/demo/wxFileHistory.py deleted file mode 100644 index 7a0dc4962f..0000000000 --- a/wxPython/demo/wxFileHistory.py +++ /dev/null @@ -1,147 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import os -import wx - -#---------------------------------------------------------------------- - -text = """\ -Right-click on the panel above the line to get a menu. This menu will -be managed by a FileHistory object and so the files you select will -automatically be added to the end of the menu and will be selectable -the next time the menu is viewed. The filename selected, either via the -Open menu item, or from the history, will be displayed in the log -window below. -""" - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - box = wx.BoxSizer(wx.VERTICAL) - - # Make and layout the controls - fs = self.GetFont().GetPointSize() - bf = wx.Font(fs+4, wx.SWISS, wx.NORMAL, wx.BOLD) - nf = wx.Font(fs+2, wx.SWISS, wx.NORMAL, wx.NORMAL) - - t = wx.StaticText(self, -1, "FileHistory") - t.SetFont(bf) - box.Add(t, 0, wx.CENTER|wx.ALL, 5) - - box.Add(wx.StaticLine(self, -1), 0, wx.EXPAND) - box.Add((10,20)) - - t = wx.StaticText(self, -1, text) - t.SetFont(nf) - box.Add(t, 0, wx.CENTER|wx.ALL, 5) - - self.SetSizer(box) - self.SetAutoLayout(True) - - # Make a menu - self.menu = m = wx.Menu() - - # Little know wx Fact #42: there are a number of pre-set IDs - # in the wx package, to be used for common controls such as those - # illustrated below. Neat, huh? - m.Append(wx.ID_NEW, "&New") - m.Append(wx.ID_OPEN, "&Open...") - m.Append(wx.ID_CLOSE, "&Close") - m.Append(wx.ID_SAVE, "&Save") - m.Append(wx.ID_SAVEAS, "Save &as...") - m.Enable(wx.ID_NEW, False) - m.Enable(wx.ID_CLOSE, False) - m.Enable(wx.ID_SAVE, False) - m.Enable(wx.ID_SAVEAS, False) - - # and a file history - self.filehistory = wx.FileHistory() - self.filehistory.UseMenu(self.menu) - - # and finally the event handler bindings - self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick) - - self.Bind(wx.EVT_MENU, self.OnFileOpenDialog, id=wx.ID_OPEN) - - self.Bind( - wx.EVT_MENU_RANGE, self.OnFileHistory, id=wx.ID_FILE1, id2=wx.ID_FILE9 - ) - - self.Bind(wx.EVT_WINDOW_DESTROY, self.Cleanup) - - - def Cleanup(self, *args): - # A little extra cleanup is required for the FileHistory control - del self.filehistory - self.menu.Destroy() - - - def OnRightClick(self, evt): - self.PopupMenu(self.menu, evt.GetPosition()) - - - def OnFileOpenDialog(self, evt): - dlg = wx.FileDialog(self, - defaultDir = os.getcwd(), - wildcard = "All Files|*", - style = wx.OPEN | wx.CHANGE_DIR) - - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.log.write("You selected %s\n" % path) - - # add it to the history - self.filehistory.AddFileToHistory(path) - - dlg.Destroy() - - - def OnFileHistory(self, evt): - # get the file based on the menu ID - fileNum = evt.GetId() - wx.ID_FILE1 - path = self.filehistory.GetHistoryFile(fileNum) - self.log.write("You selected %s\n" % path) - - # add it back to the history so it will be moved up the list - self.filehistory.AddFileToHistory(path) - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

FileHistory

- -wxFileHistory encapsulates functionality to record the last few files -visited, and to allow the user to quickly load these files using the -list appended to a menu, such as the File menu. - -

Note that this inclusion is not automatic; as illustrated in this example, -you must add files (and remove them) as deemed necessary within the framework -of your program. - -

Note also the additional cleanup required for this class, namely trapping the -enclosing window's Destroy event and deleting the file history control and its -associated menu. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxFindReplaceDialog.py b/wxPython/demo/wxFindReplaceDialog.py deleted file mode 100644 index 54cc07ee3b..0000000000 --- a/wxPython/demo/wxFindReplaceDialog.py +++ /dev/null @@ -1,123 +0,0 @@ -# 11/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Changed the event binding slightly. -# o There are issues with the GetReplaceText() method of the -# FindDialogEvent. Must be retested when this is fixed. -# - -import wx - -#--------------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - b = wx.Button(self, -1, "Show Find Dialog", (25, 50)) - self.Bind(wx.EVT_BUTTON, self.OnShowFind, b) - - b = wx.Button(self, -1, "Show Find && Replace Dialog", (25, 90)) - self.Bind(wx.EVT_BUTTON, self.OnShowFindReplace, b) - - - # jg - 11/28/03 - corrected a long standing issue here where - # EVT_COMMAND_FIND_* was being used for these event binders - # instead of the actual event IDs shown below. As a result, - # onFind() was never showing the appropriate type. I guess - # nobody really paid much attention to that little - # debugging window :-) - # - self.Bind(wx.EVT_FIND, self.OnFind) - self.Bind(wx.EVT_FIND_NEXT, self.OnFind) - self.Bind(wx.EVT_FIND_REPLACE, self.OnFind) - self.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnFind) - self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose) - - - def OnShowFind(self, evt): - data = wx.FindReplaceData() - dlg = wx.FindReplaceDialog(self, data, "Find") - dlg.data = data # save a reference to it... - dlg.Show(True) - - - def OnShowFindReplace(self, evt): - data = wx.FindReplaceData() - dlg = wx.FindReplaceDialog(self, data, "Find & Replace", wx.FR_REPLACEDIALOG) - dlg.data = data # save a reference to it... - dlg.Show(True) - - - def OnFind(self, evt): - map = { - wx.wxEVT_COMMAND_FIND : "FIND", - wx.wxEVT_COMMAND_FIND_NEXT : "FIND_NEXT", - wx.wxEVT_COMMAND_FIND_REPLACE : "REPLACE", - wx.wxEVT_COMMAND_FIND_REPLACE_ALL : "REPLACE_ALL", - } - - et = evt.GetEventType() - - #print evt.GetReplaceString() - - if et in map: - evtType = map[et] - else: - evtType = "**Unknown Event Type**" - - #>> Todo: the GetReplaceString() method is broken. Has to be - # fixed. - if et == wx.EVT_COMMAND_FIND_REPLACE or et == wx.EVT_COMMAND_FIND_REPLACE_ALL: - replaceTxt = "Replace text: %s" % evt.GetReplaceString() - else: - replaceTxt = "" - - self.log.write("%s -- Find text: %s %s Flags: %d \n" % - (evtType, evt.GetFindString(), replaceTxt, evt.GetFlags())) - - - def OnFindClose(self, evt): - self.log.write("FindReplaceDialog closing...\n") - evt.GetDialog().Destroy() - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#--------------------------------------------------------------------------- - - - - -overview = """\ -FindReplaceDialog is a standard modeless dialog which is used to allow the user -to search for some text (and possibly replace it with something else). The actual -searching is supposed to be done in the owner window which is the parent of this -dialog. Note that it means that unlike for the other standard dialogs this one -must have a parent window. Also note that there is no way to use this -dialog in a modal way; it is always, by design and implementation, modeless. - -FileReplaceDialog requires the use of FindReplaceData. This holds the -data for the dialog. It is used to initialize the dialog with the default values -and will keep the last values from the dialog when it is closed. It is also -updated each time a FindDialogEvent is generated so instead of using the -FindDialogEvent methods you can also directly query this object. Care must be -taken not to use this object after the dialog is destroyed. The data within -will be invalid after the parent dialog is destroyed. -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxFloatBar.py b/wxPython/demo/wxFloatBar.py deleted file mode 100644 index c218731bb4..0000000000 --- a/wxPython/demo/wxFloatBar.py +++ /dev/null @@ -1,124 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o OK, Main.py indicates this is deprecated. But I don't see a -# replacement yet. So conversion is done anyway. -# -# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Issues - library has to be converted to work properly -# with new namespace. -# -# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxFloatBar -> FloatBar -# - -import wx -import wx.lib.floatbar - -import images - - -class TestFloatBar(wx.Frame): - def __init__(self, parent, log): - wx.Frame.__init__( - self, parent, -1, 'Test ToolBar', wx.DefaultPosition, (500, 300) - ) - - self.log = log - - win = wx.Window(self, -1) - win.SetBackgroundColour("WHITE") - wx.StaticText( - win, -1, "Drag the toolbar to float it,\n" - "Toggle the last tool to remove\nthe title.", (15,15) - ) - - tb = wx.lib.floatbar.FloatBar(self, -1) - self.SetToolBar(tb) - tb.SetFloatable(1) - tb.SetTitle("Floating!") - self.CreateStatusBar() - - tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10) - - tb.AddSimpleTool(20, images.getOpenBitmap(), "Open") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20) - - tb.AddSeparator() - tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30) - - tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40) - - tb.AddSeparator() - - tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap()) - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60) - - tb.Realize() - - self.tb = tb - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - - - def OnCloseWindow(self, event): - self.Destroy() - - def OnToolClick(self, event): - self.log.WriteText("tool %s clicked\n" % event.GetId()) - - if event.GetId() == 60: - print event.GetExtraLong(), event.IsChecked(), event.GetInt(), self.tb.GetToolState(60) - - if event.GetExtraLong(): - self.tb.SetTitle("") - else: - self.tb.SetTitle("Floating!") - - def OnToolRClick(self, event): - self.log.WriteText("tool %s right-clicked\n" % event.GetId()) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestFloatBar(frame, log) - frame.otherWin = win - win.Show(True) - -#--------------------------------------------------------------------------- - -overview = """\ -FloatBar is a subclass of wx.ToolBar, implemented in Python, which -can be detached from its frame. - -Drag the toolbar with the mouse to make it float, and drag it back, or -close it to make the toolbar return to its original position. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - - - - - - - - - - - - - diff --git a/wxPython/demo/wxFontDialog.py b/wxPython/demo/wxFontDialog.py deleted file mode 100644 index 2135c491f1..0000000000 --- a/wxPython/demo/wxFontDialog.py +++ /dev/null @@ -1,144 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - btn = wx.Button(self, -1, "Select Font") - self.Bind(wx.EVT_BUTTON, self.OnSelectFont, btn) - - self.sampleText = wx.TextCtrl(self, -1, "Sample Text") - #from wxPython.lib.stattext import wxGenStaticText - #self.sampleText = wxGenStaticText(self, -1, "Sample Text") - - self.curFont = self.sampleText.GetFont() - self.curClr = wx.BLACK - - fgs = wx.FlexGridSizer(cols=2, vgap=5, hgap=5) - fgs.AddGrowableCol(1) - fgs.AddGrowableRow(0) - - fgs.Add(btn) - fgs.Add(self.sampleText, 0, wx.ADJUST_MINSIZE|wx.GROW) - - fgs.Add((15,15)); fgs.Add((15,15)) # an empty row - - fgs.Add(wx.StaticText(self, -1, "PointSize:")) - self.ps = wx.StaticText(self, -1, "") - font = self.ps.GetFont() - font.SetWeight(wx.BOLD) - self.ps.SetFont(font) - fgs.Add(self.ps, 0, wx.ADJUST_MINSIZE) - - fgs.Add(wx.StaticText(self, -1, "Family:")) - self.family = wx.StaticText(self, -1, "") - self.family.SetFont(font) - fgs.Add(self.family, 0, wx.ADJUST_MINSIZE) - - fgs.Add(wx.StaticText(self, -1, "Style:")) - self.style = wx.StaticText(self, -1, "") - self.style.SetFont(font) - fgs.Add(self.style, 0, wx.ADJUST_MINSIZE) - - fgs.Add(wx.StaticText(self, -1, "Weight:")) - self.weight = wx.StaticText(self, -1, "") - self.weight.SetFont(font) - fgs.Add(self.weight, 0, wx.ADJUST_MINSIZE) - - fgs.Add(wx.StaticText(self, -1, "Face:")) - self.face = wx.StaticText(self, -1, "") - self.face.SetFont(font) - fgs.Add(self.face, 0, wx.ADJUST_MINSIZE) - - fgs.Add((15,15)); fgs.Add((15,15)) # an empty row - - fgs.Add(wx.StaticText(self, -1, "wx.NativeFontInfo:")) - self.nfi = wx.StaticText(self, -1, "") - self.nfi.SetFont(font) - fgs.Add(self.nfi, 0, wx.ADJUST_MINSIZE) - - # give it some border space - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(fgs, 0, wx.GROW|wx.ADJUST_MINSIZE|wx.ALL, 25) - - self.SetSizer(sizer) - self.UpdateUI() - - - def UpdateUI(self): - self.sampleText.SetFont(self.curFont) - self.ps.SetLabel(str(self.curFont.GetPointSize())) - self.family.SetLabel(self.curFont.GetFamilyString()) - self.style.SetLabel(self.curFont.GetStyleString()) - self.weight.SetLabel(self.curFont.GetWeightString()) - self.face.SetLabel(self.curFont.GetFaceName()) - self.nfi.SetLabel(self.curFont.GetNativeFontInfo().ToString()) - self.Layout() - - - def OnSelectFont(self, evt): - data = wx.FontData() - data.EnableEffects(True) - data.SetColour(self.curClr) # set colour - data.SetInitialFont(self.curFont) - - dlg = wx.FontDialog(self, data) - - if dlg.ShowModal() == wx.ID_OK: - data = dlg.GetFontData() - font = data.GetChosenFont() - colour = data.GetColour() - - self.log.WriteText('You selected: "%s", %d points, color %s\n' % - (font.GetFaceName(), font.GetPointSize(), - colour.Get())) - - self.curFont = font - self.curClr = colour - self.UpdateUI() - - # Don't destroy the dialog until you get everything you need from the - # dialog! - dlg.Destroy() - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#--------------------------------------------------------------------------- - - -overview = """\ -This class allows you to use the system font selection dialog -from within your program. Generally speaking, this allows you -to select a font by its name, font size, and weight, and -on some systems such things as strikethrough and underline. - -As with other dialogs used in wxPython, it is important to -use the class' methods to extract the information you need -about the font before you destroy the dialog. Failure -to observe this almost always leads to a program failure of -some sort, often ugly. - -This demo serves two purposes; it shows how to use the dialog -to GET font information from the user, but also shows how -to APPLY that information once you get it. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxFrame.py b/wxPython/demo/wxFrame.py deleted file mode 100644 index b2028e6eb5..0000000000 --- a/wxPython/demo/wxFrame.py +++ /dev/null @@ -1,71 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class MyFrame(wx.Frame): - def __init__( - self, parent, ID, title, pos=wx.DefaultPosition, - size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE - ): - - wx.Frame.__init__(self, parent, ID, title, pos, size, style) - panel = wx.Panel(self, -1) - - button = wx.Button(panel, 1003, "Close Me") - button.SetPosition((15, 15)) - self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - - - def OnCloseMe(self, event): - self.Close(True) - - def OnCloseWindow(self, event): - self.Destroy() - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = MyFrame(frame, -1, "This is a wxFrame", size=(350, 200), - style = wx.DEFAULT_FRAME_STYLE)# | wx.FRAME_TOOL_WINDOW ) - frame.otherWin = win - win.Show(True) - - -#--------------------------------------------------------------------------- - - -overview = """\ -A Frame is a window whose size and position can (usually) be changed by -the user. It usually has thick borders and a title bar, and can optionally -contain a menu bar, toolbar and status bar. A frame can contain any window -that is not a Frame or Dialog. It is one of the most fundamental of the -wxWindows components. - -A Frame that has a status bar and toolbar created via the -CreateStatusBar / CreateToolBar functions manages -these windows, and adjusts the value returned by GetClientSize -to reflect the remaining size available to application windows. - -By itself, a Frame is not too useful, but with the addition of Panels and -other child objects, it encompasses the framework around which most user -interfaces are constructed. - -If you plan on using Sizers and auto-layout features, be aware that the Frame -class lacks the ability to handle these features unless it contains a Panel. -The Panel has all the necessary functionality to both control the size of -child components, and also communicate that information in a useful way to -the Frame itself. -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxGLCanvas.py b/wxPython/demo/wxGLCanvas.py deleted file mode 100644 index 51c231e22a..0000000000 --- a/wxPython/demo/wxGLCanvas.py +++ /dev/null @@ -1,283 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Note: unable to install PyOpenGL on my system as I am running Python 2.3 -# and PyOpenGL does not support anything above Python 2.2. Did what I could, -# but odds are good there are problems. -# - -import wx - -try: - import wx.glcanvas as glcanvas - haveGLCanvas = True -except ImportError: - haveGLCanvas = False - -try: - # The Python OpenGL package can be found at - # http://PyOpenGL.sourceforge.net/ - - import OpenGL.GL as gl - import OpenGL.GLUT as glut - haveOpenGL = True -except ImportError: - haveOpenGL = False - -#---------------------------------------------------------------------- - -if not haveGLCanvas: - def runTest(frame, nb, log): - dlg = wx.MessageDialog( - frame, 'The wxGLCanvas has not been included with this build of wxPython!', - 'Sorry', wx.OK | wx.ICON_INFORMATION - ) - - dlg.ShowModal() - dlg.Destroy() - -elif not haveOpenGL: - def runTest(frame, nb, log): - dlg = wx.MessageDialog( - frame, 'The OpenGL package was not found. You can get it at\n' - 'http://PyOpenGL.sourceforge.net/', 'Sorry', wx.OK | wx.ICON_INFORMATION - ) - - dlg.ShowModal() - dlg.Destroy() - - -else: - buttonDefs = { - wx.NewId() : ('CubeCanvas', 'Cube'), - wx.NewId() : ('ConeCanvas', 'Cone'), - } - - class ButtonPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - box = wx.BoxSizer(wx.VERTICAL) - box.Add((20, 30)) - keys = buttonDefs.keys() - keys.sort() - - for k in keys: - text = buttonDefs[k][1] - btn = wx.Button(self, k, text) - box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 15) - self.Bind(wx.EVT_BUTTON, self.OnButton, id=k) - - #** Enable this to show putting a wxGLCanvas on the wxPanel - if 0: - c = CubeCanvas(self) - c.SetSize((200, 200)) - box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15) - - self.SetAutoLayout(True) - self.SetSizer(box) - - - def OnButton(self, evt): - canvasClassName = buttonDefs[evt.GetId()][0] - canvasClass = eval(canvasClassName) - frame = wx.Frame(None, -1, canvasClassName, size=(400,400)) - canvas = canvasClass(frame) - frame.Show(True) - - - - def runTest(frame, nb, log): - win = ButtonPanel(nb, log) - return win - - - - - class MyCanvasBase(glcanvas.GLCanvas): - def __init__(self, parent): - glcanvas.GLCanvas.__init__(self, parent, -1) - self.init = False - # initial mouse position - self.lastx = self.x = 30 - self.lasty = self.y = 30 - self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) - self.Bind(wx.EVT_SIZE, self.OnSize) - self.Bind(wx.EVT_PAINT, self.OnPaint) - self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) # needs fixing... - self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) - self.Bind(wx.EVT_MOTION, self.OnMouseMotion) - - def OnEraseBackground(self, event): - pass # Do nothing, to avoid flashing on MSW. - - def OnSize(self, event): - size = self.GetClientSize() - - if self.GetContext(): - self.SetCurrent() - glcanvas.glViewport(0, 0, size.width, size.height) - - def OnPaint(self, event): - dc = wx.PaintDC(self) - self.SetCurrent() - - if not self.init: - self.InitGL() - self.init = True - - self.OnDraw() - - def OnMouseDown(self, evt): - self.CaptureMouse() - - def OnMouseUp(self, evt): - self.ReleaseMouse() - - def OnMouseMotion(self, evt): - if evt.Dragging() and evt.LeftIsDown(): - self.x, self.y = self.lastx, self.lasty - self.x, self.y = evt.GetPosition() - self.Refresh(False) - - - class CubeCanvas(MyCanvasBase): - def InitGL(self): - # set viewing projection - glcanvas.glMatrixMode(glcanvas.GL_PROJECTION); - glcanvas.glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0); - - # position viewer - glcanvas.glMatrixMode(glcanvas.GL_MODELVIEW); - glcanvas.glTranslatef(0.0, 0.0, -2.0); - - # position object - glcanvas.glRotatef(self.y, 1.0, 0.0, 0.0); - glcanvas.glRotatef(self.x, 0.0, 1.0, 0.0); - - glcanvas.glEnable(glcanvas.GL_DEPTH_TEST); - glcanvas.glEnable(glcanvas.GL_LIGHTING); - glcanvas.glEnable(glcanvas.GL_LIGHT0); - - - def OnDraw(self): - # clear color and depth buffers - glcanvas.glClear(glcanvas.GL_COLOR_BUFFER_BIT | glcanvas.GL_DEPTH_BUFFER_BIT) - - # draw six faces of a cube - glcanvas.glBegin(glcanvas.GL_QUADS) - glcanvas.glNormal3f( 0.0, 0.0, 1.0) - glcanvas.glVertex3f( 0.5, 0.5, 0.5) - glcanvas.glVertex3f(-0.5, 0.5, 0.5) - glcanvas.glVertex3f(-0.5,-0.5, 0.5) - glcanvas.glVertex3f( 0.5,-0.5, 0.5) - - glcanvas.glNormal3f( 0.0, 0.0,-1.0) - glcanvas.glVertex3f(-0.5,-0.5,-0.5) - glcanvas.glVertex3f(-0.5, 0.5,-0.5) - glcanvas.glVertex3f( 0.5, 0.5,-0.5) - glcanvas.glVertex3f( 0.5,-0.5,-0.5) - - glcanvas.glNormal3f( 0.0, 1.0, 0.0) - glcanvas.glVertex3f( 0.5, 0.5, 0.5) - glcanvas.glVertex3f( 0.5, 0.5,-0.5) - glcanvas.glVertex3f(-0.5, 0.5,-0.5) - glcanvas.glVertex3f(-0.5, 0.5, 0.5) - - glcanvas.glNormal3f( 0.0,-1.0, 0.0) - glcanvas.glVertex3f(-0.5,-0.5,-0.5) - glcanvas.glVertex3f( 0.5,-0.5,-0.5) - glcanvas.glVertex3f( 0.5,-0.5, 0.5) - glcanvas.glVertex3f(-0.5,-0.5, 0.5) - - glcanvas.glNormal3f( 1.0, 0.0, 0.0) - glcanvas.glVertex3f( 0.5, 0.5, 0.5) - glcanvas.glVertex3f( 0.5,-0.5, 0.5) - glcanvas.glVertex3f( 0.5,-0.5,-0.5) - glcanvas.glVertex3f( 0.5, 0.5,-0.5) - - glcanvas.glNormal3f(-1.0, 0.0, 0.0) - glcanvas.glVertex3f(-0.5,-0.5,-0.5) - glcanvas.glVertex3f(-0.5,-0.5, 0.5) - glcanvas.glVertex3f(-0.5, 0.5, 0.5) - glcanvas.glVertex3f(-0.5, 0.5,-0.5) - glcanvas.glEnd() - - glcanvas.glRotatef((self.lasty - self.y)/100., 1.0, 0.0, 0.0); - glcanvas.glRotatef((self.lastx - self.x)/100., 0.0, 1.0, 0.0); - - self.SwapBuffers() - - - class ConeCanvas(MyCanvasBase): - def InitGL( self ): - glcanvas.glMatrixMode(glcanvas.GL_PROJECTION); - # camera frustrum setup - glcanvas.glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0); - glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_AMBIENT, [0.2, 0.2, 0.2, 1.0]) - glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0]) - glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_SPECULAR, [1.0, 0.0, 1.0, 1.0]) - glcanvas.glMaterial(glcanvas.GL_FRONT, glcanvas.GL_SHININESS, 50.0) - glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_AMBIENT, [0.0, 1.0, 0.0, 1.0]) - glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0]) - glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_SPECULAR, [1.0, 1.0, 1.0, 1.0]) - glcanvas.glLight(glcanvas.GL_LIGHT0, glcanvas.GL_POSITION, [1.0, 1.0, 1.0, 0.0]); - glcanvas.glLightModel(glcanvas.GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0]) - glcanvas.glEnable(glcanvas.GL_LIGHTING) - glcanvas.glEnable(glcanvas.GL_LIGHT0) - glcanvas.glDepthFunc(glcanvas.GL_LESS) - glcanvas.glEnable(glcanvas.GL_DEPTH_TEST) - glcanvas.glClear(glcanvas.GL_COLOR_BUFFER_BIT | glcanvas.GL_DEPTH_BUFFER_BIT) - # position viewer - glcanvas.glMatrixMode(glcanvas.GL_MODELVIEW); - - - def OnDraw(self): - # clear color and depth buffers - glcanvas.glClear(glcanvas.GL_COLOR_BUFFER_BIT | glcanvas.GL_DEPTH_BUFFER_BIT); - # use a fresh transformation matrix - glcanvas.glPushMatrix() - # position object - glcanvas.glTranslate(0.0, 0.0, -2.0); - glcanvas.glRotate(30.0, 1.0, 0.0, 0.0); - glcanvas.glRotate(30.0, 0.0, 1.0, 0.0); - - glcanvas.glTranslate(0, -1, 0) - glcanvas.glRotate(250, 1, 0, 0) - glcanvas.glutSolidCone(0.5, 1, 30, 5) - glcanvas.glPopMatrix() - glcanvas.glRotatef((self.lasty - self.y)/100., 0.0, 0.0, 1.0); - glcanvas.glRotatef(0.0, (self.lastx - self.x)/100., 1.0, 0.0); - # push into visible buffer - self.SwapBuffers() - - - - -#---------------------------------------------------------------------- - - - -overview = """\ -""" - - -#---------------------------------------------------------------------- - -def _test(): - class MyApp(wxApp): - def OnInit(self): - frame = wx.Frame(None, -1, "GL Demos", wx.DefaultPosition, (600,300)) - #win = ConeCanvas(frame) - MySplitter(frame) - frame.Show(True) - self.SetTopWindow(frame) - return True - - app = MyApp(0) - app.MainLoop() - -if __name__ == '__main__': - _test() - diff --git a/wxPython/demo/wxGauge.py b/wxPython/demo/wxGauge.py deleted file mode 100644 index 5d65255f09..0000000000 --- a/wxPython/demo/wxGauge.py +++ /dev/null @@ -1,70 +0,0 @@ -# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - self.count = 0 - - wx.StaticText(self, -1, "This example shows the wxGauge control.", (45, 15)) - - self.g1 = wx.Gauge(self, -1, 50, (110, 50), (250, 25)) - self.g1.SetBezelFace(3) - self.g1.SetShadowWidth(3) - - self.g2 = wx.Gauge( - self, -1, 50, (110, 95), (250, 25), - wx.GA_HORIZONTAL|wx.GA_SMOOTH - ) - - self.g2.SetBezelFace(5) - self.g2.SetShadowWidth(5) - - self.Bind(wx.EVT_IDLE, self.IdleHandler) - - - def IdleHandler(self, event): - self.count = self.count + 1 - - if self.count >= 50: - self.count = 0 - - self.g1.SetValue(self.count) - self.g2.SetValue(self.count) - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -A Gauge is a horizontal or vertical bar which shows a quantity in a graphical -fashion. It is often used to indicate progress through lengthy tasks, such as -file copying or data analysis. - -When the Gauge is initialized, it's "complete" value is usually set; at any rate, -before using the Gauge, the maximum value of the control must be set. As the task -progresses, the Gauge is updated by the program via the SetValue method. - -This control is for use within a GUI; there is a seperate ProgressDialog class -to present the same sort of control as a dialog to the user. -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxGenericDirCtrl.py b/wxPython/demo/wxGenericDirCtrl.py deleted file mode 100644 index 30d8bbb75e..0000000000 --- a/wxPython/demo/wxGenericDirCtrl.py +++ /dev/null @@ -1,73 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - txt1 = wx.StaticText(self, -1, "style=0") - dir1 = wx.GenericDirCtrl(self, -1, size=(200,225), style=0) - - txt2 = wx.StaticText(self, -1, "wx.DIRCTRL_DIR_ONLY") - dir2 = wx.GenericDirCtrl(self, -1, size=(200,225), style=wx.DIRCTRL_DIR_ONLY) - - txt3 = wx.StaticText(self, -1, "wx.DIRCTRL_SHOW_FILTERS") - dir3 = wx.GenericDirCtrl(self, -1, size=(200,225), style=wx.DIRCTRL_SHOW_FILTERS, - filter="All files (*.*)|*.*|Python files (*.py)|*.py") - - sz = wx.FlexGridSizer(cols=3, hgap=5, vgap=5) - sz.Add((35, 35)) # some space above - sz.Add((35, 35)) - sz.Add((35, 35)) - - sz.Add(txt1) - sz.Add(txt2) - sz.Add(txt3) - - sz.Add(dir1, 0, wx.EXPAND) - sz.Add(dir2, 0, wx.EXPAND) - sz.Add(dir3, 0, wx.EXPAND) - - sz.Add((35,35)) # some space below - - sz.AddGrowableRow(2) - sz.AddGrowableCol(0) - sz.AddGrowableCol(1) - sz.AddGrowableCol(2) - - self.SetSizer(sz) - self.SetAutoLayout(True) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -This control can be used to place a directory listing (with optional files) -on an arbitrary window. The control contains a TreeCtrl window representing -the directory hierarchy, and optionally, a Choice window containing a list -of filters. - -The filters work in the same manner as in FileDialog. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxGrid.py b/wxPython/demo/wxGrid.py deleted file mode 100644 index 78eae6b678..0000000000 --- a/wxPython/demo/wxGrid.py +++ /dev/null @@ -1,104 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -buttonDefs = { - 814 : ('GridSimple', ' Simple wxGrid, catching all events '), - 815 : ('GridStdEdRend', ' wxGrid showing Editors and Renderers '), - 818 : ('GridHugeTable', ' A wxGrid with a HUGE table (100 MILLION cells!) '), - 817 : ('GridCustTable', ' wxGrid using a custom Table, with non-string data '), - 819 : ('GridEnterHandler',' Remapping keys to behave differently '), - 820 : ('GridCustEditor', ' Shows how to create a custom Cell Editor '), - 821 : ('GridDragable', ' A wxGrid with dragable rows and columns '), - 822 : ('GridDragAndDrop', ' Shows how to make a grid a drop target for files'), - } - - -class ButtonPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - box = wx.BoxSizer(wx.VERTICAL) - box.Add((20, 20)) - keys = buttonDefs.keys() - keys.sort() - - for k in keys: - text = buttonDefs[k][1] - btn = wx.Button(self, k, text) - box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 10) - self.Bind(wx.EVT_BUTTON, self.OnButton, btn) - - self.SetAutoLayout(True) - self.SetSizer(box) - - - def OnButton(self, evt): - modName = buttonDefs[evt.GetId()][0] - module = __import__(modName) - frame = module.TestFrame(None, self.log) - frame.Show(True) - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = ButtonPanel(nb, log) - return win - -#--------------------------------------------------------------------------- - - - -overview = """\ - -

wxGrid

- -This demo shows various ways of using the new and -improved wxGrid class. Unfortunatly it has not been -documented yet, and while it is somewhat backwards compatible, if you -try to go by the current wxGrid documentation you will probably just -confuse yourself. -

-You can look at the sources for these samples to learn a lot about how -the new classes work. -

    -
  1. GridSimple.py A simple grid that shows -how to catch all the various events. - -

    -

  2. GridStdEdRend.py A grid that -uses non-default Cell Editors and Cell Renderers. - -

    -

  3. GridHugeTable.py A grid that -uses a non-default Grid Table. This table is read-only and simply -generates on the fly a unique string for each cell. - -

    -

  4. GridCustTable.py This grid -shows how to deal with tables that have non-string data, and how Cell -Editors and Cell Renderers are automatically chosen based on the data -type. - -

    -

  5. GridEnterHandler.pyThis one -changes how the ENTER key works, moving the current cell left to right -and wrapping around to the next row when needed. -
-

- -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxGridBagSizer.py b/wxPython/demo/wxGridBagSizer.py deleted file mode 100644 index 51ebb0c1de..0000000000 --- a/wxPython/demo/wxGridBagSizer.py +++ /dev/null @@ -1,148 +0,0 @@ - -import wx # This module uses the new wx namespace - -#---------------------------------------------------------------------- -gbsDescription = """\ -The wxGridBagSizer is similar to the wxFlexGridSizer except the items are explicitly positioned -in a virtual cell of the layout grid, and column or row spanning is allowed. For example, this -static text is positioned at (0,0) and it spans 7 columns. -""" - - -class TestFrame(wx.Frame): - def __init__(self): - wx.Frame.__init__(self, None, -1, "wxGridBagSizer") - p = wx.Panel(self, -1) - p.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) - - gbs = self.gbs = wx.GridBagSizer(5, 5) - - gbs.Add( wx.StaticText(p, -1, gbsDescription), - (0,0), (1,7), wx.ALIGN_CENTER | wx.ALL, 5) - - gbs.Add( wx.TextCtrl(p, -1, "pos(1,0)"), (1,0) ) - gbs.Add( wx.TextCtrl(p, -1, "pos(1,1)"), (1,1) ) - gbs.Add( wx.TextCtrl(p, -1, "pos(2,0)"), (2,0) ) - gbs.Add( wx.TextCtrl(p, -1, "pos(2,1)"), (2,1) ) - - gbs.Add( wx.TextCtrl(p, -1, "pos(3,2), span(1,2)\nthis row and col are growable", style=wx.TE_MULTILINE), - (3,2), (1,2), flag=wx.EXPAND ) - - gbs.Add( wx.TextCtrl(p, -1, "pos(4,3), span(3,1)", style=wx.TE_MULTILINE), - (4,3), (3,1), wx.EXPAND) - - gbs.Add( wx.TextCtrl(p, -1, "pos(5,4)"), (5,4), flag=wx.EXPAND ) - gbs.Add( wx.TextCtrl(p, -1, "pos(6,5)"), (6,5), flag=wx.EXPAND ) - gbs.Add( wx.TextCtrl(p, -1, "pos(7,6)"), (7,6) ) - - moveBtn1 = wx.Button(p, -1, "Move this to (3,6)") - moveBtn2 = wx.Button(p, -1, "Move this to (3,6)"); - gbs.Add( moveBtn1, (10,2) ) - gbs.Add( moveBtn2, (10,3) ) - - hideBtn = wx.Button(p, -1, "Hide this item -->") - gbs.Add(hideBtn, (12, 3)) - - hideTxt = wx.TextCtrl(p, -1, "pos(12,4), size(150, -1)", size = (150,-1)) - gbs.Add( hideTxt, (12,4) ) - - showBtn = wx.Button(p, -1, "<-- Show it again") - gbs.Add(showBtn, (12, 5)) - showBtn.Disable() - self.hideBtn = hideBtn - self.showBtn = showBtn - self.hideTxt = hideTxt - - self.Bind(wx.EVT_BUTTON, self.OnHideButton, hideBtn) - self.Bind(wx.EVT_BUTTON, self.OnShowButton, showBtn) - self.Bind(wx.EVT_BUTTON, self.OnMoveButton, moveBtn1) - self.Bind(wx.EVT_BUTTON, self.OnMoveButton, moveBtn2) - - # Add a spacer at the end to ensure some extra space at the bottom - gbs.Add((10,10), (14,7)) - - gbs.AddGrowableRow(3) - gbs.AddGrowableCol(2) - - p.SetSizerAndFit(gbs) - self.SetClientSize(p.GetSize()) - - - def OnHideButton(self, evt): - self.gbs.Hide(self.hideTxt) - self.hideBtn.Disable() - self.showBtn.Enable() - self.gbs.Layout() - - - def OnShowButton(self, evt): - self.gbs.Show(self.hideTxt) - self.hideBtn.Enable() - self.showBtn.Disable() - self.gbs.Layout() - - - def OnMoveButton(self, evt): - btn = evt.GetEventObject() - curPos = self.gbs.GetItemPosition(btn) - - # if it's already at the "other" spot then move it back - if curPos == (3,6): - self.gbs.SetItemPosition(btn, self.lastPos) - btn.SetLabel("Move this to (3,6)") - else: - if self.gbs.CheckForIntersection( (3,6), (1,1) ): - wx.MessageBox("""\ -wxGridBagSizer will not allow items to be in the same cell as -another item, so this operation will fail. You will also get an assert -when compiled in debug mode.""", - "Warning", wx.OK | wx.ICON_INFORMATION) - - try: - if self.gbs.SetItemPosition(btn, (3,6)): - self.lastPos = curPos - btn.SetLabel("Move it back") - except wx.PyAssertionError: - pass - - self.gbs.Layout() - - - def OnLeftDown(self, evt): - pt = evt.GetPosition() - item = self.gbs.FindItemAtPoint(pt) - if item is None: - print "no item at", `pt` - else: - print "item found: ", `item.GetPos()`, "--", `item.GetSpan()` - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestFrame() - frame.otherWin = win - win.Show(True) - - -#---------------------------------------------------------------------- - - - -overview = """ -

wxGridBagSizer

- -The wxGridBagSizer is more or less a port of the the RowColSizer (that -has been in the wxPython.lib package for quite some time) to C++. It -allows items to be placed at specific layout grid cells, and items can -span across more than one row or column. - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxGrid_MegaExample.py b/wxPython/demo/wxGrid_MegaExample.py deleted file mode 100644 index 751e7ab291..0000000000 --- a/wxPython/demo/wxGrid_MegaExample.py +++ /dev/null @@ -1,487 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import wx.grid as Grid - -import images - -class MegaTable(Grid.PyGridTableBase): - """ - A custom wxGrid Table using user supplied data - """ - def __init__(self, data, colnames, plugins): - """data is a list of the form - [(rowname, dictionary), - dictionary.get(colname, None) returns the data for column - colname - """ - # The base class must be initialized *first* - Grid.PyGridTableBase.__init__(self) - self.data = data - self.colnames = colnames - self.plugins = plugins or {} - # XXX - # we need to store the row length and column length to - # see if the table has changed size - self._rows = self.GetNumberRows() - self._cols = self.GetNumberCols() - - def GetNumberCols(self): - return len(self.colnames) - - def GetNumberRows(self): - return len(self.data) - - def GetColLabelValue(self, col): - return self.colnames[col] - - def GetRowLabelValue(self, row): - return "row %03d" % int(self.data[row][0]) - - def GetValue(self, row, col): - return str(self.data[row][1].get(self.GetColLabelValue(col), "")) - - def GetRawValue(self, row, col): - return self.data[row][1].get(self.GetColLabelValue(col), "") - - def SetValue(self, row, col, value): - self.data[row][1][self.GetColLabelValue(col)] = value - - def ResetView(self, grid): - """ - (Grid) -> Reset the grid view. Call this to - update the grid if rows and columns have been added or deleted - """ - grid.BeginBatch() - - for current, new, delmsg, addmsg in [ - (self._rows, self.GetNumberRows(), Grid.GRIDTABLE_NOTIFY_ROWS_DELETED, Grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), - (self._cols, self.GetNumberCols(), Grid.GRIDTABLE_NOTIFY_COLS_DELETED, Grid.GRIDTABLE_NOTIFY_COLS_APPENDED), - ]: - - if new < current: - msg = Grid.GridTableMessage(self,delmsg,new,current-new) - grid.ProcessTableMessage(msg) - elif new > current: - msg = Grid.GridTableMessage(self,addmsg,new-current) - grid.ProcessTableMessage(msg) - self.UpdateValues(grid) - - grid.EndBatch() - - self._rows = self.GetNumberRows() - self._cols = self.GetNumberCols() - # update the column rendering plugins - self._updateColAttrs(grid) - - # update the scrollbars and the displayed part of the grid - grid.AdjustScrollbars() - grid.ForceRefresh() - - - def UpdateValues(self, grid): - """Update all displayed values""" - # This sends an event to the grid table to update all of the values - msg = Grid.GridTableMessage(self, Grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) - grid.ProcessTableMessage(msg) - - def _updateColAttrs(self, grid): - """ - wxGrid -> update the column attributes to add the - appropriate renderer given the column name. (renderers - are stored in the self.plugins dictionary) - - Otherwise default to the default renderer. - """ - col = 0 - - for colname in self.colnames: - attr = Grid.GridCellAttr() - if colname in self.plugins: - renderer = self.plugins[colname](self) - - if renderer.colSize: - grid.SetColSize(col, renderer.colSize) - - if renderer.rowSize: - grid.SetDefaultRowSize(renderer.rowSize) - - attr.SetReadOnly(True) - attr.SetRenderer(renderer) - - grid.SetColAttr(col, attr) - col += 1 - - # ------------------------------------------------------ - # begin the added code to manipulate the table (non wx related) - def AppendRow(self, row): - #print 'append' - entry = {} - - for name in self.colnames: - entry[name] = "Appended_%i"%row - - # XXX Hack - # entry["A"] can only be between 1..4 - entry["A"] = random.choice(range(4)) - self.data.insert(row, ["Append_%i"%row, entry]) - - def DeleteCols(self, cols): - """ - cols -> delete the columns from the dataset - cols hold the column indices - """ - # we'll cheat here and just remove the name from the - # list of column names. The data will remain but - # it won't be shown - deleteCount = 0 - cols = cols[:] - cols.sort() - - for i in cols: - self.colnames.pop(i-deleteCount) - # we need to advance the delete count - # to make sure we delete the right columns - deleteCount += 1 - - if not len(self.colnames): - self.data = [] - - def DeleteRows(self, rows): - """ - rows -> delete the rows from the dataset - rows hold the row indices - """ - deleteCount = 0 - rows = rows[:] - rows.sort() - - for i in rows: - self.data.pop(i-deleteCount) - # we need to advance the delete count - # to make sure we delete the right rows - deleteCount += 1 - - def SortColumn(self, col): - """ - col -> sort the data based on the column indexed by col - """ - name = self.colnames[col] - _data = [] - - for row in self.data: - rowname, entry = row - _data.append((entry.get(name, None), row)) - - _data.sort() - self.data = [] - - for sortvalue, row in _data: - self.data.append(row) - - # end table manipulation code - # ---------------------------------------------------------- - - -# -------------------------------------------------------------------- -# Sample wxGrid renderers - -class MegaImageRenderer(Grid.PyGridCellRenderer): - def __init__(self, table): - """ - Image Renderer Test. This just places an image in a cell - based on the row index. There are N choices and the - choice is made by choice[row%N] - """ - Grid.PyGridCellRenderer.__init__(self) - self.table = table - self._choices = [images.getSmilesBitmap, - images.getMondrianBitmap, - images.get_10s_Bitmap, - images.get_01c_Bitmap] - - self.colSize = None - self.rowSize = None - - def Draw(self, grid, attr, dc, rect, row, col, isSelected): - choice = self.table.GetRawValue(row, col) - bmp = self._choices[ choice % len(self._choices)]() - image = wx.MemoryDC() - image.SelectObject(bmp) - - # clear the background - dc.SetBackgroundMode(wx.SOLID) - - if isSelected: - dc.SetBrush(wx.Brush(wx.BLUE, wx.SOLID)) - dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID)) - else: - dc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID)) - dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID)) - dc.DrawRectangleRect(rect) - - #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height)) - - # copy the image but only to the size of the grid cell - width, height = bmp.GetWidth(), bmp.GetHeight() - - if width > rect.width-2: - width = rect.width-2 - - if height > rect.height-2: - height = rect.height-2 - - dc.Blit((rect.x+1, rect.y+1), (width, height), - image, - (0, 0), wx.COPY, True) - - -class MegaFontRenderer(Grid.PyGridCellRenderer): - def __init__(self, table, color="blue", font="ARIAL", fontsize=8): - """Render data in the specified color and font and fontsize""" - Grid.PyGridCellRenderer.__init__(self) - self.table = table - self.color = color - self.font = wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, font) - self.selectedBrush = wx.Brush("blue", wx.SOLID) - self.normalBrush = wx.Brush(wx.WHITE, wx.SOLID) - self.colSize = None - self.rowSize = 50 - - def Draw(self, grid, attr, dc, rect, row, col, isSelected): - # Here we draw text in a grid cell using various fonts - # and colors. We have to set the clipping region on - # the grid's DC, otherwise the text will spill over - # to the next cell - dc.SetClippingRect(rect) - - # clear the background - dc.SetBackgroundMode(wx.SOLID) - - if isSelected: - dc.SetBrush(wx.Brush(wx.BLUE, wx.SOLID)) - dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID)) - else: - dc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID)) - dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID)) - dc.DrawRectangleRect(rect) - - #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height)) - - text = self.table.GetValue(row, col) - dc.SetBackgroundMode(wx.SOLID) - - # change the text background based on whether the grid is selected - # or not - if isSelected: - dc.SetBrush(self.selectedBrush) - dc.SetTextBackground("blue") - else: - dc.SetBrush(self.normalBrush) - dc.SetTextBackground("white") - - dc.SetTextForeground(self.color) - dc.SetFont(self.font) - dc.DrawText(text, (rect.x+1, rect.y+1)) - - # Okay, now for the advanced class :) - # Let's add three dots "..." - # to indicate that that there is more text to be read - # when the text is larger than the grid cell - - width, height = dc.GetTextExtent(text) - - if width > rect.width-2: - width, height = dc.GetTextExtent("...") - x = rect.x+1 + rect.width-2 - width - dc.DrawRectangle((x, rect.y+1), (width+1, height)) - dc.DrawText("...", (x, rect.y+1)) - - dc.DestroyClippingRegion() - - -# -------------------------------------------------------------------- -# Sample Grid using a specialized table and renderers that can -# be plugged in based on column names - -class MegaGrid(Grid.Grid): - def __init__(self, parent, data, colnames, plugins=None): - """parent, data, colnames, plugins=None - Initialize a grid using the data defined in data and colnames - (see MegaTable for a description of the data format) - plugins is a dictionary of columnName -> column renderers. - """ - - # The base class must be initialized *first* - Grid.Grid.__init__(self, parent, -1) - self._table = MegaTable(data, colnames, plugins) - self.SetTable(self._table) - self._plugins = plugins - - self.Bind(Grid.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClicked) - - def Reset(self): - """reset the view based on the data in the table. Call - this when rows are added or destroyed""" - self._table.ResetView(self) - - def OnLabelRightClicked(self, evt): - # Did we click on a row or a column? - row, col = evt.GetRow(), evt.GetCol() - if row == -1: self.colPopup(col, evt) - elif col == -1: self.rowPopup(row, evt) - - def rowPopup(self, row, evt): - """(row, evt) -> display a popup menu when a row label is right clicked""" - appendID = wx.NewId() - deleteID = wx.NewId() - x = self.GetRowSize(row)/2 - - if not self.GetSelectedRows(): - self.SelectRow(row) - - menu = wx.Menu() - xo, yo = evt.GetPosition() - menu.Append(appendID, "Append Row") - menu.Append(deleteID, "Delete Row(s)") - - def append(event, self=self, row=row): - self._table.AppendRow(row) - self.Reset() - - def delete(event, self=self, row=row): - rows = self.GetSelectedRows() - self._table.DeleteRows(rows) - self.Reset() - - self.Bind(wx.EVT_MENU, append, id=appendID) - self.Bind(wx.EVT_MENU, delete, id=deleteID) - self.PopupMenu(menu, (x, yo)) - menu.Destroy() - return - - - def colPopup(self, col, evt): - """(col, evt) -> display a popup menu when a column label is - right clicked""" - x = self.GetColSize(col)/2 - menu = wx.Menu() - id1 = wx.NewId() - sortID = wx.NewId() - - xo, yo = evt.GetPosition() - self.SelectCol(col) - cols = self.GetSelectedCols() - self.Refresh() - menu.Append(id1, "Delete Col(s)") - menu.Append(sortID, "Sort Column") - - def delete(event, self=self, col=col): - cols = self.GetSelectedCols() - self._table.DeleteCols(cols) - self.Reset() - - def sort(event, self=self, col=col): - self._table.SortColumn(col) - self.Reset() - - self.Bind(wx.EVT_MENU, delete, id=id1) - - if len(cols) == 1: - self.Bind(wx.EVT_MENU, sort, id=sortID) - - self.PopupMenu(menu, (xo, 0)) - menu.Destroy() - return - -# ----------------------------------------------------------------- -# Test data -# data is in the form -# [rowname, dictionary] -# where dictionary.get(colname, None) -> returns the value for the cell -# -# the colname must also be supplied -import random -colnames = ["Row", "This", "Is", "A", "Test"] - -data = [] - -for row in range(1000): - d = {} - for name in ["This", "Test", "Is"]: - d[name] = random.random() - - d["Row"] = len(data) - # XXX - # the "A" column can only be between one and 4 - d["A"] = random.choice(range(4)) - data.append((str(row), d)) - -class MegaFontRendererFactory: - def __init__(self, color, font, fontsize): - """ - (color, font, fontsize) -> set of a factory to generate - renderers when called. - func = MegaFontRenderFactory(color, font, fontsize) - renderer = func(table) - """ - self.color = color - self.font = font - self.fontsize = fontsize - - def __call__(self, table): - return MegaFontRenderer(table, self.color, self.font, self.fontsize) - - -#--------------------------------------------------------------------------- - -class TestFrame(wx.Frame): - def __init__(self, parent, plugins={"This":MegaFontRendererFactory("red", "ARIAL", 8), - "A":MegaImageRenderer, - "Test":MegaFontRendererFactory("orange", "TIMES", 24),}): - wx.Frame.__init__(self, parent, -1, - "Test Frame", size=(640,480)) - - grid = MegaGrid(self, data, colnames, plugins) - grid.Reset() - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestFrame(frame) - frame.otherWin = win - win.Show(True) - - - -overview = """Mega Grid Example - -This example attempts to show many examples and tricks of -using a virtual grid object. Hopefully the source isn't too jumbled. - -Features: -
    -
  1. Uses a virtual grid -
  2. Columns and rows have popup menus (right click on labels) -
  3. Columns and rows can be deleted (i.e. table can be - resized) -
  4. Dynamic renderers. Renderers are plugins based on - column header name. Shows a simple Font Renderer and - an Image Renderer. -
- -Look for 'XXX' in the code to indicate some workarounds for non-obvious -behavior and various hacks. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxHtmlWindow.py b/wxPython/demo/wxHtmlWindow.py deleted file mode 100644 index edfe7027b6..0000000000 --- a/wxPython/demo/wxHtmlWindow.py +++ /dev/null @@ -1,239 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o got the wxpTag stuff working right. -# -# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxScrolledMessageDialog -> ScrolledMessageDialog -# - -import os -import sys - -import wx -import wx.html as html -import wx.lib.wxpTag - -from Main import opj - -#---------------------------------------------------------------------- - -# This shows how to catch the OnLinkClicked non-event. (It's a virtual -# method in the C++ code...) -class MyHtmlWindow(html.HtmlWindow): - def __init__(self, parent, id, log): - html.HtmlWindow.__init__(self, parent, id, style=wx.NO_FULL_REPAINT_ON_RESIZE) - self.log = log - self.Bind(wx.EVT_SCROLLWIN, self.OnScroll ) - - def OnScroll( self, event ): - #print 'event.GetOrientation()',event.GetOrientation() - #print 'event.GetPosition()',event.GetPosition() - event.Skip() - - def OnLinkClicked(self, linkinfo): - self.log.WriteText('OnLinkClicked: %s\n' % linkinfo.GetHref()) - - # Virtuals in the base class have been renamed with base_ on the front. - self.base_OnLinkClicked(linkinfo) - - - def OnSetTitle(self, title): - self.log.WriteText('OnSetTitle: %s\n' % title) - self.base_OnSetTitle(title) - - def OnCellMouseHover(self, cell, x, y): - self.log.WriteText('OnCellMouseHover: %s, (%d %d)\n' % (cell, x, y)) - self.base_OnCellMouseHover(cell, x, y) - - def OnCellClicked(self, cell, x, y, evt): - self.log.WriteText('OnCellClicked: %s, (%d %d)\n' % (cell, x, y)) - self.base_OnCellClicked(cell, x, y, evt) - - -# This filter doesn't really do anything but show how to use filters -class MyHtmlFilter(html.HtmlFilter): - def __init__(self, log): - html.HtmlFilter.__init__(self) - self.log = log - - # This method decides if this filter is able to read the file - def CanRead(self, fsfile): - self.log.write("CanRead: %s\n" % fsfile.GetMimeType()) - return False - - # If CanRead returns True then this method is called to actually - # read the file and return the contents. - def ReadFile(self, fsfile): - return "" - - -class TestHtmlPanel(wx.Panel): - def __init__(self, parent, frame, log): - wx.Panel.__init__(self, parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) - self.log = log - self.frame = frame - self.cwd = os.path.split(sys.argv[0])[0] - - if not self.cwd: - self.cwd = os.getcwd() - if frame: - self.titleBase = frame.GetTitle() - - html.HtmlWindow_AddFilter(MyHtmlFilter(log)) - - self.html = MyHtmlWindow(self, -1, log) - self.html.SetRelatedFrame(frame, self.titleBase + " -- %s") - self.html.SetRelatedStatusBar(0) - - self.printer = html.HtmlEasyPrinting() - - self.box = wx.BoxSizer(wx.VERTICAL) - self.box.Add(self.html, 1, wx.GROW) - - subbox = wx.BoxSizer(wx.HORIZONTAL) - - btn = wx.Button(self, -1, "Load File") - self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn) - subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) - - btn = wx.Button(self, -1, "Load URL") - self.Bind(wx.EVT_BUTTON, self.OnLoadURL, btn) - subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) - - btn = wx.Button(self, -1, "With Widgets") - self.Bind(wx.EVT_BUTTON, self.OnWithWidgets, btn) - subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) - - btn = wx.Button(self, -1, "Back") - self.Bind(wx.EVT_BUTTON, self.OnBack, btn) - subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) - - btn = wx.Button(self, -1, "Forward") - self.Bind(wx.EVT_BUTTON, self.OnForward, btn) - subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) - - btn = wx.Button(self, -1, "Print") - self.Bind(wx.EVT_BUTTON, self.OnPrint, btn) - subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) - - btn = wx.Button(self, -1, "View Source") - self.Bind(wx.EVT_BUTTON, self.OnViewSource, btn) - subbox.Add(btn, 1, wx.GROW | wx.ALL, 2) - - self.box.Add(subbox, 0, wx.GROW) - self.SetSizer(self.box) - self.SetAutoLayout(True) - - # A button with this ID is created on the widget test page. - self.Bind(wx.EVT_BUTTON, self.OnOk, id=wx.ID_OK) - - self.OnShowDefault(None) - - - def ShutdownDemo(self): - # put the frame title back - if self.frame: - self.frame.SetTitle(self.titleBase) - - - def OnShowDefault(self, event): - name = os.path.join(self.cwd, opj('data/test.htm')) - self.html.LoadPage(name) - - - def OnLoadFile(self, event): - dlg = wx.FileDialog(self, wildcard = '*.htm*', style=wx.OPEN) - - if dlg.ShowModal(): - path = dlg.GetPath() - self.html.LoadPage(path) - - dlg.Destroy() - - - def OnLoadURL(self, event): - dlg = wx.TextEntryDialog(self, "Enter a URL") - - if dlg.ShowModal(): - url = dlg.GetValue() - self.html.LoadPage(url) - - dlg.Destroy() - - - def OnWithWidgets(self, event): - os.chdir(self.cwd) - name = os.path.join(self.cwd, opj('data/widgetTest.htm')) - self.html.LoadPage(name) - - - def OnOk(self, event): - self.log.WriteText("It works!\n") - - def OnBack(self, event): - if not self.html.HistoryBack(): - wx.MessageBox("No more items in history!") - - - def OnForward(self, event): - if not self.html.HistoryForward(): - wx.MessageBox("No more items in history!") - - - def OnViewSource(self, event): - import wx.lib.dialogs - - source = self.html.GetParser().GetSource() - - dlg = wx.lib.dialogs.ScrolledMessageDialog(self, source, 'HTML Source') - dlg.ShowModal() - dlg.Destroy() - - - def OnPrint(self, event): - self.printer.GetPrintData().SetPaperId(wx.PAPER_LETTER) - self.printer.PrintFile(self.html.GetOpenedPage()) - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestHtmlPanel(nb, frame, log) - print wx.Window_FindFocus() - return win - - -#---------------------------------------------------------------------- - - -overview = """ -

wxHtmlWindow

- -

wxHtmlWindow is capable of parsing and rendering most -simple HTML tags. - -

It is not intended to be a high-end HTML browser. If you're -looking for something like that see the IEHtmlWin class, which -wraps the core MSIE HTML viewer. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - - - - - - - - diff --git a/wxPython/demo/wxIEHtmlWin.py b/wxPython/demo/wxIEHtmlWin.py deleted file mode 100644 index 33e5b8c8be..0000000000 --- a/wxPython/demo/wxIEHtmlWin.py +++ /dev/null @@ -1,221 +0,0 @@ -# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o iewin.py is missing -# - -import wx - -if wx.Platform == '__WXMSW__': - import wx.iewin as iewin - -#---------------------------------------------------------------------- - -class TestPanel(wx.Window): - def __init__(self, parent, log, frame=None): - wx.Window.__init__( - self, parent, -1, - style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE - ) - - self.log = log - self.current = "http://wxPython.org/" - self.frame = frame - - if frame: - self.titleBase = frame.GetTitle() - - sizer = wx.BoxSizer(wx.VERTICAL) - btnSizer = wx.BoxSizer(wx.HORIZONTAL) - - self.ie = iewin.IEHtmlWin(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE) - - - btn = wx.Button(self, wx.NewId(), "Open", style=wx.BU_EXACTFIT) - wx.EVT_BUTTON(self, btn.GetId(), self.OnOpenButton) - btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) - - btn = wx.Button(self, wx.NewId(), "Home", style=wx.BU_EXACTFIT) - wx.EVT_BUTTON(self, btn.GetId(), self.OnHomeButton) - btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) - - btn = wx.Button(self, wx.NewId(), "<--", style=wx.BU_EXACTFIT) - wx.EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton) - btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) - - btn = wx.Button(self, wx.NewId(), "-->", style=wx.BU_EXACTFIT) - wx.EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton) - btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) - - btn = wx.Button(self, wx.NewId(), "Stop", style=wx.BU_EXACTFIT) - wx.EVT_BUTTON(self, btn.GetId(), self.OnStopButton) - btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) - - btn = wx.Button(self, wx.NewId(), "Search", style=wx.BU_EXACTFIT) - wx.EVT_BUTTON(self, btn.GetId(), self.OnSearchPageButton) - btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) - - btn = wx.Button(self, wx.NewId(), "Refresh", style=wx.BU_EXACTFIT) - wx.EVT_BUTTON(self, btn.GetId(), self.OnRefreshPageButton) - btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) - - txt = wx.StaticText(self, -1, "Location:") - btnSizer.Add(txt, 0, wx.CENTER|wx.ALL, 2) - - self.location = wx.ComboBox( - self, wx.NewId(), "", style=wx.CB_DROPDOWN|wx.PROCESS_ENTER - ) - - wx.EVT_COMBOBOX(self, self.location.GetId(), self.OnLocationSelect) - wx.EVT_KEY_UP(self.location, self.OnLocationKey) - wx.EVT_CHAR(self.location, self.IgnoreReturn) - btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2) - - sizer.Add(btnSizer, 0, wx.EXPAND) - sizer.Add(self.ie, 1, wx.EXPAND) - - self.ie.Navigate(self.current) - self.location.Append(self.current) - - self.SetSizer(sizer) - self.SetAutoLayout(True) - wx.EVT_SIZE(self, self.OnSize) - - # Hook up the event handlers for the IE window - iewin.EVT_MSHTML_BEFORENAVIGATE2(self, -1, self.OnBeforeNavigate2) - iewin.EVT_MSHTML_NEWWINDOW2(self, -1, self.OnNewWindow2) - iewin.EVT_MSHTML_DOCUMENTCOMPLETE(self, -1, self.OnDocumentComplete) - #EVT_MSHTML_PROGRESSCHANGE(self, -1, self.OnProgressChange) - iewin.EVT_MSHTML_STATUSTEXTCHANGE(self, -1, self.OnStatusTextChange) - iewin.EVT_MSHTML_TITLECHANGE(self, -1, self.OnTitleChange) - - - def ShutdownDemo(self): - # put the frame title back - if self.frame: - self.frame.SetTitle(self.titleBase) - - - def OnSize(self, evt): - self.Layout() - - - def OnLocationSelect(self, evt): - url = self.location.GetStringSelection() - self.log.write('OnLocationSelect: %s\n' % url) - self.ie.Navigate(url) - - def OnLocationKey(self, evt): - if evt.KeyCode() == wx.WXK_RETURN: - URL = self.location.GetValue() - self.location.Append(URL) - self.ie.Navigate(URL) - else: - evt.Skip() - - - def IgnoreReturn(self, evt): - if evt.GetKeyCode() != wx.WXK_RETURN: - evt.Skip() - - def OnOpenButton(self, event): - dlg = wx.TextEntryDialog(self, "Open Location", - "Enter a full URL or local path", - self.current, wx.OK|wx.CANCEL) - dlg.CentreOnParent() - - if dlg.ShowModal() == wx.ID_OK: - self.current = dlg.GetValue() - self.ie.Navigate(self.current) - - dlg.Destroy() - - def OnHomeButton(self, event): - self.ie.GoHome() ## ET Phone Home! - - def OnPrevPageButton(self, event): - self.ie.GoBack() - - def OnNextPageButton(self, event): - self.ie.GoForward() - - def OnStopButton(self, evt): - self.ie.Stop() - - def OnSearchPageButton(self, evt): - self.ie.GoSearch() - - def OnRefreshPageButton(self, evt): - self.ie.Refresh(iewin.IEHTML_REFRESH_COMPLETELY) - - - def logEvt(self, name, event): - self.log.write('%s: %s\n' % - (name, (event.GetLong1(), event.GetLong2(), event.GetText1()))) - - def OnBeforeNavigate2(self, evt): - self.logEvt('OnBeforeNavigate2', evt) - - def OnNewWindow2(self, evt): - self.logEvt('OnNewWindow2', evt) - evt.Veto() # don't allow it - - def OnDocumentComplete(self, evt): - self.logEvt('OnDocumentComplete', evt) - self.current = evt.GetText1() - self.location.SetValue(self.current) - - def OnTitleChange(self, evt): - self.logEvt('OnTitleChange', evt) - if self.frame: - self.frame.SetTitle(self.titleBase + ' -- ' + evt.GetText1()) - - def OnStatusTextChange(self, evt): - self.logEvt('OnStatusTextChange', evt) - if self.frame: - self.frame.SetStatusText(evt.GetText1()) - - -#---------------------------------------------------------------------- -# for the demo framework... - -def runTest(frame, nb, log): - if wx.Platform == '__WXMSW__': - win = TestPanel(nb, log, frame) - return win - else: - dlg = wx.MessageDialog(frame, 'This demo only works on MSW.', - 'Sorry', wx.OK | wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - - - -overview = """\ - -

wxIEHtmlWin

- -The wxIEHtmlWin class is the first example of using a contributed -wxActiveX class in wxWindows C++. It is still experimental, but -I think it is useful. - -

Using this class is simpler than ActiveXWrapper, doesn't rely on -the win32all extensions, and is more "wx\'ish", meaning that it uses -events and etc. as would be expected from any other wx window. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - - -#---------------------------------------------------------------------- - diff --git a/wxPython/demo/wxImage.py b/wxPython/demo/wxImage.py deleted file mode 100644 index 415bfd9ce7..0000000000 --- a/wxPython/demo/wxImage.py +++ /dev/null @@ -1,81 +0,0 @@ -# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -from Main import opj - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - bmp = wx.Image(opj('bitmaps/image.bmp'), wx.BITMAP_TYPE_BMP).ConvertToBitmap() - gif = wx.Image(opj('bitmaps/image.gif'), wx.BITMAP_TYPE_GIF).ConvertToBitmap() - png = wx.Image(opj('bitmaps/image.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() - jpg = wx.Image(opj('bitmaps/image.jpg'), wx.BITMAP_TYPE_JPEG).ConvertToBitmap() - - panel = wx.Panel(nb, -1) - - pos = 10 - wx.StaticBitmap(panel, -1, bmp, (10, pos), (bmp.GetWidth(), bmp.GetHeight())) - - pos = pos + bmp.GetHeight() + 10 - wx.StaticBitmap(panel, -1, gif, (10, pos), (gif.GetWidth(), gif.GetHeight())) - - pos = pos + gif.GetHeight() + 10 - wx.StaticBitmap(panel, -1, png, (10, pos), (png.GetWidth(), png.GetHeight())) - - pos = pos + png.GetHeight() + 10 - wx.StaticBitmap(panel, -1, jpg, (10, pos), (jpg.GetWidth(), jpg.GetHeight())) - - return panel - -#---------------------------------------------------------------------- - - - -overview = """\ - - -This class encapsulates a platform-independent image. An image can be created -from data, or using wxBitmap.ConvertToImage. An image can be loaded from -a file in a variety of formats, and is extensible to new formats via image -format handlers. Functions are available to set and get image bits, so it can -be used for basic image manipulation. - -

The following image handlers are available. wxBMPHandler is always installed -by default. To use other image formats, install the appropriate handler or use -wx.InitAllImageHandlers(). - -

- - - - - - - - - - - - - -
wxBMPHandler For loading and saving, always installed.
wxPNGHandler For loading and saving.
wxJPEGHandler For loading and saving.
wxGIFHandler Only for loading, due to legal issues.
wxPCXHandler For loading and saving.
wxPNMHandler For loading and saving.
wxTIFFHandler For loading and saving.
wxIFFHandler For loading only.
wxXPMHandler For loading and saving.
wxICOHandler For loading and saving.
wxCURHandler For loading and saving.
wxANIHandler For loading only.
- -

When saving in PCX format, wxPCXHandler will count the number of different -colours in the image; if there are 256 or less colours, it will save as 8 bit, -else it will save as 24 bit. - -

Loading PNMs only works for ASCII or raw RGB images. When saving in PNM format, -wxPNMHandler will always save as raw RGB. - - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxImageFromStream.py b/wxPython/demo/wxImageFromStream.py deleted file mode 100644 index 720389a818..0000000000 --- a/wxPython/demo/wxImageFromStream.py +++ /dev/null @@ -1,50 +0,0 @@ -# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import cStringIO - -import wx - -from Main import opj - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - - data = open(opj('bitmaps/image.png'), "rb").read() - stream = cStringIO.StringIO(data) - - bmp = wx.BitmapFromImage( wx.ImageFromStream( stream )) - - wx.StaticText( - self, -1, "This image was loaded from a Python file-like object:", - (15, 15) - ) - - wx.StaticBitmap(self, -1, bmp, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight())) - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -At long last there is finally a way to load any supported image type -directly from any Python file-like object, such as a memory buffer -using StringIO. """ - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxIntCtrl.py b/wxPython/demo/wxIntCtrl.py deleted file mode 100644 index 27b968c5a2..0000000000 --- a/wxPython/demo/wxIntCtrl.py +++ /dev/null @@ -1,359 +0,0 @@ -# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o intctrl needs the renamer applied. -# o intctrl needs new event binders. -# -# 12/08/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o All issues corrected -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxIntCtrl -> IntCtrl -# - -import wx -import wx.lib.intctrl - -#---------------------------------------------------------------------- - -class TestPanel( wx.Panel ): - def __init__( self, parent, log ): - - wx.Panel.__init__( self, parent, -1 ) - self.log = log - panel = wx.Panel( self, -1 ) - - self.set_min = wx.CheckBox( panel, -1, "Set minimum value:" ) - self.min = wx.lib.intctrl.IntCtrl( panel, size=( 50, -1 ) ) - self.min.Enable( False ) - - self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" ) - self.max = wx.lib.intctrl.IntCtrl( panel, size=( 50, -1 ) ) - self.max.Enable( False ) - - self.limit_target = wx.CheckBox( panel, -1, "Limit control" ) - self.allow_none = wx.CheckBox( panel, -1, "Allow empty control" ) - self.allow_long = wx.CheckBox( panel, -1, "Allow long integers" ) - - label = wx.StaticText( panel, -1, "Resulting integer control:" ) - self.target_ctl = wx.lib.intctrl.IntCtrl( panel ) - - grid = wx.FlexGridSizer( 0, 2, 0, 0 ) - grid.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid.Add( self.min, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid.Add(self.set_max, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid.Add( self.max, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid.Add( self.limit_target, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid.Add( self.allow_none, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid.Add( self.allow_long, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid.Add( self.target_ctl, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - outer_box = wx.BoxSizer( wx.VERTICAL ) - outer_box.AddSizer( grid, 0, wx.ALIGN_CENTRE|wx.ALL, 20 ) - - panel.SetAutoLayout( True ) - panel.SetSizer( outer_box ) - outer_box.Fit( panel ) - panel.Move( (50,50) ) - self.panel = panel - - self.Bind(wx.EVT_CHECKBOX, self.OnSetMin, self.set_min) - self.Bind(wx.EVT_CHECKBOX, self.OnSetMax, self.set_max) - self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target) - self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none) - self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowLong, self.allow_long) - - self.Bind(wx.lib.intctrl.EVT_INT, self.SetTargetMinMax, self.min) - self.Bind(wx.lib.intctrl.EVT_INT, self.SetTargetMinMax, self.max) - self.Bind(wx.lib.intctrl.EVT_INT, self.OnTargetChange, self.target_ctl) - - - def OnSetMin( self, event ): - self.min.Enable( self.set_min.GetValue() ) - self.SetTargetMinMax() - - def OnSetMax( self, event ): - self.max.Enable( self.set_max.GetValue() ) - self.SetTargetMinMax() - - - def SetTargetMinMax( self, event=None ): - min = max = None - self.target_ctl.SetLimited( self.limit_target.GetValue() ) - - if self.set_min.GetValue(): - min = self.min.GetValue() - - if self.set_max.GetValue(): - max = self.max.GetValue() - - cur_min, cur_max = self.target_ctl.GetBounds() - - if min != cur_min and not self.target_ctl.SetMin( min ): - self.log.write( "min (%d) > current max (%d) -- bound not set\n" % ( min, self.target_ctl.GetMax() ) ) - self.min.SetForegroundColour( wx.RED ) - else: - self.min.SetForegroundColour( wx.BLACK ) - - self.min.Refresh() - - if max != cur_max and not self.target_ctl.SetMax( max ): - self.log.write( "max (%d) < current min (%d) -- bound not set\n" % ( max, self.target_ctl.GetMin() ) ) - self.max.SetForegroundColour( wx.RED ) - else: - self.max.SetForegroundColour( wx.BLACK ) - - self.max.Refresh() - - if min != cur_min or max != cur_max: - new_min, new_max = self.target_ctl.GetBounds() - self.log.write( "current min, max: (%s, %s)\n" % ( str(new_min), str(new_max) ) ) - - - def OnSetAllowNone( self, event ): - self.target_ctl.SetNoneAllowed( self.allow_none.GetValue() ) - - - def OnSetAllowLong( self, event ): - self.target_ctl.SetLongAllowed( self.allow_long.GetValue() ) - - - def OnTargetChange( self, event ): - ctl = event.GetEventObject() - value = ctl.GetValue() - ib_str = [ " (out of bounds)", "" ] - self.log.write( "integer value = %s%s\n" % ( str(value), ib_str[ ctl.IsInBounds(value) ] ) ) - - -#---------------------------------------------------------------------- - -def runTest( frame, nb, log ): - win = TestPanel( nb, log ) - return win - -#---------------------------------------------------------------------- - -overview = """ -

-IntCtrl provides a control that takes and returns integers as -value, and provides bounds support and optional value limiting. -

-

-Here's the API for IntCtrl: -

-    IntCtrl(
-         parent, id = -1,
-         value = 0,
-         min = None,
-         max = None,
-         limited = False,
-         allow_none = False,
-         allow_long = False,
-         default_color = wxBLACK,
-         oob_color = wxRED,
-         pos = wxDefaultPosition,
-         size = wxDefaultSize,
-         style = 0,
-         name = "integer")
-
-
    -
    value -
    If no initial value is set, the default will be zero, or - the minimum value, if specified. If an illegal string is specified, - a ValueError will result. (You can always later set the initial - value with SetValue() after instantiation of the control.) -
    -
    min -
    The minimum value that the control should allow. This can be - adjusted with SetMin(). If the control is not limited, any value - below this bound will be colored with the current out-of-bounds color. -
    -
    max -
    The maximum value that the control should allow. This can be - adjusted with SetMax(). If the control is not limited, any value - above this bound will be colored with the current out-of-bounds color. -
    -
    limited -
    Boolean indicating whether the control prevents values from - exceeding the currently set minimum and maximum values (bounds). - If False and bounds are set, out-of-bounds values will - be colored with the current out-of-bounds color. -
    -
    allow_none -
    Boolean indicating whether or not the control is allowed to be - empty, representing a value of None for the control. -
    -
    allow_long -
    Boolean indicating whether or not the control is allowed to hold - and return a value of type long as well as int. If False, the - control will be implicitly limited to have a value such that - -sys.maxint-1 <= n <= sys.maxint. -
    -
    default_color -
    Color value used for in-bounds values of the control. -
    -
    oob_color -
    Color value used for out-of-bounds values of the control - when the bounds are set but the control is not limited. -
-
-
-
EVT_INT(win, id, func) -
Respond to a wxEVT_COMMAND_INT_UPDATED event, generated when the -value changes. Notice that this event will always be sent when the -control's contents changes - whether this is due to user input or -comes from the program itself (for example, if SetValue() is called.) -
-
-
SetValue(int) -
Sets the value of the control to the integer value specified. -The resulting actual value of the control may be altered to -conform with the bounds set on the control if limited, -or colored if not limited but the value is out-of-bounds. -A ValueError exception will be raised if an invalid value -is specified. -
-
GetValue() -
Retrieves the integer value from the control. The value -retrieved will be sized as an int if possible or a long, -if necessary. -
-
-
SetMin(min=None) -
Sets the expected minimum value, or lower bound, of the control. -(The lower bound will only be enforced if the control is -configured to limit its values to the set bounds.) -If a value of None is provided, then the control will have -no explicit lower bound. If the value specified is greater than -the current lower bound, then the function returns 0 and the -lower bound will not change from its current setting. On success, -the function returns 1. -
If successful and the current value is -lower than the new lower bound, if the control is limited, the -value will be automatically adjusted to the new minimum value; -if not limited, the value in the control will be colored with -the current out-of-bounds color. -
-
GetMin() -
Gets the current lower bound value for the control. -It will return None if no lower bound is currently specified. -
-
-
SetMax(max=None) -
Sets the expected maximum value, or upper bound, of the control. -(The upper bound will only be enforced if the control is -configured to limit its values to the set bounds.) -If a value of None is provided, then the control will -have no explicit upper bound. If the value specified is less -than the current lower bound, then the function returns 0 and -the maximum will not change from its current setting. On success, -the function returns 1. -
If successful and the current value -is greater than the new upper bound, if the control is limited -the value will be automatically adjusted to the new maximum value; -if not limited, the value in the control will be colored with the -current out-of-bounds color. -
-
GetMax() -
Gets the current upper bound value for the control. -It will return None if no upper bound is currently specified. -
-
-
SetBounds(min=None,max=None) -
This function is a convenience function for setting the min and max -values at the same time. The function only applies the maximum bound -if setting the minimum bound is successful, and returns True -only if both operations succeed. Note: leaving out an argument -will remove the corresponding bound. -
GetBounds() -
This function returns a two-tuple (min,max), indicating the -current bounds of the control. Each value can be None if -that bound is not set. -
-
-
IsInBounds(value=None) -
Returns True if no value is specified and the current value -of the control falls within the current bounds. This function can also -be called with a value to see if that value would fall within the current -bounds of the given control. -
-
-
SetLimited(bool) -
If called with a value of True, this function will cause the control -to limit the value to fall within the bounds currently specified. -If the control's value currently exceeds the bounds, it will then -be limited accordingly. -If called with a value of 0, this function will disable value -limiting, but coloring of out-of-bounds values will still take -place if bounds have been set for the control. -
IsLimited() -
Returns True if the control is currently limiting the -value to fall within the current bounds. -
-
-
SetNoneAllowed(bool) -
If called with a value of True, this function will cause the control -to allow the value to be empty, representing a value of None. -If called with a value of false, this function will prevent the value -from being None. If the value of the control is currently None, -ie. the control is empty, then the value will be changed to that -of the lower bound of the control, or 0 if no lower bound is set. -
IsNoneAllowed() -
Returns True if the control currently allows its -value to be None. -
-
-
SetLongAllowed(bool) -
If called with a value of True, this function will cause the -control to allow the value to be a long. If called with a value -of False, and the value of the control is currently a long value, -the value of the control will be adjusted to fall within the -size of an integer type, at either the sys.maxint or -sys.maxint-1, -for positive and negative values, respectively. -
IsLongAllowed() -
Returns True if the control currently allows its -value to be of type long. -
-
-
SetColors(default_color=wxBLACK, oob_color=wxRED) -
Tells the control what colors to use for normal and out-of-bounds -values. If the value currently exceeds the bounds, it will be -recolored accordingly. -
GetColors() -
Returns a tuple of (default_color, oob_color) indicating -the current color settings for the control. -
-
-
Cut() -
Will allow cuts to the clipboard of the text portion of the value, -leaving the value of zero if the entire contents are "cut." -
Paste() -
Will paste the contents of the clipboard to the selected portion -of the value; if the resulting string does not represent a legal -value, a ValueError will result. If the result is out-of bounds, -it will either be adjusted or colored as appropriate. -
- -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxJoystick.py b/wxPython/demo/wxJoystick.py deleted file mode 100644 index 2c4113adf0..0000000000 --- a/wxPython/demo/wxJoystick.py +++ /dev/null @@ -1,206 +0,0 @@ - -#---------------------------------------------------------------------------- - -from wxPython.wx import * -from joystick_wdr import * - - -class JoystickTestPanel(wxPanel): - def __init__(self, parent, id, - pos = wxDefaultPosition, size = wxDefaultSize, - style = wxTAB_TRAVERSAL ): - wxPanel.__init__(self, parent, id, pos, size, style) - - MakeJoystickTestPanel( self, True ) - - try: - self.stick = wxJoystick() - self.stick.SetCapture(self) - EVT_JOYSTICK_EVENTS(self, self.OnJoystick) - self.UpdateFields() - except NotImplementedError, v: - wxMessageBox(str(v), "Exception Message") - - - def UpdateFields(self): - s = self.stick - self.GetXPositionCtrl().SetValue(str(s.GetPosition().x)) - self.GetYPositionCtrl().SetValue(str(s.GetPosition().y)) - self.GetZPositionCtrl().SetValue(str(s.GetZPosition())) - self.GetPovCtsPosCtrl().SetValue(str(s.GetPOVPosition())) - self.GetRudderPosCtrl().SetValue(str(s.GetRudderPosition())) - self.GetHasRudderCtrl().SetValue(str(s.HasRudder())) - self.GetHasZCtrl().SetValue(str(s.HasZ())) - self.GetHasPovCtrl().SetValue(str(s.HasPOV())) - self.GetHasPov4dirCtrl().SetValue(str(s.HasPOV4Dir())) - self.GetMfgIdCtrl().SetValue(str(s.GetManufacturerId())) - self.GetProdNameCtrl().SetValue(str(s.GetProductName())) - self.GetZMinCtrl().SetValue(str(s.GetZMin())) - self.GetXMaxCtrl().SetValue(str(s.GetXMax())) - self.GetNumButtonsCtrl().SetValue(str(s.GetNumberButtons())) - self.GetNumAxesCtrl().SetValue(str(s.GetNumberAxes())) - self.GetPollingMinCtrl().SetValue(str(s.GetPollingMin())) - self.GetPollingMaxCtrl().SetValue(str(s.GetPollingMax())) - self.GetUMinCtrl().SetValue(str(s.GetUMin())) - self.GetUMaxCtrl().SetValue(str(s.GetUMax())) - self.GetButtonStateCtrl().SetValue(str(s.GetButtonState())) - self.GetPovPositionCtrl().SetValue(str(s.GetPOVPosition())) - self.GetUPositionCtrl().SetValue(str(s.GetUPosition())) - self.GetVPositionCtrl().SetValue(str(s.GetVPosition())) - self.GetHasUCtrl().SetValue(str(s.HasU())) - self.GetHasVCtrl().SetValue(str(s.HasV())) - self.GetHasPovCtsCtrl().SetValue(str(s.HasPOVCTS())) - self.GetNumSticksCtrl().SetValue(str(s.GetNumberJoysticks())) - self.GetXMinCtrl().SetValue(str(s.GetXMin())) - self.GetYMinCtrl().SetValue(str(s.GetYMin())) - self.GetYMaxCtrl().SetValue(str(s.GetYMax())) - self.GetZMaxCtrl().SetValue(str(s.GetZMax())) - self.GetMaxButtonsCtrl().SetValue(str(s.GetMaxButtons())) - self.GetMaxAxesCtrl().SetValue(str(s.GetMaxAxes())) - self.GetRudderMinCtrl().SetValue(str(s.GetRudderMin())) - self.GetRudderMaxCtrl().SetValue(str(s.GetRudderMax())) - self.GetVMinCtrl().SetValue(str(s.GetVMin())) - self.GetVMaxCtrl().SetValue(str(s.GetVMax())) - - - def OnJoystick(self, evt): - self.UpdateFields() - - - # WDR: methods for JoystickTestPanel - - def GetYPositionCtrl(self): - return self.FindWindowById(ID_Y_Position_Ctrl) - - def GetXPositionCtrl(self): - return self.FindWindowById(ID_X_Position_Ctrl) - - - def GetVMaxCtrl(self): - return self.FindWindowById(ID_V_Max_Ctrl) - - def GetVMinCtrl(self): - return self.FindWindowById(ID_V_Min_Ctrl) - - def GetRudderMaxCtrl(self): - return self.FindWindowById(ID_Rudder_Max_Ctrl) - - def GetRudderMinCtrl(self): - return self.FindWindowById(ID_Rudder_Min_Ctrl) - - def GetMaxAxesCtrl(self): - return self.FindWindowById(ID_Max_Axes_Ctrl) - - def GetMaxButtonsCtrl(self): - return self.FindWindowById(ID_Max_Buttons_Ctrl) - - def GetZMaxCtrl(self): - return self.FindWindowById(ID_Z_Max_Ctrl) - - def GetYMaxCtrl(self): - return self.FindWindowById(ID_Y_Max_Ctrl) - - def GetYMinCtrl(self): - return self.FindWindowById(ID_Y_Min_Ctrl) - - def GetXMinCtrl(self): - return self.FindWindowById(ID_X_Min_Ctrl) - - def GetNumSticksCtrl(self): - return self.FindWindowById(ID_Num_Sticks_Ctrl) - - def GetHasPovCtsCtrl(self): - return self.FindWindowById(ID_Has_POV_CTS_Ctrl) - - def GetHasVCtrl(self): - return self.FindWindowById(ID_Has_V_Ctrl) - - def GetHasUCtrl(self): - return self.FindWindowById(ID_Has_U_Ctrl) - - def GetVPositionCtrl(self): - return self.FindWindowById(ID_V_Position_Ctrl) - - def GetUPositionCtrl(self): - return self.FindWindowById(ID_U_Position_Ctrl) - - def GetPovPositionCtrl(self): - return self.FindWindowById(ID_POV_Position_Ctrl) - - def GetButtonStateCtrl(self): - return self.FindWindowById(ID_Button_State_Ctrl) - - def GetUMaxCtrl(self): - return self.FindWindowById(ID_U_Max_Ctrl) - - def GetUMinCtrl(self): - return self.FindWindowById(ID_U_Min_Ctrl) - - def GetPollingMaxCtrl(self): - return self.FindWindowById(ID_Polling_Max_Ctrl) - - def GetPollingMinCtrl(self): - return self.FindWindowById(ID_Polling_Min_Ctrl) - - def GetNumAxesCtrl(self): - return self.FindWindowById(ID_Num_Axes_Ctrl) - - def GetNumButtonsCtrl(self): - return self.FindWindowById(ID_Num_Buttons_Ctrl) - - def GetXMaxCtrl(self): - return self.FindWindowById(ID_X_Max_Ctrl) - - def GetZMinCtrl(self): - return self.FindWindowById(ID_Z_Min_Ctrl) - - def GetProdNameCtrl(self): - return self.FindWindowById(ID_Prod_Name_Ctrl) - - def GetMfgIdCtrl(self): - return self.FindWindowById(ID_Mfg_ID_Ctrl) - - def GetHasPov4dirCtrl(self): - return self.FindWindowById(ID_Has_POV_4DIR_Ctrl) - - def GetHasPovCtrl(self): - return self.FindWindowById(ID_Has_POV_Ctrl) - - def GetHasZCtrl(self): - return self.FindWindowById(ID_Has_Z_Ctrl) - - def GetHasRudderCtrl(self): - return self.FindWindowById(ID_Has_Rudder_Ctrl) - - def GetRudderPosCtrl(self): - return self.FindWindowById(ID_Rudder_Pos_Ctrl) - - def GetPovCtsPosCtrl(self): - return self.FindWindowById(ID_POV_CTS_Pos_Ctrl) - - def GetZPositionCtrl(self): - return self.FindWindowById(ID_Z_Position_Ctrl) - - # WDR: handler implementations for JoysticktestPanel - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = JoystickTestPanel(nb, -1) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxKeyEvents.py b/wxPython/demo/wxKeyEvents.py deleted file mode 100644 index c992865219..0000000000 --- a/wxPython/demo/wxKeyEvents.py +++ /dev/null @@ -1,357 +0,0 @@ -# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o lib.mixins.listctrl needs wx renamer applied. -# -# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin -# - -import wx -import wx.lib.mixins.listctrl as listmix - -#---------------------------------------------------------------------- - -keyMap = { - wx.WXK_BACK : "wx.WXK_BACK", - wx.WXK_TAB : "wx.WXK_TAB", - wx.WXK_RETURN : "wx.WXK_RETURN", - wx.WXK_ESCAPE : "wx.WXK_ESCAPE", - wx.WXK_SPACE : "wx.WXK_SPACE", - wx.WXK_DELETE : "wx.WXK_DELETE", - wx.WXK_START : "wx.WXK_START", - wx.WXK_LBUTTON : "wx.WXK_LBUTTON", - wx.WXK_RBUTTON : "wx.WXK_RBUTTON", - wx.WXK_CANCEL : "wx.WXK_CANCEL", - wx.WXK_MBUTTON : "wx.WXK_MBUTTON", - wx.WXK_CLEAR : "wx.WXK_CLEAR", - wx.WXK_SHIFT : "wx.WXK_SHIFT", - wx.WXK_ALT : "wx.WXK_ALT", - wx.WXK_CONTROL : "wx.WXK_CONTROL", - wx.WXK_MENU : "wx.WXK_MENU", - wx.WXK_PAUSE : "wx.WXK_PAUSE", - wx.WXK_CAPITAL : "wx.WXK_CAPITAL", - wx.WXK_PRIOR : "wx.WXK_PRIOR", - wx.WXK_NEXT : "wx.WXK_NEXT", - wx.WXK_END : "wx.WXK_END", - wx.WXK_HOME : "wx.WXK_HOME", - wx.WXK_LEFT : "wx.WXK_LEFT", - wx.WXK_UP : "wx.WXK_UP", - wx.WXK_RIGHT : "wx.WXK_RIGHT", - wx.WXK_DOWN : "wx.WXK_DOWN", - wx.WXK_SELECT : "wx.WXK_SELECT", - wx.WXK_PRINT : "wx.WXK_PRINT", - wx.WXK_EXECUTE : "wx.WXK_EXECUTE", - wx.WXK_SNAPSHOT : "wx.WXK_SNAPSHOT", - wx.WXK_INSERT : "wx.WXK_INSERT", - wx.WXK_HELP : "wx.WXK_HELP", - wx.WXK_NUMPAD0 : "wx.WXK_NUMPAD0", - wx.WXK_NUMPAD1 : "wx.WXK_NUMPAD1", - wx.WXK_NUMPAD2 : "wx.WXK_NUMPAD2", - wx.WXK_NUMPAD3 : "wx.WXK_NUMPAD3", - wx.WXK_NUMPAD4 : "wx.WXK_NUMPAD4", - wx.WXK_NUMPAD5 : "wx.WXK_NUMPAD5", - wx.WXK_NUMPAD6 : "wx.WXK_NUMPAD6", - wx.WXK_NUMPAD7 : "wx.WXK_NUMPAD7", - wx.WXK_NUMPAD8 : "wx.WXK_NUMPAD8", - wx.WXK_NUMPAD9 : "wx.WXK_NUMPAD9", - wx.WXK_MULTIPLY : "wx.WXK_MULTIPLY", - wx.WXK_ADD : "wx.WXK_ADD", - wx.WXK_SEPARATOR : "wx.WXK_SEPARATOR", - wx.WXK_SUBTRACT : "wx.WXK_SUBTRACT", - wx.WXK_DECIMAL : "wx.WXK_DECIMAL", - wx.WXK_DIVIDE : "wx.WXK_DIVIDE", - wx.WXK_F1 : "wx.WXK_F1", - wx.WXK_F2 : "wx.WXK_F2", - wx.WXK_F3 : "wx.WXK_F3", - wx.WXK_F4 : "wx.WXK_F4", - wx.WXK_F5 : "wx.WXK_F5", - wx.WXK_F6 : "wx.WXK_F6", - wx.WXK_F7 : "wx.WXK_F7", - wx.WXK_F8 : "wx.WXK_F8", - wx.WXK_F9 : "wx.WXK_F9", - wx.WXK_F10 : "wx.WXK_F10", - wx.WXK_F11 : "wx.WXK_F11", - wx.WXK_F12 : "wx.WXK_F12", - wx.WXK_F13 : "wx.WXK_F13", - wx.WXK_F14 : "wx.WXK_F14", - wx.WXK_F15 : "wx.WXK_F15", - wx.WXK_F16 : "wx.WXK_F16", - wx.WXK_F17 : "wx.WXK_F17", - wx.WXK_F18 : "wx.WXK_F18", - wx.WXK_F19 : "wx.WXK_F19", - wx.WXK_F20 : "wx.WXK_F20", - wx.WXK_F21 : "wx.WXK_F21", - wx.WXK_F22 : "wx.WXK_F22", - wx.WXK_F23 : "wx.WXK_F23", - wx.WXK_F24 : "wx.WXK_F24", - wx.WXK_NUMLOCK : "wx.WXK_NUMLOCK", - wx.WXK_SCROLL : "wx.WXK_SCROLL", - wx.WXK_PAGEUP : "wx.WXK_PAGEUP", - wx.WXK_PAGEDOWN : "wx.WXK_PAGEDOWN", - wx.WXK_NUMPAD_SPACE : "wx.WXK_NUMPAD_SPACE", - wx.WXK_NUMPAD_TAB : "wx.WXK_NUMPAD_TAB", - wx.WXK_NUMPAD_ENTER : "wx.WXK_NUMPAD_ENTER", - wx.WXK_NUMPAD_F1 : "wx.WXK_NUMPAD_F1", - wx.WXK_NUMPAD_F2 : "wx.WXK_NUMPAD_F2", - wx.WXK_NUMPAD_F3 : "wx.WXK_NUMPAD_F3", - wx.WXK_NUMPAD_F4 : "wx.WXK_NUMPAD_F4", - wx.WXK_NUMPAD_HOME : "wx.WXK_NUMPAD_HOME", - wx.WXK_NUMPAD_LEFT : "wx.WXK_NUMPAD_LEFT", - wx.WXK_NUMPAD_UP : "wx.WXK_NUMPAD_UP", - wx.WXK_NUMPAD_RIGHT : "wx.WXK_NUMPAD_RIGHT", - wx.WXK_NUMPAD_DOWN : "wx.WXK_NUMPAD_DOWN", - wx.WXK_NUMPAD_PRIOR : "wx.WXK_NUMPAD_PRIOR", - wx.WXK_NUMPAD_PAGEUP : "wx.WXK_NUMPAD_PAGEUP", - wx.WXK_NUMPAD_NEXT : "wx.WXK_NUMPAD_NEXT", - wx.WXK_NUMPAD_PAGEDOWN : "wx.WXK_NUMPAD_PAGEDOWN", - wx.WXK_NUMPAD_END : "wx.WXK_NUMPAD_END", - wx.WXK_NUMPAD_BEGIN : "wx.WXK_NUMPAD_BEGIN", - wx.WXK_NUMPAD_INSERT : "wx.WXK_NUMPAD_INSERT", - wx.WXK_NUMPAD_DELETE : "wx.WXK_NUMPAD_DELETE", - wx.WXK_NUMPAD_EQUAL : "wx.WXK_NUMPAD_EQUAL", - wx.WXK_NUMPAD_MULTIPLY : "wx.WXK_NUMPAD_MULTIPLY", - wx.WXK_NUMPAD_ADD : "wx.WXK_NUMPAD_ADD", - wx.WXK_NUMPAD_SEPARATOR : "wx.WXK_NUMPAD_SEPARATOR", - wx.WXK_NUMPAD_SUBTRACT : "wx.WXK_NUMPAD_SUBTRACT", - wx.WXK_NUMPAD_DECIMAL : "wx.WXK_NUMPAD_DECIMAL", - wx.WXK_NUMPAD_DIVIDE : "wx.WXK_NUMPAD_DIVIDE", -} - - -#---------------------------------------------------------------------- - -class KeySink(wx.Window): - def __init__(self, parent): - wx.Window.__init__(self, parent, -1, style=wx.WANTS_CHARS - #| wx.RAISED_BORDER - #| wx.SUNKEN_BORDER - ) - - self.SetBackgroundColour(wx.BLUE) - self.haveFocus = False - self.callSkip = False - self.logKeyDn = True - self.logKeyUp = True - self.logChar = True - - self.Bind(wx.EVT_PAINT, self.OnPaint) - self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) - self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) - self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse) - - self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) - self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) - self.Bind(wx.EVT_CHAR, self.OnChar) - - - def SetCallSkip(self, skip): - self.callSkip = skip - - def SetLogKeyUp(self, val): - self.logKeyUp = val - - def SetLogKeyDn(self, val): - self.logKeyDn = val - - def SetLogChar(self, val): - self.logChar = val - - - def OnPaint(self, evt): - dc = wx.PaintDC(self) - rect = self.GetClientRect() - dc.SetTextForeground(wx.WHITE) - dc.DrawLabel("Click here and then press some keys", - rect, wx.ALIGN_CENTER | wx.ALIGN_TOP) - if self.haveFocus: - dc.SetTextForeground(wx.GREEN) - dc.DrawLabel("Have Focus", rect, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) - else: - dc.SetTextForeground(wx.RED) - dc.DrawLabel("Need Focus!", rect, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) - - - def OnSetFocus(self, evt): - self.haveFocus = True - self.Refresh() - - def OnKillFocus(self, evt): - self.haveFocus = False - self.Refresh() - - def OnMouse(self, evt): - if evt.ButtonDown(): - self.SetFocus() - - - def OnKeyDown(self, evt): - if self.logKeyDn: - self.GetParent().keylog.LogKeyEvent("KeyDown", evt) - if self.callSkip: - evt.Skip() - - def OnKeyUp(self, evt): - if self.logKeyUp: - self.GetParent().keylog.LogKeyEvent("KeyUp", evt) - if self.callSkip: - evt.Skip() - - def OnChar(self, evt): - if self.logChar: - self.GetParent().keylog.LogKeyEvent("Char", evt) - - -#---------------------------------------------------------------------- - -class KeyLog(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin): - - def __init__(self, parent): - wx.ListCtrl.__init__(self, parent, -1, - style = wx.LC_REPORT|wx.LC_VRULES|wx.LC_HRULES) - listmix.ListCtrlAutoWidthMixin.__init__(self) - - self.InsertColumn(0, "Event Type") - self.InsertColumn(1, "Key Name") - self.InsertColumn(2, "Key Code") - self.InsertColumn(3, "Modifiers") - self.InsertColumn(4, "RawKeyCode") - self.InsertColumn(5, "RawKeyFlags") - self.InsertColumn(6, "") - - for x in range(6): - self.SetColumnWidth(x, wx.LIST_AUTOSIZE_USEHEADER) - - self.SetColumnWidth(1, 125) - - - def LogKeyEvent(self, evType, evt): - keycode = evt.GetKeyCode() - keyname = keyMap.get(keycode, None) - if keyname is None: - if keycode < 256: - if keycode == 0: - keyname = "NUL" - elif keycode < 27: - keyname = "Ctrl-%s" % chr(ord('A') + keycode-1) - else: - keyname = "\"%s\"" % chr(keycode) - else: - keyname = "unknown (%s)" % keycode - - modifiers = "" - for mod, ch in [(evt.ControlDown(), 'C'), - (evt.AltDown(), 'A'), - (evt.ShiftDown(), 'S'), - (evt.MetaDown(), 'M')]: - if mod: - modifiers += ch - else: - modifiers += '-' - - id = self.InsertStringItem(self.GetItemCount(), evType) - self.SetStringItem(id, 1, keyname) - self.SetStringItem(id, 2, str(keycode)) - self.SetStringItem(id, 3, modifiers) - self.SetStringItem(id, 4, str(evt.GetRawKeyCode())) - self.SetStringItem(id, 5, str(evt.GetRawKeyFlags())) - - #print ( id, evType, keyname, str(keycode), modifiers, str(evt.GetRawKeyCode()), str(evt.GetRawKeyFlags())) - - self.EnsureVisible(id) - - - def ClearLog(self): - self.DeleteAllItems() - - -#---------------------------------------------------------------------- - - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1, style=0) - self.keysink = KeySink(self) - self.keysink.SetSize((100, 65)) - self.keylog = KeyLog(self) - - btn = wx.Button(self, -1, "Clear Log") - self.Bind(wx.EVT_BUTTON, self.OnClearBtn, btn) - - cb1 = wx.CheckBox(self, -1, "Call evt.Skip for Key Up/Dn events") - self.Bind(wx.EVT_CHECKBOX, self.OnSkipCB, cb1) - - cb2 = wx.CheckBox(self, -1, "EVT_KEY_UP") - self.Bind(wx.EVT_CHECKBOX, self.OnKeyUpCB, cb2) - cb2.SetValue(True) - - cb3 = wx.CheckBox(self, -1, "EVT_KEY_DOWN") - self.Bind(wx.EVT_CHECKBOX, self.OnKeyDnCB, cb3) - cb3.SetValue(True) - - cb4 = wx.CheckBox(self, -1, "EVT_CHAR") - self.Bind(wx.EVT_CHECKBOX, self.OnCharCB, cb4) - cb4.SetValue(True) - - buttons = wx.BoxSizer(wx.HORIZONTAL) - buttons.Add(btn, 0, wx.ALL, 4) - buttons.Add(cb1, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 6) - buttons.Add(cb2, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 6) - buttons.Add(cb3, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 6) - buttons.Add(cb4, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 6) - - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(self.keysink, 0, wx.GROW) - sizer.Add(buttons) - sizer.Add(self.keylog, 1, wx.GROW) - - self.SetSizer(sizer) - - - def OnClearBtn(self, evt): - self.keylog.ClearLog() - - def OnSkipCB(self, evt): - self.keysink.SetCallSkip(evt.GetInt()) - - def OnKeyUpCB(self, evt): - self.keysink.SetLogKeyUp(evt.GetInt()) - - def OnKeyDnCB(self, evt): - self.keysink.SetLogKeyDn(evt.GetInt()) - - def OnCharCB(self, evt): - self.keysink.SetLogChar(evt.GetInt()) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

wxKeyEvents

- -This demo simply catches all key events and prints info about them. -It is meant to be used as a compatibility test for cross platform work. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxLEDNumberCtrl.py b/wxPython/demo/wxLEDNumberCtrl.py deleted file mode 100644 index 7bb46e1647..0000000000 --- a/wxPython/demo/wxLEDNumberCtrl.py +++ /dev/null @@ -1,116 +0,0 @@ -# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import time - -import wx -import wx.gizmos as gizmos - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - led = gizmos.LEDNumberCtrl(self, -1, (25,25), (280, 50)) - led.SetValue("01234") - - led = gizmos.LEDNumberCtrl(self, -1, (25,100), (280, 50)) - led.SetValue("56789") - led.SetAlignment(gizmos.LED_ALIGN_RIGHT) - led.SetDrawFaded(False) - - led = gizmos.LEDNumberCtrl(self, -1, (25,175), (280, 50), - gizmos.LED_ALIGN_CENTER)# | gizmos.LED_DRAW_FADED) - self.clock = led - self.OnTimer(None) - - self.timer = wx.Timer(self) - self.timer.Start(1000) - self.Bind(wx.EVT_TIMER, self.OnTimer) - - - def OnTimer(self, evt): - t = time.localtime(time.time()) - st = time.strftime("%I-%M-%S", t) - self.clock.SetValue(st) - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - -overview = """\ - - -The following was gleaned as best I could from the wxWindows -source, which was a bit reluctant to reveal its secrets. My appologies if -I missed anything - jmg -

-wxLEDNumberCtrl( parent, id=-1, pos=wx.DefaultPosition, -size=wx.DefaultSize, style=LED_ALIGN_LEFT | LED_DRAW_FADED) - -

This is a control that simulates an LED clock display. It only accepts -numeric input. - -

Styles - -

-
LED_ALIGN_LEFT -
Align to the left. - -
LED_ALIGN_RIGHT -
Align to the right. - -
LED_ALIGN_CENTER -
Center on display. - -
LED_DRAW_FADED -
Not implemented. - -
- -

Methods (and best guesses at what they do) - -

-
GetAlignment() -
Returns the alignment attribute for the control. - -
GetDrawFaded() -
Returns the DrawFaded attribute for the control. - -
GetValue() -
Returns the current value of the control. - -
SetAlignment(alignment) -
Set the alignment attribute for the control. - -
SetDrawFaded(value) -
Set the DrawFaded attribute for the control. - -
SetValue(number) -
Set the value for the control. Only numeric values are accepted. - -
- -

Additionally, several methods of wx.Window are available as well. - - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxLayoutConstraints.py b/wxPython/demo/wxLayoutConstraints.py deleted file mode 100644 index 29ffeaf080..0000000000 --- a/wxPython/demo/wxLayoutConstraints.py +++ /dev/null @@ -1,152 +0,0 @@ -# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class TestLayoutConstraints(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent, -1) - self.SetAutoLayout(True) - self.Bind(wx.EVT_BUTTON, self.OnButton, id=100) - - self.SetBackgroundColour(wx.NamedColour("MEDIUM ORCHID")) - - self.panelA = wx.Window(self, -1, style=wx.SIMPLE_BORDER) - self.panelA.SetBackgroundColour(wx.BLUE) - - txt = wx.StaticText( - self.panelA, -1, - "Resize the window and see\n" - "what happens... Notice that\n" - "there is no OnSize handler.", - (5,5), (-1, 50) - ) - - txt.SetBackgroundColour(wx.BLUE) - txt.SetForegroundColour(wx.WHITE) - - lc = wx.LayoutConstraints() - lc.top.SameAs(self, wx.Top, 10) - lc.left.SameAs(self, wx.Left, 10) - lc.bottom.SameAs(self, wx.Bottom, 10) - lc.right.PercentOf(self, wx.Right, 50) - self.panelA.SetConstraints(lc) - - self.panelB = wx.Window(self, -1, style=wx.SIMPLE_BORDER) - self.panelB.SetBackgroundColour(wx.RED) - lc = wx.LayoutConstraints() - lc.top.SameAs(self, wx.Top, 10) - lc.right.SameAs(self, wx.Right, 10) - lc.bottom.PercentOf(self, wx.Bottom, 30) - lc.left.RightOf(self.panelA, 10) - self.panelB.SetConstraints(lc) - - self.panelC = wx.Window(self, -1, style=wx.SIMPLE_BORDER) - self.panelC.SetBackgroundColour(wx.WHITE) - lc = wx.LayoutConstraints() - lc.top.Below(self.panelB, 10) - lc.right.SameAs(self, wx.Right, 10) - lc.bottom.SameAs(self, wx.Bottom, 10) - lc.left.RightOf(self.panelA, 10) - self.panelC.SetConstraints(lc) - - b = wx.Button(self.panelA, 100, ' Panel A ') - lc = wx.LayoutConstraints() - lc.centreX.SameAs (self.panelA, wx.CentreX) - lc.centreY.SameAs (self.panelA, wx.CentreY) - lc.height.AsIs () - lc.width.PercentOf (self.panelA, wx.Width, 50) - b.SetConstraints(lc); - - b = wx.Button(self.panelB, 100, ' Panel B ') - lc = wx.LayoutConstraints() - lc.top.SameAs (self.panelB, wx.Top, 2) - lc.right.SameAs (self.panelB, wx.Right, 4) - lc.height.AsIs () - lc.width.AsIs () - b.SetConstraints(lc); - - self.panelD = wx.Window(self.panelC, -1, style=wx.SIMPLE_BORDER) - self.panelD.SetBackgroundColour(wx.GREEN) - wx.StaticText( - self.panelD, -1, "Panel D", (4, 4) - ).SetBackgroundColour(wx.GREEN) - - b = wx.Button(self.panelC, 100, ' Panel C ') - lc = wx.LayoutConstraints() - lc.top.Below (self.panelD) - lc.left.RightOf (self.panelD) - lc.height.AsIs () - lc.width.AsIs () - b.SetConstraints(lc); - - lc = wx.LayoutConstraints() - lc.bottom.PercentOf (self.panelC, wx.Height, 50) - lc.right.PercentOf (self.panelC, wx.Width, 50) - lc.height.SameAs (b, wx.Height) - lc.width.SameAs (b, wx.Width) - self.panelD.SetConstraints(lc); - - - def OnButton(self, event): - wx.Bell() - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestLayoutConstraints(nb) - return win - -#--------------------------------------------------------------------------- - - - -overview = """\ - -Objects of this class can be associated with a window to define its -layout constraints, with respect to siblings or its parent. - -

The class consists of the following eight constraints of class -wxIndividualLayoutConstraint, some or all of which should be accessed -directly to set the appropriate constraints. - -

    -
  • left: represents the left hand edge of the window - -
  • right: represents the right hand edge of the window - -
  • top: represents the top edge of the window - -
  • bottom: represents the bottom edge of the window - -
  • width: represents the width of the window - -
  • height: represents the height of the window - -
  • centreX: represents the horizontal centre point of the window - -
  • centreY: represents the vertical centre point of the window -
-

Most constraints are initially set to have the relationship -wxUnconstrained, which means that their values should be calculated by -looking at known constraints. The exceptions are width and height, -which are set to wxAsIs to ensure that if the user does not specify a -constraint, the existing width and height will be used, to be -compatible with panel items which often have take a default size. If -the constraint is wxAsIs, the dimension will not be changed. - -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxListBox.py b/wxPython/demo/wxListBox.py deleted file mode 100644 index c3a69d6919..0000000000 --- a/wxPython/demo/wxListBox.py +++ /dev/null @@ -1,162 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -# This listbox subclass lets you type the starting letters of what you want to -# select, and scrolls the list to the match if it is found. -class FindPrefixListBox(wx.ListBox): - def __init__(self, parent, id, pos=wx.DefaultPosition, size=wx.DefaultSize, - choices=[], style=0, validator=wx.DefaultValidator): - wx.ListBox.__init__(self, parent, id, pos, size, choices, style, validator) - self.typedText = '' - self.log = parent.log - self.Bind(wx.EVT_KEY_DOWN, self.OnKey) - - - def FindPrefix(self, prefix): - self.log.WriteText('Looking for prefix: %s\n' % prefix) - - if prefix: - prefix = prefix.lower() - length = len(prefix) - - # Changed in 2.5 because ListBox.Number() is no longer supported. - # ListBox.GetCount() is now the appropriate way to go. - for x in range(self.GetCount()): - text = self.GetString(x) - text = text.lower() - - if text[:length] == prefix: - self.log.WriteText('Prefix %s is found.\n' % prefix) - return x - - self.log.WriteText('Prefix %s is not found.\n' % prefix) - return -1 - - - def OnKey(self, evt): - key = evt.GetKeyCode() - - if key >= 32 and key <= 127: - self.typedText = self.typedText + chr(key) - item = self.FindPrefix(self.typedText) - - if item != -1: - self.SetSelection(item) - - elif key == wx.WXK_BACK: # backspace removes one character and backs up - self.typedText = self.typedText[:-1] - - if not self.typedText: - self.SetSelection(0) - else: - item = self.FindPrefix(self.typedText) - - if item != -1: - self.SetSelection(item) - else: - self.typedText = '' - evt.Skip() - - def OnKeyDown(self, evt): - pass - - -#--------------------------------------------------------------------------- - -class TestListBox(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', - 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', - 'twelve', 'thirteen', 'fourteen'] - - wx.StaticText(self, -1, "This example uses the wxListBox control.", (45, 10)) - wx.StaticText(self, -1, "Select one:", (15, 50), (65, 18)) - self.lb1 = wx.ListBox(self, 60, (80, 50), (80, 120), sampleList, wx.LB_SINGLE) - self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.lb1) - self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.lb1) - self.lb1.Bind(wx.EVT_RIGHT_UP, self.EvtRightButton) - self.lb1.SetSelection(3) - self.lb1.Append("with data", "This one has data"); - self.lb1.SetClientData(2, "This one has data"); - - - wx.StaticText(self, -1, "Select many:", (200, 50), (65, 18)) - self.lb2 = wx.ListBox(self, 70, (280, 50), (80, 120), sampleList, wx.LB_EXTENDED) - self.Bind(wx.EVT_LISTBOX, self.EvtMultiListBox, self.lb2) - self.lb2.Bind(wx.EVT_RIGHT_UP, self.EvtRightButton) - self.lb2.SetSelection(0) - - sampleList = sampleList + ['test a', 'test aa', 'test aab', - 'test ab', 'test abc', 'test abcc', - 'test abcd' ] - sampleList.sort() - wx.StaticText(self, -1, "Find Prefix:", (15, 250)) - fp = FindPrefixListBox(self, -1, (80, 250), (80, 120), sampleList, wx.LB_SINGLE) - fp.SetSelection(0) - - - def EvtListBox(self, event): - self.log.WriteText('EvtListBox: %s, %s, %s\n' % - (event.GetString(), event.IsSelection(), event.GetSelection())) - - lb = event.GetEventObject() - data = lb.GetClientData(lb.GetSelection()) - - if data is not None: - self.log.WriteText('\tdata: %s\n' % data) - - - def EvtListBoxDClick(self, event): - self.log.WriteText('EvtListBoxDClick: %s\n' % self.lb1.GetSelection()) - self.lb1.Delete(self.lb1.GetSelection()) - - def EvtMultiListBox(self, event): - self.log.WriteText('EvtMultiListBox: %s\n' % str(self.lb2.GetSelections())) - - def EvtRightButton(self, event): - self.log.WriteText('EvtRightButton: %s\n' % event.GetPosition()) - - if event.GetEventObject().GetId() == 70: - selections = list(self.lb2.GetSelections()) - selections.reverse() - - for index in selections: - self.lb2.Delete(index) - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestListBox(nb, log) - return win - -#--------------------------------------------------------------------------- - - - - -overview = """ -A listbox is used to select one or more of a list of -strings. The strings are displayed in a scrolling box, with the -selected string(s) marked in reverse video. A listbox can be single -selection (if an item is selected, the previous selection is removed) -or multiple selection (clicking an item toggles the item on or off -independently of other selections). - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxListCtrl.py b/wxPython/demo/wxListCtrl.py deleted file mode 100644 index 879bc1baa0..0000000000 --- a/wxPython/demo/wxListCtrl.py +++ /dev/null @@ -1,516 +0,0 @@ -#---------------------------------------------------------------------------- -# Name: ListCtrl.py -# Purpose: Testing lots of stuff, controls, window types, etc. -# -# Author: Robin Dunn & Gary Dumer -# -# Created: -# RCS-ID: $Id$ -# Copyright: (c) 1998 by Total Control Software -# Licence: wxWindows license -#---------------------------------------------------------------------------- -# -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o listctrl mixin needs wx renamer. -# o wx.ListItem.GetText() returns a wxString pointer, not the text. -# -# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o ColumnSorterMixin implementation was broke - added event.Skip() -# to column click event to allow event to fall through to mixin. -# -# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxColumnSorterMixin -> ColumnSorterMixin -# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin -# - -import wx -import wx.lib.mixins.listctrl as listmix - -import images - -#--------------------------------------------------------------------------- - -musicdata = { -1 : ("Bad English", "The Price Of Love", "Rock"), -2 : ("DNA featuring Suzanne Vega", "Tom's Diner", "Rock"), -3 : ("George Michael", "Praying For Time", "Rock"), -4 : ("Gloria Estefan", "Here We Are", "Rock"), -5 : ("Linda Ronstadt", "Don't Know Much", "Rock"), -6 : ("Michael Bolton", "How Am I Supposed To Live Without You", "Blues"), -7 : ("Paul Young", "Oh Girl", "Rock"), -8 : ("Paula Abdul", "Opposites Attract", "Rock"), -9 : ("Richard Marx", "Should've Known Better", "Rock"), -10: ("Rod Stewart", "Forever Young", "Rock"), -11: ("Roxette", "Dangerous", "Rock"), -12: ("Sheena Easton", "The Lover In Me", "Rock"), -13: ("Sinead O'Connor", "Nothing Compares 2 U", "Rock"), -14: ("Stevie B.", "Because I Love You", "Rock"), -15: ("Taylor Dayne", "Love Will Lead You Back", "Rock"), -16: ("The Bangles", "Eternal Flame", "Rock"), -17: ("Wilson Phillips", "Release Me", "Rock"), -18: ("Billy Joel", "Blonde Over Blue", "Rock"), -19: ("Billy Joel", "Famous Last Words", "Rock"), -20: ("Billy Joel", "Lullabye (Goodnight, My Angel)", "Rock"), -21: ("Billy Joel", "The River Of Dreams", "Rock"), -22: ("Billy Joel", "Two Thousand Years", "Rock"), -23: ("Janet Jackson", "Alright", "Rock"), -24: ("Janet Jackson", "Black Cat", "Rock"), -25: ("Janet Jackson", "Come Back To Me", "Rock"), -26: ("Janet Jackson", "Escapade", "Rock"), -27: ("Janet Jackson", "Love Will Never Do (Without You)", "Rock"), -28: ("Janet Jackson", "Miss You Much", "Rock"), -29: ("Janet Jackson", "Rhythm Nation", "Rock"), -30: ("Janet Jackson", "State Of The World", "Rock"), -31: ("Janet Jackson", "The Knowledge", "Rock"), -32: ("Spyro Gyra", "End of Romanticism", "Jazz"), -33: ("Spyro Gyra", "Heliopolis", "Jazz"), -34: ("Spyro Gyra", "Jubilee", "Jazz"), -35: ("Spyro Gyra", "Little Linda", "Jazz"), -36: ("Spyro Gyra", "Morning Dance", "Jazz"), -37: ("Spyro Gyra", "Song for Lorraine", "Jazz"), -38: ("Yes", "Owner Of A Lonely Heart", "Rock"), -39: ("Yes", "Rhythm Of Love", "Rock"), -40: ("Cusco", "Dream Catcher", "New Age"), -41: ("Cusco", "Geronimos Laughter", "New Age"), -42: ("Cusco", "Ghost Dance", "New Age"), -43: ("Blue Man Group", "Drumbone", "New Age"), -44: ("Blue Man Group", "Endless Column", "New Age"), -45: ("Blue Man Group", "Klein Mandelbrot", "New Age"), -46: ("Kenny G", "Silhouette", "Jazz"), -47: ("Sade", "Smooth Operator", "Jazz"), -48: ("David Arkenstone", "Papillon (On The Wings Of The Butterfly)", "New Age"), -49: ("David Arkenstone", "Stepping Stars", "New Age"), -50: ("David Arkenstone", "Carnation Lily Lily Rose", "New Age"), -51: ("David Lanz", "Behind The Waterfall", "New Age"), -52: ("David Lanz", "Cristofori's Dream", "New Age"), -53: ("David Lanz", "Heartsounds", "New Age"), -54: ("David Lanz", "Leaves on the Seine", "New Age"), -} - -#--------------------------------------------------------------------------- - -class TestListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin): - def __init__(self, parent, ID, pos=wx.DefaultPosition, - size=wx.DefaultSize, style=0): - wx.ListCtrl.__init__(self, parent, ID, pos, size, style) - listmix.ListCtrlAutoWidthMixin.__init__(self) - - -class TestListCtrlPanel(wx.Panel, listmix.ColumnSorterMixin): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) - - self.log = log - tID = wx.NewId() - - self.il = wx.ImageList(16, 16) - - self.idx1 = self.il.Add(images.getSmilesBitmap()) - self.sm_up = self.il.Add(images.getSmallUpArrowBitmap()) - self.sm_dn = self.il.Add(images.getSmallDnArrowBitmap()) - - self.list = TestListCtrl(self, tID, - style=wx.LC_REPORT - | wx.SUNKEN_BORDER - | wx.LC_EDIT_LABELS - #| wxLC_NO_HEADER - #| wxLC_VRULES | wxLC_HRULES - ) - - self.list.SetImageList(self.il, wx.IMAGE_LIST_SMALL) - - self.PopulateList() - - # Now that the list exists we can init the other base class, - # see wxPython/lib/mixins/listctrl.py - self.itemDataMap = musicdata - listmix.ColumnSorterMixin.__init__(self, 3) - #self.SortListItems(0, True) - - self.Bind(wx.EVT_SIZE, self.OnSize) - - self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.list) - self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected, self.list) - self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.list) - self.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnItemDelete, self.list) - self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list) - self.Bind(wx.EVT_LIST_COL_RIGHT_CLICK, self.OnColRightClick, self.list) - self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.OnColBeginDrag, self.list) - self.Bind(wx.EVT_LIST_COL_DRAGGING, self.OnColDragging, self.list) - self.Bind(wx.EVT_LIST_COL_END_DRAG, self.OnColEndDrag, self.list) - self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list) - - self.list.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick) - self.list.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) - - # for wxMSW - self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick) - - # for wxGTK - self.list.Bind(wx.EVT_RIGHT_UP, self.OnRightClick) - - - def PopulateList(self): - if 0: - # for normal, simple columns, you can add them like this: - self.list.InsertColumn(0, "Artist") - self.list.InsertColumn(1, "Title", wx.LIST_FORMAT_RIGHT) - self.list.InsertColumn(2, "Genre") - else: - # but since we want images on the column header we have to do it the hard way: - info = wx.ListItem() - info.m_mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT - info.m_image = -1 - info.m_format = 0 - info.m_text = "Artist" - self.list.InsertColumnInfo(0, info) - - info.m_format = wx.LIST_FORMAT_RIGHT - info.m_text = "Title" - self.list.InsertColumnInfo(1, info) - - info.m_format = 0 - info.m_text = "Genre" - self.list.InsertColumnInfo(2, info) - - items = musicdata.items() - for x in range(len(items)): - key, data = items[x] - self.list.InsertImageStringItem(x, data[0], self.idx1) - self.list.SetStringItem(x, 1, data[1]) - self.list.SetStringItem(x, 2, data[2]) - self.list.SetItemData(x, key) - - self.list.SetColumnWidth(0, wx.LIST_AUTOSIZE) - self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE) - self.list.SetColumnWidth(2, 100) - - # show how to select an item - self.list.SetItemState(5, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) - - # show how to change the colour of a couple items - item = self.list.GetItem(1) - item.SetTextColour(wx.BLUE) - self.list.SetItem(item) - item = self.list.GetItem(4) - item.SetTextColour(wx.RED) - self.list.SetItem(item) - - self.currentItem = 0 - - - # Used by the ColumnSorterMixin, see wxPython/lib/mixins/listctrl.py - def GetListCtrl(self): - return self.list - - # Used by the ColumnSorterMixin, see wxPython/lib/mixins/listctrl.py - def GetSortImages(self): - return (self.sm_dn, self.sm_up) - - - def OnRightDown(self, event): - self.x = event.GetX() - self.y = event.GetY() - self.log.WriteText("x, y = %s\n" % str((self.x, self.y))) - item, flags = self.list.HitTest((self.x, self.y)) - - if flags & wx.LIST_HITTEST_ONITEM: - self.list.Select(item) - - event.Skip() - - - def getColumnText(self, index, col): - item = self.list.GetItem(index, col) - return item.GetText() - - - def OnItemSelected(self, event): - ##print event.GetItem().GetTextColour() - self.currentItem = event.m_itemIndex - self.log.WriteText("OnItemSelected: %s, %s, %s, %s\n" % - (self.currentItem, - self.list.GetItemText(self.currentItem), - self.getColumnText(self.currentItem, 1), - self.getColumnText(self.currentItem, 2))) - - if self.currentItem == 10: - self.log.WriteText("OnItemSelected: Veto'd selection\n") - #event.Veto() # doesn't work - # this does - self.list.SetItemState(10, 0, wx.LIST_STATE_SELECTED) - - event.Skip() - - - def OnItemDeselected(self, evt): - item = evt.GetItem() - self.log.WriteText("OnItemDeselected: %d" % evt.m_itemIndex) - - # Show how to reselect something we don't want deselected - if evt.m_itemIndex == 11: - wx.CallAfter(self.list.SetItemState, 11, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) - - - def OnItemActivated(self, event): - self.currentItem = event.m_itemIndex - self.log.WriteText("OnItemActivated: %s\nTopItem: %s" % - (self.list.GetItemText(self.currentItem), self.list.GetTopItem())) - - def OnBeginEdit(self, event): - self.log.WriteText("OnBeginEdit") - event.Allow() - - def OnItemDelete(self, event): - self.log.WriteText("OnItemDelete\n") - - def OnColClick(self, event): - self.log.WriteText("OnColClick: %d\n" % event.GetColumn()) - event.Skip() - - def OnColRightClick(self, event): - 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") - ## Show how to not allow a column to be resized - #if event.GetColumn() == 0: - # event.Veto() - - - def OnColDragging(self, event): - self.log.WriteText("OnColDragging\n") - - def OnColEndDrag(self, event): - self.log.WriteText("OnColEndDrag\n") - - def OnDoubleClick(self, event): - self.log.WriteText("OnDoubleClick item %s\n" % self.list.GetItemText(self.currentItem)) - event.Skip() - - def OnRightClick(self, event): - self.log.WriteText("OnRightClick %s\n" % self.list.GetItemText(self.currentItem)) - - # only do this part the first time so the events are only bound once - if not hasattr(self, "popupID1"): - 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.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) - - # make a menu - menu = wx.Menu() - # add some items - menu.Append(self.popupID1, "FindItem tests") - menu.Append(self.popupID2, "Iterate Selected") - menu.Append(self.popupID3, "ClearAll and repopulate") - menu.Append(self.popupID4, "DeleteAllItems") - menu.Append(self.popupID5, "GetItem") - menu.Append(self.popupID6, "Edit") - - # Popup the menu. If an item is selected then its handler - # will be called before PopupMenu returns. - self.PopupMenu(menu, (self.x, self.y)) - menu.Destroy() - - - def OnPopupOne(self, event): - self.log.WriteText("Popup one\n") - print "FindItem:", self.list.FindItem(-1, "Roxette") - print "FindItemData:", self.list.FindItemData(-1, 11) - - def OnPopupTwo(self, event): - self.log.WriteText("Selected items:\n") - index = self.list.GetFirstSelected() - - while index != -1: - self.log.WriteText(" %s: %s\n" % (self.list.GetItemText(index), self.getColumnText(index, 1))) - index = self.list.GetNextSelected(index) - - def OnPopupThree(self, event): - self.log.WriteText("Popup three\n") - self.list.ClearAll() - wx.CallAfter(self.PopulateList) - - def OnPopupFour(self, event): - self.list.DeleteAllItems() - - def OnPopupFive(self, event): - item = self.list.GetItem(self.currentItem) - print item.m_text, item.m_itemId, self.list.GetItemData(self.currentItem) - - def OnPopupSix(self, event): - self.list.EditLabel(self.currentItem) - - - def OnSize(self, event): - w,h = self.GetClientSizeTuple() - self.list.SetDimensions(0, 0, w, h) - - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestListCtrlPanel(nb, log) - return win - -#--------------------------------------------------------------------------- - - -overview = """\ - - -A list control presents lists in a number of formats: list view, report view, -icon view and small icon view. In any case, elements are numbered from zero. -For all these modes (but not for virtual list controls), the items are stored -in the control and must be added to it using InsertItem method. - -

To intercept events from a list control, use the event table macros described in -wxListEvent. - -

Mix-ins

-This example demonstrates how to use mixins. The following mixins are available. - -

ColumnSorterMixin

- -ColumnSorterMixin(numColumns) - -

A mixin class that handles sorting of a wxListCtrl in REPORT mode when the column -header is clicked on. - -

There are a few requirments needed in order for this to work genericly: -

    -
  1. The combined class must have a GetListCtrl method that returns - the ListCtrl to be sorted, and the list control must exist at the time the - ColumnSorterMixin.__init__()method is called because it uses - GetListCtrl. - -
  2. Items in the list control must have a unique data value set with - list.SetItemData. - -
  3. The combined class must have an attribute named itemDataMap - that is a dictionary mapping the data values to a sequence of objects - representing the values in each column. These valuesare compared in - the column sorter to determine sort order. -
- -

Interesting methods to override are GetColumnSorter, -GetSecondarySortValues, and GetSortImages. - -

Methods
-
-
SetColumnCount(newNumColumns) -
Informs the mixin as to the number of columns in the control. When it is -set, it also sets up an event handler for EVT_LIST_COL_CLICK events. - -
SortListItems(col=-1, ascending=1) -
Sort the list on demand. Can also be used to set the sort column and order. - -
GetColumnWidths() -
Returns a list of column widths. Can be used to help restore the current -view later. - -
GetSortImages() -
Returns a tuple of image list indexes the indexes in the image list for an -image to be put on the column header when sorting in descending order - -
GetColumnSorter() -
Returns a callable object to be used for comparing column values when sorting. - -
GetSecondarySortValues(col, key1, key2) -
Returns a tuple of 2 values to use for secondary sort values when the -items in the selected column match equal. The default just returns the -item data values. - -
- -

ListCtrlAutoWidthMixin

- -ListCtrlAutoWidthMixin() - -

A mix-in class that automatically resizes the last column to take up the -remaining width of the ListCtrl. - -

This causes the ListCtrl to automatically take up the full width of the list, -without either a horizontal scroll bar (unless absolutely necessary) or empty -space to the right of the last column. - -

NOTE: This only works for report-style lists. - -

WARNING: If you override the EVT_SIZE event in your ListCtrl, -make sure you call event.Skip() to ensure that the mixin's _OnResize method is -called. - -

This mix-in class was written by Erik Westra - -

Methods
-
- -
resizeLastColumn(minWidth) -
Resize the last column appropriately. If the list's columns are too wide to -fit within the window, we use a horizontal scrollbar. Otherwise, we expand the -right-most column to take up the remaining free space in the list. This method is -called automatically when the ListCtrl is resized; you can also call it yourself -whenever you want the last column to be resized appropriately (eg, when adding, -removing or resizing columns). 'minWidth' is the preferred minimum width for -the last column. - -
- - -

ListCtrlSelectionManagerMix

- -ListCtrlSelectionManagerMix() - -

Mixin that defines a platform independent selection policy - -

As selection single and multi-select list return the item index or a -list of item indexes respectively. - -

Methods
-
- -
getPopupMenu() -
Override to implement dynamic menus (create) - -
setPopupMenu(menu) -
Must be set for default behaviour. - -
afterPopupMenu() -
Override to implement dynamic menus (destroy). - -
getSelection() -
Returns the current selection (or selections as a Python list if extended -selection is enabled) - - - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxListCtrl_virtual.py b/wxPython/demo/wxListCtrl_virtual.py deleted file mode 100644 index 75f5d97573..0000000000 --- a/wxPython/demo/wxListCtrl_virtual.py +++ /dev/null @@ -1,117 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx.ListItem.GetText() returns a wxString pointer, not the text. -# - -import wx -import images - -#---------------------------------------------------------------------- - -class TestVirtualList(wx.ListCtrl): - def __init__(self, parent, log): - wx.ListCtrl.__init__( - self, parent, -1, - style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES - ) - - self.log = log - - self.il = wx.ImageList(16, 16) - self.idx1 = self.il.Add(images.getSmilesBitmap()) - self.SetImageList(self.il, wx.IMAGE_LIST_SMALL) - - - self.InsertColumn(0, "First") - self.InsertColumn(1, "Second") - self.InsertColumn(2, "Third") - self.SetColumnWidth(0, 175) - self.SetColumnWidth(1, 175) - self.SetColumnWidth(2, 175) - - self.SetItemCount(1000000) - - self.attr1 = wx.ListItemAttr() - self.attr1.SetBackgroundColour("yellow") - - self.attr2 = wx.ListItemAttr() - self.attr2.SetBackgroundColour("light blue") - - self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected) - self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) - self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected) - - - def OnItemSelected(self, event): - self.currentItem = event.m_itemIndex - self.log.WriteText('OnItemSelected: "%s", "%s", "%s", "%s"\n' % - (self.currentItem, - self.GetItemText(self.currentItem), - self.getColumnText(self.currentItem, 1), - self.getColumnText(self.currentItem, 2))) - - def OnItemActivated(self, event): - self.currentItem = event.m_itemIndex - self.log.WriteText("OnItemActivated: %s\nTopItem: %s\n" % - (self.GetItemText(self.currentItem), self.GetTopItem())) - - def getColumnText(self, index, col): - item = self.GetItem(index, col) - return item.GetText() - - def OnItemDeselected(self, evt): - self.log.WriteText("OnItemDeselected: %s" % evt.m_itemIndex) - - - #--------------------------------------------------- - # These methods are callbacks for implementing the - # "virtualness" of the list... Normally you would - # determine the text, attributes and/or image based - # on values from some external data source, but for - # this demo we'll just calculate them - def OnGetItemText(self, item, col): - return "Item %d, column %d" % (item, col) - - def OnGetItemImage(self, item): - if item % 3 == 0: - return self.idx1 - else: - return -1 - - def OnGetItemAttr(self, item): - if item % 3 == 1: - return self.attr1 - elif item % 3 == 2: - return self.attr2 - else: - return None - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestVirtualList(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -This example demonstrates the ListCtrl's Virtual List features. A Virtual list -can contain any number of cells, but data is not loaded into the control itself. -It is loaded on demand via virtual methods OnGetItemText(), OnGetItemImage(), -and OnGetItemAttr(). This greatly reduces the amount of memory required -without limiting what can be done with the list control itself. -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxListbook.py b/wxPython/demo/wxListbook.py deleted file mode 100644 index 2186205cb3..0000000000 --- a/wxPython/demo/wxListbook.py +++ /dev/null @@ -1,129 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Bunches of imports that might need to go away for the final roll-out. -# - -import sys - -import wx - -import images - -import ColorPanel - -colourList = [ "Aquamarine", "Black", "Blue", "Blue Violet", "Brown", "Cadet Blue", - "Coral", "Cornflower Blue", "Cyan", "Dark Grey", "Dark Green", - "Dark Olive Green", "Dark Orchid", "Dark Slate Blue", - "Dark Slate Grey", "Dark Turquoise", "Dim Grey", "Firebrick", - "Forest Green", "Gold", "Goldenrod", "Grey", "Green", "Green Yellow", - "Indian Red", "Khaki", "Light Blue", "Light Grey", "Light Steel Blue", - "Lime Green", "Magenta", "Maroon", "Medium Aquamarine", "Medium Blue", - "Medium Forest Green", "Medium Goldenrod", "Medium Orchid", - "Medium Sea Green", "Medium Slate Blue", "Medium Spring Green", - "Medium Turquoise", "Medium Violet Red", "Midnight Blue", "Navy", - "Orange", "Orange Red", "Orchid", "Pale Green", "Pink", "Plum", - "Purple", "Red", "Salmon", "Sea Green", "Sienna", "Sky Blue", - "Slate Blue", "Spring Green", "Steel Blue", "Tan", "Thistle", - "Turquoise", "Violet", "Violet Red", "Wheat", "White", "Yellow", - "Yellow Green" - ] - -#---------------------------------------------------------------------------- - -class TestLB(wx.Listbook): - def __init__(self, parent, id, log): - wx.Listbook.__init__(self, parent, id, style= - wx.LB_DEFAULT - #wxLB_TOP - #wxLB_BOTTOM - #wxLB_LEFT - #wxLB_RIGHT - ) - self.log = log - - - # make an image list using the BlomXX images - il = wx.ImageList(32, 32) - for x in range(1, 15): - f = getattr(images, 'getBlom%02dBitmap' % x) - bmp = f() - il.Add(bmp) - self.AssignImageList(il) - - # Now make a bunch of panels for the list book - first = True - imID = 0 - for colour in colourList: - win = self.makeColorPanel(colour) - self.AddPage(win, colour, imageId=imID) - imID += 1 - if imID == il.GetImageCount(): imID = 0 - if first: - st = wx.StaticText(win.win, -1, - "You can put nearly any type of window here,\n" - "and the list can be on any side of the Listbook", - wx.Point(10, 10)) - #st.SetForegroundColour(wxWHITE) - #st.SetBackgroundColour(wxBLUE) - first = False - - - - wx.EVT_LISTBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged) - wx.EVT_LISTBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging) - - - def makeColorPanel(self, color): - p = wx.Panel(self, -1) - win = ColorPanel.ColoredPanel(p, color) - p.win = win - def OnCPSize(evt, win=win): - win.SetSize(evt.GetSize()) - p.Bind(wx.EVT_SIZE, OnCPSize) - return p - - - def OnPageChanged(self, event): - old = event.GetOldSelection() - new = event.GetSelection() - sel = self.GetSelection() - self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) - event.Skip() - - def OnPageChanging(self, event): - old = event.GetOldSelection() - new = event.GetSelection() - sel = self.GetSelection() - self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) - event.Skip() - -#---------------------------------------------------------------------------- - -def runTest(frame, nb, log): - testWin = TestLB(nb, -1, log) - return testWin - -#---------------------------------------------------------------------------- - - -overview = """\ - -

wxListbook

-

-This class is a control similar to a notebook control, but with a -wxListCtrl instead of a set of tabs. - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - - diff --git a/wxPython/demo/wxMDIWindows.py b/wxPython/demo/wxMDIWindows.py deleted file mode 100644 index a28390a674..0000000000 --- a/wxPython/demo/wxMDIWindows.py +++ /dev/null @@ -1,66 +0,0 @@ -# 11/12/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -import MDIDemo -import MDISashDemo - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - b1 = wx.Button(self, -1, "MDI demo") - self.Bind(wx.EVT_BUTTON, self.ShowMDIDemo, b1) - - b2 = wx.Button(self, -1, "MDI with SashWindows demo") - self.Bind(wx.EVT_BUTTON, self.ShowMDISashDemo, b2) - - box = wx.BoxSizer(wx.VERTICAL) - box.Add((20, 30)) - box.Add(b1, 0, wx.ALIGN_CENTER|wx.ALL, 15) - box.Add(b2, 0, wx.ALIGN_CENTER|wx.ALL, 15) - self.SetAutoLayout(True) - self.SetSizer(box) - - - def ShowMDIDemo(self, evt): - frame = MDIDemo.MyParentFrame() - frame.Show() - - def ShowMDISashDemo(self, evt): - frame = MDISashDemo.MyParentFrame() - frame.Show() - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

Multiple Document Interface

- -Although Microsoft has deprecated the MDI model, wxWindows still supports -it. Here are a couple samples of how to use it - one straightforward, the other -showing how the MDI interface can be integrated into a SashWindow interface. - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxMVCTree.py b/wxPython/demo/wxMVCTree.py deleted file mode 100644 index 79ad083a85..0000000000 --- a/wxPython/demo/wxMVCTree.py +++ /dev/null @@ -1,90 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Library must be updated for this to run. -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxMVCTree -> MVCTree -# - -import os -import sys - -import wx -import wx.lib.mvctree as tree - -logger = None -def selchanging(evt): - logger.write("SelChanging!\n") - -def selchanged(evt): - logger.write("SelChange!\n") - logger.write(str(evt.node)) -def expanded(evt): - logger.write("Expanded\n") -def closed(evt): - logger.write("Closed!\n") -def key(evt): - logger.write("Key\n") -def add(evt): - logger.write("Add\n") -def delitem(evt): - logger.write("Delete\n") - -def runTest(frame, nb, log): - #f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500)) - global logger - logger = log - p = tree.MVCTree(nb, -1) - #f = wx.Frame(frame, -1, "MVCTree") - #p = tree.MVCTree(f, -1) - p.SetAssumeChildren(True) - p.SetModel(tree.LateFSTreeModel(os.path.normpath(os.getcwd() + os.sep +'..'))) - - #Uncomment this to enable live filename editing! -# p.AddEditor(FileEditor(p)) - - p.SetMultiSelect(True) - tree.EVT_MVCTREE_SEL_CHANGING(p, p.GetId(), selchanging) - tree.EVT_MVCTREE_SEL_CHANGED(p, p.GetId(), selchanged) - tree.EVT_MVCTREE_ITEM_EXPANDED(p, p.GetId(), expanded) - tree.EVT_MVCTREE_ITEM_COLLAPSED(p, p.GetId(), closed) - tree.EVT_MVCTREE_ADD_ITEM(p, p.GetId(), add) - tree.EVT_MVCTREE_DELETE_ITEM(p, p.GetId(), delitem) - tree.EVT_MVCTREE_KEY_DOWN(p, p.GetId(), key) - - return p - #frame.otherWin = f - #f.Show(True) - #return None - - -overview = """\ - -MVCTree is a control which handles hierarchical data. It is -constructed in model-view-controller architecture, so the display of -that data, and the content of the data can be changed greatly without -affecting the other parts. - -Multiple selections are possible by holding down the Ctrl key. - -This demo shows the wxPython directory structure. The interesting part -is that the tree model is late-bound to the filesystem, so the -filenames are not retrieved until the directory is expanded. In -mvctree.py are models for generic data, and both the early and -late-bound filesystem models. - -There is also support for editing, though it's not enabled in this -demo, to avoid accidentally renaming files! - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxMask.py b/wxPython/demo/wxMask.py deleted file mode 100644 index ad35dfd9b5..0000000000 --- a/wxPython/demo/wxMask.py +++ /dev/null @@ -1,135 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -logicList = [ - ('wx.AND', wx.AND), - ('wx.AND_INVERT', wx.AND_INVERT), - ('wx.AND_REVERSE', wx.AND_REVERSE), - ('wx.CLEAR', wx.CLEAR), - ('wx.COPY', wx.COPY), - ('wx.EQUIV', wx.EQUIV), - ('wx.INVERT', wx.INVERT), - ('wx.NAND', wx.NAND), - - # this one causes an assert on wxGTK, and doesn't seem to - # do much on MSW anyway, so I'll just take it out.... - #('wxNOR', wxNOR), - - ('wx.NO_OP', wx.NO_OP), - ('wx.OR', wx.OR), - ('wx.OR_INVERT', wx.OR_INVERT), - ('wx.OR_REVERSE', wx.OR_REVERSE), - ('wx.SET', wx.SET), - ('wx.SRC_INVERT', wx.SRC_INVERT), - ('wx.XOR', wx.XOR), -] - -import images - -class TestMaskWindow(wx.ScrolledWindow): - def __init__(self, parent): - wx.ScrolledWindow.__init__(self, parent, -1) - self.SetBackgroundColour(wx.Colour(0,128,0)) - - # A reference bitmap that we won't mask - self.bmp_nomask = images.getTestStar2Bitmap() - - # One that we will - self.bmp_withmask = images.getTestStar2Bitmap() - - # this mask comes from a monochrome bitmap - self.bmp_themask = wx.BitmapFromImage(images.getTestMaskImage(), 1) - mask = wx.Mask(self.bmp_themask) - - # set the mask on our bitmap - self.bmp_withmask.SetMask(mask) - - # Now we'll create a mask in a bit of an easier way, by picking a - # colour in the image that is to be the transparent colour. - self.bmp_withcolourmask = images.getTestStar2Bitmap() - mask = wx.MaskColour(self.bmp_withcolourmask, wx.WHITE) - self.bmp_withcolourmask.SetMask(mask) - - self.SetScrollbars(20, 20, 700/20, 460/20) - - self.Bind(wx.EVT_PAINT, self.OnPaint) - - - def OnPaint (self, e): - dc = wx.PaintDC(self) - self.PrepareDC(dc) - dc.SetTextForeground(wx.WHITE) - - # make an interesting background... - dc.SetPen(wx.MEDIUM_GREY_PEN) - for i in range(100): - dc.DrawLine((0,i*10), (i*10,0)) - - # draw raw image, mask, and masked images - dc.DrawText('original image', (0,0)) - dc.DrawBitmap(self.bmp_nomask, (0,20), 0) - dc.DrawText('with colour mask', (0,100)) - dc.DrawBitmap(self.bmp_withcolourmask, (0,120), 1) - dc.DrawText('the mask image', (0,200)) - dc.DrawBitmap(self.bmp_themask, (0,220), 0) - dc.DrawText('masked image', (0,300)) - dc.DrawBitmap(self.bmp_withmask, (0,320), 1) - - cx,cy = self.bmp_themask.GetWidth(), self.bmp_themask.GetHeight() - - # draw array of assorted blit operations - mdc = wx.MemoryDC() - i = 0 - - for text, code in logicList: - x,y = 120+150*(i%4), 20+100*(i/4) - dc.DrawText(text, (x, y-20)) - mdc.SelectObject(self.bmp_withcolourmask) - dc.Blit((x,y), (cx,cy), mdc, (0,0), code, True) - i = i + 1 - - -# On wxGTK there needs to be a panel under wxScrolledWindows if they are -# going to be in a wxNotebook... -class TestPanel(wx.Panel): - def __init__(self, parent, ID): - wx.Panel.__init__(self, parent, ID) - self.win = TestMaskWindow(self) - self.Bind(wx.EVT_SIZE, self.OnSize) - - def OnSize(self, evt): - self.win.SetSize(evt.GetSize()) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, -1) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -This class encapsulates a monochrome mask bitmap, where the masked area is black -and the unmasked area is white. When associated with a bitmap and drawn in a device -context, the unmasked area of the bitmap will be drawn, and the masked area will -not be drawn. - -This example shows not only how to create a Mask, but the effects of the Device -Context (dc) Blit() method's logic codes. -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxMaskedNumCtrl.py b/wxPython/demo/wxMaskedNumCtrl.py deleted file mode 100644 index 855726b100..0000000000 --- a/wxPython/demo/wxMaskedNumCtrl.py +++ /dev/null @@ -1,346 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx.lib.maskednumctrl needs hit up with the renamer and new binders -# -# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Issues with lib corrected. -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxMaskedNumCtrl -> MaskedNumCtrl -# - -import string -import sys -import traceback - -import wx -import wx.lib.maskednumctrl as mnum -#---------------------------------------------------------------------- - -class TestPanel( wx.Panel ): - def __init__( self, parent, log ): - - wx.Panel.__init__( self, parent, -1 ) - self.log = log - panel = wx.Panel( self, -1 ) - - header = wx.StaticText(panel, -1, """\ -This shows the various options for MaskedNumCtrl. -The controls at the top reconfigure the resulting control at the bottom. -""") - header.SetForegroundColour( "Blue" ) - - intlabel = wx.StaticText( panel, -1, "Integer width:" ) - self.integerwidth = mnum.MaskedNumCtrl( - panel, value=10, integerWidth=2, allowNegative=False - ) - - fraclabel = wx.StaticText( panel, -1, "Fraction width:" ) - self.fractionwidth = mnum.MaskedNumCtrl( - panel, value=0, integerWidth=2, allowNegative=False - ) - - groupcharlabel = wx.StaticText( panel,-1, "Grouping char:" ) - self.groupchar = mnum.MaskedTextCtrl( - panel, -1, value=',', mask='&', excludeChars = '-()', - formatcodes='F', emptyInvalid=True, validRequired=True - ) - - decimalcharlabel = wx.StaticText( panel,-1, "Decimal char:" ) - self.decimalchar = mnum.MaskedTextCtrl( - panel, -1, value='.', mask='&', excludeChars = '-()', - formatcodes='F', emptyInvalid=True, validRequired=True - ) - - self.set_min = wx.CheckBox( panel, -1, "Set minimum value:" ) - # Create this MaskedNumCtrl using factory, to show how: - self.min = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 ) - self.min.Enable( False ) - - self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" ) - self.max = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 ) - self.max.Enable( False ) - - - self.limit_target = wx.CheckBox( panel, -1, "Limit control" ) - self.allow_none = wx.CheckBox( panel, -1, "Allow empty control" ) - self.group_digits = wx.CheckBox( panel, -1, "Group digits" ) - self.group_digits.SetValue( True ) - self.allow_negative = wx.CheckBox( panel, -1, "Allow negative values" ) - self.allow_negative.SetValue( True ) - self.use_parens = wx.CheckBox( panel, -1, "Use parentheses" ) - self.select_on_entry = wx.CheckBox( panel, -1, "Select on entry" ) - self.select_on_entry.SetValue( True ) - - label = wx.StaticText( panel, -1, "Resulting numeric control:" ) - font = label.GetFont() - font.SetWeight(wx.BOLD) - label.SetFont(font) - - self.target_ctl = mnum.MaskedNumCtrl( panel, -1, name="target control" ) - - label_numselect = wx.StaticText( panel, -1, """\ -Programmatically set the above -value entry ctrl:""") - self.numselect = wx.ComboBox(panel, -1, choices = [ '0', '111', '222.22', '-3', '54321.666666666', '-1353.978', - '1234567', '-1234567', '123456789', '-123456789.1', - '1234567890.', '-9876543210.9' ]) - - grid1 = wx.FlexGridSizer( 0, 4, 0, 0 ) - grid1.Add( intlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - grid1.Add( self.integerwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid1.Add( groupcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - grid1.Add( self.groupchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid1.Add( fraclabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid1.Add( self.fractionwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid1.Add( decimalcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) - grid1.Add( self.decimalchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid1.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid1.Add( self.min, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - - grid1.Add( self.set_max, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid1.Add( self.max, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - - - grid1.Add( self.limit_target, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid1.Add( self.allow_none, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - hbox1 = wx.BoxSizer( wx.HORIZONTAL ) - hbox1.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - hbox1.Add( self.group_digits, 0, wx.ALIGN_LEFT|wx.LEFT, 5 ) - grid1.Add( hbox1, 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - - grid1.Add( self.allow_negative, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid1.Add( self.use_parens, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - hbox2 = wx.BoxSizer( wx.HORIZONTAL ) - hbox2.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - hbox2.Add( self.select_on_entry, 0, wx.ALIGN_LEFT|wx.LEFT, 5 ) - grid1.Add( hbox2, 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - - - grid2 = wx.FlexGridSizer( 0, 2, 0, 0 ) - grid2.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid2.Add( self.target_ctl, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid2.Add( label_numselect, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid2.Add( self.numselect, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5) - grid2.AddGrowableCol(1) - - self.outer_box = wx.BoxSizer( wx.VERTICAL ) - self.outer_box.Add(header, 0, wx.ALIGN_LEFT|wx.TOP|wx.LEFT, 20) - self.outer_box.Add( grid1, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.BOTTOM|wx.RIGHT, 20 ) - self.outer_box.Add( grid2, 0, wx.ALIGN_LEFT|wx.ALL, 20 ) - self.grid2 = grid2 - - panel.SetAutoLayout( True ) - panel.SetSizer( self.outer_box ) - self.outer_box.Fit( panel ) - panel.Move( (50,10) ) - self.panel = panel - - self.Bind(mnum.EVT_MASKEDNUM, self.OnSetIntWidth, self.integerwidth ) - self.Bind(mnum.EVT_MASKEDNUM, self.OnSetFractionWidth, self.fractionwidth ) - self.Bind(wx.EVT_TEXT, self.OnSetGroupChar, self.groupchar ) - self.Bind(wx.EVT_TEXT, self.OnSetDecimalChar, self.decimalchar ) - - self.Bind(wx.EVT_CHECKBOX, self.OnSetMin, self.set_min ) - self.Bind(wx.EVT_CHECKBOX, self.OnSetMax, self.set_max ) - self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.min ) - self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.max ) - - self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target ) - self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none ) - self.Bind(wx.EVT_CHECKBOX, self.OnSetGroupDigits, self.group_digits ) - self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNegative, self.allow_negative ) - self.Bind(wx.EVT_CHECKBOX, self.OnSetUseParens, self.use_parens ) - self.Bind(wx.EVT_CHECKBOX, self.OnSetSelectOnEntry, self.select_on_entry ) - - self.Bind(mnum.EVT_MASKEDNUM, self.OnTargetChange, self.target_ctl ) - self.Bind(wx.EVT_COMBOBOX, self.OnNumberSelect, self.numselect ) - - - def OnSetIntWidth(self, event ): - width = self.integerwidth.GetValue() - - if width < 1: - self.log.write("integer width must be positive\n") - self.integerwidth.SetForegroundColour(wx.RED) - else: - self.integerwidth.SetForegroundColour(wx.BLACK) - self.log.write("setting integer width to %d\n" % width) - self.target_ctl.SetParameters( integerWidth = width) - # Now resize and fit the dialog as appropriate: - self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) - self.outer_box.Fit( self.panel ) - self.outer_box.SetSizeHints( self.panel ) - - - def OnSetFractionWidth(self, event ): - width = self.fractionwidth.GetValue() - self.log.write("setting fraction width to %d\n" % width) - self.target_ctl.SetParameters( fractionWidth = width) - # Now resize and fit the dialog as appropriate: - self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) - self.outer_box.Fit( self.panel ) - self.outer_box.SetSizeHints( self.panel ) - - - def OnSetGroupChar( self, event ): - char = self.groupchar.GetValue() - if self.target_ctl.GetDecimalChar() == char: - self.log.write("group and decimal chars must be different\n") - self.groupchar.SetForegroundColour(wx.RED) - else: - self.groupchar.SetForegroundColour(wx.BLACK) - self.log.write("setting group char to %s\n" % char) - self.target_ctl.SetGroupChar( char ) - - def OnSetDecimalChar( self, event ): - char = self.decimalchar.GetValue() - if self.target_ctl.GetGroupChar() == char: - self.log.write("group and decimal chars must be different\n") - self.decimalchar.SetForegroundColour(wx.RED) - else: - self.decimalchar.SetForegroundColour(wx.BLACK) - self.log.write("setting decimal char to %s\n" % char) - self.target_ctl.SetDecimalChar( char ) - - - def OnSetMin( self, event ): - self.min.Enable( self.set_min.GetValue() ) - self.SetTargetMinMax() - - def OnSetMax( self, event ): - self.max.Enable( self.set_max.GetValue() ) - self.SetTargetMinMax() - - - def SetTargetMinMax( self, event=None ): - min = max = None - self.target_ctl.SetLimited( self.limit_target.GetValue() ) - - if self.set_min.GetValue(): - min = self.min.GetValue() - if self.set_max.GetValue(): - max = self.max.GetValue() - - cur_min, cur_max = self.target_ctl.GetBounds() - - if min != cur_min and not self.target_ctl.SetMin( min ): - if self.target_ctl.GetMax() is None and cur_max > min: - self.log.write( "min (%d) won't fit in control -- bound not set\n" % min ) - else: - self.log.write( "min (%d) > current max (%d) -- bound not set\n" % ( min, self.target_ctl.GetMax() ) ) - self.min.SetParameters( signedForegroundColour=wx.RED, foregroundColour=wx.RED ) - else: - self.min.SetParameters( signedForegroundColour=wx.BLACK, foregroundColour=wx.BLACK ) - self.min.Refresh() - - if max != cur_max and not self.target_ctl.SetMax( max ): - if self.target_ctl.GetMax() is None and cur_min < max: - self.log.write( "max (%d) won't fit in control -- bound not set\n" % max ) - else: - self.log.write( "max (%d) < current min (%d) -- bound not set\n" % ( max, self.target_ctl.GetMin() ) ) - self.max.SetParameters( signedForegroundColour=wx.RED, foregroundColour=wx.RED ) - else: - self.max.SetParameters( signedForegroundColour=wx.BLACK, foregroundColour=wx.BLACK ) - self.max.Refresh() - - if min != cur_min or max != cur_max: - new_min, new_max = self.target_ctl.GetBounds() - self.log.write( "current min, max: (%s, %s)\n" % ( str(new_min), str(new_max) ) ) - - - def OnSetAllowNone( self, event ): - self.target_ctl.SetAllowNone( self.allow_none.GetValue() ) - - - def OnSetGroupDigits( self, event ): - self.target_ctl.SetGroupDigits( self.group_digits.GetValue() ) - # Now resize and fit the dialog as appropriate: - self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) - self.outer_box.Fit( self.panel ) - self.outer_box.SetSizeHints( self.panel ) - - - def OnSetAllowNegative( self, event ): - if self.allow_negative.GetValue(): - self.use_parens.Enable(True) - self.target_ctl.SetParameters(allowNegative=True, - useParensForNegatives = self.use_parens.GetValue()) - else: - self.target_ctl.SetAllowNegative(False) - # Now resize and fit the dialog as appropriate: - self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) - self.outer_box.Fit( self.panel ) - self.outer_box.SetSizeHints( self.panel ) - - - def OnSetUseParens( self, event ): - self.target_ctl.SetUseParensForNegatives( self.use_parens.GetValue() ) - # Now resize and fit the dialog as appropriate: - self.grid2.SetItemMinSize(self.target_ctl, self.target_ctl.GetSize()) - self.outer_box.Fit( self.panel ) - self.outer_box.SetSizeHints( self.panel ) - - - def OnSetSelectOnEntry( self, event ): - self.target_ctl.SetSelectOnEntry( self.select_on_entry.GetValue() ) - - - def OnTargetChange( self, event ): - ctl = event.GetEventObject() - value = ctl.GetValue() - ib_str = [ " (out of bounds)", "" ] - self.log.write( "value = %s (%s)%s\n" % ( repr(value), repr(type(value)), ib_str[ ctl.IsInBounds(value) ] ) ) - - - def OnNumberSelect( self, event ): - value = event.GetString() - if value: - if value.find('.') != -1: - numvalue = float(value) - else: - numvalue = long(value) - else: - numvalue = value # try to clear the value again - - try: - self.target_ctl.SetValue(numvalue) - except: - type, value, tb = sys.exc_info() - for line in traceback.format_exception_only(type, value): - self.log.write(line) - - -#---------------------------------------------------------------------- - -def runTest( frame, nb, log ): - win = TestPanel( nb, log ) - return win - -#---------------------------------------------------------------------- -overview = mnum.__doc__ - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxMenu.py b/wxPython/demo/wxMenu.py deleted file mode 100644 index 516241efcf..0000000000 --- a/wxPython/demo/wxMenu.py +++ /dev/null @@ -1,300 +0,0 @@ -#------------------------------------------------------------------- -# essaimenu.py -# -# menus in wxPython 2.3.3 -# -#------------------------------------------------------------------- -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import time -import wx -import images - -#------------------------------------------------------------------- - -class MyFrame(wx.Frame): - - def __init__(self, parent, id, log): - wx.Frame.__init__(self, parent, id, 'Playing with menus', size=(400, 200)) - self.log = log - self.CenterOnScreen() - - self.CreateStatusBar() - self.SetStatusText("This is the statusbar") - - tc = wx.TextCtrl(self, -1, """ -A bunch of bogus menus have been created for this frame. You -can play around with them to see how they behave and then -check the source for this sample to see how to implement them. -""", style=wx.TE_READONLY|wx.TE_MULTILINE) - - # Prepare the menu bar - menuBar = wx.MenuBar() - - # 1st menu from left - menu1 = wx.Menu() - 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, "&Close", "Close this frame") - # Add menu to the menu bar - menuBar.Append(menu1, "&Planets") - - # 2nd menu from left - menu2 = wx.Menu() - menu2.Append(201, "Hydrogen") - menu2.Append(202, "Helium") - # a submenu in the 2nd menu - submenu = wx.Menu() - 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 = wx.Menu() - # Radio items - menu3.Append(301, "IDLE", "a Python shell using tcl/tk as GUI", wx.ITEM_RADIO) - menu3.Append(302, "PyCrust", "a Python shell using wxPython as GUI", wx.ITEM_RADIO) - menu3.Append(303, "psi", "a simple Python shell using wxPython as GUI", wx.ITEM_RADIO) - menu3.AppendSeparator() - menu3.Append(304, "project1", "", wx.ITEM_NORMAL) - menu3.Append(305, "project2", "", wx.ITEM_NORMAL) - menuBar.Append(menu3, "&Shells") - - menu4 = wx.Menu() - # Check menu items - menu4.Append(401, "letters", "abcde...", wx.ITEM_CHECK) - menu4.Append(402, "digits", "123...", wx.ITEM_CHECK) - menu4.Append(403, "letters and digits", "abcd... + 123...", wx.ITEM_CHECK) - menuBar.Append(menu4, "Chec&k") - - menu5 = wx.Menu() - # Show how to put an icon in the menu - item = wx.MenuItem(menu5, 500, "&Smile!\tCtrl+S", "This one has an icon") - item.SetBitmap(images.getSmilesBitmap()) - menu5.AppendItem(item) - - # Shortcuts - menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!") - menu5.AppendSeparator() - menu5.Append(502, "Hello\tShift+H") - menu5.AppendSeparator() - menu5.Append(503, "remove the submenu") - menu6 = wx.Menu() - menu6.Append(601, "Submenu Item") - menu5.AppendMenu(504, "submenu", menu6) - menu5.Append(505, "remove this menu") - menu5.Append(506, "this is updated") - menu5.Append(507, "insert after this...") - menu5.Append(508, "...and before this") - menuBar.Append(menu5, "&Fun") - - self.SetMenuBar(menuBar) - - # Menu events - self.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight) - - self.Bind(wx.EVT_MENU, self.Menu101, id=101) - self.Bind(wx.EVT_MENU, self.Menu102, id=102) - self.Bind(wx.EVT_MENU, self.Menu103, id=103) - self.Bind(wx.EVT_MENU, self.CloseWindow, id=104) - - self.Bind(wx.EVT_MENU, self.Menu201, id=201) - self.Bind(wx.EVT_MENU, self.Menu202, id=202) - self.Bind(wx.EVT_MENU, self.Menu2031, id=2031) - self.Bind(wx.EVT_MENU, self.Menu2032, id=2032) - self.Bind(wx.EVT_MENU, self.Menu2033, id=2033) - - self.Bind(wx.EVT_MENU, self.Menu301To303, id=301) - self.Bind(wx.EVT_MENU, self.Menu301To303, id=302) - self.Bind(wx.EVT_MENU, self.Menu301To303, id=303) - self.Bind(wx.EVT_MENU, self.Menu304, id=304) - self.Bind(wx.EVT_MENU, self.Menu305, id=305) - - # Range of menu items - self.Bind(wx.EVT_MENU_RANGE, self.Menu401To403, id=401, id2=403) - - self.Bind(wx.EVT_MENU, self.Menu500, id=500) - self.Bind(wx.EVT_MENU, self.Menu501, id=501) - self.Bind(wx.EVT_MENU, self.Menu502, id=502) - self.Bind(wx.EVT_MENU, self.TestRemove, id=503) - self.Bind(wx.EVT_MENU, self.TestRemove2, id=505) - self.Bind(wx.EVT_MENU, self.TestInsert, id=507) - self.Bind(wx.EVT_MENU, self.TestInsert, id=508) - - wx.GetApp().Bind(wx.EVT_UPDATE_UI, self.TestUpdateUI, id=506) - - # Methods - - def OnMenuHighlight(self, event): - # Show how to get menu item imfo from this event handler - id = event.GetMenuId() - item = self.GetMenuBar().FindItemById(id) - text = item.GetText() - help = item.GetHelp() - - #print text, help - # but in this case just call Skip so the default is done - event.Skip() - - - 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 CloseWindow(self, event): - self.Close() - - 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 Menu500(self, event): - self.log.write('Have a happy day!\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 TestRemove(self, evt): - mb = self.GetMenuBar() - submenuItem = mb.FindItemById(601) - - if not submenuItem: - return - - submenu = submenuItem.GetMenu() - menu = submenu.GetParent() - - # This works - #menu.Remove(504) - - # this also works - menu.RemoveItem(mb.FindItemById(504)) - - # This doesn't work, as expected since submenuItem is not on menu - #menu.RemoveItem(submenuItem) - - - def TestRemove2(self, evt): - mb = self.GetMenuBar() - mb.Remove(4) - - - def TestUpdateUI(self, evt): - text = time.ctime() - evt.SetText(text) - - - def TestInsert(self, evt): - theID = 508 - # get the menu - mb = self.GetMenuBar() - menuItem = mb.FindItemById(theID) - menu = menuItem.GetMenu() - - # figure out the position to insert at - pos = 0 - - for i in menu.GetMenuItems(): - if i.GetId() == theID: - break - - pos += 1 - - # now insert the new item - ID = wx.NewId() - ##menu.Insert(pos, ID, "NewItem " + str(ID)) - item = wx.MenuItem(menu) - item.SetId(ID) - item.SetText("NewItem " + str(ID)) - menu.InsertItem(pos, item) - - -#------------------------------------------------------------------- - -wx.RegisterId(10000) - -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. - -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 -used to construct either menu bars or popup menus. - -A menu item has an integer ID associated with it which can be used to identify -the selection, or to change the menu item in some way. A menu item with a special -identifier -1 is a separator item and doesn't have an associated command but just -makes a separator line appear in the menu. - -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 -be retrieved using either IsChecked method of wxMenu or wxMenuBar 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 -in the same radio group are unchecked when a radio item is checked. The radio group -is formed by a contiguous range of radio items, i.e. it starts at the first item of -this kind and ends with the first item of a different kind (or the end of the menu). -Notice that because the radio groups are defined in terms of the item positions -inserting or removing the items in the menu containing the radio items risks to not -work correctly. Finally note that the radio items are only supported under Windows -and GTK+ currently. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxMessageDialog.py b/wxPython/demo/wxMessageDialog.py deleted file mode 100644 index 009c30fb11..0000000000 --- a/wxPython/demo/wxMessageDialog.py +++ /dev/null @@ -1,39 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - dlg = wx.MessageDialog(frame, 'Hello from Python and wxPython!', - 'A Message Box', wx.OK | wx.ICON_INFORMATION) - #wxYES_NO | wxNO_DEFAULT | wxCANCEL | wxICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - -#--------------------------------------------------------------------------- - - - -overview = """\ -This class represents a dialog that shows a single or multi-line message, with a -choice of OK, Yes, No and Cancel buttons. - -Additionally, various style flags can determine whether an icon is displayed, -and, if so, what kind. - -The dialog can be modal or not; of modal, the user's response is in the return -code of ShowModal(). If not, the response can be taken from GetReturnCode() (inherited -from the wxDialog super class). If not modal and the return code is required, it -must be retrieved before the dialog is destroyed. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxMimeTypesManager.py b/wxPython/demo/wxMimeTypesManager.py deleted file mode 100644 index b3c6b970a6..0000000000 --- a/wxPython/demo/wxMimeTypesManager.py +++ /dev/null @@ -1,355 +0,0 @@ -#---------------------------------------------------------------------- -# Name: wxMimeTypesManager -# Purpose: Demonstrate use of wx.MimeTypesManager, wx.FileType -# -# Author: Jeff Grimmett (grimmtoo@softhome.net), adapted from original -# .wdr-derived demo -# -# Created: 12/31/03 -# RCS-ID: $Id$ -# Copyright: -# Licence: wxWindows license -#---------------------------------------------------------------------- -# - - -import pprint -import wx -import images - -#---------------------------------------------------------------------------- - -# A convenient wrapper around wx.TextCtrl to give it a spiffy label. -class ExtStr(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent, -1) - sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Extension'), wx.HORIZONTAL) - self.ctl = wx.TextCtrl(self, -1, value="wav", style = wx.TE_PROCESS_ENTER ) - sizer.Add(self.ctl, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 3) - self.Enable(True) - - self.SetSizer(sizer) - sizer.Fit(self) - - def Enable(self, value): - self.ctl.Enable(value) - - def SetValue(self, value): - self.ctl.SetValue(value) - - def GetValue(self): - return(self.ctl.GetValue()) - - -class MimeTypesDemoPanel(wx.Panel): - def __init__(self, parent, log): - - self.log = log - - wx.Panel.__init__(self, parent, -1) - - # Contains everything - tsizer = wx.BoxSizer(wx.VERTICAL) - - # Contains upper controls - usizer = wx.BoxSizer(wx.HORIZONTAL) - - # A little fancy stuff to make things align right. - self.ext = ExtStr(self) - usizer.Add(self.ext, 0, wx.ALL | wx.ALIGN_TOP, 4) - self.ext.Bind(wx.EVT_TEXT_ENTER, self.OnLookup) - - # Select how to look it up - self.how = wx.RadioBox( - self, -1, "Lookup method", choices=['By extension', 'By MIME type'], - majorDimension=2, style=wx.RA_SPECIFY_COLS - ) - usizer.Add(self.how, 0, wx.ALL | wx.ALIGN_TOP, 4) - self.how.SetSelection(0) - - # Trigger a lookup (hitting ENTER in the text ctrl will do the same thing) - self.go = wx.Button(self, -1, "Go get it!") - usizer.Add(self.go, 0, wx.ALL | wx.ALIGN_CENTER, 4) - self.Bind(wx.EVT_BUTTON, self.OnLookup, self.go) - - # StaticBox with larger label than usual - lbox = wx.StaticBox(self, -1, 'wx.FileType') - lbox.SetFont( - wx.Font( - self.GetFont().GetPointSize() * 2, - self.GetFont().GetFamily(), - self.GetFont().GetStyle(), - wx.BOLD - )) - - lsizer = wx.StaticBoxSizer(lbox, wx.HORIZONTAL) - - # Contains the wx.FileType info - llsizer = wx.GridBagSizer(2, 2) - llsizer.AddGrowableCol(2) - - # This will be used for all of the labels that follow (bold label) - bfont = wx.Font( - self.GetFont().GetPointSize(), - self.GetFont().GetFamily(), - self.GetFont().GetStyle(), - wx.BOLD - ) - - #------- Icon info - - t = wx.StaticText(self, -1, 'GetIconInfo: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (0, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.icon = wx.StaticBitmap(self, -1, images.getNoIconBitmap()) - llsizer.Add(self.icon, (0, 1), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.iconsource = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) - llsizer.Add(self.iconsource, (0, 2), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.iconoffset = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) - llsizer.Add(self.iconoffset, (0, 3), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - #------- MIME Type - - t = wx.StaticText(self, -1, 'GetMimeType: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (1, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.mimetype = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) - llsizer.Add(self.mimetype, (1, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - #------- MIME Types - - t = wx.StaticText(self, -1, 'GetMimeTypes: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (2, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.mimetypes = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) - llsizer.Add(self.mimetypes, (2, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - #------- Extensions - - t = wx.StaticText(self, -1, 'GetExtensions: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (3, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.extensions = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) - llsizer.Add(self.extensions, (3, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - #------- Description - - t = wx.StaticText(self, -1, 'GetDescription: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (4, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.description = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY) - llsizer.Add(self.description, (4, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - #------- Open command - - t = wx.StaticText(self, -1, 'GetOpenCommand: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (5, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.opencommand = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) - llsizer.Add(self.opencommand, (5, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - #------- Print command - - t = wx.StaticText(self, -1, 'GetPrintCommand: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (6, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.printcommand = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY ) - llsizer.Add(self.printcommand, (6, 1), (1, 3), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - #------- All commands - - t = wx.StaticText(self, -1, 'GetAllCommands: ', style = wx.ALIGN_RIGHT ) - t.SetFont(bfont) - llsizer.Add(t, (7, 0), (1, 1), wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 2) - - self.allcommands = wx.TextCtrl(self, -1, value="", style = wx.TE_READONLY | wx.TE_DONTWRAP | wx.TE_MULTILINE ) - - # Set the default height to be smaller than normal (for - # multi-line) so the sizer can then expand it to whatever - # space is available - self.allcommands.SetSize((-1, 20)) - - llsizer.Add(self.allcommands, (7, 1), (1, 3), wx.ALL | wx.GROW | wx.ALIGN_CENTER, 2) - - # Tell the sizer to expand this row as needed - llsizer.AddGrowableRow(7) - - #---------------------------------------------------------------------------- - - lrsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Known MIME types'), wx.HORIZONTAL) - - #------- List box with known MIME types - self.mimelist = wx.ListBox(self, -1, choices=[], style = wx.LB_SINGLE | wx.LB_SORT) - lrsizer.Add(self.mimelist, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) - self.Bind(wx.EVT_LISTBOX, self.OnListbox, self.mimelist) - - #---------------------------------------------------------------------------- - - lsizer.Add(llsizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) - lsizer.Add(lrsizer, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) - - #---------------------------------------------------------------------------- - - tsizer.Add(usizer, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) - tsizer.Add(lsizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 4) - - #---------------------------------------------------------------------------- - - self.SetSizer(tsizer) - tsizer.Fit(self) - - # Populate the Known MIME types list with what is in the database - mtypes = wx.TheMimeTypesManager.EnumAllFileTypes() - for mt in mtypes: - self.mimelist.Append(mt) - - # Do a lookup of *.wav for a starting position - self.OnLookup() - - # Grab the selection from the listbox, push that into - # the text box at top, select 'MIME', and then look it up. - def OnListbox(self, event): - mimetype = event.GetString() - self.ext.SetValue(mimetype) - self.how.SetSelection(1) - self.OnLookup() - - # Look up a given file extension or MIME type. - def OnLookup(self, event=None): - txt = self.ext.GetValue() - - # For MIME lookups - if self.how.GetSelection() == 1: - fileType = wx.TheMimeTypesManager.GetFileTypeFromMimeType(txt) - msg = "Mime type" - - # Select the entered value in the list - if fileType: - if self.mimelist.FindString(txt) != -1: - self.mimelist.SetSelection(self.mimelist.FindString(txt)) - - # Must be an extension lookup - else: - fileType = wx.TheMimeTypesManager.GetFileTypeFromExtension(txt) - msg = "File extension" - - # Select the entered value in the list - if fileType: - if self.mimelist.FindString(str(fileType.GetMimeType())) != -1: - # Using CallAfter to ensure that GUI is ready before trying to - # select it (otherwise, it's selected but not visible) - wx.CallAfter(self.mimelist.SetSelection, self.mimelist.FindString(str(fileType.GetMimeType()))) - - - if fileType is None: - wx.MessageBox(msg + " not found.", "Oops!") - else: - self.Update(fileType) - - # Populate the wx.FileType fields with actual values. - def Update(self, ft): - - #------- Icon info - info = ft.GetIconInfo() - - if info is None: - bmp = images.getNoIconBitmap() - self.icon.SetBitmap(bmp) - self.iconsource.SetValue("") - self.iconoffset.SetValue("") - else: - icon, file, idx = info - if icon.Ok(): - self.icon.SetIcon(icon) - else: - bmp = images.getNoIconBitmap() - self.icon.SetBitmap(bmp) - self.iconsource.SetValue(file) - self.iconoffset.SetValue(str(idx)) - - #------- MIME type - self.mimetype.SetValue(str(ft.GetMimeType())) - #------- MIME types - self.mimetypes.SetValue(str(ft.GetMimeTypes())) - #------- Associated extensions - self.extensions.SetValue(str(ft.GetExtensions())) - #------- Description of file type - self.description.SetValue(str(ft.GetDescription())) - - #------- Prep a fake command line command - extList = ft.GetExtensions() - - if extList: - ext = extList[0] - if ext[0] == ".": ext = ext[1:] - else: - ext = "" - - filename = "SPAM" + "." + ext - mime = ft.GetMimeType() or "" - - #------- OPEN command - cmd = ft.GetOpenCommand(filename, mime) - self.opencommand.SetValue(str(cmd)) - - #------- PRINT command - cmd = ft.GetPrintCommand(filename, mime) - self.printcommand.SetValue(str(cmd)) - - #------- All commands - all = ft.GetAllCommands(filename, mime) - - if all is None: - self.allcommands.SetValue("") - else: - verbs, commands = all - text = pprint.pformat(map(None, verbs, commands)) - self.allcommands.SetValue(text) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = MimeTypesDemoPanel(nb, log) - return win - -#---------------------------------------------------------------------- - -overview = """\ - -The wx.MimeTypesManager class allows the application to retrieve the -information about all known MIME types from a system-specific location and the -filename extensions to the MIME types and vice versa. After initialization the -methods GetFileTypeFromMimeType() and GetFileTypeFromExtension() -may be called: they will return a wx.FileType object which may be further -queried for file description, icon and other attributes. - -A global instance of wx.MimeTypesManager is always available as -wx.TheMimeTypesManager. It is recommended to use this instance instead -of creating your own because gathering MIME information may take quite a long -on Unix systems. - -This demo shows how to use wx.TheMimeTypesManager to list all known MIME types -and retrieve that information as a wx.FileType from either an extension or -MIME type. - -For further information please consult the wxWindows documentation for -wx.MimeTypesManager and wx.FileType. - -""" - -#---------------------------------------------------------------------- - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxMiniFrame.py b/wxPython/demo/wxMiniFrame.py deleted file mode 100644 index 42e237ae4f..0000000000 --- a/wxPython/demo/wxMiniFrame.py +++ /dev/null @@ -1,55 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- -class MyMiniFrame(wx.MiniFrame): - def __init__( - self, parent, title, pos=wx.DefaultPosition, size=wx.DefaultSize, - style=wx.DEFAULT_FRAME_STYLE - ): - - wx.MiniFrame.__init__(self, parent, -1, title, pos, size, style) - panel = wx.Panel(self, -1) - - button = wx.Button(panel, -1, "Close Me") - button.SetPosition((15, 15)) - self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - - def OnCloseMe(self, event): - self.Close(True) - - def OnCloseWindow(self, event): - print "OnCloseWindow" - self.Destroy() - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = MyMiniFrame(frame, "This is a wxMiniFrame", - #pos=(250,250), size=(200,200), - style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ) - win.SetSize((200, 200)) - win.CenterOnParent(wx.BOTH) - frame.otherWin = win - win.Show(True) - - -#--------------------------------------------------------------------------- - - -overview = """\ -A miniframe is a frame with a small title bar. It is suitable for floating -toolbars that must not take up too much screen area. In other respects, it's the -same as a wxFrame. -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxMultiSash.py b/wxPython/demo/wxMultiSash.py deleted file mode 100644 index ce95868047..0000000000 --- a/wxPython/demo/wxMultiSash.py +++ /dev/null @@ -1,112 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx renamer needs to be applied to multisash lib. -# o There appears to be a problem with the image that -# the library is trying to use for the alternate cursor -# -# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o renamer issue shelved. -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxMultiSash -> MultiSash -# - -import wx -import wx.lib.multisash as sash -import wx.stc as stc - -#--------------------------------------------------------------------------- - -sampleText="""\ -You can drag the little tab on the vertical sash left to create another view, -or you can drag the tab on the horizontal sash to the top to create another -horizontal view. - -The red blocks on the sashes will destroy the view (bottom,left) this block -belongs to. - -A yellow rectangle also highlights the current selected view. - -By calling GetSaveData on the multiSash control the control will return its -contents and the positions of each sash as a dictionary. -Calling SetSaveData with such a dictionary will restore the control to the -state it was in when it was saved. - -If the class, that is used as a view, has GetSaveData/SetSaveData implemented, -these will also be called to save/restore their state. Any object can be -returned by GetSaveData, as it is just another object in the dictionary. -""" - -#--------------------------------------------------------------------------- - -class TestWindow(stc.StyledTextCtrl): - - # shared document reference - doc = None - - def __init__(self, parent): - stc.StyledTextCtrl.__init__(self, parent, -1, style=wx.NO_BORDER) - self.SetMarginWidth(1,0) - - if wx.Platform == '__WXMSW__': - fSize = 10 - else: - fSize = 12 - - self.StyleSetFont( - stc.STC_STYLE_DEFAULT, - wx.Font(fSize, wx.MODERN, wx.NORMAL, wx.NORMAL) - ) - - if self.doc: - self.SetDocPointer(self.doc) - else: - self.SetText(sampleText) - TestWindow.doc = self.GetDocPointer() - - - def SutdownDemo(self): - # Reset doc reference in case this demo is run again - TestWindow.doc = None - - -#--------------------------------------------------------------------------- - - -def runTest(frame, nb, log): - multi = sash.MultiSash(nb, -1, pos = (0,0), size = (640,480)) - - # Use this method to set the default class that will be created when - # a new sash is created. The class's constructor needs 1 parameter - # which is the parent of the window - multi.SetDefaultChildClass(TestWindow) - - return multi - -#---------------------------------------------------------------------- - - - -overview = """ -

MultiSash

- -MultiSash allows the user to split a window any number of times -either horizontally or vertically, and to close the split off windows -when desired. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxMultipleChoiceDialog.py b/wxPython/demo/wxMultipleChoiceDialog.py deleted file mode 100644 index e354d28070..0000000000 --- a/wxPython/demo/wxMultipleChoiceDialog.py +++ /dev/null @@ -1,92 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx renamer not applied to lib. -# -# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxMultipleChoiceDialog -> MultipleChoiceDialog -# - -import wx -import wx.lib.dialogs - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange', - 'etc', 'etc..', 'etc...' ] - - dlg = wx.lib.dialogs.MultipleChoiceDialog( - frame, - "Pick some from\n this list\nblah blah...", - "m.s.d.", lst) - - if (dlg.ShowModal() == wx.ID_OK): - print "Selection:", dlg.GetValue(), " -> ", dlg.GetValueString() - -#--------------------------------------------------------------------------- - - - -overview = """\ - - - -This is a Python implementation of a dialog that is not yet implemented in wxWindows -proper, so don't let the wxWindows documentation mislead you. - -

MultipleChoiceDialog(self, parent, msg, title, lst, -pos = wx.wxDefaultPosition, size = (200,200), style = wx.wxDEFAULT_DIALOG_STYLE) - - -

-
parent -
The parent window - -
msg -
The message that will be displayed above the list - -
title -
The text that will appear on the title bar - -
lst -
A Python list of choices that will appear in the dialog. - -
pos -
The position of the dialog - -
size -
The size of the dialog - -
style -
The style for the dialog. Only styles normally available to wxDialog are -available. - -
- -Methods - -
-
GetValue -
Returns a tuple containing the indices of the selected items - -
GetValueString -
Returns a tuple containing the text of the selected items - -
- -Additionally, MultipleChoiceDialog.lbox is a standard wx.ListBox which supports all -methods applicable to that class. - - - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxNotebook.py b/wxPython/demo/wxNotebook.py deleted file mode 100644 index 2b6b72315b..0000000000 --- a/wxPython/demo/wxNotebook.py +++ /dev/null @@ -1,139 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import sys - -import wx - -import ColorPanel -import GridSimple -import wxListCtrl -import wxScrolledWindow -import images - -#---------------------------------------------------------------------------- - -class TestNB(wx.Notebook): - def __init__(self, parent, id, log): - wx.Notebook.__init__(self, parent, id, style= - #wxNB_TOP - wx.NB_BOTTOM - #wxNB_LEFT - #wxNB_RIGHT - ) - self.log = log - - win = self.makeColorPanel(wx.BLUE) - self.AddPage(win, "Blue") - st = wx.StaticText(win.win, -1, - "You can put nearly any type of window here,\n" - "and if the platform supports it then the\n" - "tabs can be on any side of the notebook.", - (10, 10)) - - st.SetForegroundColour(wx.WHITE) - st.SetBackgroundColour(wx.BLUE) - - # Show how to put an image on one of the notebook tabs, - # first make the image list: - il = wx.ImageList(16, 16) - idx1 = il.Add(images.getSmilesBitmap()) - self.AssignImageList(il) - - # now put an image on the first tab we just created: - self.SetPageImage(0, idx1) - - - win = self.makeColorPanel(wx.RED) - self.AddPage(win, "Red") - - win = wxScrolledWindow.MyCanvas(self) - self.AddPage(win, 'ScrolledWindow') - - win = self.makeColorPanel(wx.GREEN) - self.AddPage(win, "Green") - - win = GridSimple.SimpleGrid(self, log) - self.AddPage(win, "Grid") - - win = wxListCtrl.TestListCtrlPanel(self, log) - self.AddPage(win, 'List') - - win = self.makeColorPanel(wx.CYAN) - self.AddPage(win, "Cyan") - -# win = self.makeColorPanel(wxWHITE) -# self.AddPage(win, "White") - -# win = self.makeColorPanel(wxBLACK) -# self.AddPage(win, "Black") - - win = self.makeColorPanel(wx.NamedColour('MIDNIGHT BLUE')) - self.AddPage(win, "MIDNIGHT BLUE") - - win = self.makeColorPanel(wx.NamedColour('INDIAN RED')) - self.AddPage(win, "INDIAN RED") - - self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged) - self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging) - - - def makeColorPanel(self, color): - p = wx.Panel(self, -1) - win = ColorPanel.ColoredPanel(p, color) - p.win = win - - def OnCPSize(evt, win=win): - win.SetSize(evt.GetSize()) - - p.Bind(wx.EVT_SIZE, OnCPSize) - return p - - def OnPageChanged(self, event): - old = event.GetOldSelection() - new = event.GetSelection() - sel = self.GetSelection() - self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) - event.Skip() - - def OnPageChanging(self, event): - old = event.GetOldSelection() - new = event.GetSelection() - sel = self.GetSelection() - self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) - event.Skip() - -#---------------------------------------------------------------------------- - -def runTest(frame, nb, log): - testWin = TestNB(nb, -1, log) - return testWin - -#---------------------------------------------------------------------------- - - -overview = """\ - -

wxNotebook

-

-This class represents a notebook control, which manages multiple -windows with associated tabs. -

-To use the class, create a wxNotebook object and call AddPage or -InsertPage, passing a window to be used as the page. Do not explicitly -delete the window for a page that is currently managed by wxNotebook. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - - - - - diff --git a/wxPython/demo/wxOGL.py b/wxPython/demo/wxOGL.py deleted file mode 100644 index eb7cea9c83..0000000000 --- a/wxPython/demo/wxOGL.py +++ /dev/null @@ -1,330 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o OGL's busted bigtime. Can't even use OGLInitialize() without a -# program error on w2k. -# - -import wx -import wx.ogl as ogl - -import images - -##wx.Trap() - -#---------------------------------------------------------------------- -# This creates some pens and brushes that the OGL library uses. - -ogl.OGLInitialize() - -#---------------------------------------------------------------------- - -class DiamondShape(ogl.PolygonShape): - def __init__(self, w=0.0, h=0.0): - ogl.PolygonShape.__init__(self) - if w == 0.0: - w = 60.0 - if h == 0.0: - h = 60.0 - - # Either ogl.RealPoints or 2-tuples of floats works. - - #points = [ ogl.RealPoint(0.0, -h/2.0), - # ogl.RealPoint(w/2.0, 0.0), - # ogl.RealPoint(0.0, h/2.0), - # ogl.RealPoint(-w/2.0, 0.0), - # ] - points = [ (0.0, -h/2.0), - (w/2.0, 0.0), - (0.0, h/2.0), - (-w/2.0, 0.0), - ] - - self.Create(points) - - -#---------------------------------------------------------------------- - -class RoundedRectangleShape(ogl.RectangleShape): - def __init__(self, w=0.0, h=0.0): - ogl.RectangleShape.__init__(self, w, h) - self.SetCornerRadius(-0.3) - - -#---------------------------------------------------------------------- - -class DividedShape(ogl.DividedShape): - def __init__(self, width, height, canvas): - ogl.DividedShape.__init__(self, width, height) - - region1 = ogl.ShapeRegion() - region1.SetText('DividedShape') - region1.SetProportions(0.0, 0.2) - region1.SetFormatMode(ogl.FORMAT_CENTRE_HORIZ) - self.AddRegion(region1) - - region2 = ogl.ShapeRegion() - region2.SetText('This is Region number two.') - region2.SetProportions(0.0, 0.3) - region2.SetFormatMode(ogl.FORMAT_CENTRE_HORIZ|ogl.FORMAT_CENTRE_VERT) - self.AddRegion(region2) - - region3 = ogl.ShapeRegion() - region3.SetText('Region 3\nwith embedded\nline breaks') - region3.SetProportions(0.0, 0.5) - region3.SetFormatMode(ogl.FORMAT_NONE) - self.AddRegion(region3) - - self.SetRegionSizes() - self.ReformatRegions(canvas) - - - def ReformatRegions(self, canvas=None): - rnum = 0 - - if canvas is None: - canvas = self.GetCanvas() - - dc = wx.ClientDC(canvas) # used for measuring - - for region in self.GetRegions(): - text = region.GetText() - self.FormatText(dc, text, rnum) - rnum += 1 - - - def OnSizingEndDragLeft(self, pt, x, y, keys, attch): - print "***", self - self.base_OnSizingEndDragLeft(pt, x, y, keys, attch) - self.SetRegionSizes() - self.ReformatRegions() - self.GetCanvas().Refresh() - - -#---------------------------------------------------------------------- - -class MyEvtHandler(ogl.ShapeEvtHandler): - def __init__(self, log, frame): - ogl.ShapeEvtHandler.__init__(self) - self.log = log - self.statbarFrame = frame - - def UpdateStatusBar(self, shape): - x,y = shape.GetX(), shape.GetY() - width, height = shape.GetBoundingBoxMax() - self.statbarFrame.SetStatusText("Pos: (%d,%d) Size: (%d, %d)" % - (x, y, width, height)) - - - def OnLeftClick(self, x, y, keys = 0, attachment = 0): - shape = self.GetShape() - print shape.__class__, shape.GetClassName() - canvas = shape.GetCanvas() - dc = wx.ClientDC(canvas) - canvas.PrepareDC(dc) - - if shape.Selected(): - shape.Select(False, dc) - canvas.Redraw(dc) - else: - redraw = False - shapeList = canvas.GetDiagram().GetShapeList() - toUnselect = [] - - for s in shapeList: - if s.Selected(): - # If we unselect it now then some of the objects in - # shapeList will become invalid (the control points are - # shapes too!) and bad things will happen... - toUnselect.append(s) - - shape.Select(True, dc) - - if toUnselect: - for s in toUnselect: - s.Select(False, dc) - - canvas.Redraw(dc) - - self.UpdateStatusBar(shape) - - - def OnEndDragLeft(self, x, y, keys = 0, attachment = 0): - shape = self.GetShape() - self.base_OnEndDragLeft(x, y, keys, attachment) - - if not shape.Selected(): - self.OnLeftClick(x, y, keys, attachment) - - self.UpdateStatusBar(shape) - - - def OnSizingEndDragLeft(self, pt, x, y, keys, attch): - self.base_OnSizingEndDragLeft(pt, x, y, keys, attch) - self.UpdateStatusBar(self.GetShape()) - - - def OnMovePost(self, dc, x, y, oldX, oldY, display): - self.base_OnMovePost(dc, x, y, oldX, oldY, display) - self.UpdateStatusBar(self.GetShape()) - - - def OnRightClick(self, *dontcare): - self.log.WriteText("%s\n" % self.GetShape()) - - -#---------------------------------------------------------------------- - -class TestWindow(ogl.ShapeCanvas): - def __init__(self, parent, log, frame): - ogl.ShapeCanvas.__init__(self, parent) - - maxWidth = 1000 - maxHeight = 1000 - self.SetScrollbars(20, 20, maxWidth/20, maxHeight/20) - - self.log = log - self.frame = frame - self.SetBackgroundColour("LIGHT BLUE") #wx.WHITE) - self.diagram = ogl.Diagram() - self.SetDiagram(self.diagram) - self.diagram.SetCanvas(self) - self.shapes = [] - self.save_gdi = [] - - rRectBrush = wx.Brush("MEDIUM TURQUOISE", wx.SOLID) - dsBrush = wx.Brush("WHEAT", wx.SOLID) - - self.MyAddShape( - ogl.CircleShape(80), - 100, 100, wx.Pen(wx.BLUE, 3), wx.GREEN_BRUSH, "Circle" - ) - - self.MyAddShape( - ogl.RectangleShape(85, 50), - 305, 60, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "Rectangle" - ) - - ds = self.MyAddShape( - DividedShape(140, 150, self), - 495, 145, wx.BLACK_PEN, dsBrush, '' - ) - - self.MyAddShape( - DiamondShape(90, 90), - 345, 235, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon" - ) - - self.MyAddShape( - RoundedRectangleShape(95,70), - 140, 255, wx.Pen(wx.RED, 2), rRectBrush, "Rounded Rect" - ) - - bmp = images.getTest2Bitmap() - mask = wx.MaskColour(bmp, wx.BLUE) - bmp.SetMask(mask) - - s = ogl.BitmapShape() - s.SetBitmap(bmp) - self.MyAddShape(s, 225, 150, None, None, "Bitmap") - - dc = wx.ClientDC(self) - self.PrepareDC(dc) - - for x in range(len(self.shapes)): - fromShape = self.shapes[x] - if x+1 == len(self.shapes): - toShape = self.shapes[0] - else: - toShape = self.shapes[x+1] - - line = ogl.LineShape() - line.SetCanvas(self) - line.SetPen(wx.BLACK_PEN) - line.SetBrush(wx.BLACK_BRUSH) - line.AddArrow(ogl.ARROW_ARROW) - line.MakeLineControlPoints(2) - fromShape.AddLine(line, toShape) - self.diagram.AddShape(line) - line.Show(True) - - # for some reason, the shapes have to be moved for the line to show up... - fromShape.Move(dc, fromShape.GetX(), fromShape.GetY()) - - wx.EVT_WINDOW_DESTROY(self, self.OnDestroy) - - - def MyAddShape(self, shape, x, y, pen, brush, text): - shape.SetDraggable(True, True) - shape.SetCanvas(self) - shape.SetX(x) - shape.SetY(y) - if pen: shape.SetPen(pen) - if brush: shape.SetBrush(brush) - if text: shape.AddText(text) - #shape.SetShadowMode(ogl.SHADOW_RIGHT) - self.diagram.AddShape(shape) - shape.Show(True) - - evthandler = MyEvtHandler(self.log, self.frame) - evthandler.SetShape(shape) - evthandler.SetPreviousHandler(shape.GetEventHandler()) - shape.SetEventHandler(evthandler) - - self.shapes.append(shape) - return shape - - - def OnDestroy(self, evt): - # Do some cleanup - for shape in self.diagram.GetShapeList(): - if shape.GetParent() == None: - shape.SetCanvas(None) - shape.Destroy() - - self.diagram.Destroy() - - - def OnBeginDragLeft(self, x, y, keys): - self.log.write("OnBeginDragLeft: %s, %s, %s\n" % (x, y, keys)) - - def OnEndDragLeft(self, x, y, keys): - self.log.write("OnEndDragLeft: %s, %s, %s\n" % (x, y, keys)) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - # This creates some pens and brushes that the OGL library uses. - # It should be called after the app object has been created, but - # before OGL is used. - ogl.OGLInitialize() - - win = TestWindow(nb, log, frame) - return win - -#---------------------------------------------------------------------- - -class __Cleanup: - cleanup = ogl.OGLCleanUp - def __del__(self): - self.cleanup() - -# when this module gets cleaned up then wxOGLCleanUp() will get called -__cu = __Cleanup() - - -overview = """\ -The Object Graphics Library is a library supporting the creation and -manipulation of simple and complex graphic images on a canvas. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxPageSetupDialog.py b/wxPython/demo/wxPageSetupDialog.py deleted file mode 100644 index a4e7e4e215..0000000000 --- a/wxPython/demo/wxPageSetupDialog.py +++ /dev/null @@ -1,55 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - data = wx.PageSetupDialogData() - data.SetMarginTopLeft( (15, 15) ) - data.SetMarginBottomRight( (15, 15) ) - #data.SetDefaultMinMargins(True) - data.SetPaperId(wx.PAPER_LETTER) - - dlg = wx.PageSetupDialog(frame, data) - - if dlg.ShowModal() == wx.ID_OK: - data = dlg.GetPageSetupData() - tl = data.GetMarginTopLeft() - br = data.GetMarginBottomRight() - log.WriteText('Margins are: %s %s\n' % (str(tl), str(br))) - - dlg.Destroy() - -#--------------------------------------------------------------------------- - - -overview = """\ -This class represents the page setup common dialog. The page setup dialog is standard -from Windows 95 on, replacing the print setup dialog (which is retained in Windows -and wxWindows for backward compatibility). On Windows 95 and NT 4.0 and above, -the page setup dialog is native to the windowing system, otherwise it is emulated. - -The page setup dialog contains controls for paper size (A4, A5 etc.), orientation -(landscape or portrait), and controls for setting left, top, right and bottom margin -sizes in millimetres. - -When the dialog has been closed, you need to query the wxPageSetupDialogData object -associated with the dialog. - -Note that the OK and Cancel buttons do not destroy the dialog; this must be done by -the application. As with other dialogs, do not destroy the dialog until you are done -with the data, and, conversely, do not use the wxPageSetupDialogData after the -dialog is destroyed. - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxPlotCanvas.py b/wxPython/demo/wxPlotCanvas.py deleted file mode 100644 index 4311942af3..0000000000 --- a/wxPython/demo/wxPlotCanvas.py +++ /dev/null @@ -1,56 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxPlotCanvas must be updated with new draw mechanics (tuples) before -# it can be used with 2.5. -# - -import wx -import wx.lib.wxPlotCanvas as plot - -import Numeric - -#--------------------------------------------------------------------------- - -def _InitObjects(): - # 100 points sin function, plotted as green circles - data1 = 2.*Numeric.pi*Numeric.arange(200)/200. - data1.shape = (100, 2) - data1[:,1] = Numeric.sin(data1[:,0]) - markers1 = plot.PolyMarker(data1, color='green', marker='circle',size=1) - - # 50 points cos function, plotted as red line - data1 = 2.*Numeric.pi*Numeric.arange(100)/100. - data1.shape = (50,2) - data1[:,1] = Numeric.cos(data1[:,0]) - lines = plot.PolyLine(data1, color='red') - - # A few more points... - pi = Numeric.pi - markers2 = plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), - (3.*pi/4., -1)], color='blue', - fillcolor='green', marker='cross') - - return plot.PlotGraphics([markers1, lines, markers2]) - - -#--------------------------------------------------------------------------- - - -def runTest(frame, nb, log): - win = plot.PlotCanvas(nb) - win.draw(_InitObjects(),'automatic','automatic'); - return win - -overview = plot.__doc__ - -#--------------------------------------------------------------------------- - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxPopupControl.py b/wxPython/demo/wxPopupControl.py deleted file mode 100644 index d312a9319c..0000000000 --- a/wxPython/demo/wxPopupControl.py +++ /dev/null @@ -1,107 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Is it just me or are the graphics for the control not lining up right? -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxPopupControl -> PopupControl -# - -import wx -import wx.lib.popupctl as pop -import wx.calendar as cal - -class TestDateControl(pop.PopupControl): - def __init__(self,*_args,**_kwargs): - apply(pop.PopupControl.__init__,(self,) + _args,_kwargs) - - self.win = wx.Window(self,-1,pos = (0,0),style = 0) - self.cal = cal.CalendarCtrl(self.win,-1,pos = (0,0)) - - bz = self.cal.GetBestSize() - self.win.SetSize(bz) - - # This method is needed to set the contents that will be displayed - # in the popup - self.SetPopupContent(self.win) - - # Event registration for date selection - self.cal.Bind(cal.EVT_CALENDAR_DAY, self.OnCalSelected) - - # Method called when a day is selected in the calendar - def OnCalSelected(self,evt): - self.PopDown() - date = self.cal.GetDate() - - # Format the date that was selected for the text part of the control - self.SetValue('%02d/%02d/%04d' % (date.GetDay(), - date.GetMonth()+1, - date.GetYear())) - evt.Skip() - - # Method overridden from PopupControl - # This method is called just before the popup is displayed - # Use this method to format any controls in the popup - def FormatContent(self): - # I parse the value in the text part to resemble the correct date in - # the calendar control - txtValue = self.GetValue() - dmy = txtValue.split('/') - didSet = False - - if len(dmy) == 3: - date = self.cal.GetDate() - d = int(dmy[0]) - m = int(dmy[1]) - 1 - y = int(dmy[2]) - - if d > 0 and d < 31: - if m >= 0 and m < 12: - if y > 1000: - self.cal.SetDate(wx.DateTimeFromDMY(d,m,y)) - didSet = True - - if not didSet: - self.cal.SetDate(wx.DateTime_Today()) - - -#--------------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - date = TestDateControl(self, -1, pos = (30,30), size = (100,22)) - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - -overview = """ -

PopupControl

- -PopupControl is a class that can display a value and has a button -that will popup another window similar to how a wxComboBox works. The -popup window can contain whatever is needed to edit the value. This -example uses a wxCalendarCtrl. - -

Currently a wxDialog is used for the popup. Eventually a -wxPopupWindow should be used... - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxPopupWindow.py b/wxPython/demo/wxPopupWindow.py deleted file mode 100644 index cc4d71b83f..0000000000 --- a/wxPython/demo/wxPopupWindow.py +++ /dev/null @@ -1,218 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Some issues with the listbox example; I tried correcting -# it but it's still not working the way it should. Commented -# out for now but will be revisited. -# o The math in determining the popup window's position is -# a bit off. -# - -import wx - -havePopupWindow = 1 -try: - wx.PopupWindow -except NameError: - havePopupWindow = 0 - wx.PopupWindow = wx.PopupTransientWindow = wx.Window - -#--------------------------------------------------------------------------- - -class TestPopup(wx.PopupWindow): - """Adds a bit of text and mouse movement to the wxPopupWindow""" - def __init__(self, parent, style): - wx.PopupWindow.__init__(self, parent, style) - self.SetBackgroundColour("CADET BLUE") - - st = wx.StaticText(self, -1, - "This is a special kind of top level\n" - "window that can be used for\n" - "popup menus, combobox popups\n" - "and such.\n\n" - "Try positioning the demo near\n" - "the bottom of the screen and \n" - "hit the button again.\n\n" - "In this demo this window can\n" - "be dragged with the left button\n" - "and closed with the right." - , - pos=(10,10)) - - sz = st.GetBestSize() - self.SetSize( (sz.width+20, sz.height+20) ) - - self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) - self.Bind(wx.EVT_MOTION, self.OnMouseMotion) - self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) - self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) - - st.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) - st.Bind(wx.EVT_MOTION, self.OnMouseMotion) - st.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) - st.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) - - def OnMouseLeftDown(self, evt): - self.ldPos = evt.GetEventObject().ClientToScreen(evt.GetPosition()) - self.wPos = self.ClientToScreen((0,0)) - self.CaptureMouse() - - def OnMouseMotion(self, evt): - if evt.Dragging() and evt.LeftIsDown(): - dPos = evt.GetEventObject().ClientToScreen(evt.GetPosition()) - nPos = (self.wPos.x + (dPos.x - self.ldPos.x), - self.wPos.y + (dPos.y - self.ldPos.y)) - self.Move(nPos) - - def OnMouseLeftUp(self, evt): - self.ReleaseMouse() - - def OnRightUp(self, evt): - self.Show(False) - self.Destroy() - - -class TestTransientPopup(wx.PopupTransientWindow): - """Adds a bit of text and mouse movement to the wxPopupWindow""" - def __init__(self, parent, style, log): - wx.PopupTransientWindow.__init__(self, parent, style) - self.log = log - panel = wx.Panel(self, -1) - panel.SetBackgroundColour("#FFB6C1") - st = wx.StaticText(panel, -1, - "wxPopupTransientWindow is a\n" - "wxPopupWindow which disappears\n" - "automatically when the user\n" - "clicks the mouse outside it or if it\n" - "(or its first child) loses focus in \n" - "any other way." - , - pos=(10,10)) - sz = st.GetBestSize() - panel.SetSize( (sz.width+20, sz.height+20) ) - self.SetSize(panel.GetSize()) - - def ProcessLeftDown(self, evt): - self.log.write("ProcessLeftDown\n") - return False - - def OnDismiss(self): - self.log.write("OnDismiss\n") - - - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - b = wx.Button(self, -1, "Show wxPopupWindow", (25, 50)) - self.Bind(wx.EVT_BUTTON, self.OnShowPopup, b) - - b = wx.Button(self, -1, "Show wxPopupTransientWindow", (25, 95)) - self.Bind(wx.EVT_BUTTON, self.OnShowPopupTransient, b) - - # This isn't working so well, not sure why. Commented out for - # now. - -# b = wx.Button(self, -1, "Show wxPopupWindow with listbox", (25, 140)) -# self.Bind(wx.EVT_BUTTON, self.OnShowPopupListbox, b) - - - def OnShowPopup(self, evt): - win = TestPopup(self, wx.SIMPLE_BORDER) - - # Show the popup right below or above the button - # depending on available screen space... - btn = evt.GetEventObject() - pos = btn.ClientToScreen( (0,0) ) - sz = btn.GetSize() - win.Position(pos, (0, sz[1])) - - win.Show(True) - - - def OnShowPopupTransient(self, evt): - win = TestTransientPopup(self, wx.SIMPLE_BORDER, self.log) - - # Show the popup right below or above the button - # depending on available screen space... - btn = evt.GetEventObject() - pos = btn.ClientToScreen( (0,0) ) - sz = btn.GetSize() - win.Position(pos, (0, sz[1])) - - win.Popup() - - - def OnShowPopupListbox(self, evt): - win = TestPopupWithListbox(self, wx.NO_BORDER, self.log) - - # Show the popup right below or above the button - # depending on available screen space... - btn = evt.GetEventObject() - pos = btn.ClientToScreen( (0,0) ) - sz = btn.GetSize() - win.Position(pos, (0, sz[1])) - - win.Show(True) - -class TestPopupWithListbox(wx.PopupWindow): - def __init__(self, parent, style, log): - wx.PopupWindow.__init__(self, parent, style) - - import keyword - - self.lb = wx.ListBox(self, -1, choices = keyword.kwlist) - #sz = self.lb.GetBestSize() - self.SetSize((150, 75)) #sz) - self.lb.SetSize(self.GetClientSize()) - self.lb.SetFocus() - self.Bind(wx.EVT_LISTBOX, self.OnListBox) - self.lb.Bind(wx.EVT_LEFT_DOWN, self.OnLeft) - - def OnLeft(self, evt): - obj = evt.GetEventObject() - print "OnLeft", obj - print 'Selected: %s' % obj.GetStringSelection() - obj.Show(False) - evt.Skip() - - def OnListBox(self, evt): - obj = evt.GetEventObject() - print "OnListBox", obj - print 'Selected: %s' % obj.GetString() - evt.Skip() - - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - if havePopupWindow: - win = TestPanel(nb, log) - return win - else: - dlg = wx.MessageDialog( - frame, 'wxPopupWindow is not available on this platform.', - 'Sorry', wx.OK | wx.ICON_INFORMATION - ) - - dlg.ShowModal() - dlg.Destroy() - -#--------------------------------------------------------------------------- - - -overview = """\ -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxPrintDialog.py b/wxPython/demo/wxPrintDialog.py deleted file mode 100644 index 981f0ea965..0000000000 --- a/wxPython/demo/wxPrintDialog.py +++ /dev/null @@ -1,45 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - data = wx.PrintDialogData() - - data.EnableSelection(True) - data.EnablePrintToFile(True) - data.EnablePageNumbers(True) - data.SetMinPage(1) - data.SetMaxPage(5) - data.SetAllPages(True) - - dlg = wx.PrintDialog(frame, data) - - if dlg.ShowModal() == wx.ID_OK: - data = dlg.GetPrintDialogData() - log.WriteText('GetAllPages: %d\n' % data.GetAllPages()) - - dlg.Destroy() - -#--------------------------------------------------------------------------- - - -overview = """\ -This class represents the print and print setup common dialogs. You may obtain -a wxPrinterDC device context from a successfully dismissed print dialog. - -User information is stored in a wxPrintDialogData object that is passed to the -dialog at creation time, and it is filled in by the user. As with other dialogs, -do not use this data once the dialog is dismissed, and do not destroy the dialog -until you have everything you need from it. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxProcess.py b/wxPython/demo/wxProcess.py deleted file mode 100644 index 42c46c2cd6..0000000000 --- a/wxPython/demo/wxProcess.py +++ /dev/null @@ -1,165 +0,0 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, ID, log): - wx.Panel.__init__(self, parent, ID) - self.log = log - - self.process = None - self.Bind(wx.EVT_IDLE, self.OnIdle) - - # We can either derive from wxProcess and override OnTerminate - # or we can let wxProcess send this window an event that is - # caught in the normal way... - self.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded) - - - # Make the controls - prompt = wx.StaticText(self, -1, 'Command line:') - self.cmd = wx.TextCtrl(self, -1, 'python -u data/echo.py') - self.exBtn = wx.Button(self, -1, 'Execute') - - self.out = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE|wx.TE_READONLY) - - self.inp = wx.TextCtrl(self, -1, '', style=wx.TE_PROCESS_ENTER) - self.sndBtn = wx.Button(self, -1, 'Send') - self.termBtn = wx.Button(self, -1, 'Close Stream') - self.inp.Enable(False) - self.sndBtn.Enable(False) - self.termBtn.Enable(False) - - # Hook up the events - self.Bind(wx.EVT_BUTTON, self.OnExecuteBtn, self.exBtn) - self.Bind(wx.EVT_BUTTON, self.OnSendText, self.sndBtn) - self.Bind(wx.EVT_BUTTON, self.OnCloseStream, self.termBtn) - self.Bind(wx.EVT_TEXT_ENTER, self.OnSendText, self.inp) - - - # Do the layout - box1 = wx.BoxSizer(wx.HORIZONTAL) - box1.Add(prompt, 0, wx.ALIGN_CENTER) - box1.Add(self.cmd, 1, wx.ALIGN_CENTER|wx.LEFT|wx.RIGHT, 5) - box1.Add(self.exBtn, 0) - - box2 = wx.BoxSizer(wx.HORIZONTAL) - box2.Add(self.inp, 1, wx.ALIGN_CENTER) - box2.Add(self.sndBtn, 0, wx.LEFT, 5) - box2.Add(self.termBtn, 0, wx.LEFT, 5) - - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(box1, 0, wx.EXPAND|wx.ALL, 10) - sizer.Add(self.out, 1, wx.EXPAND|wx.ALL, 10) - sizer.Add(box2, 0, wx.EXPAND|wx.ALL, 10) - - self.SetSizer(sizer) - self.SetAutoLayout(True) - - - def __del__(self): - if self.process is not None: - self.process.Detach() - self.process.CloseOutput() - self.process = None - - - def OnExecuteBtn(self, evt): - cmd = self.cmd.GetValue() - - self.process = wx.Process(self) - self.process.Redirect(); - pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) - self.log.write('OnExecuteBtn: "%s" pid: %s\n' % (cmd, pid)) - - self.inp.Enable(True) - self.sndBtn.Enable(True) - self.termBtn.Enable(True) - self.cmd.Enable(False) - self.exBtn.Enable(False) - self.inp.SetFocus() - - - def OnSendText(self, evt): - text = self.inp.GetValue() - self.inp.SetValue('') - self.log.write('OnSendText: "%s"\n' % text) - self.process.GetOutputStream().write(text + '\n') - self.inp.SetFocus() - - - def OnCloseStream(self, evt): - self.log.write('OnCloseStream\n') - #print "b4 CloseOutput" - self.process.CloseOutput() - #print "after CloseOutput" - - def OnIdle(self, evt): - if self.process is not None: - stream = self.process.GetInputStream() - - if stream.CanRead(): - text = stream.read() - self.out.AppendText(text) - - - def OnProcessEnded(self, evt): - self.log.write('OnProcessEnded, pid:%s, exitCode: %s\n' % - (evt.GetPid(), evt.GetExitCode())) - - stream = self.process.GetInputStream() - - if stream.CanRead(): - text = stream.read() - self.out.AppendText(text) - - self.process.Destroy() - self.process = None - self.inp.Enable(False) - self.sndBtn.Enable(False) - self.termBtn.Enable(False) - self.cmd.Enable(True) - self.exBtn.Enable(True) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, -1, log) - return win - - -#---------------------------------------------------------------------- - - -overview = """\ - -

wxProcess

- -wxProcess lets you get notified when an asyncronous child process -started by wxExecute terminates, and also to get input/output streams -for the child process's stdout, stderr and stdin. - -

-This demo launches a simple python script that echos back on stdout -lines that it reads from stdin. You can send text to the echo -process' stdin by typing in the lower textctrl and clicking Send. - -

-Clicking the Close Stream button will close the demo's end of the -stdin pipe to the child process. In our case that will cause the -child process to exit its main loop. - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxProgressDialog.py b/wxPython/demo/wxProgressDialog.py deleted file mode 100644 index 9144175976..0000000000 --- a/wxPython/demo/wxProgressDialog.py +++ /dev/null @@ -1,61 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx.ProgressDialog appears to be broken. No abort button -# and it's not possible to dismiss it otherwise. -# - -import wx - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - max = 20 - - dlg = wx.ProgressDialog("Progress dialog example", - "An informative message", - maximum = max, - parent=frame, - style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL) - - keepGoing = True - count = 0 - - while keepGoing and count < max: - count = count + 1 - #print count - wx.Sleep(1) - - if count == max / 2: - keepGoing = dlg.Update(count, "Half-time!") - else: - keepGoing = dlg.Update(count) - - dlg.Destroy() - - -#--------------------------------------------------------------------------- - - -overview = """\ -This class represents a dialog that shows a short message and a progress bar. -Optionally, it can display an ABORT button - -This dialog indicates the progress of some event that takes a while to accomplish, -usually, such as file copy progress, download progress, and so on. The display -is completely under control of the program; you must update the dialog from -within the program creating it. - -When the dialog closes, you must check to see if the user aborted the process or -not, and act accordingly -- that is, if the PD_CAN_ABORT style flag is set. -If not then you may progress blissfully onward. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxPyColourChooser.py b/wxPython/demo/wxPyColourChooser.py deleted file mode 100644 index b31fe51326..0000000000 --- a/wxPython/demo/wxPyColourChooser.py +++ /dev/null @@ -1,72 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated URL for SF link in overview. -# -# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxPyColorChooser -> PyColorChooser -# o wxPyColourChooser -> PyColourChooser -# - -import wx -import wx.lib.colourchooser as cc - -#--------------------------------------------------------------- - -class TestColourChooser(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - chooser = cc.PyColourChooser(self, -1) - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(chooser, 0, wx.ALL, 25) - - self.SetAutoLayout(True) - self.SetSizer(sizer) - -#--------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestColourChooser(nb, log) - return win - -#--------------------------------------------------------------- - -overview = """ -The PyColourChooser component creates a colour chooser window -that is similar to the Microsoft Windows colour chooser dialog. -This dialog component is drawn in a panel, and thus can be -embedded inside any widget (although it cannot be resized). -This colour chooser may also be substituted for the colour -chooser on any platform that might have an ugly one :) - -How to use it ------------------------------- - -The demo (demo/PyColourChooser.py code shows how to display -a colour chooser and retrieve its options. - -Contact and Author Info ------------------------------- - -PyColourChooser was written and is maintained by: - - Michael Gilfix - -You can find the latest PyColourChooser code at -http://sourceforge.net/projects/wxcolourchooser/. If you have -any suggestions or want to submit a patch, please send -it my way at: mgilfix@eecs.tufts.edu -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxRadioBox.py b/wxPython/demo/wxRadioBox.py deleted file mode 100644 index cd583a3378..0000000000 --- a/wxPython/demo/wxRadioBox.py +++ /dev/null @@ -1,73 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class TestRadioBox(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - #self.SetBackgroundColour(wx.BLUE) - - sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', - 'six', 'seven', 'eight'] - - sizer = wx.BoxSizer(wx.VERTICAL) - - rb = wx.RadioBox( - self, -1, "wx.RadioBox", wx.DefaultPosition, wx.DefaultSize, - sampleList, 2, wx.RA_SPECIFY_COLS - ) - - self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, rb) - #rb.SetBackgroundColour(wx.BLUE) - rb.SetToolTip(wx.ToolTip("This is a ToolTip!")) - #rb.SetLabel("wxRadioBox") - - sizer.Add(rb, 0, wx.ALL, 20) - - rb = wx.RadioBox( - self, -1, "", wx.DefaultPosition, wx.DefaultSize, - sampleList, 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER - ) - - self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, rb) - rb.SetToolTip(wx.ToolTip("This box has no label")) - - sizer.Add(rb, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 20) - - self.SetSizer(sizer) - - - def EvtRadioBox(self, event): - self.log.WriteText('EvtRadioBox: %d\n' % event.GetInt()) - -# Doesn't appear to be used for anything. -# def EvtRadioButton(self, event): -# self.log.write('EvtRadioButton:%d\n' % event.GetId()) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestRadioBox(nb, log) - return win - - - -overview = """\ -A radio box item is used to select one of number of mutually exclusive -choices. It is displayed as a vertical column or horizontal row of -labelled buttons. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxRadioButton.py b/wxPython/demo/wxRadioButton.py deleted file mode 100644 index ad4ee8ce7c..0000000000 --- a/wxPython/demo/wxRadioButton.py +++ /dev/null @@ -1,130 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel( wx.Panel ): - def __init__( self, parent, log ): - - wx.Panel.__init__( self, parent, -1 ) - self.log = log - panel = wx.Panel( self, -1 ) - - # 1st group of controls: - self.group1_ctrls = [] - radio1 = wx.RadioButton( panel, -1, " Radio1 ", style = wx.RB_GROUP ) - text1 = wx.TextCtrl( panel, -1, "" ) - radio2 = wx.RadioButton( panel, -1, " Radio2 " ) - text2 = wx.TextCtrl( panel, -1, "" ) - radio3 = wx.RadioButton( panel, -1, " Radio3 " ) - text3 = wx.TextCtrl( panel, -1, "" ) - self.group1_ctrls.append((radio1, text1)) - self.group1_ctrls.append((radio2, text2)) - self.group1_ctrls.append((radio3, text3)) - - # 2nd group of controls: - self.group2_ctrls = [] - radio4 = wx.RadioButton( panel, -1, " Radio1 ", style = wx.RB_GROUP ) - text4 = wx.TextCtrl( panel, -1, "" ) - radio5 = wx.RadioButton( panel, -1, " Radio2 " ) - text5 = wx.TextCtrl( panel, -1, "" ) - radio6 = wx.RadioButton( panel, -1, " Radio3 " ) - text6 = wx.TextCtrl( panel, -1, "" ) - self.group2_ctrls.append((radio4, text4)) - self.group2_ctrls.append((radio5, text5)) - self.group2_ctrls.append((radio6, text6)) - - # Layout controls on panel: - vs = wx.BoxSizer( wx.VERTICAL ) - - box1_title = wx.StaticBox( panel, -1, "Group 1" ) - box1 = wx.StaticBoxSizer( box1_title, wx.VERTICAL ) - grid1 = wx.FlexGridSizer( 0, 2, 0, 0 ) - - for radio, text in self.group1_ctrls: - grid1.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) - grid1.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) - - box1.AddSizer( grid1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) - vs.AddSizer( box1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) - - box2_title = wx.StaticBox( panel, -1, "Group 2" ) - box2 = wx.StaticBoxSizer( box2_title, wx.VERTICAL ) - grid2 = wx.FlexGridSizer( 0, 2, 0, 0 ) - - for radio, text in self.group2_ctrls: - grid2.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) - grid2.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) - - box2.AddSizer( grid2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) - vs.AddSizer( box2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) - - panel.SetSizer( vs ) - vs.Fit( panel ) - panel.Move( (50,50) ) - self.panel = panel - - # Setup event handling and initial state for controls: - for radio, text in self.group1_ctrls: - self.Bind(wx.EVT_RADIOBUTTON, self.OnGroup1Select, radio ) - - for radio, text in self.group2_ctrls: - self.Bind(wx.EVT_RADIOBUTTON, self.OnGroup2Select, radio ) - - for radio, text in self.group1_ctrls + self.group2_ctrls: - radio.SetValue(0) - text.Enable(False) - - def OnGroup1Select( self, event ): - radio_selected = event.GetEventObject() - self.log.write('Group1 %s selected\n' % radio_selected.GetLabel() ) - - for radio, text in self.group1_ctrls: - if radio is radio_selected: - text.Enable(True) - else: - text.Enable(False) - - def OnGroup2Select( self, event ): - radio_selected = event.GetEventObject() - self.log.write('Group2 %s selected\n' % radio_selected.GetLabel() ) - - for radio, text in self.group2_ctrls: - if radio is radio_selected: - text.Enable(True) - else: - text.Enable(False) - -#---------------------------------------------------------------------- - -def runTest( frame, nb, log ): - win = TestPanel( nb, log ) - return win - -#---------------------------------------------------------------------- - - -overview = """\ - -

-This demo shows how individual radio buttons can be used to build -more complicated selection mechanisms... -

-It uses 2 groups of wxRadioButtons, where the groups are defined by -instantiation. When a wxRadioButton is created with the wxRB_GROUP -style, all subsequent wxRadioButtons created without it are implicitly -added to that group by the framework. - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxRightTextCtrl.py b/wxPython/demo/wxRightTextCtrl.py deleted file mode 100644 index 9d28c46c79..0000000000 --- a/wxPython/demo/wxRightTextCtrl.py +++ /dev/null @@ -1,79 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o The rightalign library needs converted for this to work correctly. -# -# 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o All issues resolved. -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxRightTextCtrl -> RightTextCtrl -# - -############################################################################\ -# Note: this demo has been converted, but the control is deprecated because | -# wx.TextCtrl now supports the wx.TE_RIGHT style flag, which makes this | -# control completely superfluous. | -############################################################################/ - -import wx -import wx.lib.rightalign as right - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent, -1) - - fgs = wx.FlexGridSizer(cols=2, vgap=5, hgap=5) - - txt = wx.StaticText( - self, -1, - "These text controls will align their contents to\n" - "the right (on wxMSW) when they don't have focus.", - style=wx.ALIGN_RIGHT - ) - - fgs.Add(txt) - fgs.Add(right.RightTextCtrl(self, -1, "", size=(75, -1))) - - fgs.Add((10,10)) - fgs.Add(right.RightTextCtrl(self, -1, "123.45", size=(75, -1))) - - fgs.Add((10,10)) - fgs.Add(right.RightTextCtrl(self, -1, "234.56", size=(75, -1))) - - fgs.Add((10,10)) - fgs.Add(right.RightTextCtrl(self, -1, "345.67", size=(75, -1))) - - fgs.Add((10,10)) - fgs.Add(right.RightTextCtrl(self, -1, "456.78", size=(75, -1))) - - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(fgs, 0, wx.ALL, 25) - - self.SetSizer(sizer) - self.SetAutoLayout(True) - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb) - return win - -#---------------------------------------------------------------------- - -overview = right.__doc__ - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxSashWindow.py b/wxPython/demo/wxSashWindow.py deleted file mode 100644 index b70a3ee7a1..0000000000 --- a/wxPython/demo/wxSashWindow.py +++ /dev/null @@ -1,151 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Should be renamed to wxSashLayoutWindow.py -# - -import wx - -#--------------------------------------------------------------------------- - -class TestSashWindow(wx.Panel): - ID_WINDOW_TOP = 5100 - ID_WINDOW_LEFT1 = 5101 - ID_WINDOW_LEFT2 = 5102 - ID_WINDOW_BOTTOM = 5103 - - - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - - self.log = log - - # will occupy the space not used by the Layout Algorithm - self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER) - - self.Bind( - wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag, - id=self.ID_WINDOW_TOP, id2=self.ID_WINDOW_BOTTOM, - ) - - self.Bind(wx.EVT_SIZE, self.OnSize) - - - # Create some layout windows - # A window like a toolbar - win = wx.SashLayoutWindow( - self, self.ID_WINDOW_TOP, wx.DefaultPosition, (200, 30), - wx.NO_BORDER|wx.SW_3D - ) - - win.SetDefaultSize((1000, 30)) - win.SetOrientation(wx.LAYOUT_HORIZONTAL) - win.SetAlignment(wx.LAYOUT_TOP) - win.SetBackgroundColour(wx.Colour(255, 0, 0)) - win.SetSashVisible(wx.SASH_BOTTOM, True) - - self.topWindow = win - - - # A window like a statusbar - win = wx.SashLayoutWindow( - self, self.ID_WINDOW_BOTTOM, wx.DefaultPosition, (200, 30), - wx.NO_BORDER|wx.SW_3D - ) - - win.SetDefaultSize((1000, 30)) - win.SetOrientation(wx.LAYOUT_HORIZONTAL) - win.SetAlignment(wx.LAYOUT_BOTTOM) - win.SetBackgroundColour(wx.Colour(0, 0, 255)) - win.SetSashVisible(wx.SASH_TOP, True) - - self.bottomWindow = win - - # A window to the left of the client window - win = wx.SashLayoutWindow( - self, self.ID_WINDOW_LEFT1, wx.DefaultPosition, (200, 30), - wx.NO_BORDER|wx.SW_3D - ) - - win.SetDefaultSize((120, 1000)) - win.SetOrientation(wx.LAYOUT_VERTICAL) - win.SetAlignment(wx.LAYOUT_LEFT) - win.SetBackgroundColour(wx.Colour(0, 255, 0)) - win.SetSashVisible(wx.SASH_RIGHT, True) - win.SetExtraBorderSize(10) - textWindow = wx.TextCtrl( - win, -1, "", wx.DefaultPosition, wx.DefaultSize, - wx.TE_MULTILINE|wx.SUNKEN_BORDER - ) - - textWindow.SetValue("A sub window") - - self.leftWindow1 = win - - - # Another window to the left of the client window - win = wx.SashLayoutWindow( - self, self.ID_WINDOW_LEFT2, wx.DefaultPosition, (200, 30), - wx.NO_BORDER|wx.SW_3D - ) - - win.SetDefaultSize((120, 1000)) - win.SetOrientation(wx.LAYOUT_VERTICAL) - win.SetAlignment(wx.LAYOUT_LEFT) - win.SetBackgroundColour(wx.Colour(0, 255, 255)) - win.SetSashVisible(wx.SASH_RIGHT, True) - - self.leftWindow2 = win - - - def OnSashDrag(self, event): - if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: - return - - eID = event.GetId() - - if eID == self.ID_WINDOW_TOP: - self.topWindow.SetDefaultSize((1000, event.GetDragRect().height)) - - elif eID == self.ID_WINDOW_LEFT1: - self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000)) - - - elif eID == self.ID_WINDOW_LEFT2: - self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000)) - - elif eID == self.ID_WINDOW_BOTTOM: - self.bottomWindow.SetDefaultSize((1000, event.GetDragRect().height)) - - wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) - self.remainingSpace.Refresh() - - def OnSize(self, event): - wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestSashWindow(nb, log) - return win - -#--------------------------------------------------------------------------- - - -overview = """\ -wxSashLayoutWindow responds to OnCalculateLayout events generated by -wxLayoutAlgorithm. It allows the application to use simple accessors to -specify how the window should be laid out, rather than having to respond -to events. The fact that the class derives from wxSashWindow allows sashes -to be used if required, to allow the windows to be user-resizable. - -The documentation for wxLayoutAlgorithm explains the purpose of this class -in more detail. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxScrolledMessageDialog.py b/wxPython/demo/wxScrolledMessageDialog.py deleted file mode 100644 index 03158917af..0000000000 --- a/wxPython/demo/wxScrolledMessageDialog.py +++ /dev/null @@ -1,51 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o dialogs library needs updated to wx -# -# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o dialogs library converted. All is well. -# -# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxScrolledMessageDialog -> ScrolledMessageDialog -# - -import wx -import wx.lib.dialogs - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - f = open("Main.py", "r") - msg = f.read() - f.close() - - dlg = wx.lib.dialogs.ScrolledMessageDialog(frame, msg, "message test") - dlg.ShowModal() - -#--------------------------------------------------------------------------- - - - -overview = """\ - -ScrolledMessageDialog(parent, msg, caption, pos=wx.DefaultPosition, size=(500,300)) - -This class represents a message dialog that uses a wxTextCtrl to display the -message. This allows more flexible information display without having to be -as much concerned with layout requirements. A text file can simply be used - -This dialog offers no special attributes or methods beyond those supported -by wxDialog. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxScrolledPanel.py b/wxPython/demo/wxScrolledPanel.py deleted file mode 100644 index c9fa69e05d..0000000000 --- a/wxPython/demo/wxScrolledPanel.py +++ /dev/null @@ -1,131 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o scrolledpanel lib needs wx update -# -# 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o lib updated, all is well. -# -# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxScrolledPanel -> ScrolledPanel -# - -import wx -import wx.lib.scrolledpanel as scrolled - -#---------------------------------------------------------------------- - -text = "one two buckle my shoe three four shut the door five six pick up sticks seven eight lay them straight nine ten big fat hen" - - -class TestPanel(scrolled.ScrolledPanel): - def __init__(self, parent, log): - self.log = log - scrolled.ScrolledPanel.__init__(self, parent, -1) - - vbox = wx.BoxSizer(wx.VERTICAL) - desc = wx.StaticText(self, -1, - "ScrolledPanel extends wxScrolledWindow, adding all " - "the necessary bits to set up scroll handling for you.\n\n" - "Here are three fixed size examples of its use. The " - "demo panel for this sample is also using it -- the \nwxStaticLine" - "below is intentionally made too long so a scrollbar will be " - "activated." - ) - desc.SetForegroundColour("Blue") - vbox.Add(desc, 0, wx.ALIGN_LEFT|wx.ALL, 5) - vbox.Add(wx.StaticLine(self, -1, size=(1024,-1)), 0, wx.ALL, 5) - vbox.Add((20,20)) - - words = text.split() - - panel1 = scrolled.ScrolledPanel(self, -1, size=(120,300), - style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER ) - fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4) - - for word in words: - label = wx.StaticText(panel1, -1, word+":") - tc = wx.TextCtrl(panel1, -1, word, size=(50,-1)) - fgs1.Add(label, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) - fgs1.Add(tc, flag=wx.EXPAND|wx.RIGHT, border=25) - - panel1.SetSizer( fgs1 ) - panel1.SetAutoLayout(1) - panel1.SetupScrolling( scroll_x=False ) - - panel2 = scrolled.ScrolledPanel(self, -1, size=(350, 40), - style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) - panel3 = scrolled.ScrolledPanel(self, -1, size=(200,100), - style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) - - fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4) - fgs3 = wx.FlexGridSizer(cols=5, vgap=4, hgap=4) - - for i in range(len(words)): - word = words[i] - if i % 5 != 4: - label2 = wx.StaticText(panel2, -1, word) - fgs2.Add(label2, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) - label3 = wx.StaticText(panel3, -1, word) - fgs3.Add(label3, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) - else: - tc2 = wx.TextCtrl(panel2, -1, word, size=(50,-1)) - fgs2.Add(tc2, flag=wx.LEFT, border=5) - tc3 = wx.TextCtrl(panel3, -1, word ) - fgs3.Add(tc3, flag=wx.LEFT, border=5) - - panel2.SetSizer( fgs2 ) - panel2.SetAutoLayout(1) - panel2.SetupScrolling(scroll_y = False) - - panel3.SetSizer( fgs3 ) - panel3.SetAutoLayout(1) - panel3.SetupScrolling() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((20,20)) - hbox.Add(panel1, 0) - hbox.Add((40, 10)) - - vbox2 = wx.BoxSizer(wx.VERTICAL) - vbox2.Add(panel2, 0) - vbox2.Add((20, 50)) - - vbox2.Add(panel3, 0) - vbox2.Add((20, 10)) - hbox.Add(vbox2) - - vbox.AddSizer(hbox, 0) - self.SetSizer(vbox) - self.SetAutoLayout(1) - self.SetupScrolling() - - -#---------------------------------------------------------------------- - - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -ScrolledPanel fills a "hole" in the implementation of wxScrolledWindow, -providing automatic scrollbar and scrolling behavior and the tab traversal -mangement that wxScrolledWindow lacks. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxScrolledWindow.py b/wxPython/demo/wxScrolledWindow.py deleted file mode 100644 index 753835e374..0000000000 --- a/wxPython/demo/wxScrolledWindow.py +++ /dev/null @@ -1,248 +0,0 @@ -# 11/12/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Rudimentary overview doc added. -# - -import wx - -import images - -BUFFERED = 1 - -#--------------------------------------------------------------------------- - -class MyCanvas(wx.ScrolledWindow): - def __init__(self, parent, id = -1, size = wx.DefaultSize): - wx.ScrolledWindow.__init__(self, parent, id, (0, 0), size=size, style=wx.SUNKEN_BORDER) - - self.lines = [] - self.maxWidth = 1000 - self.maxHeight = 1000 - self.x = self.y = 0 - self.curLine = [] - self.drawing = False - - self.SetBackgroundColour("WHITE") - self.SetCursor(wx.StockCursor(wx.CURSOR_PENCIL)) - bmp = images.getTest2Bitmap() - mask = wx.MaskColour(bmp, wx.BLUE) - bmp.SetMask(mask) - self.bmp = bmp - - self.SetScrollbars(20, 20, self.maxWidth/20, self.maxHeight/20) - - if BUFFERED: - # Initialize the buffer bitmap. No real DC is needed at this point. - self.buffer = wx.EmptyBitmap(self.maxWidth, self.maxHeight) - dc = wx.BufferedDC(None, self.buffer) - dc.SetBackground(wx.Brush(self.GetBackgroundColour())) - dc.Clear() - self.DoDrawing(dc) - - self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftButtonEvent) - self.Bind(wx.EVT_LEFT_UP, self.OnLeftButtonEvent) - self.Bind(wx.EVT_MOTION, self.OnLeftButtonEvent) - self.Bind(wx.EVT_PAINT, self.OnPaint) - - - def getWidth(self): - return self.maxWidth - - def getHeight(self): - return self.maxHeight - - - def OnPaint(self, event): - if BUFFERED: - # Create a buffered paint DC. It will create the real - # wx.PaintDC and then blit the bitmap to it when dc is - # deleted. Since we don't need to draw anything else - # here that's all there is to it. - dc = wx.BufferedPaintDC(self, self.buffer) - else: - dc = wx.PaintDC(self) - self.PrepareDC(dc) - # since we're not buffering in this case, we have to - # paint the whole window, potentially very time consuming. - self.DoDrawing(dc) - - - def DoDrawing(self, dc, printing=False): - dc.BeginDrawing() - dc.SetPen(wx.Pen('RED')) - dc.DrawRectangle((5, 5), (50, 50)) - - dc.SetBrush(wx.LIGHT_GREY_BRUSH) - dc.SetPen(wx.Pen('BLUE', 4)) - dc.DrawRectangle((15, 15), (50, 50)) - - dc.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL)) - dc.SetTextForeground(wx.Colour(0xFF, 0x20, 0xFF)) - te = dc.GetTextExtent("Hello World") - dc.DrawText("Hello World", (60, 65)) - - dc.SetPen(wx.Pen('VIOLET', 4)) - dc.DrawLine((5, 65+te[1]), (60+te[0], 65+te[1])) - - lst = [(100,110), (150,110), (150,160), (100,160)] - dc.DrawLines(lst, -60) - dc.SetPen(wx.GREY_PEN) - dc.DrawPolygon(lst, 75) - dc.SetPen(wx.GREEN_PEN) - dc.DrawSpline(lst+[(100,100)]) - - dc.DrawBitmap(self.bmp, (200, 20), True) - dc.SetTextForeground(wx.Colour(0, 0xFF, 0x80)) - dc.DrawText("a bitmap", (200, 85)) - -## dc.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL)) -## dc.SetTextForeground("BLACK") -## dc.DrawText("TEST this STRING", (10, 200)) -## print dc.GetFullTextExtent("TEST this STRING") - - font = wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL) - dc.SetFont(font) - dc.SetTextForeground(wx.BLACK) - - for a in range(0, 360, 45): - dc.DrawRotatedText("Rotated text...", (300, 300), a) - - dc.SetPen(wx.TRANSPARENT_PEN) - dc.SetBrush(wx.BLUE_BRUSH) - dc.DrawRectangle((50,500),(50,50)) - dc.DrawRectangle((100,500),(50,50)) - - dc.SetPen(wx.Pen('RED')) - dc.DrawEllipticArc((200, 500), (50, 75), 0, 90) - - if not printing: - # This has troubles when used on a print preview in wxGTK, - # probably something to do with the pen styles and the scaling - # it does... - y = 20 - - for style in [wx.DOT, wx.LONG_DASH, wx.SHORT_DASH, wx.DOT_DASH, wx.USER_DASH]: - pen = wx.Pen("DARK ORCHID", 1, style) - if style == wx.USER_DASH: - pen.SetCap(wx.CAP_BUTT) - pen.SetDashes([1,2]) - pen.SetColour("RED") - dc.SetPen(pen) - dc.DrawLine((300, y), (400, y)) - y = y + 10 - - dc.SetBrush(wx.TRANSPARENT_BRUSH) - dc.SetPen(wx.Pen(wx.Colour(0xFF, 0x20, 0xFF), 1, wx.SOLID)) - dc.DrawRectangle((450, 50), (100, 100)) - old_pen = dc.GetPen() - new_pen = wx.Pen("BLACK", 5) - dc.SetPen(new_pen) - dc.DrawRectangle((470, 70), (60, 60)) - dc.SetPen(old_pen) - dc.DrawRectangle((490, 90), (20, 20)) - - self.DrawSavedLines(dc) - dc.EndDrawing() - - - def DrawSavedLines(self, dc): - dc.SetPen(wx.Pen('MEDIUM FOREST GREEN', 4)) - - for line in self.lines: - for coords in line: - apply(dc.DrawLine, coords) - - - def SetXY(self, event): - self.x, self.y = self.ConvertEventCoords(event) - - def ConvertEventCoords(self, event): - xView, yView = self.GetViewStart() - xDelta, yDelta = self.GetScrollPixelsPerUnit() - return (event.GetX() + (xView * xDelta), - event.GetY() + (yView * yDelta)) - - def OnLeftButtonEvent(self, event): - if event.LeftDown(): - self.SetFocus() - self.SetXY(event) - self.curLine = [] - self.CaptureMouse() - self.drawing = True - - elif event.Dragging() and self.drawing: - if BUFFERED: - # If doing buffered drawing, create the buffered DC, giving it - # it a real DC to blit to when done. - cdc = wx.ClientDC(self) - self.PrepareDC(cdc) - dc = wx.BufferedDC(cdc, self.buffer) - else: - dc = wx.ClientDC(self) - self.PrepareDC(dc) - - dc.BeginDrawing() - dc.SetPen(wx.Pen('MEDIUM FOREST GREEN', 4)) - coords = [(self.x, self.y) , self.ConvertEventCoords(event)] - self.curLine.append(coords) - apply(dc.DrawLine, coords) - self.SetXY(event) - dc.EndDrawing() - - - elif event.LeftUp() and self.drawing: - self.lines.append(self.curLine) - self.curLine = [] - self.ReleaseMouse() - self.drawing = False - - -## This is an example of what to do for the EVT_MOUSEWHEEL event, -## but since wxScrolledWindow does this already it's not -## necessary to do it ourselves. You would need to add an event table -## entry to __init__() to direct wheelmouse events to this handler. - -## wheelScroll = 0 -## def OnWheel(self, evt): -## delta = evt.GetWheelDelta() -## rot = evt.GetWheelRotation() -## linesPer = evt.GetLinesPerAction() -## print delta, rot, linesPer -## ws = self.wheelScroll -## ws = ws + rot -## lines = ws / delta -## ws = ws - lines * delta -## self.wheelScroll = ws -## if lines != 0: -## lines = lines * linesPer -## vsx, vsy = self.GetViewStart() -## scrollTo = vsy - lines -## self.Scroll(-1, scrollTo) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = MyCanvas(nb) - return win - -#--------------------------------------------------------------------------- - - - -overview = """ - - -The wx.ScrolledWindow class manages scrolling for its client area, transforming the -coordinates according to the scrollbar positions, and setting the scroll positions, -thumb sizes and ranges according to the area in view. - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxSingleChoiceDialog.py b/wxPython/demo/wxSingleChoiceDialog.py deleted file mode 100644 index 34c6f50b5f..0000000000 --- a/wxPython/demo/wxSingleChoiceDialog.py +++ /dev/null @@ -1,42 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - dlg = wx.SingleChoiceDialog( - frame, 'Test Single Choice', 'The Caption', - ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'], - wx.CHOICEDLG_STYLE - ) - - if dlg.ShowModal() == wx.ID_OK: - log.WriteText('You selected: %s\n' % dlg.GetStringSelection()) - - dlg.Destroy() - -#--------------------------------------------------------------------------- - - - - -overview = """\ -This class represents a dialog that shows a list of strings, and allows the user -to select one. Double-clicking on a list item is equivalent to single-clicking -and then pressing OK. - -As with all dialogs, be sure to retrieve the information you need BEFORE you -destroy the dialog. -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxSlider.py b/wxPython/demo/wxSlider.py deleted file mode 100644 index 11284aa86a..0000000000 --- a/wxPython/demo/wxSlider.py +++ /dev/null @@ -1,52 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - self.count = 0 - - wx.StaticText(self, -1, "This is a wxSlider.", (45, 15)) - - slider = wx.Slider( - self, 100, 25, 1, 100, (30, 60), (250, -1), - wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS - ) - - slider.SetTickFreq(5, 1) - - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - - -overview = """\ -A slider is a control with a handle which can be pulled back and forth to -change the value. - -In Windows versions below Windows 95, a scrollbar is used to simulate the slider. -In Windows 95, the track bar control is used. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxSpinButton.py b/wxPython/demo/wxSpinButton.py deleted file mode 100644 index acbe912fb1..0000000000 --- a/wxPython/demo/wxSpinButton.py +++ /dev/null @@ -1,61 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o EVT_SPIN events (or something about them) freezes up the app. -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - self.count = 0 - - wx.StaticText(self, -1, "This example uses the wxSpinButton control.", (45, 15)) - - self.text = wx.TextCtrl(self, -1, "1", (30, 50), (60, -1)) - h = self.text.GetSize().height - - self.spin = wx.SpinButton(self, -1, (92, 50), (h, h), wx.SP_VERTICAL) - self.spin.SetRange(1, 100) - self.spin.SetValue(1) - - self.Bind(wx.EVT_SPIN, self.OnSpin, self.spin) - - - def OnSpin(self, event): - self.text.SetValue(str(event.GetPosition())) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -A wxSpinButton has two small up and down (or left and right) arrow buttons. -It is often used next to a text control for increment and decrementing a value. -Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not -implemented for all platforms (Win32 and GTK only currently). - -NB: the range supported by this control (and wxSpinCtrl) depends on the platform -but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version -of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit -range is supported. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxSpinCtrl.py b/wxPython/demo/wxSpinCtrl.py deleted file mode 100644 index 427be32326..0000000000 --- a/wxPython/demo/wxSpinCtrl.py +++ /dev/null @@ -1,50 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - self.count = 0 - - wx.StaticText(self, -1, "This example uses the wxSpinCtrl control.", (45, 15)) - sc = wx.SpinCtrl(self, -1, "", (30, 50), (80, -1)) - sc.SetRange(1,100) - sc.SetValue(5) - #sc.Enable(False) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -wxSpinCtrl combines wxTextCtrl and wxSpinButton in one control. - -Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not -implemented for all platforms (Win32 and GTK only currently). - -NB: the range supported by this control depends on the platform -but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version -of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit -range is supported. - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxSplitterWindow.py b/wxPython/demo/wxSplitterWindow.py deleted file mode 100644 index d25e626923..0000000000 --- a/wxPython/demo/wxSplitterWindow.py +++ /dev/null @@ -1,60 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -class MySplitter(wx.SplitterWindow): - def __init__(self, parent, ID, log): - wx.SplitterWindow.__init__(self, parent, ID) - self.log = log - - self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged) - self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging) - - def OnSashChanged(self, evt): - self.log.WriteText("sash changed to %s\n" % str(evt.GetSashPosition())) - # uncomment this to not allow the change - #evt.SetSashPosition(-1) - - def OnSashChanging(self, evt): - self.log.WriteText("sash changing to %s\n" % str(evt.GetSashPosition())) - # uncomment this to not allow the change - #evt.SetSashPosition(-1) - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - splitter = MySplitter(nb, -1, log) - - p1 = wx.Window(splitter, -1) - p1.SetBackgroundColour(wx.RED) - wx.StaticText(p1, -1, "Panel One", (5,5)).SetBackgroundColour(wx.RED) - - p2 = wx.Window(splitter, -1) - p2.SetBackgroundColour(wx.BLUE) - wx.StaticText(p2, -1, "Panel Two", (5,5)).SetBackgroundColour(wx.BLUE) - - splitter.SetMinimumPaneSize(20) - splitter.SplitVertically(p1, p2, 100) - - return splitter - - -#--------------------------------------------------------------------------- - - -overview = """\ -This class manages up to two subwindows. The current view can be split -into two programmatically (perhaps from a menu command), and unsplit -either programmatically or via the wxSplitterWindow user interface. -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxStaticBitmap.py b/wxPython/demo/wxStaticBitmap.py deleted file mode 100644 index 2bfecf0433..0000000000 --- a/wxPython/demo/wxStaticBitmap.py +++ /dev/null @@ -1,51 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import images - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - self.count = 0 - - wx.StaticText(self, -1, "This is a wxStaticBitmap.", (45, 15)) - - bmp = images.getTest2Bitmap() - mask = wx.MaskColour(bmp, wx.BLUE) - bmp.SetMask(mask) - wx.StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight())) - - bmp = images.getRobinBitmap() - wx.StaticBitmap(self, -1, bmp, (80, 150)) - - wx.StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175)) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - -overview = """\ -A static bitmap control displays a bitmap. - -The bitmap to be displayed should have a small number of colours, such as 16, -to avoid palette problems. - -A bitmap can be derived from most image formats using the wxImage class. - -""" - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxStaticText.py b/wxPython/demo/wxStaticText.py deleted file mode 100644 index 22874ef480..0000000000 --- a/wxPython/demo/wxStaticText.py +++ /dev/null @@ -1,61 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o Removed the USE_GENERIC code because it doesn't work unless you use -# the 'from wx import *' methodology. -# - -import wx - -#--------------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent, -1) - - wx.StaticText(self, -1, "This is an example of static text", (20, 10)) - wx.StaticText(self, -1, "using the wxStaticText Control.", (20, 30)) - - wx.StaticText( - self, -1, "Is this yellow?", (20, 70), (90, -1) - ).SetBackgroundColour('Yellow') - - wx.StaticText( - self, -1, "align center", (120, 70), (90, -1), wx.ALIGN_CENTER - ).SetBackgroundColour('Yellow') - - wx.StaticText( - self, -1, "align right", (220, 70), (90, -1), wx.ALIGN_RIGHT - ).SetBackgroundColour('Yellow') - - str = "This is a different font." - text = wx.StaticText(self, -1, str, (20, 100)) - font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL) - text.SetFont(font) - #text.SetSize(text.GetBestSize()) - - wx.StaticText(self, -1, "Multi-line wxStaticText\nline 2\nline 3\n\nafter empty line", (20,150)) - wx.StaticText(self, -1, "Align right multi-line\nline 2\nline 3\n\nafter empty line", (220,150), style=wx.ALIGN_RIGHT) - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - panel = TestPanel(nb) - return panel - - -#--------------------------------------------------------------------------- - - -overview = '''\ -A static text control displays one or more lines of read-only text. - -''' - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxStatusBar.py b/wxPython/demo/wxStatusBar.py deleted file mode 100644 index 0d1cd90880..0000000000 --- a/wxPython/demo/wxStatusBar.py +++ /dev/null @@ -1,124 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import time -import wx - -#--------------------------------------------------------------------------- - -class CustomStatusBar(wx.StatusBar): - def __init__(self, parent, log): - wx.StatusBar.__init__(self, parent, -1) - - # This status bar has three fields - self.SetFieldsCount(3) - self.log = log - self.sizeChanged = False - self.Bind(wx.EVT_SIZE, self.OnSize) - self.Bind(wx.EVT_IDLE, self.OnIdle) - - # Field 0 ... just text - self.SetStatusText("A Custom StatusBar...", 0) - - # This will fall into field 1 (the second field) - self.cb = wx.CheckBox(self, 1001, "toggle clock") - self.Bind(wx.EVT_CHECKBOX, self.OnToggleClock, self.cb) - self.cb.SetValue(True) - - # set the initial position of the checkbox - self.Reposition() - - # We're going to use a timer to drive a 'clock' in the last - # field. - self.timer = wx.PyTimer(self.Notify) - self.timer.Start(1000) - self.Notify() - - - # Handles events from the timer we started in __init__(). - # We're using it to drive a 'clock' in field 2 (the third field). - def Notify(self): - t = time.localtime(time.time()) - st = time.strftime("%d-%b-%Y %I:%M:%S", t) - self.SetStatusText(st, 2) - self.log.WriteText("tick...\n") - - - # the checkbox was clicked - def OnToggleClock(self, event): - if self.cb.GetValue(): - self.timer.Start(1000) - self.Notify() - else: - self.timer.Stop() - - - def OnSize(self, evt): - self.Reposition() # for normal size events - - # Set a flag so the idle time handler will also do the repositioning. - # It is done this way to get around a buglet where GetFieldRect is not - # accurate during the EVT_SIZE resulting from a frame maximize. - self.sizeChanged = True - - - def OnIdle(self, evt): - if self.sizeChanged: - self.Reposition() - - - # reposition the checkbox - def Reposition(self): - rect = self.GetFieldRect(1) - self.cb.SetPosition((rect.x+2, rect.y+2)) - self.cb.SetSize((rect.width-4, rect.height-4)) - self.sizeChanged = False - - - -class TestCustomStatusBar(wx.Frame): - def __init__(self, parent, log): - wx.Frame.__init__(self, parent, -1, 'Test Custom StatusBar') - - self.sb = CustomStatusBar(self, log) - self.SetStatusBar(self.sb) - tc = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE) - - self.SetSize((500, 300)) - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - - def OnCloseWindow(self, event): - self.sb.timer.Stop() - del self.sb.timer - self.Destroy() - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestCustomStatusBar(frame, log) - frame.otherWin = win - win.Show(True) - -#--------------------------------------------------------------------------- - - -overview = """\ -A status bar is a narrow window that can be placed along the bottom of -a frame to give small amounts of status information. It can contain -one or more fields, one or more of which can be variable length -according to the size of the window. - -This example demonstrates how to create a custom status bar with actual -gadgets embedded in it. In this case, the first field is just plain text, -The second one has a checkbox that enables the timer, and the third -field has a clock that shows the current time when it is enabled. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxStyledTextCtrl_1.py b/wxPython/demo/wxStyledTextCtrl_1.py deleted file mode 100644 index 5eff81c883..0000000000 --- a/wxPython/demo/wxStyledTextCtrl_1.py +++ /dev/null @@ -1,300 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o EVT_STC_DRAG_OVER event GetdragResult() is not an int -# o wx.TheClipboard.Flush() generates an error on program exit. -# - -import wx -import wx.stc as stc - -import images - -#---------------------------------------------------------------------- - -debug = 1 - - -demoText = """\ - -This editor is provided by a class named wxStyledTextCtrl. As -the name suggests, you can define styles that can be applied to -sections of text. This will typically be used for things like -syntax highlighting code editors, but I'm sure that there are other -applications as well. A style is a combination of font, point size, -foreground and background colours. The editor can handle -proportional fonts just as easily as monospaced fonts, and various -styles can use different sized fonts. - -There are a few canned language lexers and colourizers included, -(see the next demo) or you can handle the colourization yourself. -If you do you can simply register an event handler and the editor -will let you know when the visible portion of the text needs -styling. - -wxStyledTextEditor also supports setting markers in the margin... - - - - -...and indicators within the text. You can use these for whatever -you want in your application. Cut, Copy, Paste, Drag and Drop of -text works, as well as virtually unlimited Undo and Redo -capabilities, (right click to try it out.) -""" - -if wx.Platform == '__WXMSW__': - face1 = 'Arial' - face2 = 'Times New Roman' - face3 = 'Courier New' - pb = 10 -else: - face1 = 'Helvetica' - face2 = 'Times' - face3 = 'Courier' - pb = 10 - - -#---------------------------------------------------------------------- -# This shows how to catch the Modified event from the wxStyledTextCtrl - -class MySTC(stc.StyledTextCtrl): - def __init__(self, parent, ID, log): - stc.StyledTextCtrl.__init__(self, parent, ID) - self.log = log - - self.Bind(stc.EVT_STC_DO_DROP, self.OnDoDrop) - self.Bind(stc.EVT_STC_DRAG_OVER, self.OnDragOver) - self.Bind(stc.EVT_STC_START_DRAG, self.OnStartDrag) - self.Bind(stc.EVT_STC_MODIFIED, self.OnModified) - - self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) - - def OnDestroy(self, evt): - # This is how the clipboard contents can be preserved after - # the app has exited. - wx.TheClipboard.Flush() - evt.Skip() - - - def OnStartDrag(self, evt): - self.log.write("OnStartDrag: %d, %s\n" - % (evt.GetDragAllowMove(), evt.GetDragText())) - - if debug and evt.GetPosition() < 250: - evt.SetDragAllowMove(False) # you can prevent moving of text (only copy) - evt.SetDragText("DRAGGED TEXT") # you can change what is dragged - #evt.SetDragText("") # or prevent the drag with empty text - - - def OnDragOver(self, evt): - #Todo: evt.GetdragResult() response is not an int - - self.log.write( - "OnDragOver: x,y=(%d, %d) pos: %d DragResult: %d\n" - % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult()) - ) - - if debug and evt.GetPosition() < 250: - evt.SetDragResult(wx.DragNone) # prevent dropping at the beginning of the buffer - - - def OnDoDrop(self, evt): - self.log.write("OnDoDrop: x,y=(%d, %d) pos: %d DragResult: %d\n" - "\ttext: %s\n" - % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult(), - evt.GetDragText())) - - if debug and evt.GetPosition() < 500: - evt.SetDragText("DROPPED TEXT") # Can change text if needed - #evt.SetDragResult(wx.DragNone) # Can also change the drag operation, but it - # is probably better to do it in OnDragOver so - # there is visual feedback - - #evt.SetPosition(25) # Can also change position, but I'm not sure why - # you would want to... - - - - - def OnModified(self, evt): - self.log.write("""OnModified - Mod type: %s - At position: %d - Lines added: %d - Text Length: %d - Text: %s\n""" % ( self.transModType(evt.GetModificationType()), - evt.GetPosition(), - evt.GetLinesAdded(), - evt.GetLength(), - repr(evt.GetText()) )) - - - def transModType(self, modType): - st = "" - table = [(stc.STC_MOD_INSERTTEXT, "InsertText"), - (stc.STC_MOD_DELETETEXT, "DeleteText"), - (stc.STC_MOD_CHANGESTYLE, "ChangeStyle"), - (stc.STC_MOD_CHANGEFOLD, "ChangeFold"), - (stc.STC_PERFORMED_USER, "UserFlag"), - (stc.STC_PERFORMED_UNDO, "Undo"), - (stc.STC_PERFORMED_REDO, "Redo"), - (stc.STC_LASTSTEPINUNDOREDO, "Last-Undo/Redo"), - (stc.STC_MOD_CHANGEMARKER, "ChangeMarker"), - (stc.STC_MOD_BEFOREINSERT, "B4-Insert"), - (stc.STC_MOD_BEFOREDELETE, "B4-Delete") - ] - - for flag,text in table: - if flag & modType: - st = st + text + " " - - if not st: - st = 'UNKNOWN' - - return st - - - - -#---------------------------------------------------------------------- - -_USE_PANEL = 1 - -def runTest(frame, nb, log): - if not _USE_PANEL: - ed = p = MySTC(nb, -1, log) - - else: - p = wx.Panel(nb, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) - ed = MySTC(p, -1, log) - s = wx.BoxSizer(wx.HORIZONTAL) - s.Add(ed, 1, wx.EXPAND) - p.SetSizer(s) - p.SetAutoLayout(True) - - - #ed.SetBufferedDraw(False) - #ed.StyleClearAll() - #ed.SetScrollWidth(800) - #ed.SetWrapMode(True) - - ed.SetText(demoText) - - if wx.USE_UNICODE: - import codecs - decode = codecs.lookup("utf-8")[1] - - ed.GotoPos(ed.GetLength()) - ed.AddText("\n\nwxStyledTextCtrl can also do Unicode:\n") - unitext, l = decode('\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd - ' - '\xd0\xbb\xd1\x83\xd1\x87\xd1\x88\xd0\xb8\xd0\xb9 ' - '\xd1\x8f\xd0\xb7\xd1\x8b\xd0\xba \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f!\n\n') - ed.AddText('\tRussian: ') - ed.AddText(unitext) - ed.GotoPos(0) - - ed.EmptyUndoBuffer() - - # make some styles - ed.StyleSetSpec(stc.STC_STYLE_DEFAULT, "size:%d,face:%s" % (pb, face3)) - ed.StyleSetSpec(1, "size:%d,bold,face:%s,fore:#0000FF" % (pb+2, face1)) - ed.StyleSetSpec(2, "face:%s,italic,fore:#FF0000,size:%d" % (face2, pb)) - ed.StyleSetSpec(3, "face:%s,bold,size:%d" % (face2, pb+2)) - ed.StyleSetSpec(4, "face:%s,size:%d" % (face1, pb-1)) - - # Now set some text to those styles... Normally this would be - # done in an event handler that happens when text needs displayed. - ed.StartStyling(98, 0xff) - ed.SetStyling(6, 1) # set style for 6 characters using style 1 - - ed.StartStyling(190, 0xff) - ed.SetStyling(20, 2) - - ed.StartStyling(310, 0xff) - ed.SetStyling(4, 3) - ed.SetStyling(2, 0) - ed.SetStyling(10, 4) - - - # line numbers in the margin - ed.SetMarginType(0, stc.STC_MARGIN_NUMBER) - ed.SetMarginWidth(0, 22) - ed.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "size:%d,face:%s" % (pb, face1)) - - # setup some markers - ed.SetMarginType(1, stc.STC_MARGIN_SYMBOL) - ed.MarkerDefine(0, stc.STC_MARK_ROUNDRECT, "#CCFF00", "RED") - #ed.MarkerDefine(1, stc.STC_MARK_CIRCLE, "FOREST GREEN", "SIENNA") - ed.MarkerDefineBitmap(1, images.getFolder1Bitmap()) - ed.MarkerDefine(2, stc.STC_MARK_SHORTARROW, "blue", "blue") - ed.MarkerDefine(3, stc.STC_MARK_ARROW, "#00FF00", "#00FF00") - - # put some markers on some lines - ed.MarkerAdd(17, 0) - ed.MarkerAdd(18, 1) - ed.MarkerAdd(19, 2) - ed.MarkerAdd(20, 3) - ed.MarkerAdd(20, 0) - - - # and finally, an indicator or two - ed.IndicatorSetStyle(0, stc.STC_INDIC_SQUIGGLE) - ed.IndicatorSetForeground(0, wx.RED) - ed.IndicatorSetStyle(1, stc.STC_INDIC_DIAGONAL) - ed.IndicatorSetForeground(1, wx.BLUE) - ed.IndicatorSetStyle(2, stc.STC_INDIC_STRIKE) - ed.IndicatorSetForeground(2, wx.RED) - - ed.StartStyling(836, stc.STC_INDICS_MASK) - ed.SetStyling(10, stc.STC_INDIC0_MASK) - ed.SetStyling(10, stc.STC_INDIC1_MASK) - ed.SetStyling(10, stc.STC_INDIC2_MASK | stc.STC_INDIC1_MASK) - - - # some test stuff... - if debug: - print "GetTextLength(): ", ed.GetTextLength(), len(ed.GetText()) - print "GetText(): ", repr(ed.GetText()) - print - print "GetStyledText(98, 104): ", repr(ed.GetStyledText(98, 104)), len(ed.GetStyledText(98, 104)) - print - print "GetCurLine(): ", repr(ed.GetCurLine()) - ed.GotoPos(5) - print "GetCurLine(): ", repr(ed.GetCurLine()) - print - print "GetLine(1): ", repr(ed.GetLine(1)) - print - ed.SetSelection(25, 35) - print "GetSelectedText(): ", repr(ed.GetSelectedText()) - print "GetTextRange(25, 35): ", repr(ed.GetTextRange(25, 35)) - print "FindText(0, max, 'indicators'): ", - print ed.FindText(0, ed.GetTextLength(), "indicators") - - ed.GotoPos(0) - - - return p - - - -#---------------------------------------------------------------------- - - -overview = """\ - -Once again, no docs yet. Sorry. But this -and this should -be helpful. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxStyledTextCtrl_2.py b/wxPython/demo/wxStyledTextCtrl_2.py deleted file mode 100644 index f9514cf521..0000000000 --- a/wxPython/demo/wxStyledTextCtrl_2.py +++ /dev/null @@ -1,400 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import keyword - -import wx -import wx.stc as stc - -import images - -#---------------------------------------------------------------------- - -demoText = """\ -## This version of the editor has been set up to edit Python source -## code. Here is a copy of wxPython/demo/Main.py to play with. - - -""" - -#---------------------------------------------------------------------- - - -if wx.Platform == '__WXMSW__': - faces = { 'times': 'Times New Roman', - 'mono' : 'Courier New', - 'helv' : 'Arial', - 'other': 'Comic Sans MS', - 'size' : 10, - 'size2': 8, - } -else: - faces = { 'times': 'Times', - 'mono' : 'Courier', - 'helv' : 'Helvetica', - 'other': 'new century schoolbook', - 'size' : 12, - 'size2': 10, - } - - -#---------------------------------------------------------------------- - -class PythonSTC(stc.StyledTextCtrl): - - fold_symbols = 2 - - def __init__(self, parent, ID): - stc.StyledTextCtrl.__init__(self, parent, ID, - style = wx.NO_FULL_REPAINT_ON_RESIZE) - - self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) - self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT) - - self.SetLexer(stc.STC_LEX_PYTHON) - self.SetKeyWords(0, " ".join(keyword.kwlist)) - - self.SetProperty("fold", "1") - self.SetProperty("tab.timmy.whinge.level", "1") - self.SetMargins(0,0) - - self.SetViewWhiteSpace(False) - #self.SetBufferedDraw(False) - #self.SetViewEOL(True) - - self.SetEdgeMode(stc.STC_EDGE_BACKGROUND) - self.SetEdgeColumn(78) - - # Setup a margin to hold fold markers - #self.SetFoldFlags(16) ### WHAT IS THIS VALUE? WHAT ARE THE OTHER FLAGS? DOES IT MATTER? - self.SetMarginType(2, stc.STC_MARGIN_SYMBOL) - self.SetMarginMask(2, stc.STC_MASK_FOLDERS) - self.SetMarginSensitive(2, True) - self.SetMarginWidth(2, 12) - - if self.fold_symbols == 0: - # Arrow pointing right for contracted folders, arrow pointing down for expanded - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_ARROWDOWN, "black", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_ARROW, "black", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "black", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "black", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black"); - - elif self.fold_symbols == 1: - # Plus for contracted folders, minus for expanded - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_MINUS, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_PLUS, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black"); - - elif self.fold_symbols == 2: - # Like a flattened tree control using circular headers and curved joins - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_CIRCLEMINUS, "white", "#404040"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_CIRCLEPLUS, "white", "#404040"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#404040"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNERCURVE, "white", "#404040"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_CIRCLEPLUSCONNECTED, "white", "#404040"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_CIRCLEMINUSCONNECTED, "white", "#404040"); - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNERCURVE, "white", "#404040"); - - elif self.fold_symbols == 3: - # Like a flattened tree control using square headers - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_BOXMINUS, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_BOXPLUS, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNER, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_BOXPLUSCONNECTED, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_BOXMINUSCONNECTED, "white", "#808080") - self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNER, "white", "#808080") - - - self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI) - self.Bind(stc.EVT_STC_MARGINCLICK, self.OnMarginClick) - self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed) - - # Make some styles, The lexer defines what each style is used for, we - # just have to define what each style looks like. This set is adapted from - # Scintilla sample property files. - - # Global default styles for all languages - self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % faces) - self.StyleClearAll() # Reset all to be like the default - - # Global default styles for all languages - self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % faces) - self.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces) - self.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR, "face:%(other)s" % faces) - self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, "fore:#FFFFFF,back:#0000FF,bold") - self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold") - - # Python styles - # Default - self.StyleSetSpec(stc.STC_P_DEFAULT, "fore:#000000,face:%(helv)s,size:%(size)d" % faces) - # Comments - self.StyleSetSpec(stc.STC_P_COMMENTLINE, "fore:#007F00,face:%(other)s,size:%(size)d" % faces) - # Number - self.StyleSetSpec(stc.STC_P_NUMBER, "fore:#007F7F,size:%(size)d" % faces) - # String - self.StyleSetSpec(stc.STC_P_STRING, "fore:#7F007F,face:%(helv)s,size:%(size)d" % faces) - # Single quoted string - self.StyleSetSpec(stc.STC_P_CHARACTER, "fore:#7F007F,face:%(helv)s,size:%(size)d" % faces) - # Keyword - self.StyleSetSpec(stc.STC_P_WORD, "fore:#00007F,bold,size:%(size)d" % faces) - # Triple quotes - self.StyleSetSpec(stc.STC_P_TRIPLE, "fore:#7F0000,size:%(size)d" % faces) - # Triple double quotes - self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE, "fore:#7F0000,size:%(size)d" % faces) - # Class name definition - self.StyleSetSpec(stc.STC_P_CLASSNAME, "fore:#0000FF,bold,underline,size:%(size)d" % faces) - # Function or method name definition - self.StyleSetSpec(stc.STC_P_DEFNAME, "fore:#007F7F,bold,size:%(size)d" % faces) - # Operators - self.StyleSetSpec(stc.STC_P_OPERATOR, "bold,size:%(size)d" % faces) - # Identifiers - self.StyleSetSpec(stc.STC_P_IDENTIFIER, "fore:#000000,face:%(helv)s,size:%(size)d" % faces) - # Comment-blocks - self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, "fore:#7F7F7F,size:%(size)d" % faces) - # End of line where string is not closed - self.StyleSetSpec(stc.STC_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % faces) - - self.SetCaretForeground("BLUE") - - - # register some images for use in the AutoComplete box. - self.RegisterImage(1, images.getSmilesBitmap()) - self.RegisterImage(2, images.getFile1Bitmap()) - self.RegisterImage(3, images.getCopy2Bitmap()) - - - def OnKeyPressed(self, event): - if self.CallTipActive(): - self.CallTipCancel() - key = event.KeyCode() - - if key == 32 and event.ControlDown(): - pos = self.GetCurrentPos() - - # Tips - if event.ShiftDown(): - self.CallTipSetBackground("yellow") - self.CallTipShow(pos, 'lots of of text: blah, blah, blah\n\n' - 'show some suff, maybe parameters..\n\n' - 'fubar(param1, param2)') - # Code completion - else: - #lst = [] - #for x in range(50000): - # lst.append('%05d' % x) - #st = " ".join(lst) - #print len(st) - #self.AutoCompShow(0, st) - - kw = keyword.kwlist[:] - kw.append("zzzzzz?2") - kw.append("aaaaa?2") - kw.append("__init__?3") - kw.append("zzaaaaa?2") - kw.append("zzbaaaa?2") - kw.append("this_is_a_longer_value") - #kw.append("this_is_a_much_much_much_much_much_much_much_longer_value") - - kw.sort() # Python sorts are case sensitive - self.AutoCompSetIgnoreCase(False) # so this needs to match - - # Images are specified with a appended "?type" - for i in range(len(kw)): - if kw[i] in keyword.kwlist: - kw[i] = kw[i] + "?1" - - self.AutoCompShow(0, " ".join(kw)) - else: - event.Skip() - - - def OnUpdateUI(self, evt): - # check for matching braces - braceAtCaret = -1 - braceOpposite = -1 - charBefore = None - caretPos = self.GetCurrentPos() - - if caretPos > 0: - charBefore = self.GetCharAt(caretPos - 1) - styleBefore = self.GetStyleAt(caretPos - 1) - - # check before - if charBefore and chr(charBefore) in "[]{}()" and styleBefore == stc.STC_P_OPERATOR: - braceAtCaret = caretPos - 1 - - # check after - if braceAtCaret < 0: - charAfter = self.GetCharAt(caretPos) - styleAfter = self.GetStyleAt(caretPos) - - if charAfter and chr(charAfter) in "[]{}()" and styleAfter == stc.STC_P_OPERATOR: - braceAtCaret = caretPos - - if braceAtCaret >= 0: - braceOpposite = self.BraceMatch(braceAtCaret) - - if braceAtCaret != -1 and braceOpposite == -1: - self.BraceBadLight(braceAtCaret) - else: - self.BraceHighlight(braceAtCaret, braceOpposite) - #pt = self.PointFromPosition(braceOpposite) - #self.Refresh(True, wxRect(pt.x, pt.y, 5,5)) - #print pt - #self.Refresh(False) - - - def OnMarginClick(self, evt): - # fold and unfold as needed - if evt.GetMargin() == 2: - if evt.GetShift() and evt.GetControl(): - self.FoldAll() - else: - lineClicked = self.LineFromPosition(evt.GetPosition()) - - if self.GetFoldLevel(lineClicked) & stc.STC_FOLDLEVELHEADERFLAG: - if evt.GetShift(): - self.SetFoldExpanded(lineClicked, True) - self.Expand(lineClicked, True, True, 1) - elif evt.GetControl(): - if self.GetFoldExpanded(lineClicked): - self.SetFoldExpanded(lineClicked, False) - self.Expand(lineClicked, False, True, 0) - else: - self.SetFoldExpanded(lineClicked, True) - self.Expand(lineClicked, True, True, 100) - else: - self.ToggleFold(lineClicked) - - - def FoldAll(self): - lineCount = self.GetLineCount() - expanding = True - - # find out if we are folding or unfolding - for lineNum in range(lineCount): - if self.GetFoldLevel(lineNum) & stc.STC_FOLDLEVELHEADERFLAG: - expanding = not self.GetFoldExpanded(lineNum) - break; - - lineNum = 0 - - while lineNum < lineCount: - level = self.GetFoldLevel(lineNum) - if level & stc.STC_FOLDLEVELHEADERFLAG and \ - (level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE: - - if expanding: - self.SetFoldExpanded(lineNum, True) - lineNum = self.Expand(lineNum, True) - lineNum = lineNum - 1 - else: - lastChild = self.GetLastChild(lineNum, -1) - self.SetFoldExpanded(lineNum, False) - - if lastChild > lineNum: - self.HideLines(lineNum+1, lastChild) - - lineNum = lineNum + 1 - - - - def Expand(self, line, doExpand, force=False, visLevels=0, level=-1): - lastChild = self.GetLastChild(line, level) - line = line + 1 - - while line <= lastChild: - if force: - if visLevels > 0: - self.ShowLines(line, line) - else: - self.HideLines(line, line) - else: - if doExpand: - self.ShowLines(line, line) - - if level == -1: - level = self.GetFoldLevel(line) - - if level & stc.STC_FOLDLEVELHEADERFLAG: - if force: - if visLevels > 1: - self.SetFoldExpanded(line, True) - else: - self.SetFoldExpanded(line, False) - - line = self.Expand(line, doExpand, force, visLevels-1) - - else: - if doExpand and self.GetFoldExpanded(line): - line = self.Expand(line, True, force, visLevels-1) - else: - line = self.Expand(line, False, force, visLevels-1) - else: - line = line + 1; - - return line - - -#---------------------------------------------------------------------- - -_USE_PANEL = 1 - -def runTest(frame, nb, log): - if not _USE_PANEL: - ed = p = PythonSTC(nb, -1) - else: - p = wx.Panel(nb, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE) - ed = PythonSTC(p, -1) - s = wx.BoxSizer(wx.HORIZONTAL) - s.Add(ed, 1, wx.EXPAND) - p.SetSizer(s) - p.SetAutoLayout(True) - - - ed.SetText(demoText + open('Main.py').read()) - ed.EmptyUndoBuffer() - ed.Colourise(0, -1) - - # line numbers in the margin - ed.SetMarginType(1, stc.STC_MARGIN_NUMBER) - ed.SetMarginWidth(1, 25) - - return p - - - -#---------------------------------------------------------------------- - - -overview = """\ - -Once again, no docs yet. Sorry. But this -and this should -be helpful. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - - - - - -#---------------------------------------------------------------------- -#---------------------------------------------------------------------- - diff --git a/wxPython/demo/wxTextCtrl.py b/wxPython/demo/wxTextCtrl.py deleted file mode 100644 index 8c954a43b1..0000000000 --- a/wxPython/demo/wxTextCtrl.py +++ /dev/null @@ -1,176 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import sys -import wx - -#--------------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def OnSetFocus(self, evt): - print "OnSetFocus" - evt.Skip() - def OnKillFocus(self, evt): - print "OnKillFocus" - evt.Skip() - def OnWindowDestroy(self, evt): - print "OnWindowDestroy" - evt.Skip() - - - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - l1 = wx.StaticText(self, -1, "wx.TextCtrl") - t1 = wx.TextCtrl(self, -1, "Test it out and see", size=(125, -1)) - t1.SetInsertionPoint(0) - self.tc1 = t1 - - self.Bind(wx.EVT_TEXT, self.EvtText, t1) - t1.Bind(wx.EVT_CHAR, self.EvtChar) - t1.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) - t1.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) - t1.Bind(wx.EVT_WINDOW_DESTROY, self.OnWindowDestroy) - - l2 = wx.StaticText(self, -1, "Password") - t2 = wx.TextCtrl(self, -1, "", size=(125, -1), style=wx.TE_PASSWORD) - self.Bind(wx.EVT_TEXT, self.EvtText, t2) - - l3 = wx.StaticText(self, -1, "Multi-line") - t3 = wx.TextCtrl(self, -1, - "Here is a looooooooooooooong line of text set in the control.\n\n" - "The quick brown fox jumped over the lazy dog...", - size=(200, 100), style=wx.TE_MULTILINE) - - t3.SetInsertionPoint(0) - self.Bind(wx.EVT_TEXT, self.EvtText, t3) - b = wx.Button(self, -1, "Test Replace") - self.Bind(wx.EVT_BUTTON, self.OnTestReplace, b) - b2 = wx.Button(self, -1, "Test GetSelection") - self.Bind(wx.EVT_BUTTON, self.OnTestGetSelection, b2) - b3 = wx.Button(self, -1, "Test WriteText") - self.Bind(wx.EVT_BUTTON, self.OnTestWriteText, b3) - self.tc = t3 - - - l4 = wx.StaticText(self, -1, "Rich Text") - t4 = wx.TextCtrl(self, -1, "If supported by the native control, this is red, and this is a different font.", - size=(200, 100), style=wx.TE_MULTILINE|wx.TE_RICH2) - t4.SetInsertionPoint(0) - t4.SetStyle(44, 47, wx.TextAttr("RED", "YELLOW")) - points = t4.GetFont().GetPointSize() # get the current size - f = wx.Font(points+3, wx.ROMAN, wx.ITALIC, wx.BOLD, True) - t4.SetStyle(63, 77, wx.TextAttr("BLUE", wx.NullColour, f)) - - l5 = wx.StaticText(self, -1, "Test Positions") - t5 = wx.TextCtrl(self, -1, "0123456789\n" * 5, size=(200, 100), - style = wx.TE_MULTILINE - #| wx.TE_RICH - | wx.TE_RICH2 - ) - t5.Bind(wx.EVT_LEFT_DOWN, self.OnT5LeftDown) - self.t5 = t5 - - bsizer = wx.BoxSizer(wx.VERTICAL) - bsizer.Add(b, 0, wx.GROW|wx.ALL, 4) - bsizer.Add(b2, 0, wx.GROW|wx.ALL, 4) - bsizer.Add(b3, 0, wx.GROW|wx.ALL, 4) - - sizer = wx.FlexGridSizer(cols=3, hgap=6, vgap=6) - sizer.AddMany([ l1, t1, (0,0), - l2, t2, (0,0), - l3, t3, bsizer, - l4, t4, (0,0), - l5, t5, (0,0), - ]) - border = wx.BoxSizer(wx.VERTICAL) - border.Add(sizer, 0, wx.ALL, 25) - self.SetSizer(border) - self.SetAutoLayout(True) - - - def EvtText(self, event): - self.log.WriteText('EvtText: %s\n' % event.GetString()) - - - def EvtChar(self, event): - self.log.WriteText('EvtChar: %d\n' % event.GetKeyCode()) - event.Skip() - - - def OnTestReplace(self, evt): - self.tc.Replace(5, 9, "IS A") - #self.tc.Remove(5, 9) - - def OnTestWriteText(self, evt): - self.tc.WriteText("TEXT") - - def OnTestGetSelection(self, evt): - start, end = self.tc.GetSelection() - text = self.tc.GetValue() - if wx.Platform == "__WXMSW__": # This is why GetStringSelection was added - text = text.replace('\n', '\r\n') - - self.log.write("multi-line GetSelection(): (%d, %d)\n" - "\tGetStringSelection(): %s\n" - "\tSelectedText: %s\n" % - (start, end, - self.tc.GetStringSelection(), - repr(text[start:end]))) - - start, end = self.tc1.GetSelection() - text = self.tc1.GetValue() - - if wx.Platform == "__WXMSW__": # This is why GetStringSelection was added - text = text.replace('\n', '\r\n') - - self.log.write("single-line GetSelection(): (%d, %d)\n" - "\tGetStringSelection(): %s\n" - "\tSelectedText: %s\n" % - (start, end, - self.tc1.GetStringSelection(), - repr(text[start:end]))) - - - def OnT5LeftDown(self, evt): - evt.Skip() - wx.CallAfter(self.LogT5Position, evt) - - def LogT5Position(self, evt): - text = self.t5.GetValue() - ip = self.t5.GetInsertionPoint() - lp = self.t5.GetLastPosition() - self.log.write("LogT5Position:\n" - "\tGetInsertionPoint:\t%d\n" - "\ttext[insertionpoint]:\t%s\n" - "\tGetLastPosition:\t%d\n" - "\tlen(text):\t\t%d\n" - % (ip, text[ip], lp, len(text))) - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#--------------------------------------------------------------------------- - - -overview = """\ -A text control allows text to be displayed and (possibly) edited. It may be single -line or multi-line, support styles or not, be read-only or not, and even supports -text masking for such things as passwords. - - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxTextEntryDialog.py b/wxPython/demo/wxTextEntryDialog.py deleted file mode 100644 index 3083749bd1..0000000000 --- a/wxPython/demo/wxTextEntryDialog.py +++ /dev/null @@ -1,42 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - dlg = wx.TextEntryDialog( - frame, 'What is your favorite programming language?', - 'Duh??', 'Python') - - dlg.SetValue("Python is the best!") - - if dlg.ShowModal() == wx.ID_OK: - log.WriteText('You entered: %s\n' % dlg.GetValue()) - - dlg.Destroy() - - -#--------------------------------------------------------------------------- - - - -overview = """\ -This class represents a dialog that requests a one-line text string from the user. -It is implemented as a generic wxWindows dialog. Along with the usual wxDialog -style flags, all of the wxTextCtrl TE_* style flags are accepted, so, for example, -wx.TE_PASSWORD could be used to create a password dialog. - -As with other dialogs of this type, the user input must be retrieved prior to -destroying the dialog. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxTimeCtrl.py b/wxPython/demo/wxTimeCtrl.py deleted file mode 100644 index aa5cf52762..0000000000 --- a/wxPython/demo/wxTimeCtrl.py +++ /dev/null @@ -1,250 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx renamer needed for timectrl lib -# o presense of spin control causing probs (see spin ctrl demo for details) -# -# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o New binders applied. Issues still exist. -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxTimeCtrl -> TimeCtrl -# o wxScrolledPanel -> ScrolledPanel -# - -import wx -import wx.lib.timectrl as timectl -import wx.lib.scrolledpanel as scrolled - -#---------------------------------------------------------------------- - -class TestPanel( scrolled.ScrolledPanel ): - def __init__( self, parent, log ): - - scrolled.ScrolledPanel.__init__( self, parent, -1 ) - self.log = log - - - text1 = wx.StaticText( self, -1, "12-hour format:") - self.time12 = timectl.TimeCtrl( self, -1, name="12 hour control" ) - spin1 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,20), 0 ) - self.time12.BindSpinButton( spin1 ) - - text2 = wx.StaticText( self, -1, "24-hour format:") - spin2 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,20), 0 ) - self.time24 = timectl.TimeCtrl( - self, -1, name="24 hour control", fmt24hr=True, - spinButton = spin2 - ) - - text3 = wx.StaticText( self, -1, "No seconds\nor spin button:") - self.spinless_ctrl = timectl.TimeCtrl( - self, -1, name="spinless control", - display_seconds = False - ) - - grid = wx.FlexGridSizer( 0, 2, 10, 5 ) - grid.Add( text1, 0, wx.ALIGN_RIGHT ) - hbox1 = wx.BoxSizer( wx.HORIZONTAL ) - hbox1.Add( self.time12, 0, wx.ALIGN_CENTRE ) - hbox1.Add( spin1, 0, wx.ALIGN_CENTRE ) - grid.Add( hbox1, 0, wx.LEFT ) - - grid.Add( text2, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM ) - hbox2 = wx.BoxSizer( wx.HORIZONTAL ) - hbox2.Add( self.time24, 0, wx.ALIGN_CENTRE ) - hbox2.Add( spin2, 0, wx.ALIGN_CENTRE ) - grid.Add( hbox2, 0, wx.LEFT ) - - grid.Add( text3, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM ) - grid.Add( self.spinless_ctrl, 0, wx.LEFT ) - - - buttonChange = wx.Button( self, -1, "Change Controls") - self.radio12to24 = wx.RadioButton( - self, -1, "Copy 12-hour time to 24-hour control", - wx.DefaultPosition, wx.DefaultSize, wx.RB_GROUP - ) - - self.radio24to12 = wx.RadioButton( - self, -1, "Copy 24-hour time to 12-hour control" - ) - - self.radioWx = wx.RadioButton( self, -1, "Set controls to 'now' using wxDateTime") - self.radioMx = wx.RadioButton( self, -1, "Set controls to 'now' using mxDateTime") - - radio_vbox = wx.BoxSizer( wx.VERTICAL ) - radio_vbox.Add( self.radio12to24, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - radio_vbox.Add( self.radio24to12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - radio_vbox.Add( self.radioWx, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - radio_vbox.Add( self.radioMx, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - - box_label = wx.StaticBox( self, -1, "Change Controls through API" ) - buttonbox = wx.StaticBoxSizer( box_label, wx.HORIZONTAL ) - buttonbox.Add( buttonChange, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) - buttonbox.Add( radio_vbox, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) - - hbox = wx.BoxSizer( wx.HORIZONTAL ) - hbox.Add( grid, 0, wx.ALIGN_LEFT|wx.ALL, 15 ) - hbox.Add( buttonbox, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 20 ) - - - box_label = wx.StaticBox( self, -1, "Bounds Control" ) - boundsbox = wx.StaticBoxSizer( box_label, wx.HORIZONTAL ) - self.set_bounds = wx.CheckBox( self, -1, "Set time bounds:" ) - - minlabel = wx.StaticText( self, -1, "minimum time:" ) - self.min = timectl.TimeCtrl( self, -1, name="min", display_seconds = False ) - self.min.Enable( False ) - - maxlabel = wx.StaticText( self, -1, "maximum time:" ) - self.max = timectl.TimeCtrl( self, -1, name="max", display_seconds = False ) - self.max.Enable( False ) - - self.limit_check = wx.CheckBox( self, -1, "Limit control" ) - - label = wx.StaticText( self, -1, "Resulting time control:" ) - self.target_ctrl = timectl.TimeCtrl( self, -1, name="new" ) - - grid2 = wx.FlexGridSizer( 0, 2, 0, 0 ) - grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid2.Add( self.set_bounds, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid3 = wx.FlexGridSizer( 0, 2, 5, 5 ) - grid3.Add(minlabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL ) - grid3.Add( self.min, 0, wx.ALIGN_LEFT ) - grid3.Add(maxlabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL ) - grid3.Add( self.max, 0, wx.ALIGN_LEFT ) - grid2.Add(grid3, 0, wx.ALIGN_LEFT ) - - grid2.Add( self.limit_check, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - grid2.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - grid2.Add( self.target_ctrl, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - boundsbox.Add(grid2, 0, wx.ALIGN_CENTER|wx.EXPAND|wx.ALL, 5) - - vbox = wx.BoxSizer( wx.VERTICAL ) - vbox.Add( (20, 20) ) - vbox.Add( hbox, 0, wx.ALIGN_LEFT|wx.ALL, 5) - vbox.Add( boundsbox, 0, wx.ALIGN_LEFT|wx.ALL, 5 ) - - - outer_box = wx.BoxSizer( wx.VERTICAL ) - outer_box.Add( vbox, 0, wx.ALIGN_LEFT|wx.ALL, 5) - - - # Turn on mxDateTime option only if we can import the module: - try: - from mx import DateTime - except ImportError: - self.radioMx.Enable( False ) - - - self.SetAutoLayout( True ) - self.SetSizer( outer_box ) - outer_box.Fit( self ) - self.SetupScrolling() - - self.Bind(wx.EVT_BUTTON, self.OnButtonClick, buttonChange ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time12 ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time24 ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.spinless_ctrl ) - self.Bind(wx.EVT_CHECKBOX, self.OnBoundsCheck, self.set_bounds ) - self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_check ) - self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.min ) - self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.max ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.target_ctrl ) - - - def OnTimeChange( self, event ): - timectrl = self.FindWindowById( event.GetId() ) - ib_str = [ " (out of bounds)", "" ] - - self.log.write('%s time = %s%s\n' % ( timectrl.GetName(), timectrl.GetValue(), ib_str[ timectrl.IsInBounds() ] ) ) - - - def OnButtonClick( self, event ): - if self.radio12to24.GetValue(): - self.time24.SetValue( self.time12.GetValue() ) - - elif self.radio24to12.GetValue(): - self.time12.SetValue( self.time24.GetValue() ) - - elif self.radioWx.GetValue(): - now = wx.DateTime_Now() - self.time12.SetValue( now ) - # (demonstrates that G/SetValue returns/takes a wxDateTime) - self.time24.SetValue( self.time12.GetValue(as_wxDateTime=True) ) - - # (demonstrates that G/SetValue returns/takes a wxTimeSpan) - self.spinless_ctrl.SetValue( self.time12.GetValue(as_wxTimeSpan=True) ) - - elif self.radioMx.GetValue(): - from mx import DateTime - now = DateTime.now() - self.time12.SetValue( now ) - - # (demonstrates that G/SetValue returns/takes a DateTime) - self.time24.SetValue( self.time12.GetValue(as_mxDateTime=True) ) - - # (demonstrates that G/SetValue returns/takes a DateTimeDelta) - self.spinless_ctrl.SetValue( self.time12.GetValue(as_mxDateTimeDelta=True) ) - - - def OnBoundsCheck( self, event ): - self.min.Enable( self.set_bounds.GetValue() ) - self.max.Enable( self.set_bounds.GetValue() ) - self.SetTargetMinMax() - - - def SetTargetMinMax( self, event=None ): - min = None - max = None - - if self.set_bounds.GetValue(): - min = self.min.GetWxDateTime() - max = self.max.GetWxDateTime() - else: - min, max = None, None - - cur_min, cur_max = self.target_ctrl.GetBounds() - - # jmg - A little expirimental change to ensure that min - # or max contain valid values before we use them - if min and (min != cur_min): self.target_ctrl.SetMin( min ) - if max and (max != cur_max): self.target_ctrl.SetMax( max ) - - self.target_ctrl.SetLimited( self.limit_check.GetValue() ) - - if min != cur_min or max != cur_max: - new_min, new_max = self.target_ctrl.GetBounds() - - if new_min and new_max: - self.log.write( "current min, max: (%s, %s)\n" % ( new_min.FormatTime(), new_max.FormatTime() ) ) - else: - self.log.write( "current min, max: (None, None)\n" ) - -#---------------------------------------------------------------------- - -def runTest( frame, nb, log ): - win = TestPanel( nb, log ) - return win - -#---------------------------------------------------------------------- - -overview = timectl.__doc__ - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxTimer.py b/wxPython/demo/wxTimer.py deleted file mode 100644 index 7f71b1f442..0000000000 --- a/wxPython/demo/wxTimer.py +++ /dev/null @@ -1,89 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import time -import wx - -#--------------------------------------------------------------------------- - -## For your convenience; an example of creating your own timer class. -## -## class TestTimer(wxTimer): -## def __init__(self, log = None): -## wxTimer.__init__(self) -## self.log = log -## def Notify(self): -## wxBell() -## if self.log: -## self.log.WriteText('beep!\n') - -#--------------------------------------------------------------------------- - -ID_Start = wx.NewId() -ID_Stop = wx.NewId() -ID_Timer = wx.NewId() -ID_Timer2 = wx.NewId() - -class TestTimerWin(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - wx.StaticText(self, -1, "This is a timer example", (15, 30)) - wx.Button(self, ID_Start, ' Start ', (15, 75), wx.DefaultSize) - wx.Button(self, ID_Stop, ' Stop ', (115, 75), wx.DefaultSize) - - self.timer = wx.Timer(self, # object to send the event to - ID_Timer) # event id to use - - self.timer2 = wx.Timer(self, # object to send the event to - ID_Timer2) # event id to use - - self.Bind(wx.EVT_BUTTON, self.OnStart, id=ID_Start) - self.Bind(wx.EVT_BUTTON, self.OnStop, id=ID_Stop) - self.Bind(wx.EVT_TIMER, self.OnTimer, id=ID_Timer) - self.Bind(wx.EVT_TIMER, self.OnTimer2, id=ID_Timer2) - - def OnStart(self, event): - self.timer.Start(1000) - self.timer2.Start(1500) - - def OnStop(self, event): - self.timer.Stop() - self.timer2.Stop() - - def OnTimer(self, event): - wx.Bell() - if self.log: - self.log.WriteText('beep!\n') - - def OnTimer2(self, event): - wx.Bell() - if self.log: - self.log.WriteText('beep 2!\n') - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestTimerWin(nb, log) - return win - -#--------------------------------------------------------------------------- - - - -overview = """\ -The wxTimer class allows you to execute code at specified intervals from -within the wxPython event loop. Timers can be one-shot or repeating. - -""" - - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxToggleButton.py b/wxPython/demo/wxToggleButton.py deleted file mode 100644 index 7beec9983a..0000000000 --- a/wxPython/demo/wxToggleButton.py +++ /dev/null @@ -1,67 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -haveToggleBtn = 1 - -try: - wx.ToggleButton -except NameError: - haveToggleBtn = 0 - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - panel = wx.Panel(self, -1) - buttons = wx.BoxSizer(wx.HORIZONTAL) - - for word in "These are toggle buttons".split(): - b = wx.ToggleButton(panel, -1, word) - self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b) - buttons.Add(b, flag=wx.ALL, border=5) - - panel.SetAutoLayout(True) - panel.SetSizer(buttons) - buttons.Fit(panel) - panel.Move((50,50)) - - def OnToggle(self, evt): - self.log.write("Button %d toggled\n" % evt.GetId()) - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - if haveToggleBtn: - win = TestPanel(nb, log) - return win - else: - dlg = wx.MessageDialog(frame, 'wxToggleButton is not available on this platform.', - 'Sorry', wx.OK | wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - - -#---------------------------------------------------------------------- - - -overview = """\ -wxToggleButton is a button that stays pressed when clicked by the user. -In other words, it is similar to wxCheckBox in functionality but looks like a -wxButton. - -This class is only available under wxMSW and wxGTK currently. - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxToolBar.py b/wxPython/demo/wxToolBar.py deleted file mode 100644 index b609061504..0000000000 --- a/wxPython/demo/wxToolBar.py +++ /dev/null @@ -1,143 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import images - -#--------------------------------------------------------------------------- - -class TestToolBar(wx.Frame): - def __init__(self, parent, log): - wx.Frame.__init__(self, parent, -1, 'Test ToolBar', size=(500, 300)) - self.log = log - self.timer = None - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - - wx.Window(self, -1).SetBackgroundColour(wx.NamedColour("WHITE")) - - # Use the wxFrame internals to create the toolbar and associate it all - # in one tidy method call. - tb = self.CreateToolBar( wx.TB_HORIZONTAL - | wx.NO_BORDER - | wx.TB_FLAT - | wx.TB_TEXT - ) - - # Here's a 'simple' toolbar example, and how to bind it using SetToolBar() - #tb = wx.ToolBarSimple(self, -1, wx.DefaultPosition, wx.DefaultSize, - # wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT) - #self.SetToolBar(tb) - # But we're doing it a different way here. - - log.write("Default toolbar tool size: %s\n" % tb.GetToolBitmapSize()) - - self.CreateStatusBar() - - tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'") - #tb.AddLabelTool(10, "New", images.getNewBitmap(), shortHelp="New", longHelp="Long help for 'New'") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10) - - tb.AddSimpleTool(20, images.getOpenBitmap(), "Open", "Long help for 'Open'") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20) - - tb.AddSeparator() - tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy", "Long help for 'Copy'") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30) - - tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste", "Long help for 'Paste'") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40) - - tb.AddSeparator() - - tool = tb.AddCheckTool(50, images.getTog1Bitmap(), - shortHelp="Toggle this") - self.Bind(wx.EVT_TOOL, self.OnToolClick, id=50) - -## tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap(), -## shortHelp="Toggle with 2 bitmaps") -## self.Bind(EVT_TOOL, self.OnToolClick, id=60) - - self.Bind(wx.EVT_TOOL_ENTER, self.OnToolEnter) - self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick) # Match all - self.Bind(wx.EVT_TIMER, self.OnClearSB) - - tb.AddSeparator() - cbID = wx.NewId() - - tb.AddControl( - wx.ComboBox( - tb, cbID, "", choices=["", "This", "is a", "wxComboBox"], - size=(150,-1), style=wx.CB_DROPDOWN - )) - - self.Bind(wx.EVT_COMBOBOX, self.OnCombo, id=cbID) - tb.AddControl(wx.TextCtrl(tb, -1, "Toolbar controls!!", size=(150, -1))) - - # Final thing to do for a toolbar is call the Realize() method. This - # causes it to render (more or less, that is). - tb.Realize() - - - def OnToolClick(self, event): - self.log.WriteText("tool %s clicked\n" % event.GetId()) - tb = self.GetToolBar() - tb.EnableTool(10, not tb.GetToolEnabled(10)) - - def OnToolRClick(self, event): - self.log.WriteText("tool %s right-clicked\n" % event.GetId()) - - def OnCombo(self, event): - self.log.WriteText("combobox item selected: %s\n" % event.GetString()) - - def OnToolEnter(self, event): - self.log.WriteText('OnToolEnter: %s, %s\n' % (event.GetId(), event.GetInt())) - - if self.timer is None: - self.timer = wx.Timer(self) - - if self.timer.IsRunning(): - self.timer.Stop() - - self.timer.Start(2000) - event.Skip() - - - def OnClearSB(self, event): # called for the timer event handler - self.SetStatusText("") - self.timer.Stop() - self.timer = None - - - def OnCloseWindow(self, event): - if self.timer is not None: - self.timer.Stop() - self.timer = None - self.Destroy() - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestToolBar(frame, log) - frame.otherWin = win - win.Show(True) - -#--------------------------------------------------------------------------- - - - -overview = """\ - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxTreeCtrl.py b/wxPython/demo/wxTreeCtrl.py deleted file mode 100644 index 547d05c87c..0000000000 --- a/wxPython/demo/wxTreeCtrl.py +++ /dev/null @@ -1,206 +0,0 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import string -import wx -import images - -#--------------------------------------------------------------------------- - -class MyTreeCtrl(wx.TreeCtrl): - def __init__(self, parent, id, pos, size, style, log): - wx.TreeCtrl.__init__(self, parent, id, pos, size, style) - self.log = log - - def OnCompareItems(self, item1, item2): - t1 = self.GetItemText(item1) - t2 = self.GetItemText(item2) - self.log.WriteText('compare: ' + t1 + ' <> ' + t2 + '\n') - if t1 < t2: return -1 - if t1 == t2: return 0 - return 1 - -#--------------------------------------------------------------------------- - -class TestTreeCtrlPanel(wx.Panel): - def __init__(self, parent, log): - # Use the WANTS_CHARS style so the panel doesn't eat the Return key. - wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) - self.Bind(wx.EVT_SIZE, self.OnSize) - - self.log = log - tID = wx.NewId() - - self.tree = MyTreeCtrl(self, tID, wx.DefaultPosition, wx.DefaultSize, - wx.TR_HAS_BUTTONS - | wx.TR_EDIT_LABELS - #| wx.TR_MULTIPLE - #| wx.TR_HIDE_ROOT - , self.log) - - isz = (16,16) - il = wx.ImageList(isz[0], isz[1]) - fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) - fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) - fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz)) - smileidx = il.Add(images.getSmilesBitmap()) - - self.tree.SetImageList(il) - self.il = il - - # NOTE: For some reason tree items have to have a data object in - # order to be sorted. Since our compare just uses the labels - # we don't need any real data, so we'll just use None below for - # the item data. - - self.root = self.tree.AddRoot("The Root Item") - self.tree.SetPyData(self.root, None) - self.tree.SetItemImage(self.root, fldridx, wx.TreeItemIcon_Normal) - self.tree.SetItemImage(self.root, fldropenidx, wx.TreeItemIcon_Expanded) - - - for x in range(15): - child = self.tree.AppendItem(self.root, "Item %d" % x) - self.tree.SetPyData(child, None) - self.tree.SetItemImage(child, fldridx, wx.TreeItemIcon_Normal) - self.tree.SetItemImage(child, fldropenidx, wx.TreeItemIcon_Expanded) - - for y in range(5): - last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y))) - self.tree.SetPyData(last, None) - self.tree.SetItemImage(last, fldridx, wx.TreeItemIcon_Normal) - self.tree.SetItemImage(last, fldropenidx, wx.TreeItemIcon_Expanded) - - for z in range(5): - item = self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z)) - self.tree.SetPyData(item, None) - self.tree.SetItemImage(item, fileidx, wx.TreeItemIcon_Normal) - self.tree.SetItemImage(item, smileidx, wx.TreeItemIcon_Selected) - - self.tree.Expand(self.root) - self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded, self.tree) - self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, self.tree) - self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree) - self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.tree) - self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndEdit, self.tree) - self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate, self.tree) - - self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) - self.tree.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick) - self.tree.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) - - - - def OnRightClick(self, event): - pt = event.GetPosition(); - item, flags = self.tree.HitTest(pt) - self.log.WriteText("OnRightClick: %s, %s, %s\n" % - (self.tree.GetItemText(item), type(item), item.__class__)) - self.tree.SelectItem(item) - - - def OnRightUp(self, event): - pt = event.GetPosition(); - item, flags = self.tree.HitTest(pt) - self.log.WriteText("OnRightUp: %s (manually starting label edit)\n" - % self.tree.GetItemText(item)) - self.tree.EditLabel(item) - - - - def OnBeginEdit(self, event): - self.log.WriteText("OnBeginEdit\n") - # show how to prevent edit... - if self.tree.GetItemText(event.GetItem()) == "The Root Item": - wx.Bell() - self.log.WriteText("You can't edit this one...\n") - - # Lets just see what's visible of its children - cookie = 0 - root = event.GetItem() - (child, cookie) = self.tree.GetFirstChild(root, cookie) - - while child.IsOk(): - self.log.WriteText("Child [%s] visible = %d" % - (self.tree.GetItemText(child), - self.tree.IsVisible(child))) - (child, cookie) = self.tree.GetNextChild(root, cookie) - - event.Veto() - - - def OnEndEdit(self, event): - self.log.WriteText("OnEndEdit\n") - # show how to reject edit, we'll not allow any digits - for x in event.GetLabel(): - if x in string.digits: - self.log.WriteText("You can't enter digits...\n") - event.Veto() - return - - - def OnLeftDClick(self, event): - pt = event.GetPosition(); - item, flags = self.tree.HitTest(pt) - self.log.WriteText("OnLeftDClick: %s\n" % self.tree.GetItemText(item)) - parent = self.tree.GetItemParent(item) - self.tree.SortChildren(parent) - event.Skip() - - - def OnSize(self, event): - w,h = self.GetClientSizeTuple() - self.tree.SetDimensions(0, 0, w, h) - - - def OnItemExpanded(self, event): - item = event.GetItem() - self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item)) - - def OnItemCollapsed(self, event): - item = event.GetItem() - self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item)) - - def OnSelChanged(self, event): - self.item = event.GetItem() - self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(self.item)) - if wx.Platform == '__WXMSW__': - self.log.WriteText("BoundingRect: %s\n" % - self.tree.GetBoundingRect(self.item, True)) - #items = self.tree.GetSelections() - #print map(self.tree.GetItemText, items) - event.Skip() - - - def OnActivate(self, event): - self.log.WriteText("OnActivate: %s\n" % self.tree.GetItemText(self.item)) - - -#--------------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestTreeCtrlPanel(nb, log) - return win - -#--------------------------------------------------------------------------- - - - - - -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])]) - diff --git a/wxPython/demo/wxTreeListCtrl.py b/wxPython/demo/wxTreeListCtrl.py deleted file mode 100644 index 4015c0665f..0000000000 --- a/wxPython/demo/wxTreeListCtrl.py +++ /dev/null @@ -1,121 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import wx.gizmos as gizmos - -import images - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - self.Bind(wx.EVT_SIZE, self.OnSize) - - self.tree = gizmos.TreeListCtrl(self, -1, style = wx.TR_DEFAULT_STYLE - #| wx.TR_ROW_LINES - #| wx.TR_NO_LINES - #| wx.TR_TWIST_BUTTONS - ) - isz = (16,16) - il = wx.ImageList(isz[0], isz[1]) - fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) - fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) - fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz)) - smileidx = il.Add(images.getSmilesBitmap()) - - self.tree.SetImageList(il) - self.il = il - - # create some columns - self.tree.AddColumn("Main column") - self.tree.AddColumn("Column 1") - self.tree.AddColumn("Column 2") - self.tree.SetMainColumn(0) # the one with the tree in it... - self.tree.SetColumnWidth(0, 175) - - - self.root = self.tree.AddRoot("The Root Item") - self.tree.SetItemText(self.root, "col 1 root", 1) - self.tree.SetItemText(self.root, "col 2 root", 2) - self.tree.SetItemImage(self.root, fldridx, which = wx.TreeItemIcon_Normal) - self.tree.SetItemImage(self.root, fldropenidx, which = wx.TreeItemIcon_Expanded) - - - for x in range(15): - txt = "Item %d" % x - child = self.tree.AppendItem(self.root, txt) - self.tree.SetItemText(child, txt + "(c1)", 1) - self.tree.SetItemText(child, txt + "(c2)", 2) - self.tree.SetItemImage(child, fldridx, which = wx.TreeItemIcon_Normal) - self.tree.SetItemImage(child, fldropenidx, which = wx.TreeItemIcon_Expanded) - - for y in range(5): - txt = "item %d-%s" % (x, chr(ord("a")+y)) - last = self.tree.AppendItem(child, txt) - self.tree.SetItemText(last, txt + "(c1)", 1) - self.tree.SetItemText(last, txt + "(c2)", 2) - self.tree.SetItemImage(last, fldridx, which = wx.TreeItemIcon_Normal) - self.tree.SetItemImage(last, fldropenidx, which = wx.TreeItemIcon_Expanded) - - for z in range(5): - txt = "item %d-%s-%d" % (x, chr(ord("a")+y), z) - item = self.tree.AppendItem(last, txt) - self.tree.SetItemText(item, txt + "(c1)", 1) - self.tree.SetItemText(item, txt + "(c2)", 2) - self.tree.SetItemImage(item, fileidx, which = wx.TreeItemIcon_Normal) - self.tree.SetItemImage(item, smileidx, which = wx.TreeItemIcon_Selected) - - - self.tree.Expand(self.root) - - self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) - - - def OnRightUp(self, evt): - # Convert the position from being relative to the subwindow to - # being relative to the outer treelist window so HitTest will - # have the point it is expecting. - pos = evt.GetPosition() - pos = self.tree.GetMainWindow().ClientToScreen(pos) - pos = self.tree.ScreenToClient(pos) - item, flags, col = self.tree.HitTest(pos) - - if item: - print flags, col, self.tree.GetItemText(item, col) - - - def OnSize(self, evt): - self.tree.SetSize(self.GetSize()) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

wxTreeListCtrl

- -The wx.TreeListCtrl is essentially a wx.TreeCtrl with extra columns, -such that the look is similar to a wx.ListCtrl. - - -""" - - -if __name__ == '__main__': - #raw_input("Press enter...") - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxVListBox.py b/wxPython/demo/wxVListBox.py deleted file mode 100644 index cbe7707698..0000000000 --- a/wxPython/demo/wxVListBox.py +++ /dev/null @@ -1,135 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -#---------------------------------------------------------------------- - -# The wxVListBox is much like a regular wxListBox except you draw the -# items yourself and the items can vary in height. -class MyVListBox(wx.VListBox): - - # This method must be overridden. When called it should draw the - # n'th item on the dc within the rect. How it is drawn, and what - # is drawn is entirely up to you. - def OnDrawItem(self, dc, rect, n): - if self.GetSelection() == n: - c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT) - else: - c = self.GetForegroundColour()#wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT) - dc.SetTextForeground(c) - dc.DrawLabel(self._getItemText(n), rect, - wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) - - # This method must be overridden. It should return the height - # required to draw the n'th item. - def OnMeasureItem(self, n): - height = 0 - - for line in self._getItemText(n).split('\n'): - w, h = self.GetTextExtent(line) - height += h - - return height + 5 - - - # These are also overridable: - # - # OnDrawSeparator(dc, rect, n) - # Draw a separator between items. Note that rect may be reduced - # in size if desired so OnDrawItem gets a smaller rect. - # - # OnDrawBackground(dc, rect, n) - # Draw the background and maybe a border if desired. - - - def _getItemText(self, item): - if item % 2 == 0: - return "This is item# %d" % item - else: - return "This is item# %d\n with an extra line" % item - -#---------------------------------------------------------------------- - -# The wx.HtmlListBox derives from wx.VListBox, but draws each item -# itself as a wx.HtmlCell. -class MyHtmlListBox(wx.HtmlListBox): - - def OnGetItem(self, n): - if n % 2 == 0: - return "This is item# %d" % n - else: - return "This is item# %d
Any HTML is okay." % n - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - spacer = 50 - - vlb = MyVListBox(self, -1, size=(150, 250), style=wx.BORDER_SUNKEN) - vlb.SetItemCount(50) - vlb.SetSelection(0) - vlb.SetFocus() - vlbSizer = wx.BoxSizer(wx.VERTICAL) - vlbSizer.Add((spacer, spacer)) - vlbSizer.Add(wx.StaticText(self, -1, "wx.VListBox"), 0, 5, wx.ALL) - vlbSizer.Add(vlb) - - hlb = MyHtmlListBox(self, -1, size=(150, 250), style=wx.BORDER_SUNKEN) - hlb.SetItemCount(50) - hlb.SetSelection(0) - hlbSizer = wx.BoxSizer(wx.VERTICAL) - hlbSizer.Add((spacer, spacer)) - hlbSizer.Add(wx.StaticText(self, -1, "wx.HtmlListBox"), 0, 5, wx.ALL) - hlbSizer.Add(hlb) - - sizer = wx.BoxSizer(wx.HORIZONTAL) - sizer.Add((spacer, spacer)) - sizer.Add(vlbSizer) - sizer.Add((spacer, spacer)) - sizer.Add((spacer, spacer)) - sizer.Add(hlbSizer) - - self.SetSizer(sizer) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

wxVListBox and wxHtmlListBox

-
- -The "V" in wxVListBox stands for both "virtual" because it can have an -unlimited number of items since it doesn't store them itself, and -"variable" since items can vary in height. It has much the same -interface as wxListBox and also emits the same events so you can use -the same EVT_LISTBOX function to connect a handler. -

- -The wxHtmlListBox derives from wxVListBox, but draws each item itself -as a wxHtmlCell. This means that you just need to provide a snippet -of HTML for each item when requested. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxValidator.py b/wxPython/demo/wxValidator.py deleted file mode 100644 index b31b56b8f3..0000000000 --- a/wxPython/demo/wxValidator.py +++ /dev/null @@ -1,244 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import string -import wx - - -#---------------------------------------------------------------------- - -ALPHA_ONLY = 1 -DIGIT_ONLY = 2 - -class MyValidator(wx.PyValidator): - def __init__(self, flag=None, pyVar=None): - wx.PyValidator.__init__(self) - self.flag = flag - self.Bind(wx.EVT_CHAR, self.OnChar) - - def Clone(self): - return MyValidator(self.flag) - - def Validate(self, win): - tc = self.GetWindow() - val = tc.GetValue() - - if self.flag == ALPHA_ONLY: - for x in val: - if x not in string.letters: - return False - - elif self.flag == DIGIT_ONLY: - for x in val: - if x not in string.digits: - return False - - return True - - - def OnChar(self, event): - key = event.KeyCode() - - if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255: - event.Skip() - return - - if self.flag == ALPHA_ONLY and chr(key) in string.letters: - event.Skip() - return - - if self.flag == DIGIT_ONLY and chr(key) in string.digits: - event.Skip() - return - - if not wx.Validator_IsSilent(): - wx.Bell() - - # Returning without calling even.Skip eats the event before it - # gets to the text control - return - -#---------------------------------------------------------------------- - -class TestValidatorPanel(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent, -1) - self.SetAutoLayout(True) - VSPACE = 10 - - fgs = wx.FlexGridSizer(0, 2) - - fgs.Add((1,1)) - fgs.Add(wx.StaticText(self, -1, "These controls have validators that limit\n" - "the type of characters that can be entered.")) - - fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) - - label = wx.StaticText(self, -1, "Alpha Only: ") - fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) - - fgs.Add(wx.TextCtrl(self, -1, "", validator = MyValidator(ALPHA_ONLY))) - - fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) - - label = wx.StaticText(self, -1, "Digits Only: ") - fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) - fgs.Add(wx.TextCtrl(self, -1, "", validator = MyValidator(DIGIT_ONLY))) - - fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) - fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) - fgs.Add((0,0)) - b = wx.Button(self, -1, "Test Dialog Validation") - self.Bind(wx.EVT_BUTTON, self.OnDoDialog, b) - fgs.Add(b) - - border = wx.BoxSizer() - border.Add(fgs, 1, wx.GROW|wx.ALL, 25) - self.SetSizer(border) - self.Layout() - - def OnDoDialog(self, evt): - dlg = TestValidateDialog(self) - dlg.ShowModal() - dlg.Destroy() - - -#---------------------------------------------------------------------- - -class TextObjectValidator(wx.PyValidator): - """ This validator is used to ensure that the user has entered something - into the text object editor dialog's text field. - """ - def __init__(self): - """ Standard constructor. - """ - wx.PyValidator.__init__(self) - - - - def Clone(self): - """ Standard cloner. - - Note that every validator must implement the Clone() method. - """ - return TextObjectValidator() - - - def Validate(self, win): - """ Validate the contents of the given text control. - """ - textCtrl = self.GetWindow() - text = textCtrl.GetValue() - - if len(text) == 0: - wx.MessageBox("A text object must contain some text!", "Error") - textCtrl.SetBackgroundColour("pink") - textCtrl.SetFocus() - textCtrl.Refresh() - return False - else: - textCtrl.SetBackgroundColour( - wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) - textCtrl.Refresh() - return True - - - def TransferToWindow(self): - """ Transfer data from validator to window. - - The default implementation returns False, indicating that an error - occurred. We simply return True, as we don't do any data transfer. - """ - return True # Prevent wxDialog from complaining. - - - def TransferFromWindow(self): - """ Transfer data from window to validator. - - The default implementation returns False, indicating that an error - occurred. We simply return True, as we don't do any data transfer. - """ - return True # Prevent wxDialog from complaining. - -#---------------------------------------------------------------------- - -class TestValidateDialog(wx.Dialog): - def __init__(self, parent): - wx.Dialog.__init__(self, parent, -1, "Validated Dialog") - - self.SetAutoLayout(True) - VSPACE = 10 - - fgs = wx.FlexGridSizer(0, 2) - - fgs.Add((1,1)); - fgs.Add(wx.StaticText(self, -1, - "These controls must have text entered into them. Each\n" - "one has a validator that is checked when the Okay\n" - "button is clicked.")) - - fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) - - label = wx.StaticText(self, -1, "First: ") - fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) - - fgs.Add(wx.TextCtrl(self, -1, "", validator = TextObjectValidator())) - - fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE)) - - label = wx.StaticText(self, -1, "Second: ") - fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER) - fgs.Add(wx.TextCtrl(self, -1, "", validator = TextObjectValidator())) - - - buttons = wx.BoxSizer(wx.HORIZONTAL) - b = wx.Button(self, wx.ID_OK, "Okay") - b.SetDefault() - buttons.Add(b, 0, wx.ALL, 10) - buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 0, wx.ALL, 10) - - border = wx.BoxSizer(wx.VERTICAL) - border.Add(fgs, 1, wx.GROW|wx.ALL, 25) - border.Add(buttons) - self.SetSizer(border) - border.Fit(self) - self.Layout() - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestValidatorPanel(nb) - return win - -#---------------------------------------------------------------------- - - - -overview = """\ - - -wxValidator is the base class for a family of validator classes that mediate -between a class of control, and application data. - -

A validator has three major roles: - -

    -
  1. to transfer data from a C++ variable or own storage to and from a control; -
  2. to validate data in a control, and show an appropriate error message; -
  3. to filter events (such as keystrokes), thereby changing the behaviour of the associated control. -
-

Validators can be plugged into controls dynamically. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxWave.py b/wxPython/demo/wxWave.py deleted file mode 100644 index b84e62148b..0000000000 --- a/wxPython/demo/wxWave.py +++ /dev/null @@ -1,61 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx - -from Main import opj - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent, -1) - - b = wx.Button(self, -1, "Play Sound 1", (25, 25)) - self.Bind(wx.EVT_BUTTON, self.OnButton1, b) - - b = wx.Button(self, -1, "Play Sound 2", (25, 65)) - self.Bind(wx.EVT_BUTTON, self.OnButton2, b) - - - def OnButton1(self, evt): - try: - wave = wx.Wave(opj('data/anykey.wav')) - wave.Play() - except NotImplementedError, v: - wx.MessageBox(str(v), "Exception Message") - - - def OnButton2(self, evt): - try: - wave = wx.Wave(opj('data/plan.wav')) - wave.Play() - except NotImplementedError, v: - wx.MessageBox(str(v), "Exception Message") - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb) - return win - -#---------------------------------------------------------------------- - - -overview = """\ -This class represents a short wave file, in Windows WAV format, that can -be stored in memory and played. Currently this class is implemented on Windows -and GTK (Linux) only. - -This demo offers two examples, both driven by buttons, but obviously the event -that drives the playing of the sound can come from anywhere. - -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) diff --git a/wxPython/demo/wxWizard.py b/wxPython/demo/wxWizard.py deleted file mode 100644 index 7c7d5d80f6..0000000000 --- a/wxPython/demo/wxWizard.py +++ /dev/null @@ -1,253 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/3-/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o WizardPage* doesn't support GetId() -# - -import wx -import wx.wizard as wiz -import images - -#---------------------------------------------------------------------- - -def makePageTitle(wizPg, title): - sizer = wx.BoxSizer(wx.VERTICAL) - wizPg.SetSizer(sizer) - title = wx.StaticText(wizPg, -1, title) - title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) - sizer.AddWindow(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) - sizer.AddWindow(wx.StaticLine(wizPg, -1), 0, wx.EXPAND|wx.ALL, 5) - return sizer - -#---------------------------------------------------------------------- - -class TitledPage(wiz.WizardPageSimple): - def __init__(self, parent, title): - wiz.WizardPageSimple.__init__(self, parent) - self.sizer = makePageTitle(self, title) - - -#---------------------------------------------------------------------- - -class SkipNextPage(wiz.PyWizardPage): - def __init__(self, parent, title): - wiz.PyWizardPage.__init__(self, parent) - self.next = self.prev = None - self.sizer = makePageTitle(self, title) - - self.cb = wx.CheckBox(self, -1, "Skip next page") - self.sizer.Add(self.cb, 0, wx.ALL, 5) - - def SetNext(self, next): - self.next = next - - def SetPrev(self, prev): - self.prev = prev - - - # Classes derived from wxPyWizardPanel must override - # GetNext and GetPrev, and may also override GetBitmap - # as well as all those methods overridable by - # wx.PyWindow. - - def GetNext(self): - """If the checkbox is set then return the next page's next page""" - next = self.next - if self.cb.GetValue(): - next = next.GetNext() - return next - - def GetPrev(self): - return self.prev - -#---------------------------------------------------------------------- - -class UseAltBitmapPage(wiz.PyWizardPage): - def __init__(self, parent, title): - wiz.PyWizardPage.__init__(self, parent) - self.next = self.prev = None - self.sizer = makePageTitle(self, title) - - self.sizer.Add(wx.StaticText(self, -1, "This page uses a different bitmap"), - 0, wx.ALL, 5) - - def SetNext(self, next): - self.next = next - - def SetPrev(self, prev): - self.prev = prev - - def GetNext(self): - return self.next - - def GetPrev(self): - return self.prev - - def GetBitmap(self): - # You usually wouldn't need to override this method - # since you can set a non-default bitmap in the - # wxWizardPageSimple constructor, but if you need to - # dynamically change the bitmap based on the - # contents of the wizard, or need to also change the - # next/prev order then it can be done by overriding - # GetBitmap. - return images.getWizTest2Bitmap() - -#---------------------------------------------------------------------- - -class TestPanel(wx.Panel): - ID_wiz = wx.NewId() - - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - b = wx.Button(self, -1, "Run Simple Wizard", pos=(50, 50)) - self.Bind(wx.EVT_BUTTON, self.OnRunSimpleWizard, b) - - b = wx.Button(self, -1, "Run Dynamic Wizard", pos=(50, 100)) - self.Bind(wx.EVT_BUTTON, self.OnRunDynamicWizard, b) - - wiz.EVT_WIZARD_PAGE_CHANGED(self, self.ID_wiz, self.OnWizPageChanged) - wiz.EVT_WIZARD_PAGE_CHANGING(self, self.ID_wiz, self.OnWizPageChanging) - wiz.EVT_WIZARD_CANCEL(self, self.ID_wiz, self.OnWizCancel) - - - def OnWizPageChanged(self, evt): - if evt.GetDirection(): - dir = "forward" - else: - dir = "backward" - - page = evt.GetPage() - self.log.write("OnWizPageChanged: %s, %s\n" % (dir, page.__class__)) - - - def OnWizPageChanging(self, evt): - if evt.GetDirection(): - dir = "forward" - else: - dir = "backward" - - page = evt.GetPage() - self.log.write("OnWizPageChanging: %s, %s\n" % (dir, page.__class__)) - - - def OnWizCancel(self, evt): - page = evt.GetPage() - self.log.write("OnWizCancel: %s\n" % page.__class__) - - # Show how to prevent cancelling of the wizard. The - # other events can be Veto'd too. - if page is self.page1: - wx.MessageBox("Cancelling on the first page has been prevented.", "Sorry") - evt.Veto() - - def OnWizFinished(self, evt): - self.log.write("OnWizFinished\n") - - - def OnRunSimpleWizard(self, evt): - # Create the wizard and the pages - wizard = wiz.Wizard(self, self.ID_wiz, "Simple Wizard", - images.getWizTest1Bitmap()) - page1 = TitledPage(wizard, "Page 1") - page2 = TitledPage(wizard, "Page 2") - page3 = TitledPage(wizard, "Page 3") - page4 = TitledPage(wizard, "Page 4") - self.page1 = page1 - - page1.sizer.Add(wx.StaticText(page1, -1, """ -This wizard is totally useless, but is meant to show how to -chain simple wizard pages together in a non-dynamic manner. -IOW, the order of the pages never changes, and so the -wxWizardPageSimple class can easily be used for the pages.""")) - wizard.FitToPage(page1) - page4.sizer.Add(wx.StaticText(page4, -1, "\nThis is the last page.")) - - # Use the convenience Chain function to connect the pages - wiz.WizardPageSimple_Chain(page1, page2) - wiz.WizardPageSimple_Chain(page2, page3) - wiz.WizardPageSimple_Chain(page3, page4) - - if wizard.RunWizard(page1): - wx.MessageBox("Wizard completed successfully", "That's all folks!") - else: - wx.MessageBox("Wizard was cancelled", "That's all folks!") - - - - def OnRunDynamicWizard(self, evt): - # Create the wizard and the pages - #wizard = wx.PreWizard() - #wizard.SetExtraStyle(wx.WIZARD_EX_HELPBUTTON) - #wizard.Create(self, self.ID_wiz, "Simple Wizard", - # images.getWizTest1Bitmap()) - wizard = wiz.Wizard(self, self.ID_wiz, "Simple Wizard", - images.getWizTest1Bitmap()) - - page1 = TitledPage(wizard, "Page 1") - page2 = SkipNextPage(wizard, "Page 2") - page3 = TitledPage(wizard, "Page 3") - page4 = UseAltBitmapPage(wizard, "Page 4") - page5 = TitledPage(wizard, "Page 5") - self.page1 = page1 - - page1.sizer.Add(wx.StaticText(page1, -1, """ -This wizard shows the ability to choose at runtime the order -of the pages and also which bitmap is shown. -""")) - wizard.FitToPage(page1) - page5.sizer.Add(wx.StaticText(page5, -1, "\nThis is the last page.")) - - # Set the initial order of the pages - page1.SetNext(page2) - page2.SetPrev(page1) - page2.SetNext(page3) - page3.SetPrev(page2) - page3.SetNext(page4) - page4.SetPrev(page3) - page4.SetNext(page5) - page5.SetPrev(page4) - - - if wizard.RunWizard(page1): - wx.MessageBox("Wizard completed successfully", "That's all folks!") - else: - wx.MessageBox("Wizard was cancelled", "That's all folks!") - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

wxWizard

- -wxWizard is the central class for implementing 'wizard-like' -dialogs. These dialogs are mostly familiar to Windows users and are -nothing else but a sequence of 'pages' each of them displayed inside a -dialog which has the buttons to pass to the next (and previous) pages. -

-The wizards are typically used to decompose a complex dialog into -several simple steps and are mainly useful to the novice users, hence -it is important to keep them as simple as possible. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxXmlResource.py b/wxPython/demo/wxXmlResource.py deleted file mode 100644 index 208e229eac..0000000000 --- a/wxPython/demo/wxXmlResource.py +++ /dev/null @@ -1,80 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import wx.xrc as xrc - -from Main import opj - -#---------------------------------------------------------------------- - -RESFILE = opj("data/resource_wdr.xrc") - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - wx.Panel.__init__(self, parent, -1) - self.log = log - - # make the components - label = wx.StaticText(self, -1, "The lower panel was built from this XML:") - label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)) - - resourceText = open(RESFILE).read() - text = wx.TextCtrl(self, -1, resourceText, - style=wx.TE_READONLY|wx.TE_MULTILINE) - text.SetInsertionPoint(0) - - line = wx.StaticLine(self, -1) - - # This shows a few different ways to load XML Resources - if 0: - # XML Resources can be loaded from a file like this: - res = xrc.XmlResource(RESFILE) - - elif 1: - # or from a Virtual FileSystem: - wx.FileSystem_AddHandler(wx.MemoryFSHandler()) - wx.MemoryFSHandler_AddFile("XRC_Resources/data_file", resourceText) - res = xrc.XmlResource("memory:XRC_Resources/data_file") - - else: - # or from a string, like this: - res = xrc.EmptyXmlResource() - res.LoadFromString(resourceText) - - - # Now create a panel from the resource data - panel = res.LoadPanel(self, "MyPanel") - - # and do the layout - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(label, 0, wx.EXPAND|wx.TOP|wx.LEFT, 5) - sizer.Add(text, 1, wx.EXPAND|wx.ALL, 5) - sizer.Add(line, 0, wx.EXPAND) - sizer.Add(panel, 1, wx.EXPAND|wx.ALL, 5) - - self.SetSizer(sizer) - self.SetAutoLayout(True) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -""" - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxXmlResourceHandler.py b/wxPython/demo/wxXmlResourceHandler.py deleted file mode 100644 index 2098c5da41..0000000000 --- a/wxPython/demo/wxXmlResourceHandler.py +++ /dev/null @@ -1,195 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# o There are issues using the wx namespace within the xrc code. -# -# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Error report: "Error: No handler found for XML node 'object', -# class 'wx.StaticText'!"; no text shows on panel. -# - -import wx -import wx.xrc as xrc - -#---------------------------------------------------------------------- - -resourceText = r''' - - - - - - 200,100 - - - 10,10 - - - -''' - -#---------------------------------------------------------------------- - -class MyBluePanel(wx.Panel): - def __init__(self, parent, id, pos, size, style, name): - wx.Panel.__init__(self, parent, id, pos, size, style, name) - - # This is the little bit of customization that we do for this - # silly example. It could just as easily have been done in - # the resource. - self.SetBackgroundColour("BLUE") - self.SetForegroundColour("WHITE") - - -# To do it the more complex way, (see below) we need to write the -# class a little differently... This could obviously be done with a -# single class, but I wanted to make separate ones to make clear what -# the different requirements are. -class PreMyBluePanel(wx.Panel): - def __init__(self): - p = wx.PrePanel() - self.PostCreate(p) - - def Create(self, parent, id, pos, size, style, name): - wx.Panel.Create(self, parent, id, pos, size, style, name) - self.SetBackgroundColour("BLUE") - self.SetForegroundColour("WHITE") - - -#---------------------------------------------------------------------- - -class MyBluePanelXmlHandler(xrc.XmlResourceHandler): - def __init__(self): - xrc.XmlResourceHandler.__init__(self) - # Specify the styles recognized by objects of this type - self.AddStyle("wx.NO_3D", wx.NO_3D); - self.AddStyle("wx.TAB_TRAVERSAL", wx.TAB_TRAVERSAL); - self.AddStyle("wx.WS_EX_VALIDATE_RECURSIVELY", wx.WS_EX_VALIDATE_RECURSIVELY); - self.AddStyle("wx.CLIP_CHILDREN", wx.CLIP_CHILDREN); - self.AddWindowStyles(); - - # This method and the next one are required for XmlResourceHandlers - def CanHandle(self, node): - return self.IsOfClass(node, "MyBluePanel") - - def DoCreateResource(self): - # NOTE: wxWindows can be created in either a single-phase or - # in a two-phase way. Single phase is what you normally do, - # and two-phase creates the instnace first, and then later - # creates the actual window when the Create method is called. - # (In wxPython the first phase is done using the wxPre* - # function, for example, wxPreFrame, wxPrePanel, etc.) - # - # wxXmlResource supports either method, a premade instance can - # be created and populated by xrc using the appropriate - # LoadOn* method (such as LoadOnPanel) or xrc can create the - # instance too, using the Load* method. However this makes - # the handlers a bit more complex. If you can be sure that a - # particular class will never be loaded using a pre-existing - # instance, then you can make the handle much simpler. I'll - # show both methods below. - - if 1: - # The simple method assumes that there is no existing - # instance. Be sure of that with an assert. - assert self.GetInstance() is None - - # Now create the object - panel = MyBluePanel(self.GetParentAsWindow(), - self.GetID(), - self.GetPosition(), - self.GetSize(), - self.GetStyle("style", wx.TAB_TRAVERSAL), - self.GetName() - ) - else: - # When using the more complex (but more flexible) method - # the instance may already have been created, check for it - panel = self.GetInstance() - if panel is None: - # if not, then create the instance (but not the window) - panel = PreMyBluePanel() - - # Now call the panel's Create method to actually create the window - panel.Create(self.GetParentAsWindow(), - self.GetID(), - self.GetPosition(), - self.GetSize(), - self.GetStyle("style", wx.TAB_TRAVERSAL), - self.GetName() - ) - - # These two things should be done in either case: - # Set standard window attributes - self.SetupWindow(panel) - # Create any child windows of this node - self.CreateChildren(panel) - - return panel - - -#---------------------------------------------------------------------- - - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - # make the components - label = wx.StaticText(self, -1, "The lower panel was built from this XML:") - label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)) - - text = wx.TextCtrl(self, -1, resourceText, - style=wx.TE_READONLY|wx.TE_MULTILINE) - text.SetInsertionPoint(0) - - line = wx.StaticLine(self, -1) - - # Load the resource - res = xrc.EmptyXmlResource() - res.InsertHandler(MyBluePanelXmlHandler()) - res.LoadFromString(resourceText) - - # Now create a panel from the resource data - panel = res.LoadObject(self, "MyPanel", "MyBluePanel") - - # and do the layout - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(label, 0, wx.EXPAND|wx.TOP|wx.LEFT, 5) - sizer.Add(text, 1, wx.EXPAND|wx.ALL, 5) - sizer.Add(line, 0, wx.EXPAND) - sizer.Add(panel, 1, wx.EXPAND|wx.ALL, 5) - - self.SetSizer(sizer) - self.SetAutoLayout(True) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

wxXmlResourceHandler

- -Deriving a class from wxXmlResourceHandler allows you to specify your -own classes in XRC resources, and your handler class will then be used -to create instances of that class when the resource is loaded. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) - diff --git a/wxPython/demo/wxXmlResourceSubclass.py b/wxPython/demo/wxXmlResourceSubclass.py deleted file mode 100644 index f587ba9275..0000000000 --- a/wxPython/demo/wxXmlResourceSubclass.py +++ /dev/null @@ -1,108 +0,0 @@ -# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# - -import wx -import wx.xrc as xrc - -#---------------------------------------------------------------------- - -resourceText = r''' - - - - - - 200,100 - - - 10,10 - - - -''' - -#---------------------------------------------------------------------- - -class MyBluePanel(wx.Panel): - def __init__(self): - p = wx.PrePanel() - self.PostCreate(p) - - self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate) - - def OnCreate(self, evt): - # This is the little bit of customization that we do for this - # silly example. It could just as easily have been done in - # the resource. We do it in the EVT_WINDOW_CREATE handler - # because the window doesn't really exist yet in the __init__. - self.SetBackgroundColour("BLUE") - self.SetForegroundColour("WHITE") - -#---------------------------------------------------------------------- - - -class TestPanel(wx.Panel): - def __init__(self, parent, log): - self.log = log - wx.Panel.__init__(self, parent, -1) - - # make the components - label = wx.StaticText(self, -1, "The lower panel was built from this XML:") - label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)) - - text = wx.TextCtrl(self, -1, resourceText, - style=wx.TE_READONLY|wx.TE_MULTILINE) - text.SetInsertionPoint(0) - - line = wx.StaticLine(self, -1) - - # Load the resource - res = xrc.EmptyXmlResource() - res.LoadFromString(resourceText) - - # Now create a panel from the resource data - panel = res.LoadPanel(self, "MyPanel") - - # and do the layout - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(label, 0, wx.EXPAND|wx.TOP|wx.LEFT, 5) - sizer.Add(text, 1, wx.EXPAND|wx.ALL, 5) - sizer.Add(line, 0, wx.EXPAND) - sizer.Add(panel, 1, wx.EXPAND|wx.ALL, 5) - - self.SetSizer(sizer) - self.SetAutoLayout(True) - - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestPanel(nb, log) - return win - -#---------------------------------------------------------------------- - - - -overview = """ -

wxXmlResourceSubclass

- -Sometimes it is necessary to use custom classes, but you still want -them to be created from XRC. The subclass XRC attribute allows you to -do that. - - -""" - - - -if __name__ == '__main__': - import sys,os - import run - run.main(['', os.path.basename(sys.argv[0])]) -