Closed R-fred closed 3 years ago
You can use "template" column. This is a working example:
import pglet
from pglet import Grid, Columns, Column, Items, Item, SearchBox, Stack, Link, Html
class VideoItem2:
def __init__(self, title: str, publishedon: str, duration: str, link: str):
self.title = title
self.publishedon = publishedon
self.duration = duration
self.link = link
class VideoItem3:
def __init__(self, title: str, publishedon: str, duration: str, link: str):
self.title = title
self.publishedon = publishedon
self.duration = duration
self.link = link
class VideoItem4:
def __init__(self, title: str, publishedon: str, duration: str, link: str):
self.title = title
self.publishedon = publishedon
self.duration = duration
self.link = link
def main(page):
page.title = "Youtube downloader"
page.update()
page.add(Stack(width="80%", controls=[SearchBox(width=600, value="search")]))
page.add(Stack(width="80%", controls=[Grid(preserve_selection=True,
columns=[
Column(resizable=True, name="title", field_name="title", sortable=True),
Column(resizable=True, name="published on", field_name="publishedon"),
Column(resizable=True, name="duration", field_name="duration"),
Column(min_width=250, resizable=True, name="link", template_controls=[
Link(value='{link}', url='{link}', size='small')
])
],
items=[
VideoItem2(title="Google", duration="12:00", publishedon="20 years ago", link="http://www.google.com"),
VideoItem3(title="Apple", duration="11:00", publishedon="40 years ago", link="http://www.apple.com"),
VideoItem4(title="BBC", duration="13:00", publishedon="70 years ago", link="http://www.bbc.co.uk")
])
])
)
pglet.app(name="Youtube Downloader", local=False, target=main)
@FeodorFitsner, I tested it, works great thanks!
Cool, thanks for the update!
I tried using the code below to insert a link in an item in a Grid. The link does not show. I am guessing it only returns the link object rather than the link itself.
Adding the link separately worked as expected.
HTML output: