Grouping Widgets on different panel to respond to parent.GetGrandParent().FindWindowByName

Thanks to Zetcode for the great tutorials on wxpthon, There is something that
captured my attention on the zetcode toturial on the lession of ListControl,
while giving a demo he showed a code that i didn't understand quite well
which is "parent.GetGrandParent().FindWindowByName", which behaved much fine
when a ListControl is clicked items corresponding to the clicked actions are
displayed on the right ListControl. Here are my question?

Suppose i have a group of widgets like wx.TextCtrl, wx.StaticText,
wx.Button, and much much more!!!, is there a way i can make them such that
they can be called by "parent.GetGrandParent().FindWindowByName"? and be
displayed on the other panel.

If it is not possible please reffer me to any other way which can accomplish
this, style used by zetcode to change item on different panel by
"parent.GetGrandParent().FindWindowByName"

Please try to see this Picture of My Application and you will now what i
mean, If you want the source code i will upload them for you, just 3 files.
ThANKS

<http://wxpython-users.1045709.n5.nabble.com/file/n5715562/RegisterCom.png>

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Grouping-Widgets-on-different-panel-to-respond-to-parent-GetGrandParent-FindWindowByName-tp5715562.html
Sent from the wxPython-users mailing list archive at Nabble.com.

I think you end up linking things too much together.

You might want to consider "pubsub" which is distributed with wxPython.

Werner

···

On 02/01/2013 18:26, want_learn1 wrote:

Thanks to Zetcode for the great tutorials on wxpthon, There is something that
captured my attention on the zetcode toturial on the lession of ListControl,
while giving a demo he showed a code that i didn't understand quite well
which is "parent.GetGrandParent().FindWindowByName", which behaved much fine
when a ListControl is clicked items corresponding to the clicked actions are
displayed on the right ListControl. Here are my question?

Suppose i have a group of widgets like wx.TextCtrl, wx.StaticText,
wx.Button, and much much more!!!, is there a way i can make them such that
they can be called by "parent.GetGrandParent().FindWindowByName"? and be
displayed on the other panel.

If it is not possible please reffer me to any other way which can accomplish
this, style used by zetcode to change item on different panel by
"parent.GetGrandParent().FindWindowByName"

Exactly. You need a publisher, an object that has two methods:
def publish(signal, *args) # used by the model
def subscribe(signal, handler) # used mostly in the initialization of the controller

wx.lib.pubsub (I’m not sure if this is the module) is an acepptable solution but it has problems with pyInstaller.

···

On Wednesday, January 2, 2013 7:02:24 PM UTC, werner wrote:

On 02/01/2013 18:26, want_learn1 wrote:

Thanks to Zetcode for the great tutorials on wxpthon, There is something that

captured my attention on the zetcode toturial on the lession of ListControl,

while giving a demo he showed a code that i didn’t understand quite well

which is “parent.GetGrandParent().FindWindowByName”, which behaved much fine

when a ListControl is clicked items corresponding to the clicked actions are

displayed on the right ListControl. Here are my question?

Suppose i have a group of widgets like wx.TextCtrl, wx.StaticText,

wx.Button, and much much more!!!, is there a way i can make them such that

they can be called by “parent.GetGrandParent().FindWindowByName”? and be

displayed on the other panel.

If it is not possible please reffer me to any other way which can accomplish

this, style used by zetcode to change item on different panel by

“parent.GetGrandParent().FindWindowByName”

I think you end up linking things too much together.

You might want to consider “pubsub” which is distributed with wxPython.

Werner

Thanks to Zetcode for the great tutorials on wxpthon, There is something that

captured my attention on the zetcode toturial on the lession of ListControl,

while giving a demo he showed a code that i didn’t understand quite well

which is “parent.GetGrandParent().FindWindowByName”, which behaved much fine

when a ListControl is clicked items corresponding to the clicked actions are

displayed on the right ListControl. Here are my question?

Suppose i have a group of widgets like wx.TextCtrl, wx.StaticText,

wx.Button, and much much more!!!, is there a way i can make them such that

they can be called by “parent.GetGrandParent().FindWindowByName”? and be

displayed on the other panel.

I think what you want to understand is how to communicate information from one panel to another, yes?

The simplest way is to name your objects like self.textCtrl, self.staticText, etc. Now they are all available in the frame’s namespace. So, for example (here “self” refers to the frame):

#Panels on left and right
self.left_panel = wx.Panel(parent=self)
self.right_panel = wx.Panel(parent=self)

#Text controls on left and right
self.textCtrl_left= wx.TextCtrl(parent=self.left_panel)
self.textCtrl_right= wx.TextCtrl(parent=self.right_panel)

#A button on rhe right
self.button_right = wx.Button(parent=self.right_panel,label=‘Press me’)

#Now bind that button
self.button_right.Bind(wx.EVT_BUTTON, self.OnButtonRight)

#In the event handler, you can pass things easily from right to left:

def OnButtonRight(self,event):

#get the text from the text control on the right...
value_of_right_textCtrl = self.textCtrl_right.GetValue()

#...and display it on the left:
self.textCtrl_left.SetValue(value_of_right_textCtrl)

There are other ways to pass information around, such as pubsub, as was mentioned. But this is simple and gets you started.

Che

···

On Wed, Jan 2, 2013 at 12:26 PM, want_learn1 wangolob@gmail.com wrote:

If it is not possible please reffer me to any other way which can accomplish

this, style used by zetcode to change item on different panel by

“parent.GetGrandParent().FindWindowByName”

Please try to see this Picture of My Application and you will now what i

mean, If you want the source code i will upload them for you, just 3 files.

ThANKS

<http://wxpython-users.1045709.n5.nabble.com/file/n5715562/RegisterCom.png>

View this message in context: http://wxpython-users.1045709.n5.nabble.com/Grouping-Widgets-on-different-panel-to-respond-to-parent-GetGrandParent-FindWindowByName-tp5715562.html

Sent from the wxPython-users mailing list archive at Nabble.com.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

What problems with pyInstaller?

I package it with py2exe and while there were problems they have been resolved in the latest version.

Werner

···

On 02/01/2013 20:13, Filipe Funenga wrote:

Exactly. You need a publisher, an object that has two methods:
    def publish(signal, *args) # used by the model
    def subscribe(signal, handler) # used mostly in the initialization of the controller

wx.lib.pubsub (I'm not sure if this is the module) is an acepptable solution but it has problems with pyInstaller.

Ok i understand that one let me try that method