[GRASSGUI] Re: python question - waiting for a variable to change
Michael Barton
michael.barton at asu.edu
Mon Mar 19 14:13:03 EDT 2007
Daniel,
Please excuse my novice ignorance. I guess I need a bit of clarification.
>> Is your response below related to such a work flow?
>
> Yes. The idea is:
>
> module A calls module B *and tells it what to do when closing*
>
> technically, you would have in A
>
> def do_the_rest( the_value_we_need ):
> do_it( the_value_we_need )
>
> moduleB.startplease( when_finished = do_the_rest )
I understand this and can add it to the LayerTree class in gismutils
>
> and module B has to a) accept this when_finished parameter in the
> startplease method and b) call it within the button pressed event. Stg
> like:
This is where I'm more fuzzy.
>
> def startplease( self, when_finished=None):
> self.onRunHook = when_finished
> ...
>
Is self.onRunHook an event handler method or a variable? Is it built in or
something I'd need to create?
This (and the button) are in module B. I don't understand what
self.onRunHook() is doing.
> def onRun(self, event):
> ...
> if self.onRunHook is not None:
> self.onRunHook() # run it
> ...
>
Sorry to be so dense.
Michael
>> It's the same idea as
>> launching a dialog and then invoking the ShowModal() method to wait until it
>> closes and capture what the dialog does. Does this need to be done via a
>> dialog only, or can it be emulated with a normal window?
>
> In wx you can have modal panels, so yes, you can build your own
> dialog-like window and set it to modal mode. You may grab the thuban
> sources and look at the classifier ui code for inspiration.
>
>> Michael
>
> Daniel.
>
>> On 3/19/07 9:24 AM, "Daniel Calvelo" <dca.gis at gmail.com> wrote:
>>
>>> You could make your callback function (the one you wish executed as
>>> the value is returned) a parameter to __init__ in menuform, that is
>>> called from within menuform.onRun if set to stg else than None. I
>>> think that is what you call a hook.
>>>
>>> You have to build something quite involved to have signaling objects
>>> behave like normal variables, AFAICT.
>>>
>>> Daniel.
>>>
>>> On 3/19/07, Michael Barton <michael.barton at asu.edu> wrote:
>>>>
>>>> I've run into a little problem that is taxing my neophyte Python
>>>> programming abilities. However we do a popup panel for setting display
>>>> layer
>>>> options, I think it is necessary to do something along the lines of the
>>>> following....
>>>>
>>>> 1. Start the options popup. This is currently done with a double click on
>>>> the layer, which calls the onActivate even handler. For a raster, the event
>>>> handler uses...
>>>> drastcmd = menuform.GUI().parseCommand('d.rast', gmpath)
>>>> ...to start the autogenerated GUI.
>>>>
>>>> 2. When you press the "run" button for this d.* command, the assembled
>>>> command (d.rast + options) is simply returned.
>>>>
>>>> 3. Now drastcmd should contain a complete d.rast command string.
>>>>
>>>> So, how do I wait in onActivate until the "run" button is pressed on the
>>>> popup and the information is returned to drastcmd (i.e., the value of
>>>> drastcmd is changed). Or, alternatively, how can a change in the value of
>>>> drastcmd generate an event that I can capture and process? I messed around
>>>> with wait() (thinking about tk_wait in TclTk), but couldn't get it to do
>>>> what I wanted.
>>>>
>>>>
>>>> Michael
>>>> __________________________________________
>>>> Michael Barton, Professor of Anthropology
>>>> School of Human Evolution & Social Change
>>>> Center for Social Dynamics & Complexity
>>>> Arizona State University
>>>>
>>>> phone: 480-965-6213
>>>> fax: 480-965-7671
>>>> www: http://www.public.asu.edu/~cmbarton
>>>>
>>>>
>>>
>>
>> __________________________________________
>> Michael Barton, Professor of Anthropology
>> School of Human Evolution & Social Change
>> Center for Social Dynamics & Complexity
>> Arizona State University
>>
>> phone: 480-965-6213
>> fax: 480-965-7671
>> www: http://www.public.asu.edu/~cmbarton
>>
>>
>>
>
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton
More information about the grass-gui
mailing list