|
7 | 7 |
|
8 | 8 | import Tkinter |
9 | 9 | from tkFileDialog import askopenfilename |
10 | | -from PIL import ImageTk, Image |
11 | 10 | import pygem as pg |
12 | 11 | import sys |
13 | 12 | import os |
@@ -54,6 +53,9 @@ def __init__(self): |
54 | 53 | self.label_params = None |
55 | 54 | self.url = 'https://github.com/mathLab/PyGeM' |
56 | 55 |
|
| 56 | + self.canvas = None |
| 57 | + self.img = None |
| 58 | + |
57 | 59 |
|
58 | 60 |
|
59 | 61 | def _chose_geometry(self): |
@@ -121,83 +123,60 @@ def _goto_website(self): |
121 | 123 | webbrowser.open(self.url) |
122 | 124 |
|
123 | 125 |
|
124 | | - def start(self): |
| 126 | + def main(self): |
125 | 127 | """ |
126 | 128 | The method inizializes and visualizes the window. |
127 | 129 | """ |
128 | | - |
129 | | - image = Image.open('readme/logo_PyGeM_small.png') |
130 | | - image = image.resize((50, 50), Image.ANTIALIAS) |
131 | | - img = ImageTk.PhotoImage(image) |
132 | | - panel = Label(self.root, image = img) |
133 | | - panel.pack(side = "bottom", padx = 5, pady = 5,anchor=SE) |
134 | | - |
135 | | - geo_frame = Frame(self.root) |
136 | | - geo_frame.pack(anchor=W) |
| 130 | + |
| 131 | + self.logo_panel = Tkinter.Canvas(self.root, height=60 , width=60) |
| 132 | + self.logo_panel.pack(side = "bottom", padx = 5, pady = 5,anchor=Tkinter.SE) |
| 133 | + self.img = Tkinter.PhotoImage(master=self.logo_panel, file='readme/logo_PyGeM_gui.gif') |
| 134 | + self.logo_panel.create_image(35,35, image=self.img) |
| 135 | + |
| 136 | + code_frame = Tkinter.Frame(self.root) |
| 137 | + code_frame.pack() |
137 | 138 |
|
138 | 139 | # Buttons 1 |
139 | | - button_1 = Tkinter.Button(geo_frame, text ="Pick the geometry", command = self._chose_geometry) |
140 | | - button_1.pack(side=LEFT, padx = 5, pady = 5) |
141 | | - self.label_geo=Label(geo_frame, textvariable=self.print_geometry_path, fg='red') |
| 140 | + Tkinter.Button(code_frame, text ="Pick the geometry", command = self._chose_geometry).grid(row=0, column=0, padx=3, pady=3) |
| 141 | + self.label_geo=Tkinter.Label(code_frame, textvariable=self.print_geometry_path, fg='red') |
142 | 142 | self.print_geometry_path.set("No geometry chosen!") |
143 | | - self.label_geo.pack(side=LEFT, padx = 5, pady = 5) |
| 143 | + self.label_geo.grid(row=0, column=1, padx=3, pady=3) |
144 | 144 |
|
145 | | - # Button 2 |
146 | | - params_frame = Frame(self.root) |
147 | | - params_frame.pack(anchor=W) |
148 | | - |
149 | | - button_2 = Tkinter.Button(params_frame, text ="Pick the parameters", command = self._chose_parameters) |
150 | | - button_2.pack(side=LEFT, padx = 5, pady = 5) |
151 | | - self.label_params = Label( params_frame, textvariable=self.print_parameter_path, fg='red') |
| 145 | + # Button 2 |
| 146 | + Tkinter.Button(code_frame, text ="Pick the parameters", command = self._chose_parameters).grid(row=1, column=0, padx=3, pady=3) |
| 147 | + self.label_params = Tkinter.Label(code_frame, textvariable=self.print_parameter_path, fg='red') |
152 | 148 | self.print_parameter_path.set("No parameters file chosen!") |
153 | | - self.label_params.pack(side=LEFT, padx = 5, pady = 5) |
| 149 | + self.label_params.grid(row=1, column=1, padx=3, pady=3) |
154 | 150 |
|
155 | 151 | # Entry |
156 | | - entryframe = Frame(self.root) |
157 | | - entryframe.pack(padx = 5, pady = 5, anchor=W) |
158 | | - |
159 | | - label_geo_out = Label(entryframe, text="Output geometry file") |
160 | | - label_geo_out.pack( side = LEFT) |
161 | | - entry_geo_out = Entry(entryframe, bd =5, textvariable=self.outfilename) |
162 | | - entry_geo_out.pack(side = LEFT) |
| 152 | + Tkinter.Label(code_frame, text="Output geometry file").grid(row=2, column=0, padx=3, pady=3) |
| 153 | + Tkinter.Entry(code_frame, bd =5, textvariable=self.outfilename).grid(row=2, column=1, padx=3, pady=3) |
163 | 154 |
|
164 | 155 | # Checkboxes |
165 | | - checkframe_orig = Frame(self.root) |
166 | | - checkframe_orig.pack(anchor=W) |
167 | | - |
168 | | - check_lattice_orig = Checkbutton(checkframe_orig, text = "Dump Original FFD lattice", variable = self.check_var_1, \ |
| 156 | + Tkinter.Checkbutton(code_frame, text = "Dump Original FFD lattice", variable = self.check_var_1, \ |
169 | 157 | onvalue = 1, offvalue = 0, height=3, \ |
170 | | - width = 20) |
| 158 | + width = 20).grid(row=3, column=0) |
| 159 | + Tkinter.Entry(code_frame, bd =5, textvariable=self.outfilename_lattice_orig).grid(row=3, column=1) |
171 | 160 |
|
172 | | - check_lattice_orig.pack(side=LEFT) |
173 | | - |
174 | | - entry_lattice_orig = Entry(checkframe_orig, bd =5, textvariable=self.outfilename_lattice_orig) |
175 | | - entry_lattice_orig.pack(side = LEFT) |
176 | | - |
177 | | - checkframe_mod = Frame(self.root) |
178 | | - checkframe_mod.pack(anchor=W) |
179 | | - |
180 | | - check_lattice_mod = Checkbutton(checkframe_mod, text = "Dump Morphed FFD lattice", variable = self.check_var_2, \ |
| 161 | + Tkinter.Checkbutton(code_frame, text = "Dump Morphed FFD lattice", variable = self.check_var_2, \ |
181 | 162 | onvalue = 1, offvalue = 0, height=3, \ |
182 | | - width = 20) |
183 | | - |
184 | | - check_lattice_mod.pack(side=LEFT) |
185 | | - |
186 | | - entry_lattice_mod = Entry(checkframe_mod, bd =5, textvariable=self.outfilename_lattice_mod) |
187 | | - entry_lattice_mod.pack(side = LEFT) |
| 163 | + width = 20).grid(row=4, column=0) |
| 164 | + Tkinter.Entry(code_frame, bd =5, textvariable=self.outfilename_lattice_mod).grid(row=4, column=1) |
188 | 165 |
|
189 | 166 | # Run button |
190 | | - button_run = Tkinter.Button(self.root, text ="Run PyGeM", command = self._run_simulation, bg='#065893', fg='#f19625', font='bold') |
191 | | - button_run.pack() |
| 167 | + Tkinter.Button(code_frame, text ="Run PyGeM", command = self._run_simulation, bg='#065893', fg='#f19625', font='bold').grid(row=5, column=0, padx=3, pady=3) |
192 | 168 |
|
193 | 169 | # Menu |
194 | | - menubar = Menu(self.root) |
| 170 | + menubar = Tkinter.Menu(self.root) |
195 | 171 |
|
196 | | - helpmenu = Menu(menubar, tearoff=0) |
| 172 | + helpmenu = Tkinter.Menu(menubar, tearoff=0) |
197 | 173 | helpmenu.add_command(label="About...", command=self._goto_website) |
198 | 174 | menubar.add_cascade(label="Help", menu=helpmenu) |
199 | 175 |
|
200 | 176 | self.root.config(menu=menubar) |
201 | 177 |
|
| 178 | + |
| 179 | + def start(self): |
| 180 | + |
202 | 181 | self.root.mainloop() |
203 | 182 |
|
0 commit comments