#font.py
from kivy.app import App
from kivy.properties import StringProperty
from kivy.uix.widget import Widget
class Font(Widget):
digit = StringProperty("1")
num = 1
enable = False
def button_click(self):
if self.enable:
self.num += 1
self.digit = str(self.num)
def toggle(self, widget):
print("toggle state: " + widget.state)
if widget.state == "normal":
widget.text = "OFF"
self.enable = False
else:
widget.text = "ON"
self.enable = True
class FontApp(App):
pass
FontApp().run()
--------------------
#font.kv
Font:
BoxLayout:
size: root.width, root.height
ToggleButton:
text: "off"
on_state: root.toggle(self)
size_hint: None, 1
width: "100dp"
font_size: "70dp"
Button:
text: "Count"
on_press: root.button_click()
font_size: "70dp"
Label:
text: root.digit
font_name: "font/LCD.ttf"
font_size: "200dp"
reference:
No comments:
Post a Comment