-
Notifications
You must be signed in to change notification settings - Fork 0
/
squaring.py
30 lines (23 loc) · 833 Bytes
/
squaring.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
"""
CP1404 Week 11 Workshop - GUI program to square a number
Lindsay Ward, IT@JCU
13/10/2015
"""
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
__author__ = 'Lindsay Ward'
class SquareNumberApp(App):
""" SquareNumberApp is a Kivy App for squaring a number """
def build(self):
""" build the Kivy app from the kv file """
Window.size = (200, 100)
self.title = "Square Number"
self.root = Builder.load_file('squaring.kv')
return self.root
def handle_calculate(self):
""" handle calculation (could be button press or other call), output result to label widget """
value = float(self.root.ids.input_number.text)
result = value ** 2
self.root.ids.output_label.text = str(result)
SquareNumberApp().run()