1212import os
1313import webbrowser
1414
15+ from matplotlib .backends .backend_tkagg import FigureCanvasTkAgg
16+ from matplotlib .figure import Figure
17+
18+
1519class Gui (object ):
1620 """
1721 The class for the Graphic Unit Interface.
@@ -32,12 +36,17 @@ class Gui(object):
3236 :cvar Tkinter.Label label_geo: label related to 'print_geometry_path'.
3337 :cvar Tkinter.Label label_params: label related to 'print_parameters_path'.
3438 :cvar string url: url of the github page of PyGeM.
39+ :cvar Tkinter.Canvas logo_panel: canvas for PyGeM logo.
40+ :cvar Tkinter.PhotoImage img: PyGeM logo.
3541
3642 """
3743
3844 def __init__ (self ):
3945
4046 self .root = Tkinter .Tk ()
47+ self .root .resizable (width = False , height = False )
48+ self .root .minsize (width = 1400 , height = 400 )
49+ self .root .maxsize (width = 1400 , height = 400 )
4150 self .root .title ('PyGeM' )
4251
4352 self .filename_geometry = Tkinter .StringVar ()
@@ -52,11 +61,13 @@ def __init__(self):
5261 self .label_geo = None
5362 self .label_params = None
5463 self .url = 'https://github.com/mathLab/PyGeM'
55-
56- self .canvas = None
64+ self .logo_panel = None
5765 self .img = None
5866
5967
68+ self .orig_geo_frame = None
69+ self .mod_geo_frame = None
70+
6071
6172 def _chose_geometry (self ):
6273 """
@@ -107,7 +118,16 @@ def _run_simulation(self):
107118 free_form .perform ()
108119 new_mesh_points = free_form .modified_mesh_points
109120
110- geo_handler .write (new_mesh_points , self .outfilename .get () + file_extension_in )
121+ geo_handler .write (new_mesh_points , self .outfilename .get () + file_extension_in )
122+
123+ if file_extension_in in ['.vtk' , '.stl' , '.iges' , '.igs' ]:
124+ figure_in = geo_handler .plot ()
125+ figure_in .set_size_inches (4 , 3 )
126+ FigureCanvasTkAgg (figure_in , master = self .orig_geo_frame ).get_tk_widget ().grid (row = 1 , column = 0 , padx = 5 , pady = 5 )
127+
128+ figure_out = geo_handler .plot (self .outfilename .get () + file_extension_in )
129+ figure_out .set_size_inches (4 , 3 )
130+ FigureCanvasTkAgg (figure_out , master = self .mod_geo_frame ).get_tk_widget ().grid (row = 1 , column = 0 , padx = 5 , pady = 5 )
111131
112132 if self .check_var_1 .get () == 1 :
113133 pg .utils .write_bounding_box (params , self .outfilename_lattice_orig .get () + '.vtk' , False )
@@ -129,12 +149,23 @@ def main(self):
129149 """
130150
131151 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 )
152+ self .logo_panel .pack (side = "bottom" , padx = 5 , pady = 5 ,anchor = Tkinter .SE )
133153 self .img = Tkinter .PhotoImage (master = self .logo_panel , file = 'readme/logo_PyGeM_gui.gif' )
134154 self .logo_panel .create_image (35 ,35 , image = self .img )
135155
136- code_frame = Tkinter .Frame (self .root )
137- code_frame .pack ()
156+ self .orig_geo_frame = Tkinter .Frame (self .root , height = 450 , width = 360 , bg = '#c1d0f0' )
157+ self .orig_geo_frame .pack (side = "left" , padx = 5 , pady = 5 )
158+ self .orig_geo_frame .pack_propagate (0 )
159+ Tkinter .Label (self .orig_geo_frame , text = "INPUT GEOMETRY" , bg = '#c1d0f0' , font = ("Arial" , 20 )).grid (row = 0 , column = 0 , padx = 3 , pady = 3 )
160+
161+ self .mod_geo_frame = Tkinter .Frame (self .root , height = 450 , width = 360 , bg = '#80ff80' , padx = 5 , pady = 5 )
162+ self .mod_geo_frame .pack (side = "right" , padx = 5 , pady = 5 )
163+ self .mod_geo_frame .pack_propagate (0 )
164+ Tkinter .Label (self .mod_geo_frame , text = "OUTPUT GEOMETRY" , bg = '#80ff80' , font = ("Arial" , 20 )).grid (row = 0 , column = 0 , padx = 3 , pady = 3 )
165+
166+ code_frame = Tkinter .Frame (self .root , height = 490 , width = 360 , relief = Tkinter .GROOVE , borderwidth = 1 )
167+ code_frame .pack (padx = 5 , pady = 5 )
168+ code_frame .pack_propagate (0 )
138169
139170 # Buttons 1
140171 Tkinter .Button (code_frame , text = "Pick the geometry" , command = self ._chose_geometry ).grid (row = 0 , column = 0 , padx = 3 , pady = 3 )
@@ -164,7 +195,8 @@ def main(self):
164195 Tkinter .Entry (code_frame , bd = 5 , textvariable = self .outfilename_lattice_mod ).grid (row = 4 , column = 1 )
165196
166197 # Run button
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 )
198+ Tkinter .Button (code_frame , text = "Run PyGeM" , command = self ._run_simulation , bg = '#065893' , fg = '#f19625' , \
199+ font = 'bold' ).grid (row = 5 , column = 0 , columnspan = 2 , padx = 3 , pady = 3 )
168200
169201 # Menu
170202 menubar = Tkinter .Menu (self .root )
0 commit comments