Skip to content

Commit

Permalink
Add a link_activated event to Label
Browse files Browse the repository at this point in the history
  • Loading branch information
sccolbert committed May 30, 2013
1 parent e8d994c commit 269b386
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions enaml/qt/qt_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ def init_widget(self):
self.set_text(d.text, sh_guard=False)
self.set_align(d.align)
self.set_vertical_align(d.vertical_align)
self.widget.linkActivated.connect(self.on_link_activated)

#--------------------------------------------------------------------------
# Signal Handlers
#--------------------------------------------------------------------------
def on_link_activated(self, link):
""" Handle the link activated signal.
"""
self.declaration.link_activated(link)

#--------------------------------------------------------------------------
# ProxyLabel API
Expand Down
8 changes: 7 additions & 1 deletion enaml/widgets/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#------------------------------------------------------------------------------
from atom.api import Typed, ForwardTyped, Unicode, Enum, observe, set_default
from atom.api import (
Typed, ForwardTyped, Unicode, Enum, Event, observe, set_default
)

from enaml.core.declarative import d_

Expand Down Expand Up @@ -42,6 +44,10 @@ class Label(Control):
#: The vertical alignment of the text in the widget area.
vertical_align = d_(Enum('center', 'top', 'bottom'))

#: An event emitted when the user clicks a link in the label.
#: The payload will be the link that was clicked.
link_activated = d_(Event(), writable=False)

#: Labels hug their width weakly by default.
hug_width = set_default('weak')

Expand Down

0 comments on commit 269b386

Please sign in to comment.