-
I have a problem with import wx
from pyrx import Ap, command
@command
def doit():
frame = wx.Frame(None, title="Demo")
btn = wx.Button(frame, label="Click me")
def task():
with wx.ProgressDialog(
"Demo",
"Running...",
maximum=100,
parent=frame,
# parent=None,
style=wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE | wx.PD_APP_MODAL,
) as progress:
for i in range(101):
progress.Update(i, f"Progress: {i}%")
wx.MilliSleep(10)
btn.Bind(wx.EVT_BUTTON, lambda event: task())
frame.Show() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Wondering why you’re using a wxFrame instead of a wxDialog import wx
from pyrx import Ap, command
@command
def doit():
dlg = wx.Dialog(None, title="Demo")
btn = wx.Button(dlg, label="Click me")
def task():
with wx.ProgressDialog(
"Demo",
"Running...",
maximum=100,
parent=dlg,
# parent=None,
style=wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE | wx.PD_APP_MODAL,
) as progress:
for i in range(101):
progress.Update(i, f"Progress: {i}%")
wx.MilliSleep(10)
btn.Bind(wx.EVT_BUTTON, lambda event: task())
dlg.ShowModal() |
Beta Was this translation helpful? Give feedback.
-
import wx
from pyrx import command
@command
def doit():
frame = wx.Frame(None, title="Demo")
btn = wx.Button(frame, label="Click me")
def task():
with wx.ProgressDialog(
"Demo",
"Running...",
maximum=100,
parent=frame,
# parent=None,
style=wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE | wx.PD_APP_MODAL,
) as progress:
for i in range(101):
keep_going, _ = progress.Update(i, f"Progress: {i}%")
if not keep_going:
return
wx.MilliSleep(10)
btn.Bind(wx.EVT_BUTTON, lambda event: task())
frame.Show() |
Beta Was this translation helpful? Give feedback.
wx.YieldIfNeeded()
seems to help, I also fixed the assert mentioned above in the latest refresh build, though I need to test this moretry