Hello,
My program should display download progress (user interruptable)
So if user gets bored he can stop downloading by pressing button.
Dialog also shouldn't wait for user keypress if download is complete
Below is my ugly solution with defects:
- After dialog is closed program waits for some keypress.
How can i get rid of it?
Thanks in advance for any help.
cut here<<<<<<<<<<<<<<
from wxPython.wx import *
import wx
import time
···
#----------------------------------------------------------------------
class FetchUpgrade(wxDialog):
def __init__(self,parent):
wxDialog.__init__(self, parent, -1, "Example dialog", wxDefaultPosition, wxSize(350,200),wxRESIZE_BORDER | wxCAPTION | wxSYSTEM_MENU)
self.infomessage=wxStaticText(self, -1, "progress indicator",pos=wxPoint(48, 24), size=wxSize(91, 13))
self.progress= wxGauge(self, -1, 10, pos=wxPoint(32, 48), size=wxSize(248, 24),)
self.cancel=wxButton(self, 1000, ' Stop ', pos=wxPoint(120, 80), size=wxSize(75, 23))
EVT_BUTTON(self,1000,self.CancelButton)
def CancelButton(self,evt):
print "cancelling"
self.Close()
def ShowModal(self):
wx.CallAfter(self.RunFetch)
return wx.Dialog.ShowModal(self)
def Show(self):
wx.CallAfter(self.RunFetch)
return wx.Dialog.Show(self)
def RunFetch(self):
for i in xrange(1,self.progress.GetRange()+1):
time.sleep(0.1)
self.progress.SetValue(i)
print i
self.Close()
#----------------------------------------------------------------------
class Frame(wxFrame):
def __init__(self,parent, title):
wxFrame.__init__(self, None, -1, title, style= wxDEFAULT_FRAME_STYLE)
self.FetchUpgrade=FetchUpgrade(self)
self.FetchUpgrade.ShowModal()
self.Destroy()
dlg = wxMessageDialog(self, 'Upgrade Done!', 'A Message Box', wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
#----------------------------------------------------------------------
class MyApp(wxApp):
def OnInit(self):
frame = Frame(self,'appname')
frame.Show(true)
return true
#----------------------------------------------------------------------
myapp = MyApp(0)
myapp.MainLoop()
--
Igor.
mailto:igor@tyumbit.ru