-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyGUI.py
117 lines (97 loc) · 3.26 KB
/
pyGUI.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from mttkinter import *
import tktable
class PyGUI:
def __init__(self, version):
self.root = mtTkinter.Tk(className='FOECLIGBCalculator')
self.root.title(version+' FOE CLI GB Calculator')
self.root.geometry("250x350")
self.version = version
self.gbTitle = mtTkinter.StringVar()
self.gbOwnerName = mtTkinter.StringVar()
self.remainingFPs = mtTkinter.StringVar()
self.investText = mtTkinter.StringVar()
self.profitText = mtTkinter.StringVar()
self.warningText = mtTkinter.StringVar()
self.tableArray = tktable.ArrayVar(self.root)
self.Table = tktable.Table(self.root,
state='disabled',
titlerows=1,
rows=6,
cols=3,
variable=self.tableArray,
flashmode='on')
self.createWindow()
def updateVal(self, field, val):
if field == "gbTitle":
self.gbTitle.set(val.encode('utf8'))
if field == "gbOwnerName":
self.gbOwnerName.set(val.encode('utf8'))
if field == "remainingFPs":
self.remainingFPs.set(val)
if field == "profitText":
self.profitText.set(val)
if field == "investText":
self.investText.set(val)
if field == "warningText":
self.warningText.set(val)
if field == "table":
self.updateTable(val)
def updateTable(self, val):
columns = ['#','Cost','Difference']
row_count=0
col_count=0
#SETTING COLUMNS
for col in columns:
index = "%i,%i" % (row_count,col_count)
self.tableArray[index] = col
col_count+=1
row_count=1
col_count=0
#SETTING DATA IN ROWS
for row in val:
color = 'reset'
for item in row:
index = "%i,%i" % (row_count,col_count)
## PLACING THE VALUE IN THE INDEX CELL POSITION ##
self.tableArray[index] = item
if item == "LOCKED":
color = 'red'
if col_count == 2 and isinstance(item, int) and int(item) > 0 and color == 'reset':
color = 'green'
if col_count == 1 and item == "SAFE":
color = 'yellow'
self.Table.tag_cell(color, "%i,%i" % (row_count,0))
self.Table.tag_cell(color, "%i,%i" % (row_count,1))
self.Table.tag_cell(color, "%i,%i" % (row_count,2))
col_count+=1
col_count=0
row_count+=1
def createWindow(self):
lb_gbTitle = mtTkinter.Label(self.root, textvariable=self.gbTitle, wraplength=240)
lb_gbTitle.pack(side='top', fill='x')
lb_gbOwnerName = mtTkinter.Label(self.root, textvariable=self.gbOwnerName, wraplength=240)
lb_gbOwnerName.pack()
values = [['1','-','-'],
['2','-','-'],
['3','-','-'],
['4','-','-'],
['5','-','-']]
self.updateTable(values)
self.Table.pack()
self.Table.tag_configure('green', background='green')
self.Table.tag_configure('reset', background='white')
self.Table.tag_configure('red', background='red')
self.Table.tag_configure('yellow', background='yellow')
lb_remainingFPs = mtTkinter.Label(self.root, textvariable=self.remainingFPs)
lb_remainingFPs.pack()
lb_profitText = mtTkinter.Label(self.root, textvariable=self.profitText)
lb_profitText.pack()
lb_investText = mtTkinter.Label(self.root, textvariable=self.investText)
lb_investText.pack()
lb_warningText = mtTkinter.Label(self.root, textvariable=self.warningText, wraplength=240)
lb_warningText.pack(side='bottom')
self.gbTitle.set("")
self.gbOwnerName.set("")
self.remainingFPs.set("")
self.profitText.set("")
self.warningText.set("")