2003-12-09 01:23:28 +00:00
|
|
|
# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Updated for wx namespace
|
|
|
|
#
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import wx
|
|
|
|
import images
|
2001-04-09 19:36:36 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestPanel(wx.Panel):
|
1999-04-30 03:29:54 +00:00
|
|
|
def __init__(self, parent, log):
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, -1,
|
|
|
|
style=wx.NO_FULL_REPAINT_ON_RESIZE)
|
1999-04-30 03:29:54 +00:00
|
|
|
self.log = log
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
b = wx.Button(self, 10, "Default Button", (20, 20))
|
2003-12-11 19:55:48 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnClick, b)
|
1999-12-23 20:05:08 +00:00
|
|
|
b.SetDefault()
|
2003-12-03 03:26:20 +00:00
|
|
|
b.SetSize(b.GetBestSize())
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
b = wx.Button(self, 20, "HELLO AGAIN!", (20, 80), (120, 45))
|
2003-12-11 19:55:48 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnClick, b)
|
2000-11-21 03:44:14 +00:00
|
|
|
b.SetToolTipString("This is a Hello button...")
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
if 0: # a test case for catching wx.PyAssertionError
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
#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)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
try:
|
2003-12-09 01:23:28 +00:00
|
|
|
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")
|
2003-03-25 06:35:27 +00:00
|
|
|
bmp = images.getTest2Bitmap()
|
2003-12-09 01:23:28 +00:00
|
|
|
mask = wx.MaskColour(bmp, wx.BLUE)
|
2003-03-25 06:35:27 +00:00
|
|
|
else:
|
|
|
|
bmp = images.getTest2Bitmap()
|
2003-12-09 01:23:28 +00:00
|
|
|
mask = wx.MaskColour(bmp, wx.BLUE)
|
2000-01-31 21:07:04 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
bmp.SetMask(mask)
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.BitmapButton(self, 30, bmp, (160, 20),
|
|
|
|
(bmp.GetWidth()+10, bmp.GetHeight()+10))
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnClick, id=30)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
def OnClick(self, event):
|
2003-03-25 06:35:27 +00:00
|
|
|
self.log.write("Click! (%d)\n" % event.GetId())
|
|
|
|
##wxLogDebug("debug message")
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
## wxLog_SetLogLevel(wxLOG_Message) # ignore everything above wxLOG_Message
|
1999-10-06 16:27:10 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
overview = """<html><body>
|
2003-12-09 01:23:28 +00:00
|
|
|
<h2>Button</h2>
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
A button is a control that contains a text string or a bitmap and can be
|
2003-03-25 06:35:27 +00:00
|
|
|
placed on nearly any kind of window.
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
</body></html>
|
|
|
|
"""
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
|
|
|
run.main(['', os.path.basename(sys.argv[0])])
|
1999-04-30 03:29:54 +00:00
|
|
|
|