-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (28 loc) · 1.06 KB
/
main.py
File metadata and controls
33 lines (28 loc) · 1.06 KB
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
import curse
from tktarget import TkinterTarget, Component
@TkinterTarget.component
class Main(Component):
def get_initial_state(self):
return {
"count": 0,
"color": "#000000",
}
def render(self):
def increment():
self.set_state({
"count": self.state["count"] + 1,
})
def pick_color():
from tkinter import colorchooser
self.set_state({
"color": colorchooser.askcolor(title="Pick a color")[1],
})
return ᐸframeᐳ
ㅤㅤㅤㅤㅤᐸlabelㅤforegroundꘌײ(self.state.color),ײᐳCurrentㅤcountㅤisㅤ(self.state.count),ᐸ𐤕labelᐳ
ㅤㅤㅤㅤㅤᐸbuttonㅤcommandꘌײ(increment),ײᐳIncrementᐸ𐤕buttonᐳ
ㅤㅤㅤㅤㅤᐸbuttonㅤcommandꘌײ(pick_color),ײᐳChangeㅤtextㅤcolorᐸ𐤕buttonᐳ
ᐸ𐤕frameᐳ
if __name__ == "__main__":
# Prevents the window from running twice
hack_guard = ᐸnotag𐤕ᐳ
TkinterTarget.main().start()