2003-12-09 01:23:28 +00:00
|
|
|
|
|
|
|
import wx
|
|
|
|
import wx.lib.throbber as throb
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
import throbImages # this was created using a modified version of img2py
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
from wx.lib.throbber import __doc__ as docString
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestPanel(wx.Panel):
|
2003-03-25 06:35:27 +00:00
|
|
|
def __init__(self, parent, log):
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
2003-03-25 06:35:27 +00:00
|
|
|
self.log = log
|
|
|
|
|
|
|
|
# create the throbbers
|
|
|
|
self.throbbers = {
|
|
|
|
'plain': { 'throbber': None,
|
|
|
|
'text': "Plain throbber." },
|
|
|
|
'reverse': { 'throbber': None,
|
|
|
|
'text': "This throbber runs in reverse and faster." },
|
|
|
|
'autoreverse': { 'throbber': None,
|
|
|
|
'text': "This throbber switches direction." },
|
|
|
|
'label': { 'throbber': None,
|
|
|
|
'text': "With a label." },
|
|
|
|
'overlay': { 'throbber': None,
|
|
|
|
'text': "With an overlayed image." },
|
|
|
|
'overlay+text': { 'throbber': None,
|
|
|
|
'text': "With a label and an overlayed image." },
|
|
|
|
}
|
|
|
|
|
|
|
|
images = [throbImages.catalog[i].getBitmap()
|
|
|
|
for i in throbImages.index
|
|
|
|
if i not in ['eclouds', 'logo']]
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.throbbers['plain']['throbber'] = \
|
|
|
|
throb.Throbber(self, -1, images, size=(36, 36),frameDelay = 0.1)
|
|
|
|
|
|
|
|
self.throbbers['reverse']['throbber'] = \
|
|
|
|
throb.Throbber(self, -1, images, frameDelay = 0.07)
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
self.throbbers['reverse']['throbber'].Reverse()
|
2003-12-09 01:23:28 +00:00
|
|
|
|
|
|
|
self.throbbers['autoreverse']['throbber'] = \
|
|
|
|
throb.Throbber(self, -1, images, frameDelay = 0.1, reverse = True)
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
self.throbbers['autoreverse']['throbber'].sequence.append(0)
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.throbbers['label']['throbber'] = \
|
|
|
|
throb.Throbber(self, -1, images, frameDelay = 0.1, label = 'Label')
|
|
|
|
|
|
|
|
self.throbbers['label']['throbber'].SetFont(wx.Font(
|
|
|
|
pointSize = 10, family = wx.DEFAULT, style = wx.NORMAL, weight = wx.BOLD
|
|
|
|
))
|
|
|
|
|
|
|
|
self.throbbers['overlay']['throbber'] = \
|
|
|
|
throb.Throbber(
|
|
|
|
self, -1, images, frameDelay = 0.1,
|
|
|
|
overlay = throbImages.catalog['logo'].getBitmap()
|
|
|
|
)
|
|
|
|
|
|
|
|
self.throbbers['overlay+text']['throbber'] = \
|
|
|
|
throb.Throbber(
|
|
|
|
self, -1, images, frameDelay = 0.1,
|
|
|
|
overlay = throbImages.catalog['logo'].getBitmap(), label = "Python!"
|
|
|
|
)
|
|
|
|
|
|
|
|
self.throbbers['overlay+text']['throbber'].SetFont(wx.Font(
|
|
|
|
pointSize = 8, family = wx.DEFAULT, style = wx.NORMAL, weight = wx.BOLD
|
|
|
|
))
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
# this throbber is created using a single, composite image
|
2003-12-09 01:23:28 +00:00
|
|
|
self.otherThrobber = throb.Throbber(
|
|
|
|
self, -1, throbImages.catalog['eclouds'].getBitmap(), frameDelay = 0.15,
|
|
|
|
frames = 12, frameWidth = 48, label = "Stop"
|
|
|
|
)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.otherThrobber.Bind(wx.EVT_LEFT_DOWN, self.OnClickThrobber)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
box = wx.BoxSizer(wx.VERTICAL)
|
2004-01-13 03:17:17 +00:00
|
|
|
sizer = wx.GridBagSizer()
|
2003-12-09 01:23:28 +00:00
|
|
|
box.Add(sizer, 1, wx.EXPAND|wx.ALL, 5)
|
2003-03-25 06:35:27 +00:00
|
|
|
sizer.AddGrowableCol(1)
|
|
|
|
|
2004-01-13 03:17:17 +00:00
|
|
|
sizer.Add(self.otherThrobber, (0, 2), (4, 1),flag = wx.ALIGN_CENTER_VERTICAL)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
row = 2
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
# use a list so we can keep our order
|
|
|
|
for t in ['plain', 'reverse', 'autoreverse', 'label', 'overlay', 'overlay+text']:
|
2003-12-09 01:23:28 +00:00
|
|
|
sizer.Add(
|
2004-01-13 03:17:17 +00:00
|
|
|
self.throbbers[t]['throbber'], (row, 0), (1, 1),
|
2003-12-09 01:23:28 +00:00
|
|
|
flag = wx.ALIGN_CENTER|wx.ALL, border=2
|
|
|
|
)
|
|
|
|
|
|
|
|
sizer.Add(
|
|
|
|
wx.StaticText(self, -1, self.throbbers[t]['text']),
|
2004-01-13 03:17:17 +00:00
|
|
|
(row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT
|
2003-12-09 01:23:28 +00:00
|
|
|
)
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
row += 1
|
|
|
|
|
|
|
|
# start and stop buttons
|
2003-12-09 01:23:28 +00:00
|
|
|
startButton = wx.Button(self, -1, "Start")
|
2004-01-13 03:17:17 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnStartAnimation, startButton)
|
2003-12-09 01:23:28 +00:00
|
|
|
|
|
|
|
stopButton = wx.Button(self, -1, "Stop")
|
2004-01-13 03:17:17 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnStopAnimation, stopButton)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
buttonBox = wx.BoxSizer(wx.HORIZONTAL)
|
2003-03-25 06:35:27 +00:00
|
|
|
buttonBox.AddMany([
|
2003-12-09 01:23:28 +00:00
|
|
|
(startButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5),
|
|
|
|
(stopButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5),
|
2003-03-25 06:35:27 +00:00
|
|
|
])
|
|
|
|
|
2004-01-13 03:17:17 +00:00
|
|
|
sizer.Add(
|
|
|
|
buttonBox, (len(self.throbbers) + 3, 0), (1, 3), flag = wx.ALIGN_CENTER
|
|
|
|
)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
self.SetSizer(box)
|
|
|
|
self.SetAutoLayout(True)
|
|
|
|
self.Layout()
|
|
|
|
sizer.SetSizeHints(self)
|
|
|
|
sizer.Fit(self)
|
|
|
|
|
|
|
|
for t in self.throbbers.keys():
|
|
|
|
self.throbbers[t]['throbber'].Start()
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
self.otherThrobber.Start()
|
|
|
|
self.otherThrobber.Reverse()
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
def OnDestroy(self, event):
|
|
|
|
self.log.write("got destroy event")
|
|
|
|
event.Skip()
|
|
|
|
|
|
|
|
def OnStartAnimation(self, event):
|
|
|
|
for t in self.throbbers.keys():
|
|
|
|
self.throbbers[t]['throbber'].Start()
|
|
|
|
|
|
|
|
def OnStopAnimation(self, event):
|
|
|
|
for t in self.throbbers.keys():
|
|
|
|
self.throbbers[t]['throbber'].Rest()
|
|
|
|
|
|
|
|
def OnClickThrobber(self, event):
|
|
|
|
if self.otherThrobber.Running():
|
|
|
|
self.otherThrobber.Rest()
|
|
|
|
self.otherThrobber.SetLabel("Start")
|
|
|
|
else:
|
|
|
|
self.otherThrobber.Start()
|
|
|
|
self.otherThrobber.SetLabel("Stop")
|
|
|
|
|
|
|
|
def ShutdownDemo(self):
|
|
|
|
self.otherThrobber.Rest()
|
|
|
|
for t in self.throbbers.keys():
|
|
|
|
self.throbbers[t]['throbber'].Rest()
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
2004-11-01 19:39:09 +00:00
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
overview = """<html><body>
|
|
|
|
<h4><center>Throbber</center></h4>
|
|
|
|
<p>%s</p>
|
|
|
|
</body></html>
|
|
|
|
""" % docString
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|