The UI commands never update properly, but the print statement at the end executes *before* the first call to UI.DoFit. I put in the print statement to see of the entry was getting set but just not displaying. This is not the case: the print statement displays the prior contents of resultsFilename.
wx.CallAfter(UI.DoFit)
if i < 5:
wx.CallAfter(RepT100Script, UI, i+1)
That's my suggestion.
- Josiah
mike cantor <mcantor@stanford.edu> wrote:
> Hi all,
>
> I have a wxPython application which reads information from a bunch of
> controls and, upon, pressing of a button, runs a method from a C extension
> that uses this information. One part of the interface allows the user to
> run scripts which SetValue() a bunch of the controls to pre-set
> combinations and then call the C method, possibly multiple times. For example:
>
> def RepT100Script(UI):
> UI.SetSimParamFilename("PGParams-pulse.txt")
> UI.SetFitCircuitCheckboxes(["pRepT"])
>
> for i in range(5):
> UI.SetFitLogFilename("FitLog_SimRepT100_" + str(i+1))
> UI.SetFitResultsFilename = ("FitRes_SimRepT100_" + str(i+1))
> UI.DoFit() #The C extension
>
> UI is the main wx.frame object of the app and the "Set" methods above get
> passed into UI's child panels where they eventually call SetValue(...) on
> the various controls.
>
> Now to the wierd part: If I comment out UI.DoFit(), the controls are all
> updated correctly. But with UI.DoFit() included, The control updates
> don't happen and the C extension method starts firing off! I have tried
> shots in the dark, like placing combinations of sleep(5), wx.WakeUpIdle,
> and UI.Layout() before the DoFit line, but nothing seems to work.
>
> Any ideas?
>
> Thanks,
> -mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
<hate top-posting, but I don't want to reformat this whole thread either>
wx.CallAfter is a "delayed call" feature. The callable you pass in
will be called on the next run of the wx event loop (so of course an
immediate print won't show the updated values).
I suspect that your C extension is the problem and that it is doing
something unexpected and/or buggy.
For testing purposes, I'd suggest removing the loop and only working
with one at a time for now, and calling your C extension before you
update your controls.
···
On 1/27/06, mike cantor <mcantor@stanford.edu> wrote:
Thanks for the suggestion. Unfortunately that doesn't seem to do the trick
and leads to yet weirder behavior. With:
The UI commands never update properly, but the print statement at the end
executes *before* the first call to UI.DoFit. I put in the print statement
to see of the entry was getting set but just not displaying. This is not
the case: the print statement displays the prior contents of resultsFilename.
-mike
def RepT100Script(UI, i=1):
> UI.SetSimParamFilename("PGParams-pulse.txt")
> UI.SetFitCircuitCheckboxes(["pRepT"])
> UI.SetFitLogFilename("FitLog_SimRepT100_%i"%i)
> UI.SetFitResultsFilename = ("FitRes_SimRepT100_%i"%i)
>
> wx.CallAfter(UI.DoFit)
> if i < 5:
> wx.CallAfter(RepT100Script, UI, i+1)
>
>That's my suggestion.
>
> - Josiah
>
>mike cantor <mcantor@stanford.edu> wrote:
> > Hi all,
> >
> > I have a wxPython application which reads information from a bunch of
> > controls and, upon, pressing of a button, runs a method from a C extension
> > that uses this information. One part of the interface allows the user to
> > run scripts which SetValue() a bunch of the controls to pre-set
> > combinations and then call the C method, possibly multiple times. For
> example:
> >
> > def RepT100Script(UI):
> > UI.SetSimParamFilename("PGParams-pulse.txt")
> > UI.SetFitCircuitCheckboxes(["pRepT"])
> >
> > for i in range(5):
> > UI.SetFitLogFilename("FitLog_SimRepT100_" + str(i+1))
> > UI.SetFitResultsFilename = ("FitRes_SimRepT100_" + str(i+1))
> > UI.DoFit() #The C extension
> >
> > UI is the main wx.frame object of the app and the "Set" methods above get
> > passed into UI's child panels where they eventually call SetValue(...) on
> > the various controls.
> >
> > Now to the wierd part: If I comment out UI.DoFit(), the controls are all
> > updated correctly. But with UI.DoFit() included, The control updates
> > don't happen and the C extension method starts firing off! I have tried
> > shots in the dark, like placing combinations of sleep(5), wx.WakeUpIdle,
> > and UI.Layout() before the DoFit line, but nothing seems to work.
> >
> > Any ideas?
> >
> > Thanks,
> > -mike
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> > For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
I suspect that your C extension is the problem and that it is doing
something unexpected and/or buggy.
The problem is not the C extension or the loop -- , I took out the loop and commented out the C call (inserted a print statement in its place) and the problem remains (the print happens before the UI updates).
···
For testing purposes, I'd suggest removing the loop and only working
with one at a time for now, and calling your C extension before you
update your controls.
On 1/27/06, mike cantor <mcantor@stanford.edu> wrote:
> Thanks for the suggestion. Unfortunately that doesn't seem to do the trick
> and leads to yet weirder behavior. With:
>
> def FitSim_RepT100(UI, i = 1):
> UI.SetFitkSet("pTet")
> UI.SetFitParamFilename("FitCfg_OneSim.txt")
> UI.SetSimParamFilename("PGParams-pulse.txt")
> UI.SetFitLogFilename("FitLog_SimRepT100_" + str(i+1))
> UI.SetFitResultsFilename = ("FitRes_SimRepT100_" + str(i+1))
>
> wx.CallAfter(UI.DoFit)
> if i < 6:
> wx.CallAfter(FitSim_RepT100,UI, i+1)
>
> print "results filename entry value: " +UI.GetFitResultsFilename()
>
> The UI commands never update properly, but the print statement at the end
> executes *before* the first call to UI.DoFit. I put in the print statement
> to see of the entry was getting set but just not displaying. This is not
> the case: the print statement displays the prior contents of resultsFilename.
>
> -mike
>
> def RepT100Script(UI, i=1):
> > UI.SetSimParamFilename("PGParams-pulse.txt")
> > UI.SetFitCircuitCheckboxes(["pRepT"])
> > UI.SetFitLogFilename("FitLog_SimRepT100_%i"%i)
> > UI.SetFitResultsFilename = ("FitRes_SimRepT100_%i"%i)
> >
> > wx.CallAfter(UI.DoFit)
> > if i < 5:
> > wx.CallAfter(RepT100Script, UI, i+1)
> >
> >That's my suggestion.
> >
> > - Josiah
> >
> >mike cantor <mcantor@stanford.edu> wrote:
> > > Hi all,
> > >
> > > I have a wxPython application which reads information from a bunch of
> > > controls and, upon, pressing of a button, runs a method from a C extension
> > > that uses this information. One part of the interface allows the user to
> > > run scripts which SetValue() a bunch of the controls to pre-set
> > > combinations and then call the C method, possibly multiple times. For
> > example:
> > >
> > > def RepT100Script(UI):
> > > UI.SetSimParamFilename("PGParams-pulse.txt")
> > > UI.SetFitCircuitCheckboxes(["pRepT"])
> > >
> > > for i in range(5):
> > > UI.SetFitLogFilename("FitLog_SimRepT100_" + str(i+1))
> > > UI.SetFitResultsFilename = ("FitRes_SimRepT100_" + str(i+1))
> > > UI.DoFit() #The C extension
> > >
> > > UI is the main wx.frame object of the app and the "Set" methods above get
> > > passed into UI's child panels where they eventually call SetValue(...) on
> > > the various controls.
> > >
> > > Now to the wierd part: If I comment out UI.DoFit(), the controls are all
> > > updated correctly. But with UI.DoFit() included, The control updates
> > > don't happen and the C extension method starts firing off! I have tried
> > > shots in the dark, like placing combinations of sleep(5), wx.WakeUpIdle,
> > > and UI.Layout() before the DoFit line, but nothing seems to work.
> > >
> > > Any ideas?
> > >
> > > Thanks,
> > > -mike
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> > > For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
The UI commands never update properly, but the print statement at the end executes *before* the first call to UI.DoFit.
Because that is what wx.CallAfter does. It schedules a call to the function to happen after the current event handler has completed, so your print is going to happen before that does.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!