WXpython Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gandalf

    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(p anel, 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
  • Mike Driscoll

    #2
    Re: WXpython Question

    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(p anel, 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(p anel, 15, "Hello" ,(30, 70) ,
    style=wx.ALIGN_ CENTRE)

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

    self.myText.Set Label("goodbye" )

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



    Mike

    Comment

    • Gandalf

      #3
      Re: WXpython Question

      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(p anel, 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(p anel, 15, "Hello" ,(30, 70) ,
      style=wx.ALIGN_ CENTRE)
      >
      Then you can change your text by adding this to your OnClick event
      handler:
      >
      self.myText.Set Label("goodbye" )
      >
      Have fun! And remember, there's a great wxPython mailing list too:
      >

      >
      Mike
      Thanks!

      Comment

      • David C. Ullrich

        #4
        Re: WXpython Question

        On Fri, 23 May 2008 06:40:13 -0700 (PDT), Gandalf <goldnery@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(p anel, 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(p anel, 15, "Hello" ,(30, 70) ,
        >style=wx.ALIGN _CENTRE)
        >>
        >Then you can change your text by adding this to your OnClick event
        >handler:
        >>
        >self.myText.Se tLabel("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

        Comment

        Working...