Skip to content

Commit 9870536

Browse files
committed
Resizing/Cosmetic Changes
1 parent 4df256c commit 9870536

File tree

3 files changed

+160
-11
lines changed

3 files changed

+160
-11
lines changed

ProberControl_Py3/prober/classes/GUI.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
class Application(tk.Frame):
4040

4141
def restartGUI(self, Maitre, stages = {}):
42-
self.__init__(Maitre, stages)
42+
self.__init__( Maitre, stages)
4343

4444
def __init__(self, master=None, stages={}):
4545
# Initialise GUI
4646
tk.Frame.__init__(self, master)
47+
frame = ttk.Frame(self, borderwidth=5, relief = "sunken", width=200, height = 100)
4748
self.master.title("Prober Control")
4849
self.grid()
4950

@@ -188,24 +189,44 @@ def createWidgets(self):
188189
# Parameters for adjusting main buttons on GUI (Browse, Execute, Build)
189190
self.ScriptLabel = tk.Label(self,text='Script to Execute')
190191
self.ScriptLabel.grid(column=0,row=0,columnspan=2)
192+
self.ScriptLabel.place(x = 40, y = 10)
193+
#self.ScriptLabel.place(x = 10, y = 15)
191194

192195

193196
self.ScriptEntry = tk.Entry(self,textvariable=self.FileText) #,width = 55
194-
self.ScriptEntry.grid(column=2,row=0, columnspan = 2, sticky="ew")
195-
self.rowconfigure(0, weight = 2)
196-
self.columnconfigure(2, weight = 1)
197+
self.ScriptEntry.grid(column=2,row=0, sticky= 'nsew')
198+
self.ScriptEntry.place(x=200, y=8, relwidth=0.70)
199+
197200
#self.ScriptEntry.columnconfigure(3, weight = 0)
198201
#self.ScriptEntry.columnconfigure(4, weight = 0)
199202

200203
self.BrowseButton = tk.Button(self, text='Browse Scripts',command=self.FileBrowse, height = 5, width = 20)
201-
self.BrowseButton.grid(column=0,row=2,columnspan=2, rowspan = 4, padx=5, pady=5)
204+
self.BrowseButton.grid(column=0,row=2,columnspan=2)
205+
self.BrowseButton.place(x = 10, rely = 0.1, relheight = 0.2 )
206+
#self.BrowseButton.pack()
202207

203208
self.BuildButton = tk.Button(self, text='Build Script',command=self.startScriptBuilder, height = 5, width = 20)
204-
self.BuildButton.grid(column=0,row=6,columnspan=2, rowspan = 4, padx=5, pady=5)
209+
self.BuildButton.grid(column=0,row=6,columnspan=2)
210+
self.BuildButton.place(x = 10, rely = 0.4, relheight = 0.2 )
205211

206212
myFont = tkFont.Font(size = 30)
207213
self.ScriptButton = tk.Button(self, text='Execute Script', command=self.ScriptRun, height = 5, width = 20, bg = "green", fg = "white")
208-
self.ScriptButton.grid(column=0,row=10,columnspan=2, rowspan = 4, padx=5, pady=5)
214+
self.ScriptButton.grid(column=0,row=10,columnspan=2)
215+
self.ScriptButton.place(x = 10, rely = 0.7, relheight = 0.2 )
216+
#self.ScriptButton.pack()
217+
218+
#self.grid(column = 0, row = 0)
219+
#self.master.grid(column = 0, row = 0, sticky = (N,S,E,W))
220+
#frame.grid(column = 0, row = 0, columnspan = 3, rowspan = 2, sticky = (N,S,E,W))
221+
self.grid(column=0, row=0, sticky='nsew')
222+
self.master.grid_columnconfigure(0, weight=1, minsize = 700)
223+
self.master.grid_rowconfigure(0, weight=1, minsize = 400)
224+
225+
self.rowconfigure(0, weight = 0)
226+
self.rowconfigure(2, weight = 1)
227+
self.rowconfigure(6, weight = 1)
228+
self.rowconfigure(10, weight = 1)
229+
209230

210231
#self.ScriptButton['font'] = myFont
211232

@@ -221,7 +242,9 @@ def createWidgets(self):
221242

222243
#Console Text Widget
223244
self.Console = tk.Text(self, height=18, width=55)
224-
self.Console.grid(column=2,row=2,columnspan = 2, rowspan = 30)
245+
self.Console.grid(column=2,row=2)
246+
self.Console.place(x = 200, y = 40, relwidth = 0.70, relheight = 0.80)
247+
225248

226249
# Auto Generate Fields for Connected Stages
227250
self.StageButtonI = 0
@@ -519,11 +542,18 @@ def backwardKey(self,event):
519542
t_x = threading.Thread(target=self.Stages[self.ActiveStage].step, args=('B'))
520543
t_x.start()
521544

545+
def main():
546+
root = Tk()
547+
app = Application(master=root)
548+
#root.focus_set()
549+
root.mainloop()
522550
if __name__=='__main__':
551+
main()
552+
523553
### Create Instance of Window
524-
app = Application()
554+
525555
### Set Focus on windows to catch key strokes
526-
app.focus_set()
556+
527557
### Start Looping and wating for events
528558

529559
#while True:
@@ -537,7 +567,7 @@ def backwardKey(self,event):
537567
mod.function()
538568
time.sleep(1)
539569
'''
540-
app.mainloop()
570+
541571

542572

543573
'''

TkinterTest2.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#
2+
# Laying out a tkinter grid
3+
#
4+
# Please also find two images:
5+
# GridLayout.png and screenshot.png
6+
# Credit: Modified by Larz60+ From the original:
7+
# 'http://www.tkdocs.com/tutorial/grid.html'
8+
#
9+
from tkinter import *
10+
from tkinter import ttk
11+
12+
13+
class ResizableWindow:
14+
def __init__(self, parent):
15+
self.parent = parent
16+
self.f1_style = ttk.Style()
17+
self.f1_style.configure('My.TFrame', background='#334353')
18+
self.f1 = ttk.Frame(self.parent, style='My.TFrame', padding=(3, 3, 12, 12)) # added padding
19+
20+
self.f1.grid(column=0, row=0, sticky=(N, S, E, W)) # added sticky
21+
self.f2 = ttk.Frame(self.f1, borderwidth=5, relief="sunken", width=200, height=100)
22+
self.namelbl = ttk.Label(self.f1, text="Name")
23+
self.name = ttk.Entry(self.f1)
24+
25+
self.onevar = BooleanVar()
26+
self.twovar = BooleanVar()
27+
self.threevar = BooleanVar()
28+
29+
self.onevar.set(True)
30+
self.twovar.set(False)
31+
self.threevar.set(True)
32+
33+
self.one = ttk.Checkbutton(self.f1, text="One", variable=self.onevar, onvalue=True)
34+
self.two = ttk.Checkbutton(self.f1, text="Two", variable=self.twovar, onvalue=True)
35+
self.three = ttk.Checkbutton(self.f1, text="Three", variable=self.threevar, onvalue=True)
36+
self.ok = ttk.Button(self.f1, text="Okay")
37+
#self.test = ttk.Entry(self.f1)
38+
self.cancel = ttk.Button(self.f1, text="Cancel")
39+
40+
self.f1.grid(column=0, row=0, sticky=(N, S, E, W)) # added sticky
41+
self.f2.grid(column=0, row=0, columnspan=3, rowspan=2, sticky=(N, S, E, W)) # added sticky
42+
self.namelbl.grid(column=3, row=0, columnspan=2, sticky=(N, W), padx=5) # added sticky, padx
43+
self.name.grid(column=3, row=1, columnspan=2, sticky=(N, E, W), pady=5, padx=5) # added sticky, pady, padx
44+
self.one.grid(column=0, row=3)
45+
self.two.grid(column=1, row=3)
46+
self.three.grid(column=2, row=3)
47+
self.ok.grid(column=3, row=3)
48+
self.cancel.grid(column=4, row=3)
49+
#self.test.grid(column= 5, row = 3)
50+
51+
# added resizing configs
52+
self.parent.columnconfigure(0, weight=1)
53+
self.parent.rowconfigure(0, weight=1)
54+
self.f1.columnconfigure(0, weight=3)
55+
self.f1.columnconfigure(1, weight=3)
56+
self.f1.columnconfigure(2, weight=3)
57+
self.f1.columnconfigure(3, weight=3)
58+
self.f1.columnconfigure(4, weight=3)
59+
self.f1.rowconfigure(1, weight=1)
60+
#self.f1.columnconfigure(5, weight = 1)
61+
62+
def get_widget_attributes(self):
63+
all_widgets = self.f1.winfo_children()
64+
for widg in all_widgets:
65+
print('\nWidget Name: {}'.format(widg.winfo_class()))
66+
keys = widg.keys()
67+
for key in keys:
68+
print("Attribute: {:<20}".format(key), end=' ')
69+
value = widg[key]
70+
vtype = type(value)
71+
print('Type: {:<30} Value: {}'.format(str(vtype), value))
72+
73+
74+
def main():
75+
root = Tk()
76+
rw = ResizableWindow(root)
77+
#rw.get_widget_attributes()
78+
root.mainloop()
79+
80+
81+
if __name__ == '__main__':
82+
main()

tKinterTest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import tkinter as tk
2+
from tkinter import *
3+
4+
test = Tk()
5+
'''
6+
test.testButton = tk.Button(test, text = 'hi', height = 5, width = 10)
7+
test.testButton.grid(column=0, row = 0, columnspan =3, rowspan = 2, sticky = 'ew')
8+
test.scriptEntry = tk.Entry(test)
9+
test.scriptEntry.grid(column = 0, row = 2, columnspan = 3, rowspan = 3, sticky = 'ew')
10+
'''
11+
12+
test.ScriptLabel = tk.Label(test,text='Script to Execute')
13+
test.ScriptLabel.grid(column=0,row=0,columnspan=2)
14+
15+
16+
test.ScriptEntry = tk.Entry(test) #,width = 55
17+
test.ScriptEntry.grid(column=2,row=0, columnspan = 2, sticky="ew")
18+
test.rowconfigure(0, weight = 2)
19+
test.columnconfigure(2, weight = 1)
20+
#test.ScriptEntry.columnconfigure(3, weight = 0)
21+
#test.ScriptEntry.columnconfigure(4, weight = 0)
22+
23+
test.BrowseButton = tk.Button(test, text='Browse Scripts', height = 5, width = 20)
24+
test.BrowseButton.grid(column=0,row=2,columnspan=2, rowspan = 4, padx=5, pady=5)
25+
26+
test.BuildButton = tk.Button(test, text='Build Script', height = 5, width = 20)
27+
test.BuildButton.grid(column=0,row=6,columnspan=2, rowspan = 4, padx=5, pady=5)
28+
29+
test.ScriptButton = tk.Button(test, text='Execute Script', height = 5, width = 20, bg = "green", fg = "white")
30+
test.ScriptButton.grid(column=0,row=10,columnspan=2, rowspan = 4, padx=5, pady=5)
31+
32+
test.ScriptEntry.columnconfigure(0, weight = 1)
33+
test.ScriptEntry.rowconfigure(0, weight = 1)
34+
#test.columnconfigure(1, weight = 1)
35+
#test.columnconfigure(2, weight = 1)
36+
37+
test.mainloop()

0 commit comments

Comments
 (0)