LinkLabel Proposal
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 9h 45m
- Merged PRs (30d)
- 58
Description
First of all I know that toga is not aimed to support widget primitives.
But there is already `Label` widget that serves for quite low level purposes:
- form inputs short description (like label in html)
- putting any text here or there (like paragraph in html (however there is need for MultiLineLabel https://github.com/beeware/toga/issues/766))
So I think it may be useful as useful is html tag.
`Label`-inherited POC for Winforms:
```python
from toga_winforms.libs import WinForms
from toga_winforms.widgets.label import Label as WinFormsLabel
class WinformsLinkLabel(WinFormsLabel):
def create(self):
self.native = WinForms.LinkLabel()
self.native.LinkClicked += WinForms.LinkLabelLinkClickedEventHandler(
self.interface._link_clicked
)
class LinkLabel(toga.Label):
def __init__(self, text, link=None, id=None, style=None, factory=None):
toga.Widget.__init__(self, id=id, style=style, factory=factory)
self._impl = WinformsLinkLabel(interface=self)
# self._impl = self.factory.Label(interface=self)
self.link = link
self.text = text
@property
def link(self):
if self._link is None:
return self.text
return self._link
@link.setter
def link(self, link):
self._link = link
def _link_clicked(self, el, _):
webbrowser.open(self.link)
```
My usecase: a dead simple GUI - with link to my repository. I wanted to avoid strange `Button` with URL inside (alternatively clickable github icon would be OK but not supported currently #774 outside of native commands palette), or create `Group` named "About" inside which will be "See on github" action, as it would be the only one command and on Windows it feels strange.
Contributor guide
Research direction
Start by reading the existing Label implementation and the WinForms POC in toga_winforms.widgets.label and toga_winforms.libs. Review the related MultiLineLabel issue (#766) and determine the intended cross-platform scope and API for a LinkLabel. Done means the proposal has an agreed design and implementation path across the supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100