-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdtDBN_GUI.py
162 lines (120 loc) · 5.83 KB
/
sdtDBN_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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#########################################
# Imports
from os import path
import platform
from tkinter import *
from tkinter import filedialog
from tkinter import ttk
from mainMenu.Menu import *
from utils.ScrollableFrame import *
from utils.ElemThree import *
from utils.ElemTwoInput import *
from utils.ElemTwoSelect import *
from tabs.tab1.PageElements import *
from tabs.tab1.LearnDBN import *
from tabs.tab1.Tab1 import *
from tabs.tab1_1.Tab1_1 import *
from tabs.tab1_2.Tab1_2 import *
from tabs.tab2.Tab2 import *
from tabs.tab3.Tab3 import *
from tabs.tab4.Tab4 import *
from tabs.tab5.Tab5 import *
#########################################
# Root of program made with tkinter lib
root = Tk()
root.title("sdtDBNs GUI")
root.geometry("1150x685")
root.resizable(True, True)
currOS = platform.system()
if (currOS == 'Windows'): # If in Windows
if (path.exists("icons/ist_logo_icon.ico")): # Just safety guard
root.iconbitmap("icons/ist_logo_icon.ico")
else:
if (path.exists("icons/ist_logo_gif.gif")): # Just safety guard
icon_img = PhotoImage(file='icons/ist_logo_gif.gif')
root.iconphoto(True, icon_img)
##################################################################################
##################################################################################
##################################################################################
##################################################################################
# Program styling definittions
#########################################
# Some fonts
font_tabs = ("Times", 11)
font_tabs_bold = ("Times", 10, "bold")
font_bold = ("Times", 12, "bold")
font_italic = ("Times", 11, "italic")
font_insert = ("Times", 13, "bold")
font_insertButton = ("Times", 14, "bold")
font_ok_notok = ("Times", 11, "bold italic")
#########################################
# Creation of style object
s = ttk.Style()
s.theme_use('clam')
#########################################
# Tabs styling
s.configure("TNotebook.Tab", padding = (10, 3, 10, 3), relief = "flat", background = "#FF4500", font = font_tabs, bordercolor = "#FF007F", focuscolor = "None")
s.map('TNotebook.Tab', background = [('selected','red')], font = [('selected', font_tabs_bold), ('active', font_tabs_bold)])
#########################################
# Notebook styling
s.configure("TNotebook", background = "white", bordercolor = "#FF007F", padding = (5,5,5,5))
#########################################
# Frames styling
s.configure("TFrame", background = "#FFCCCC") # Set all frames with same color
#########################################
# Styling of labels
s.configure("ask.TLabel", background = "#FFCCCC", font = font_bold, foreground = "#FF4500")
s.configure("filenames.TLabel", background = "#FFCCCC", font = font_italic)
s.configure("ok.TLabel", background = "#FFCCCC", font = font_ok_notok, foreground = "green")
s.configure("notok.TLabel", background = "#FFCCCC", font = font_ok_notok, foreground = "red")
#########################################
# Styling of entries
s.configure("TEntry", background = "#FFCCCC", foreground = "#FF4500", fieldbackground = "#FFCCCC", bordercolor = "#FFCCCC")
s.map("TEntry", fieldbackground = [('focus','white')] , foreground = [('focus','black')], bordercolor = [('focus','black')] )
#########################################
# Styling of buttons
s.configure('TButton', background = '#FFCCCC', foreground = 'black', font = font_bold, bordercolor = "#FF4500", focuscolor = "None", padding = (0, 7, 0, 7))
s.map('TButton', foreground = [('active','#FF4500')], font = [('active', font_insertButton)] )
#########################################
# Styling of option menus
s.configure('TMenubutton', background = '#FFCCCC', foreground = 'black', font = font_bold, bordercolor = "#FF4500", focuscolor = "None", padding = (10, 10, 10, 10), arrowsize = 2)
s.map('TMenubutton', foreground = [('active','#FF4500')])
##################################################################################
##################################################################################
##################################################################################
##################################################################################
# Main menu bar
windowMenu = MyMenu(root)
##################################################################################
##################################################################################
# Creating vertical and horizontal scrollbars
frameWithScroll = ScrollableFrame(root)
frameWithScroll.grid(row=1, column=1, sticky="nsew")
def changeScrollsPosition(event):
frameWithScroll.canvas.config(width = root.winfo_width()-20, height = root.winfo_height()-20)
root.bind( "<Configure>", changeScrollsPosition )
#########################################
# Define tab environment
tabControl = ttk.Notebook(frameWithScroll.scrollable_frame)
#########################################
# Create the several tabs
tab5 = Tab5(tabControl, 200)
tab4 = Tab4(tabControl, 200)
tab3 = Tab3(tabControl, 200)
tab2 = Tab2(tabControl, 200, tab3, tab4, tab5)
tab1_2 = Tab1_2(tabControl, 200)
tab1_1 = Tab1_1(tabControl, 200, tab1_2, tab2, tab3, tab4, tab5)
tab1 = Tab1(tabControl, 200, tab1_2, tab2, tab3, tab4, tab5)
#########################################
# Create TAB menu
tabControl.add(tab1.dbnLearnFrame, text="Learn DBN from data")
tabControl.add(tab1_1.dbnLearnFileFrame, text="Load DBN from file")
tabControl.add(tab1_2.frameInfoToImg, text="Get Image of DBN")
tabControl.add(tab2.frameObsInf, text="Observations to Inference")
tabControl.add(tab3.framePredictSpecific, text="Predict attribute distribution")
tabControl.add(tab4.framePredictProgres, text="Predict progression")
tabControl.add(tab5.framePredictMany, text="Predictions for many IDs")
tabControl.pack(fill="both", expand=True)
#########################################
# Mainloop of program
root.mainloop()