Skip to main content

Link

Link navigates to an external web page or initiate command within the app.

Examples​

Live demo

import pglet
from pglet import Link
with pglet.page("basic-links") as page:
page.add(
Link(url='http://google.com', value='Visit Google', new_window=True),
Link(value='Link without URL', size='large'),
Link(url='http://google.com', value='Disabled link', disabled=True))
import pglet
from pglet import Link, Text
with pglet.page("link-with-click-event") as page:

def link_clicked(e):
l.data += 1
t.value = f"Link clicked {l.data} time(s)"
page.update()

l = Link(value="Link with 'click' event", on_click=link_clicked, title='Click me!', data=0)
t = Text()

page.add(l, t)
input()
import pglet
from pglet import Link, Text, Icon, Button
with pglet.page("link-with-child-controls") as page:

from pglet import Text, Icon, Button
page.add(
Link(url='http://google.com', controls=[
Icon('Globe'),
Button('Action Button', action = True),
Text(' Link with child controls')
]))

Properties​

NameTypeDefaultDescription
valuestringLink text.
urlstringLink URL to navigate. If url is not specified the link will be firing click event.
newWindowboolfalseWhether to open link in a new browser window.
titlestringPopup hint for the link.
sizestringtiny, xSmall, small, smallPlus, medium, mediumPlus, large, xLarge, xxLarge, superLarge, mega
boldboolfalseWhether font weight is bold.
italicboolfalseWhether font style is italic.
preboolfalsePreformatted text in monospace font.
alignstringleftleft, center, right, justify

Events​

NameDescription
clickFires when a user clicks the link.

Child controls​

  • Any control - will be wrapped by the link.