Is there a way to make a label clickable?
Like a web link, but not using any web related stuff.
Hi,
Is there a way to make a label clickable?
Like a web link, but not using any web related stuff.
See:
1) wx.lib.agw.hyperlink
2) wx.HyperlinkCtrl
If you don't like what these 2 guys do, I believe you can just tweak
wx.lib.stattext to do what you want.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
···
On 13 March 2012 21:28, Tomás Acauan Schertel wrote:
Sure, just bind the mouse event:
wx.EVT_LEFT_DOWN(label, event_handler)
Should work...
Regards,
Dietmar
···
Am 13.03.2012 21:28, schrieb Tom�s Acauan Schertel:
Is there a way to make a label clickable?
Like a web link, but not using any web related stuff.
On some platforms, but not all. On wxGTK the StaticText is not a real widget so we're not always able to capture mouse events for it. (IIRC with some versions of GTK we can).
So if the OP doesn't want something that looks like a link like what you get with one of the hyperlink controls then the best bet is to use the generic static text widget in wx.lib.stattext as Andrea suggested and bind the mouse events to it like what you suggest.
···
On 3/13/12 2:30 PM, Dietmar Schwertberger wrote:
Am 13.03.2012 21:28, schrieb Tom�s Acauan Schertel:
Is there a way to make a label clickable?
Like a web link, but not using any web related stuff.Sure, just bind the mouse event:
wx.EVT_LEFT_DOWN(label, event_handler)
Should work...
--
Robin Dunn
Software Craftsman
Thanks all for your replies.
I really liked wx.HyperlinkCtrl, but it opens my default web browser.
What I really like is a web link alike, but opening a wx.dialog.
Hope I can make myself clear.
···
–
Tomás Schertel
Linux Registered User #304838
Arch Linux User
http://www.archlinux.org/
On Tue, Mar 13, 2012 at 19:09, Robin Dunn robin@alldunn.com wrote:
On 3/13/12 2:30 PM, Dietmar Schwertberger wrote:
Am 13.03.2012 21:28, schrieb Tomás Acauan Schertel:
Is there a way to make a label clickable?
Like a web link, but not using any web related stuff.
Sure, just bind the mouse event:wx.EVT_LEFT_DOWN(label, event_handler)
Should work…
On some platforms, but not all. On wxGTK the StaticText is not a real widget so we’re not always able to capture mouse events for it. (IIRC with some versions of GTK we can).
So if the OP doesn’t want something that looks like a link like what you get with one of the hyperlink controls then the best bet is to use the generic static text widget in wx.lib.stattext as Andrea suggested and bind the mouse events to it like what you suggest.
–
Robin Dunn
Software Craftsman
–
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
That is the default behavior. To do what you want you can just catch the EVT_HYPERLINK event and do what you need in that handler.
···
On 3/13/12 4:57 PM, Tom�s Acauan Schertel wrote:
Thanks all for your replies.
I really liked wx.HyperlinkCtrl, but it opens my default web browser.
What I really like is a web link alike, but opening a wx.dialog.
Hope I can make myself clear.
--
Robin Dunn
Software Craftsman
I’ve created a simple static text and used Bind to call a function. Like this:
text = wx.StaticText(id=-1, label=‘Click here’, parent=panel, pos=(2, 97), size=(60, 30), style=0)
self.Bind(wx.EVT_LEFT_DOWN, self.OnClick, text)
def OnClick(self, event):
print “Hi there”
But when I click on my text “Click here”, nothing happens.
What Am I doing wrong?
···
–
Tomás Schertel
Linux Registered User #304838
Arch Linux User
http://www.archlinux.org/
On Tue, Mar 13, 2012 at 21:19, Robin Dunn robin@alldunn.com wrote:
On 3/13/12 4:57 PM, Tomás Acauan Schertel wrote:
Thanks all for your replies.
I really liked wx.HyperlinkCtrl, but it opens my default web browser.
What I really like is a web link alike, but opening a wx.dialog.
Hope I can make myself clear.
That is the default behavior. To do what you want you can just catch the EVT_HYPERLINK event and do what you need in that handler.
–
Robin Dunn
Software Craftsman
–
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
Hi,
I've created a simple static text and used Bind to call a function. Like
this:text = wx.StaticText(id=-1, label='Click here', parent=panel, pos=(2, 97),
size=(60, 30), style=0)self.Bind(wx.EVT_LEFT_DOWN, self.OnClick, text)
def OnClick(self, event):
print "Hi there"But when I click on my text "Click here", nothing happens.
What Am I doing wrong?
Don't use the standard wx.StaticText (as Robin suggested already),
simply use wx.lib.stattext or one of the HyperlinkCtrl I suggested
before. Both solutions will work (for the second one you just need to
catch the EVT_HYPERLINK event and do whatever you need).
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
···
On 14 March 2012 04:42, Tomás Acauan Schertel wrote:
Thanks guys. I did it.
I used a wx.HyperlinkCtrl with bind, as you said.
···
–
Tomás Schertel
Linux Registered User #304838
Arch Linux User
http://www.archlinux.org/
On Wed, Mar 14, 2012 at 05:21, Andrea Gavana andrea.gavana@gmail.com wrote:
Hi,
On 14 March 2012 04:42, Tomás Acauan Schertel wrote:
I’ve created a simple static text and used Bind to call a function. Like
this:
text = wx.StaticText(id=-1, label=‘Click here’, parent=panel, pos=(2, 97),
size=(60, 30), style=0)
self.Bind(wx.EVT_LEFT_DOWN, self.OnClick, text)
def OnClick(self, event):
print "Hi there"
But when I click on my text “Click here”, nothing happens.
What Am I doing wrong?
Don’t use the standard wx.StaticText (as Robin suggested already),
simply use wx.lib.stattext or one of the HyperlinkCtrl I suggested
before. Both solutions will work (for the second one you just need to
catch the EVT_HYPERLINK event and do whatever you need).
Andrea.
“Imagination Is The Only Weapon In The War Against Reality.”
–
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
I see you're now using the HyperLinkCtrl but here is some info about why this didn't work for you. The mouse events are not command events, so they are only sent to the window where they happened and are not propagated up the parent chain. So in other words, the mouse events for text (if static texts on your platform and wx version are able to generate mouse events) will never be seen by self in your example above, only by text. So you need to bind the handler to text instead of self.
http://wiki.wxpython.org/self.Bind_vs._self.button.Bind
···
On 3/13/12 8:42 PM, Tom�s Acauan Schertel wrote:
I've created a simple static text and used Bind to call a function. Like
this:text = wx.StaticText(id=-1, label='Click here', parent=panel, pos=(2,
97), size=(60, 30), style=0)self.Bind(wx.EVT_LEFT_DOWN, self.OnClick, text)
def OnClick(self, event):
print "Hi there"But when I click on my text "Click here", nothing happens.
What Am I doing wrong?
--
Robin Dunn
Software Craftsman