-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathflet-spot.py
61 lines (49 loc) · 1.39 KB
/
flet-spot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Flet Metals Spot Kitco Prices by Hololeo
import flet
from flet import Page, Tab, Tabs, Image
import time
import threading
isRunning = False
def update_App():
global isRunning
update_tabs()
time.sleep (60)
update_App()
def getSilver():
return Image(src=f"https://www.kitco.com/images/live/silver.gif?ts={time.time()}")
def getGold():
return Image(src=f"https://www.kitco.com/images/live/gold.gif?ts={time.time()}")
def getPlatinum():
return Image(src=f"https://www.kitco.com/images/live/plati.gif?ts={time.time()}")
def tab_on_change (e):
update_tabs ()
def update_tabs ():
t = gPage.tabs
t.tabs[0].content = getGold()
t.tabs[1].content = getSilver()
t.tabs[2].content = getPlatinum()
t.update()
def buildTabs(page):
t = Tabs(
selected_index=1,
animation_duration=300,
tabs=[
Tab (text="Gold",content=getGold(),),
Tab (text="Silver",content=getSilver(),),
Tab (text="Platinum",content=getPlatinum(),),
],
expand=1,
on_change = tab_on_change
)
return t
def main(page: Page):
global gPage
gPage = page
page.title = "Flet Spot - Hololeo Labs"
page.tabs = buildTabs(page)
page.add(page.tabs)
page.update()
isRunning = True
th = threading.Thread (target=update_App, args={}, daemon=True)
th.start()
flet.app(target=main)