"Realtime" update on enter

Hi,

I have a notebook with x panels containing ListCtrls sitting in an AUI frame
Underneath the notebook I have another boxsizer w/ text ctrls, radios,
validators, ... I want to fill in 'real time', i.e. whenever some values
are entered in the ListCtrl Cells I want to update what is displayed on
the boxsizer's panel/ set the ctrls values and update ...

What would be the smartest way to do this?
I have some clumsy approach that works but produces a lot of overhead ...
Should I poll the values from the boxsizer panel's ctrls? Or rather
trigger some event whenever sthg is updated on a notebook panel? Is
there a 'global' approach to bind some update event to ALL my ctrls that
accept values?
I could not find any examples for such a thing so any suggestion, code
or personal experiece shared is highly appreciated.

ThanX

what about using pubsub? In your ListCtrl you fire an event when data is entered, that event does a pubsub.sendMessage and the controls interested in that value are doing a pubsub.subscribe.

In my app things work the "other way round", i.e. I fill listctrls from tables in my database and when I select an entry in the listctrl I use self.InitDialog which in turn fires the validators.TransferToWindow method for each control which is child of "self" (including grandchild etc etc). Or data is entered into my controls on when a button "save" is pressed I check if controls have all valid values and if yes save to database using validators.TransferFromWindow and do a refresh of the listctrl.

Was going to suggest validators but I am not sure that that would work for your use case.

Werner

···

On 10/05/2011 10:33 AM, Tobias Weber wrote:

Hi,

I have a notebook with x panels containing ListCtrls sitting in an AUI frame
Underneath the notebook I have another boxsizer w/ text ctrls, radios,
validators, ... I want to fill in 'real time', i.e. whenever some values
are entered in the ListCtrl Cells I want to update what is displayed on
the boxsizer's panel/ set the ctrls values and update ...

What would be the smartest way to do this?
I have some clumsy approach that works but produces a lot of overhead ...
Should I poll the values from the boxsizer panel's ctrls? Or rather
trigger some event whenever sthg is updated on a notebook panel? Is
there a 'global' approach to bind some update event to ALL my ctrls that
accept values?
I could not find any examples for such a thing so any suggestion, code
or personal experiece shared is highly appreciated.

Thank you Werner,

though it is working fine w/ pubsub I was playing around w/ validators
as well...
(understanding them is essential I guess)

My question:

Almost all examples use dialogs which automatically call
TransferFromWindow and TransferToWindow when opened and closed respectively.
I like the example (using a dialog) in the wx.Python in Action book,
which reads from the TextCtrl and writes to a dictionary under a given
key ...

Still, here is the question:

How do my validator and my reference to it have to look like in order to
get triggered when either a button is pressed or another panel in my
notebookCtrl is opened , ... , i.e. 'read all ctrl data (textCtrls and
listCtrls) and update the dictionary, ...'
Right now my validator class is triggered right when i open the panel w/
ctrls on it and i do not know how to get it to call a funtion, ... in my
validator class ...
Snippet attached.

ThanX

validator.py (1.18 KB)

···

Am 05.10.11 12:42, schrieb werner:

On 10/05/2011 10:33 AM, Tobias Weber wrote:

Hi,

I have a notebook with x panels containing ListCtrls sitting in an
AUI frame
Underneath the notebook I have another boxsizer w/ text ctrls, radios,
validators, ... I want to fill in 'real time', i.e. whenever some values
are entered in the ListCtrl Cells I want to update what is displayed on
the boxsizer's panel/ set the ctrls values and update ...

What would be the smartest way to do this?
I have some clumsy approach that works but produces a lot of overhead
...
Should I poll the values from the boxsizer panel's ctrls? Or rather
trigger some event whenever sthg is updated on a notebook panel? Is
there a 'global' approach to bind some update event to ALL my ctrls that
accept values?
I could not find any examples for such a thing so any suggestion, code
or personal experiece shared is highly appreciated.

what about using pubsub? In your ListCtrl you fire an event when data
is entered, that event does a pubsub.sendMessage and the controls
interested in that value are doing a pubsub.subscribe.

In my app things work the "other way round", i.e. I fill listctrls
from tables in my database and when I select an entry in the listctrl
I use self.InitDialog which in turn fires the
validators.TransferToWindow method for each control which is child of
"self" (including grandchild etc etc). Or data is entered into my
controls on when a button "save" is pressed I check if controls have
all valid values and if yes save to database using
validators.TransferFromWindow and do a refresh of the listctrl.

Was going to suggest validators but I am not sure that that would work
for your use case.

Werner

Hi Tobias,

Thank you Werner,

though it is working fine w/ pubsub I was playing around w/ validators
as well...
(understanding them is essential I guess)

My question:

Almost all examples use dialogs which automatically call
TransferFromWindow and TransferToWindow when opened and closed respectively.
I like the example (using a dialog) in the wx.Python in Action book,
which reads from the TextCtrl and writes to a dictionary under a given
key ...

Still, here is the question:

How do my validator and my reference to it have to look like in order to
get triggered when either a button is pressed or another panel in my
notebookCtrl is opened , ... , i.e. 'read all ctrl data (textCtrls and
listCtrls) and update the dictionary, ...'
Right now my validator class is triggered right when i open the panel w/
ctrls on it and i do not know how to get it to call a funtion, ... in my
validator class ...
Snippet attached.

BTW, I think most of us here on the list prefer bottom posting.

With regards to your problem, you need to make two changes.

1. have at least one key in your data dict;-) , data = {"CUSTOMER": 'some customer'}
2. then when you want to load data to the controls you call "self.InitDialog() - it is a wx.Window method so it is available in wx.Frame

You could also call "self.TransferDataToWindow()" and to get the data from the controls you call "self.TransferDataFromWindow()", you should also be aware of "self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY)"

See also:
http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.Window.html

Werner

···

On 10/07/2011 12:09 AM, Tobias Weber wrote: