Re: (wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-17 Thread Terry Carroll
Thanks to both kyosohma and 7stud for the suggestions.  I'll try
variations on the code suggested by 7stud, and follow up to the
wx-python list as kyosohma  suggested if I need more help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-16 Thread 7stud
On Sep 15, 5:25 pm, 7stud [EMAIL PROTECTED] wrote:
dialog.Destroy()
timer.Stop()

win.Show() #

You can also change that last line to win.Destroy(), and then the user
will never see the frame.

-- 
http://mail.python.org/mailman/listinfo/python-list


(wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-15 Thread Terry Carroll
I'm trying to use wx.ProgressBar, and the cancel button is not
responding.

Here is a simple program that exhibits the problem:

#
import  wx
import time

max = 10
app = wx.PySimpleApp()
dlg = wx.ProgressDialog(Progress dialog example,
   variables to be shown here,
   maximum = max,
   style = wx.PD_CAN_ABORT
| wx.PD_CAN_SKIP
#| wx.PD_APP_MODAL
| wx.PD_ELAPSED_TIME
| wx.PD_ESTIMATED_TIME
| wx.PD_REMAINING_TIME
)

keepGoing = True
skip = False
count = 0

while keepGoing and count  max:
count += 1
wx.MilliSleep(1000)
#time.sleep(1)
newtext = (before) count: %s, keepGoing: %s, skip: %s  % \
  (count, keepGoing, skip)
print newtext
(keepGoing, skip) = dlg.Update(count, newtext)
newtext = (after) count: %s, keepGoing: %s, skip: %s  % \
  (count, keepGoing, skip)
print newtext
dlg.Destroy()
#

The dialog looks right when this runs, but  

What's right: I get a progress bar;  it includes Skip and Cancel
buttons; it shows 10 seconds of progress, and updates once per second
with the variables' values on each iteration.

What's wrong is that I can't get clicking on the Skip or Cancel
buttons to have any effect.  Instead, as soon as the dialog displays,
I get an hourglass, and it doesn't matter what I click on.  Here's
what the print statements display, consistently, regardless of what I
try to click or whether I click nothing at all:

I:\pythontest1.py
(before) count: 1, keepGoing: True, skip: False
(after) count: 1, keepGoing: True, skip: False
(before) count: 2, keepGoing: True, skip: False
(after) count: 2, keepGoing: True, skip: True
(before) count: 3, keepGoing: True, skip: True
(after) count: 3, keepGoing: True, skip: True
(before) count: 4, keepGoing: True, skip: True
(after) count: 4, keepGoing: True, skip: True
(before) count: 5, keepGoing: True, skip: True
(after) count: 5, keepGoing: True, skip: True
(before) count: 6, keepGoing: True, skip: True
(after) count: 6, keepGoing: True, skip: True
(before) count: 7, keepGoing: True, skip: True
(after) count: 7, keepGoing: True, skip: True
(before) count: 8, keepGoing: True, skip: True
(after) count: 8, keepGoing: True, skip: True
(before) count: 9, keepGoing: True, skip: True
(after) count: 9, keepGoing: True, skip: True
(before) count: 10, keepGoing: True, skip: True
(after) count: 10, keepGoing: True, skip: True

Two oddities here: 

1) As I read the docs, the keepGoing variable should be set to True,
unless I click on Cancel, in which case it should be set to False
(which would end the loop).  That doesn't happen.  This is really what
I'm most concerned here with. 

2) The variable skip: set to False on the first iteration, and then
set to True on subsequent iterations?  Note that this happens even if
no buttons are selected.  This is just a weirdness to me, and not my
main concern, but I thought I'd mention it in case it's relevant.

You can see some variations in the commented-out code that I tried;
they did not help. 

Relevant software and releases:

OS: Windows XP Home Edition, Version 2002, SP2
Python: ActivePython 2.5.0.0
wxPython: 2.8.1.1 (msw-unicode)

Any help appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-15 Thread kyosohma
On Sep 15, 12:57 am, Terry Carroll [EMAIL PROTECTED] wrote:
 I'm trying to use wx.ProgressBar, and the cancel button is not
 responding.

 Here is a simple program that exhibits the problem:

 #
 import  wx
 import time

 max = 10
 app = wx.PySimpleApp()
 dlg = wx.ProgressDialog(Progress dialog example,
variables to be shown here,
maximum = max,
style = wx.PD_CAN_ABORT
 | wx.PD_CAN_SKIP
 #| wx.PD_APP_MODAL
 | wx.PD_ELAPSED_TIME
 | wx.PD_ESTIMATED_TIME
 | wx.PD_REMAINING_TIME
 )

 keepGoing = True
 skip = False
 count = 0

 while keepGoing and count  max:
 count += 1
 wx.MilliSleep(1000)
 #time.sleep(1)
 newtext = (before) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 (keepGoing, skip) = dlg.Update(count, newtext)
 newtext = (after) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 dlg.Destroy()
 #

 The dialog looks right when this runs, but

 What's right: I get a progress bar;  it includes Skip and Cancel
 buttons; it shows 10 seconds of progress, and updates once per second
 with the variables' values on each iteration.

 What's wrong is that I can't get clicking on the Skip or Cancel
 buttons to have any effect.  Instead, as soon as the dialog displays,
 I get an hourglass, and it doesn't matter what I click on.  Here's
 what the print statements display, consistently, regardless of what I
 try to click or whether I click nothing at all:

 I:\pythontest1.py
 (before) count: 1, keepGoing: True, skip: False
 (after) count: 1, keepGoing: True, skip: False
 (before) count: 2, keepGoing: True, skip: False
 (after) count: 2, keepGoing: True, skip: True
 (before) count: 3, keepGoing: True, skip: True
 (after) count: 3, keepGoing: True, skip: True
 (before) count: 4, keepGoing: True, skip: True
 (after) count: 4, keepGoing: True, skip: True
 (before) count: 5, keepGoing: True, skip: True
 (after) count: 5, keepGoing: True, skip: True
 (before) count: 6, keepGoing: True, skip: True
 (after) count: 6, keepGoing: True, skip: True
 (before) count: 7, keepGoing: True, skip: True
 (after) count: 7, keepGoing: True, skip: True
 (before) count: 8, keepGoing: True, skip: True
 (after) count: 8, keepGoing: True, skip: True
 (before) count: 9, keepGoing: True, skip: True
 (after) count: 9, keepGoing: True, skip: True
 (before) count: 10, keepGoing: True, skip: True
 (after) count: 10, keepGoing: True, skip: True

 Two oddities here:

 1) As I read the docs, the keepGoing variable should be set to True,
 unless I click on Cancel, in which case it should be set to False
 (which would end the loop).  That doesn't happen.  This is really what
 I'm most concerned here with.

 2) The variable skip: set to False on the first iteration, and then
 set to True on subsequent iterations?  Note that this happens even if
 no buttons are selected.  This is just a weirdness to me, and not my
 main concern, but I thought I'd mention it in case it's relevant.

 You can see some variations in the commented-out code that I tried;
 they did not help.

 Relevant software and releases:

 OS: Windows XP Home Edition, Version 2002, SP2
 Python: ActivePython 2.5.0.0
 wxPython: 2.8.1.1 (msw-unicode)

 Any help appreciated.

I'm not seeing the error either. The code looks very similar to the
example in the demo. Maybe you can look at it and see the difference?
The only thing I see is that the demo embeds the ProgressDialog into a
Panel object.

You should probably post this to the wxPython mailing group:
http://wxpython.org/maillist.php

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-15 Thread 7stud
On Sep 14, 11:57 pm, Terry Carroll [EMAIL PROTECTED] wrote:
 I'm trying to use wx.ProgressBar, and the cancel button is not
 responding.

 Here is a simple program that exhibits the problem:

 #
 import  wx
 import time

 max = 10
 app = wx.PySimpleApp()
 dlg = wx.ProgressDialog(Progress dialog example,
variables to be shown here,
maximum = max,
style = wx.PD_CAN_ABORT
 | wx.PD_CAN_SKIP
 #| wx.PD_APP_MODAL
 | wx.PD_ELAPSED_TIME
 | wx.PD_ESTIMATED_TIME
 | wx.PD_REMAINING_TIME
 )

 keepGoing = True
 skip = False
 count = 0

 while keepGoing and count  max:
 count += 1
 wx.MilliSleep(1000)
 #time.sleep(1)
 newtext = (before) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 (keepGoing, skip) = dlg.Update(count, newtext)
 newtext = (after) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 dlg.Destroy()
 #

 The dialog looks right when this runs, but  

 What's right: I get a progress bar;  it includes Skip and Cancel
 buttons; it shows 10 seconds of progress, and updates once per second
 with the variables' values on each iteration.

 What's wrong is that I can't get clicking on the Skip or Cancel
 buttons to have any effect.  Instead, as soon as the dialog displays,
 I get an hourglass, and it doesn't matter what I click on.  Here's
 what the print statements display, consistently, regardless of what I
 try to click or whether I click nothing at all:

 I:\pythontest1.py
 (before) count: 1, keepGoing: True, skip: False
 (after) count: 1, keepGoing: True, skip: False
 (before) count: 2, keepGoing: True, skip: False
 (after) count: 2, keepGoing: True, skip: True
 (before) count: 3, keepGoing: True, skip: True
 (after) count: 3, keepGoing: True, skip: True
 (before) count: 4, keepGoing: True, skip: True
 (after) count: 4, keepGoing: True, skip: True
 (before) count: 5, keepGoing: True, skip: True
 (after) count: 5, keepGoing: True, skip: True
 (before) count: 6, keepGoing: True, skip: True
 (after) count: 6, keepGoing: True, skip: True
 (before) count: 7, keepGoing: True, skip: True
 (after) count: 7, keepGoing: True, skip: True
 (before) count: 8, keepGoing: True, skip: True
 (after) count: 8, keepGoing: True, skip: True
 (before) count: 9, keepGoing: True, skip: True
 (after) count: 9, keepGoing: True, skip: True
 (before) count: 10, keepGoing: True, skip: True
 (after) count: 10, keepGoing: True, skip: True

 Two oddities here:

 1) As I read the docs, the keepGoing variable should be set to True,
 unless I click on Cancel, in which case it should be set to False
 (which would end the loop).  That doesn't happen.  This is really what
 I'm most concerned here with.

 2) The variable skip: set to False on the first iteration, and then
 set to True on subsequent iterations?  Note that this happens even if
 no buttons are selected.  This is just a weirdness to me, and not my
 main concern, but I thought I'd mention it in case it's relevant.

 You can see some variations in the commented-out code that I tried;
 they did not help.

 Relevant software and releases:

 OS: Windows XP Home Edition, Version 2002, SP2
 Python: ActivePython 2.5.0.0
 wxPython: 2.8.1.1 (msw-unicode)

 Any help appreciated.

Supposedly a progress dialog does not work well on its own because
events get screwed up when there isn't a main loop.  Try this:

import wx

app = wx.PySimpleApp()

win = wx.Frame(None, -1, Test Progress Dialog)
button = wx.Button(win, -1, start download)

def on_button_click(evt):
max = 10
dialog = wx.ProgressDialog(
Loading,
progress:,
max,
style = wx.PD_CAN_ABORT
|wx.PD_ELAPSED_TIME
|wx.PD_ESTIMATED_TIME
|wx.PD_REMAINING_TIME
)


keep_going = True
skip = False
count = 0
while keep_going and (count  max):
count += 1
wx.MilliSleep(1000)

(keep_going, skip) = dialog.Update(count)
print skip

dialog.Destroy()


button.Bind(wx.EVT_BUTTON, on_button_click)

win.Show()
app.MainLoop()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-15 Thread 7stud

Terry Carroll wrote:
 I'm trying to use wx.ProgressBar, and the cancel button is not
 responding.

 Here is a simple program that exhibits the problem:

 #
 import  wx
 import time

 max = 10
 app = wx.PySimpleApp()
 dlg = wx.ProgressDialog(Progress dialog example,
variables to be shown here,
maximum = max,
style = wx.PD_CAN_ABORT
 | wx.PD_CAN_SKIP
 #| wx.PD_APP_MODAL
 | wx.PD_ELAPSED_TIME
 | wx.PD_ESTIMATED_TIME
 | wx.PD_REMAINING_TIME
 )

 keepGoing = True
 skip = False
 count = 0

 while keepGoing and count  max:
 count += 1
 wx.MilliSleep(1000)
 #time.sleep(1)
 newtext = (before) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 (keepGoing, skip) = dlg.Update(count, newtext)
 newtext = (after) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 dlg.Destroy()
 #

 The dialog looks right when this runs, but

 What's right: I get a progress bar;  it includes Skip and Cancel
 buttons; it shows 10 seconds of progress, and updates once per second
 with the variables' values on each iteration.

 What's wrong is that I can't get clicking on the Skip or Cancel
 buttons to have any effect.  Instead, as soon as the dialog displays,
 I get an hourglass, and it doesn't matter what I click on.  Here's
 what the print statements display, consistently, regardless of what I
 try to click or whether I click nothing at all:

 I:\pythontest1.py
 (before) count: 1, keepGoing: True, skip: False
 (after) count: 1, keepGoing: True, skip: False
 (before) count: 2, keepGoing: True, skip: False
 (after) count: 2, keepGoing: True, skip: True
 (before) count: 3, keepGoing: True, skip: True
 (after) count: 3, keepGoing: True, skip: True
 (before) count: 4, keepGoing: True, skip: True
 (after) count: 4, keepGoing: True, skip: True
 (before) count: 5, keepGoing: True, skip: True
 (after) count: 5, keepGoing: True, skip: True
 (before) count: 6, keepGoing: True, skip: True
 (after) count: 6, keepGoing: True, skip: True
 (before) count: 7, keepGoing: True, skip: True
 (after) count: 7, keepGoing: True, skip: True
 (before) count: 8, keepGoing: True, skip: True
 (after) count: 8, keepGoing: True, skip: True
 (before) count: 9, keepGoing: True, skip: True
 (after) count: 9, keepGoing: True, skip: True
 (before) count: 10, keepGoing: True, skip: True
 (after) count: 10, keepGoing: True, skip: True

 Two oddities here:

 1) As I read the docs, the keepGoing variable should be set to True,
 unless I click on Cancel, in which case it should be set to False
 (which would end the loop).  That doesn't happen.  This is really what
 I'm most concerned here with.

 2) The variable skip: set to False on the first iteration, and then
 set to True on subsequent iterations?  Note that this happens even if
 no buttons are selected.  This is just a weirdness to me, and not my
 main concern, but I thought I'd mention it in case it's relevant.

 You can see some variations in the commented-out code that I tried;
 they did not help.

 Relevant software and releases:

 OS: Windows XP Home Edition, Version 2002, SP2
 Python: ActivePython 2.5.0.0
 wxPython: 2.8.1.1 (msw-unicode)

 Any help appreciated.

Or, if you want the progress dialog to start when your app starts--
rather than after a user clicks on a button--you can use a short
timer:

import wx

app = wx.PySimpleApp()

win = wx.Frame(None, -1, Test Progress Dialog)
timer = wx.Timer(win)
#win.Bind(wx.EVT_TIMER, on_timer_expiry, timer)

def on_timer_expiry(evt):
max = 10
dialog = wx.ProgressDialog(
Loading,
progress:,
max,
style = wx.PD_CAN_ABORT
|wx.PD_ELAPSED_TIME
|wx.PD_ESTIMATED_TIME
|wx.PD_REMAINING_TIME
)


keep_going = True
skip = False
count = 0
while keep_going and (count  max):
count += 1
wx.MilliSleep(1000)

(keep_going, skip) = dialog.Update(count)
print skip

dialog.Destroy()
timer.Stop()

win.Bind(wx.EVT_TIMER, on_timer_expiry, timer)
timer.Start(1000)

win.Show()
app.MainLoop()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-15 Thread 7stud
On Sep 14, 11:57 pm, Terry Carroll [EMAIL PROTECTED] wrote:
 I'm trying to use wx.ProgressBar, and the cancel button is not
 responding.

 Here is a simple program that exhibits the problem:

 #
 import  wx
 import time

 max = 10
 app = wx.PySimpleApp()
 dlg = wx.ProgressDialog(Progress dialog example,
variables to be shown here,
maximum = max,
style = wx.PD_CAN_ABORT
 | wx.PD_CAN_SKIP
 #| wx.PD_APP_MODAL
 | wx.PD_ELAPSED_TIME
 | wx.PD_ESTIMATED_TIME
 | wx.PD_REMAINING_TIME
 )

 keepGoing = True
 skip = False
 count = 0

 while keepGoing and count  max:
 count += 1
 wx.MilliSleep(1000)
 #time.sleep(1)
 newtext = (before) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 (keepGoing, skip) = dlg.Update(count, newtext)
 newtext = (after) count: %s, keepGoing: %s, skip: %s  % \
   (count, keepGoing, skip)
 print newtext
 dlg.Destroy()
 #

 The dialog looks right when this runs, but  

 What's right: I get a progress bar;  it includes Skip and Cancel
 buttons; it shows 10 seconds of progress, and updates once per second
 with the variables' values on each iteration.

 What's wrong is that I can't get clicking on the Skip or Cancel
 buttons to have any effect.  Instead, as soon as the dialog displays,
 I get an hourglass, and it doesn't matter what I click on.  Here's
 what the print statements display, consistently, regardless of what I
 try to click or whether I click nothing at all:

 I:\pythontest1.py
 (before) count: 1, keepGoing: True, skip: False
 (after) count: 1, keepGoing: True, skip: False
 (before) count: 2, keepGoing: True, skip: False
 (after) count: 2, keepGoing: True, skip: True
 (before) count: 3, keepGoing: True, skip: True
 (after) count: 3, keepGoing: True, skip: True
 (before) count: 4, keepGoing: True, skip: True
 (after) count: 4, keepGoing: True, skip: True
 (before) count: 5, keepGoing: True, skip: True
 (after) count: 5, keepGoing: True, skip: True
 (before) count: 6, keepGoing: True, skip: True
 (after) count: 6, keepGoing: True, skip: True
 (before) count: 7, keepGoing: True, skip: True
 (after) count: 7, keepGoing: True, skip: True
 (before) count: 8, keepGoing: True, skip: True
 (after) count: 8, keepGoing: True, skip: True
 (before) count: 9, keepGoing: True, skip: True
 (after) count: 9, keepGoing: True, skip: True
 (before) count: 10, keepGoing: True, skip: True
 (after) count: 10, keepGoing: True, skip: True

 Two oddities here:

 1) As I read the docs, the keepGoing variable should be set to True,
 unless I click on Cancel, in which case it should be set to False
 (which would end the loop).  That doesn't happen.  This is really what
 I'm most concerned here with.

 2) The variable skip: set to False on the first iteration, and then
 set to True on subsequent iterations?  Note that this happens even if
 no buttons are selected.  This is just a weirdness to me, and not my
 main concern, but I thought I'd mention it in case it's relevant.

 You can see some variations in the commented-out code that I tried;
 they did not help.

 Relevant software and releases:

 OS: Windows XP Home Edition, Version 2002, SP2
 Python: ActivePython 2.5.0.0
 wxPython: 2.8.1.1 (msw-unicode)

 Any help appreciated.

And here's a version that hides the frame and shows it only after the
progress dialog has finished or been cancelled:

import wx

app = wx.PySimpleApp()

win = wx.Frame(None, -1, Test Progress Dialog)
timer = wx.Timer(win)
#win.Bind(wx.EVT_TIMER, on_timer_expiry, timer)

def on_timer_expiry(evt):
max = 10
dialog = wx.ProgressDialog(
Loading,
progress:,
max,
style = wx.PD_CAN_ABORT
|wx.PD_CAN_SKIP
|wx.PD_ELAPSED_TIME
|wx.PD_ESTIMATED_TIME
|wx.PD_REMAINING_TIME
)


keep_going = True
skip = False
count = 0
while keep_going and (count  max):
count += 1
wx.MilliSleep(1000)

(keep_going, skip) = dialog.Update(count)
print skip

dialog.Destroy()
timer.Stop()

win.Show() #



win.Bind(wx.EVT_TIMER, on_timer_expiry, timer)
timer.Start(1000)

#win.Show()
app.MainLoop()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (wxPython) wx.ProgressDialog - how to cancel out of?

2007-09-15 Thread 7stud
Terry Carroll wrote:

 2) The variable skip: set to False on the first iteration, and then
 set to True on subsequent iterations?  Note that this happens even if
 no buttons are selected.  This is just a weirdness to me, and not my
 main concern, but I thought I'd mention it in case it's relevant.


The docs say:

wx.PD_CAN_SKIP
This flag tells the dialog that it should have a Skip button which
the user may press. If this happens, the next call to Update() will
return True in the second component of its return value.

What I'm seeing is: the second item in the tuple returned by Update()
is False if the skip button wasn't clicked and it's True for one
return value when the skip button was clicked, then the value reverts
back to False when Update() returns the next time.

-- 
http://mail.python.org/mailman/listinfo/python-list