question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LinkLabel Proposal

See original GitHub issue

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:

So I think it may be useful as useful is html tag.

Label-inherited POC for Winforms:

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:20 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
samschottcommented, Jul 8, 2020

The API doesn’t need to be that complex, though

Fair point. Also, there is yet another option: have a single text attribute and a text_format attribute which can be for instance “plain”, “html” or another markup language such as “markdown” if this should be supported in the future. This works around having two different properties that hold the displayed text while still preventing ambiguity.

I’ll look into stripping certain html tags. Python’s XML parser may have trouble with self-closing html tags.

1reaction
freakboy3742commented, Feb 3, 2020

That’s what I was afraid of - if we can’t get the size of the underlying text, then we can’t use the size of the text in layout calculations.

The HTMLLabel widget looks interesting. If I’m reading that right, it’s going back to basics - literally drawing all the component text. That seems slighly overkill under the circumstances, though.

In which case, having the Windows implementation be “concatenation of Winforms.Label” (and Winforms.LinkLabel, as needed) might be the easiest path forward.

As an aside/simplification, you should find that you can assign attributes directly, rather than invoking set_ methods - self.native.set_ReadOnly(True) should be equivalent to self.native.ReadOnly = True.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LinkLabel Class (System.Windows.Forms) | Microsoft Learn
Represents a Windows label control that can display hyperlinks. In this article. Definition; Examples; Remarks; Constructors; Properties; Methods; Events ...
Read more >
Press enter to click a LinkLabel - Stack Overflow
If I have a linklabel on a .net winform, is there anyway I can, when the link label is focused, get a press...
Read more >
LinkLabel Bluetooth Enabled Label Printer
LinkLabel Bluetooth Enabled Label Printer. Item#: LS3000-PRINTER. $4,334.40 $3,684.24. LinkLabel Bluetooth Enabled Label Printer quantity. Add to cart.
Read more >
Link Label Prediction in Signed Social Networks
We propose a matrix factorization based technique MF-LiSP that exhibits strong generalization guarantees. We also investigate the applicability of logistic ...
Read more >
A Robust Algorithm Based on Link Label Propagation for ...
Various methods have been proposed to identify the functional modules in PPI networks, but most of these methods do not consider the noisy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found