Animating wx.TextCtrl and Inserting a hyperlink

255 views
Skip to first unread message

austin aigbe

unread,
Dec 13, 2015, 9:43:33 AM12/13/15
to wxPython-users
Hello,

I am trying to port the Synfig UI (i.e synfig-studio) to wxPython.

For the AboutBox GUI, I noticed that GTK has some very cool features (e.g hyperlink in a text control, text control is able to glide upwards when you click a button to display it)
However, I have been able to create my own wx AboutDialog with all the features offered by the GTK equivalent. The only thing left are the animated license and credit text boxes and the hyperlink in the text box.

I don't want to use the wx html Window. Is there a way of including a hyperlink in a TextCtrl?

Secondly, how can I animate the TextCtrl to glide up when it is displayed?

Thirdly, how can I animate the text to scroll up in the wx.TextCtrl? 

Code attached with screen shot of what I am trying to achieve. You might have to download Synfig (http://www.synfig.org/cms/) to see the animated credits and license text boxes of the About Synfig Studio  widget.


Thanks.

Regards,
Austin
synfig-gtk-original-version.PNG
synfig-wxpy-version.PNG
synfig_icon.png
dialog_test.py
synfig_icon.ico

Mike Driscoll

unread,
Dec 15, 2015, 10:03:37 AM12/15/15
to wxPython-users

The regular text control widget doesn't really support hyperlinks, but the RichTextCtrl does. The TextCtrl does have a rich text mode, but I couldn't find any information about whether it had support for hyperlinks. I don't know how to get the animations you want. But one of the other guys on the list might.

Mike

Dev Player

unread,
Jan 12, 2016, 10:44:20 AM1/12/16
to wxpython-users
Check out the FloatCanvas in the wx Demo. Here is an old post: 

austin aigbe

unread,
Jan 13, 2016, 11:03:35 AM1/13/16
to wxpytho...@googlegroups.com
What I actually want is for the TextCtrl widget itself to scroll up while displaying.

I am not interested in animating the text in the TextCtrl. I want to animate the TextCtrl widget to appear gradually from bottom to top.

Thanks.

On Tue, Jan 12, 2016 at 4:44 PM, Dev Player <devp...@gmail.com> wrote:
Check out the FloatCanvas in the wx Demo. Here is an old post: 

--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/Rs0ASUzidGk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

DevPlayer

unread,
Jan 17, 2016, 3:51:16 AM1/17/16
to wxPython-users
Perhaps this is a starting point:


austin aigbe

unread,
Jan 17, 2016, 6:26:48 AM1/17/16
to wxpytho...@googlegroups.com
Thanks. Exactly what I was looking for.

On Sun, Jan 17, 2016 at 9:51 AM, DevPlayer <devp...@gmail.com> wrote:
Perhaps this is a starting point:


C M

unread,
Jan 17, 2016, 12:19:05 PM1/17/16
to wxpytho...@googlegroups.com
On Wed, Jan 13, 2016 at 11:03 AM, austin aigbe <eshi...@gmail.com> wrote:
What I actually want is for the TextCtrl widget itself to scroll up while displaying.

I am not interested in animating the text in the TextCtrl. I want to animate the TextCtrl widget to appear gradually from bottom to top.

I see you got your answer, but it occurs to me to ask: why do you want this? Offhand, I don't see the UX benefit of this effect. For what it's worth, I myself have never liked a part of a screen I am trying to read that is moving on its own (and I've read similar critiques on forums).
 

Metallicow

unread,
Jan 18, 2016, 4:06:43 AM1/18/16
to wxPython-users


Sure it does. On windows mostly I believe. I think somehow it works with linux gtk.

        self.gTextCtrl = tc = wx.TextCtrl(self, wx.ID_ANY, '',
                                          style
=wx.BORDER_SUNKEN |
                                                wx
.TE_MULTILINE |
                                                wx
.TE_NOHIDESEL |
                                                wx
.TE_RICH2 | wx.TE_AUTO_URL |
                                                wx
.TE_READONLY
                                               
)
       
# In case user for example creates the dialog then sets the font
       
# on the dialog or the textctrl(maybe the user needs a mono font...)
       
# we need to update the message so the auto url shows up and works right.
       
# so we will override SetFont.
        tc
.SetFont = self.SetFont
        tc
.SetValue(message)  # Update AutoURL after creation.
        tc
.Bind(wx.EVT_TEXT_URL, self.OnTextURL)
        tc
.SetHelpText(_(u'This is the scrolled message dialog text.'))

   
def SetFont(self, font):
       
"""
        Sets the font for this window.

        SetFont(self, Font font) -> bool

        :param `font`:
        :type `font`: `wx.Font`
        :returns: Whether the font was successfully set.
        :rtype: bool
        """

       
print(self)
       
boolean = super(wx.TextCtrl, self.gTextCtrl).SetFont(font)
       
self.gTextCtrl.SetValue(self.gTextCtrl.GetValue())
       
return boolean

   
def OnTextURL(self, event):
       
"""
        Handles the ``wx.EVT_TEXT_URL`` event for :attr:`gTextCtrl`

        :param `event`: A `wx.TextURLEvent` to be processed.
        :type `event`: `wx.TextURLEvent`
        """

        mouseEvent
= event.GetMouseEvent()
       
if mouseEvent.LeftDClick():
            urlStart
= event.GetURLStart()
            urlEnd
= event.GetURLEnd()
            url
= self.gTextCtrl.GetRange(urlStart, urlEnd)
            webbrowser
.open_new_tab(url)



 
Reply all
Reply to author
Forward
0 new messages