-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
86 lines (70 loc) · 2.49 KB
/
gui.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder
from kivy.config import Config
from kivymd.app import MDApp
from kivy.animation import Animation
from kivy.graphics import Color, Line
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from math import cos, sin, pi
from kivy.clock import Clock
import time
import datetime
from kivy.properties import StringProperty, NumericProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
Builder.load_file('clock.kv')
# class Ticks(Widget):
# def __init__(self, **kwargs):
# super(Ticks, self).__init__(**kwargs)
# self.bind(pos=self.update_clock)
# self.bind(size=self.update_clock)
#
# def update_clock(self, *args):
# self.canvas.clear()
# with self.canvas:
# time = datetime.datetime.now()
# Color(0.2, 0.5, 0.2)
# Line(points=[self.center_x, self.center_y, self.center_x+0.8*self.r*sin(pi/30*time.second), self.center_y+0.8*self.r*cos(pi/30*time.second)], width=1, cap="round")
# Color(0.3, 0.6, 0.3)
# Line(points=[self.center_x, self.center_y, self.center_x+0.7*self.r*sin(pi/30*time.minute), self.center_y+0.7*self.r*cos(pi/30*time.minute)], width=2, cap="round")
# Color(0.4, 0.7, 0.4)
# th = time.hour*60 + time.minute
# Line(points=[self.center_x, self.center_y, self.center_x+0.5*self.r*sin(pi/360*th), self.center_y+0.5*self.r*cos(pi/360*th)], width=3, cap="round")
#
#
class MyLayout(BoxLayout):
your_time = StringProperty()
def __init__(self, **kwargs):
super(MyLayout, self).__init__(**kwargs)
self.orientation = "vertical"
self.padding = 10
Clock.schedule_interval(self.set_time, 0.1)
def build(self):
ScreenManager().add_widget(MenuScreen(name='menu'))
ScreenManager().add_widget(BataryaScreen(name='batarya'))
def set_time(self, dt):
self.your_time = time.strftime("%d/%m/%Y %H:%M")
class Gui(App):
def build(self):
return MyLayout()
class MenuScreen(Screen):
pass
class BataryaScreen(Screen):
pass
#
# class MyClockWidget(FloatLayout):
# pass
#
# class MyClockApp(App):
# def build(self):
# clock = MyClockWidget()
# Clock.schedule_interval(clock.ticks.update_clock, 1)
# return clock
#
#
# if __name__ == '__main__':
# MyClockApp().run()
if __name__ == "__main__":
Gui().run()