-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoperators.py
executable file
·34 lines (28 loc) · 1.17 KB
/
operators.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
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from system import CalculatorSystem
class OperatorsGrid(Gtk.Grid):
def __init__(self, display, calc_system):
Gtk.Grid.__init__(self)
self.calc_system = calc_system
self.column_homogeneous=True
self.display = display
self.operators_button = []
self.operators = ['+', '-', '*', '/']
self.create_operators_grid()
self.connect_operators()
def create_operators_grid(self):
for operator in self.operators:
self.operators_button.append(Gtk.Button(label='{}'.format(operator)))
for button in self.operators_button:
button.set_size_request(50, 25)
self.attach(self.operators_button[0], 0, 0, 6, 6)
self.attach(self.operators_button[1], 5, 0, 6, 6)
self.attach(self.operators_button[2], 0, 6, 5, 5)
self.attach(self.operators_button[3], 6, 6, 5, 5)
def connect_operators(self):
for button in self.operators_button:
button.connect('clicked', self.set_op)
def set_op(self, widget):
self.calc_system.set_operation(widget.get_label())