[Tutor] Problems with Gauge Bar.
Olrik Lenstra
o.lenstra at gmail.com
Thu Aug 21 18:27:13 CEST 2008
Follow-up on this question.
I tried something (Posted below) but it doesn't work.
Here it is.
<<<<<
import wx
import os, sys
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
wx.Size(300, 250),
style = wx.DEFAULT_FRAME_STYLE & ~
(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
panel = wx.Panel(self, -1)
wx.Gauge(panel, -1, 50, (50, 30), (200, 20))
wx.Button(panel, 1, 'Scan!', (115, 90))
wx.Button(panel, 2, 'Logs', (115, 120))
wx.Button(panel, 3, 'Version', (115, 150))
wx.Button(panel, 4, 'Credits', (115, 180))
self.Bind(wx.EVT_BUTTON, self.onScan, id=1)
## self.Bind(wx.EVT_BUTTON, self.onLogs, id=2)
## self.Bind(wx.EVT_BUTTON, self.onVersion, id=3)
## self.Bind(wx.EVT_BUTTON, self.onCredits, id=4)
def onScan(self, event):
self.myfile = open('foo.txt')
self.count = 0
self.setTimer(0.01, self.processLine)
def processLine(self):
line = self.myfile.readline()
if line:
processLine(line)
self.count += 1
self.myGauge.setValue(count)
self.setTimer(0.01, self.processLine)
else:
self.myGuage.setValue(0)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'Troubleshooting Olrik')
frame.Show(True)
frame.Center()
return True
def main():
app = MyApp(0)
app.MainLoop()
if __name__ == '__main__':
main()
>>>>>
I'm not sure what I'm doing wrong.
Regards,
Olrik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080821/f19fbb9b/attachment.htm>
More information about the Tutor
mailing list