Hi
I'm having some trouble with my code. In my code, I've designed a frame with a checked box inside using wx.Frame and wx.CheckBox. I'm trying to allow users to decide whether they want to grayscale a list of images. If the user checks the box, wx.ProgressDialog is launched. All seems well, except the after theProgressDialog finishes, the frame does not close. I can't figure it out!!
Excerpt of the code below
Please advise
def grayscale_progress(path,imagelist):
app=wx.PySimpleApp()
dialog=wx.ProgressDialog("Grayscaling", "Progress", len(imagelist), style=
wx.PD_ESTIMATED_TIME
| wx.PD_REMAINING_TIME
| wx.PD_AUTO_HIDE)
count = 0
for num,images in enumerate(imagelist):
gray = Image.open(imagelist[num]).convert("L")
gray.save(os.path.join(path,images))
count += 1
dialog.Update(count)
wx.MilliSleep(500)
dialog.Destroy()
def check(path,imagelist):
app = wx.PySimpleApp()
frame=wx.Frame(None,-1,"Test",size=(250,150))
panel=wx.Panel(frame,-1)
label=wx.StaticText(panel,-1,"What to do next?",(35,20))
button=wx.Button(panel,-1,"Apply",(90,90))
gray=wx.CheckBox(panel,-1,"Gray",(35,40),(150,30))
def onclick(event):
if gray.GetValue():
grayscale_progress(path,imagelist)
frame.Destroy()
button.Bind(wx.EVT_BUTTON,onclick)
frame.Show()
app.MainLoop()