468,241 Members | 1,465 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,241 developers. It's quick & easy.

WXpython Question

I try to reach a specific wx StaticText element's text and to change
it by clicking on a button
now let's say the this is my element:

wx.StaticText(panel, 15, "Hello" ,(30, 70) , style=wx.ALIGN_CENTRE)
And this is my EVT_BUTTON bind function :

def OnClick(event):

which code shude i enter to change "hello" to "goodbay"?

thanks
Jun 27 '08 #1
3 908
On May 23, 8:24*am, Gandalf <goldn...@gmail.comwrote:
I try to reach a specific wx StaticText element's text and to change
it by clicking on a button

now let's say the this is my element:

wx.StaticText(panel, 15, "Hello" ,(30, 70) , style=wx.ALIGN_CENTRE)

And this is my EVT_BUTTON bind function :

def OnClick(event):

which code shude i enter to change "hello" to "goodbay"?

thanks

You're probably looking for SetLabel(). So if you do something like
this to instantiate the StaticText:

self.myText = wx.StaticText(panel, 15, "Hello" ,(30, 70) ,
style=wx.ALIGN_CENTRE)

Then you can change your text by adding this to your OnClick event
handler:

self.myText.SetLabel("goodbye")

Have fun! And remember, there's a great wxPython mailing list too:

http://www.wxpython.org/maillist.php

Mike
Jun 27 '08 #2
On May 23, 3:29 pm, Mike Driscoll <kyoso...@gmail.comwrote:
On May 23, 8:24 am, Gandalf <goldn...@gmail.comwrote:
I try to reach a specific wx StaticText element's text and to change
it by clicking on a button
now let's say the this is my element:
wx.StaticText(panel, 15, "Hello" ,(30, 70) , style=wx.ALIGN_CENTRE)
And this is my EVT_BUTTON bind function :
def OnClick(event):
which code shude i enter to change "hello" to "goodbay"?
thanks

You're probably looking for SetLabel(). So if you do something like
this to instantiate the StaticText:

self.myText = wx.StaticText(panel, 15, "Hello" ,(30, 70) ,
style=wx.ALIGN_CENTRE)

Then you can change your text by adding this to your OnClick event
handler:

self.myText.SetLabel("goodbye")

Have fun! And remember, there's a great wxPython mailing list too:

http://www.wxpython.org/maillist.php

Mike
Thanks!
Jun 27 '08 #3
On Fri, 23 May 2008 06:40:13 -0700 (PDT), Gandalf <go******@gmail.com>
wrote:
>On May 23, 3:29 pm, Mike Driscoll <kyoso...@gmail.comwrote:
>On May 23, 8:24 am, Gandalf <goldn...@gmail.comwrote:
I try to reach a specific wx StaticText element's text and to change
it by clicking on a button
now let's say the this is my element:
wx.StaticText(panel, 15, "Hello" ,(30, 70) , style=wx.ALIGN_CENTRE)
And this is my EVT_BUTTON bind function :
def OnClick(event):
which code shude i enter to change "hello" to "goodbay"?
thanks

You're probably looking for SetLabel(). So if you do something like
this to instantiate the StaticText:

self.myText = wx.StaticText(panel, 15, "Hello" ,(30, 70) ,
style=wx.ALIGN_CENTRE)

Then you can change your text by adding this to your OnClick event
handler:

self.myText.SetLabel("goodbye")

Have fun! And remember, there's a great wxPython mailing list too:

http://www.wxpython.org/maillist.php

Mike

Thanks!
You should also note

docs.wxwidgets.org

(I tend to find that by googling "wxTreeCtrl" or whatever.)
The descriptions of various components there are more
complete than in the (excellent!) wxPython book - it's
C++ but usually not hard to figure out what the corresponding
wxPython should be.

David C. Ullrich
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Anand | last post: by
3 posts views Thread by Equis Uno | last post: by
8 posts views Thread by Erik Johnson | last post: by
14 posts views Thread by Rod W | last post: by
1 post views Thread by Steven W. Orr | last post: by
reply views Thread by gooli | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.