wxpython: handling URL event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nisyna
    New Member
    • Jul 2007
    • 8

    wxpython: handling URL event

    I have set an url property to a text in a RichTextCtrl :
    Code:
    	   self.obj.BeginURL('file:\\\%s'% str(i[0])) 
    	   self.obj.WriteText( '%s/%s/%s\n' % (_splittata[-3], _splittata[-2], _splittata[-1]) )
    	   self.obj.EndURL()
    now the text il linked but when I click on it nothing happens: I think I need to Bind an event to the RichTextCtrl but what event? I don't know what is the appropriate event!
    Please help me!
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by nisyna
    I have set an url property to a text in a RichTextCtrl :
    Code:
    	   self.obj.BeginURL('file:\\\%s'% str(i[0])) 
    	   self.obj.WriteText( '%s/%s/%s\n' % (_splittata[-3], _splittata[-2], _splittata[-1]) )
    	   self.obj.EndURL()
    now the text il linked but when I click on it nothing happens: I think I need to Bind an event to the RichTextCtrl but what event? I don't know what is the appropriate event!
    Please help me!
    You want to bind to the wx.EVT_TEXT_URL . Something like:
    Code:
            self.textCtrl1.Bind(wx.EVT_TEXT_URL, self.OnTextCtrl1TextUrl, id=wxID_PANEL1TEXTCTRL1)

    Comment

    • nisyna
      New Member
      • Jul 2007
      • 8

      #3
      I love you ;.) !!!!! Thank you so much...it works!

      another question:
      i've done that:[CODE=python]
      self.textbox.Bi nd(wx.EVT_TEXT_ URL,self.GoToUR L)
      [/CODE]
      then:
      [CODE=python]
      def GoToURL(self,ev ent):
      print event.
      [/CODE]
      how to get the URL from the event? I think it's something like event.URL()???
      thanks
      Last edited by bartonc; Jul 5 '07, 09:33 AM. Reason: Added [CODE=python][CODE] tags.

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by nisyna
        I love you ;.) !!!!! Thank you so much...it works!

        another question:
        i've done that:[CODE=python]
        self.textbox.Bi nd(wx.EVT_TEXT_ URL,self.GoToUR L)
        [/CODE]
        then:
        [CODE=python]
        def GoToURL(self,ev ent):
        print event.
        [CODE]
        how to get the URL from the event? I think it's something like event.URL()???
        thanks
        While I'm checking, please read this section of the Posting Guidelines to learn how to use code tags. Thanks.

        Comment

        • bartonc
          Recognized Expert Expert
          • Sep 2006
          • 6478

          #5
          Originally posted by bartonc
          While I'm checking, please read this section of the Posting Guidelines to learn how to use code tags. Thanks.
          It looks like[CODE=python]event.GetString ()[/CODE]is the one you want.

          Comment

          • nisyna
            New Member
            • Jul 2007
            • 8

            #6
            Originally posted by bartonc
            While I'm checking, please read this section of the Posting Guidelines to learn how to use code tags. Thanks.
            OK sorry and thank you!

            Comment

            Working...