diff --git a/.travis.yml b/.travis.yml index 6164e05..b7f6750 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,9 @@ install: - pip install numpy-stl - pip install coveralls - pip install coverage - - pip install Pillow + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + pip install Pillow; + fi - python setup.py install script: coverage run test.py diff --git a/README.md b/README.md index 0a65f58..ebe856f 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,19 @@ To uninstall the package you have to rerun the installation and record the insta The generated html can be found in `docs/build/html`. Open up the `index.html` you find there to browse. +## Gui +**PyGeM** comes with a very basic Graphic Unit Interface. + +Pick the geometry, the parameters file, set the name of the output and decide whether dump the FFD lattice or not. +Now just click on the `Run PyGeM` button and that is it. + +

+ +

+

+PyGeM GUI: how it appears when it pops up. +

+ ## Testing We are using Travis CI for continuous intergration testing. You can check out the current status [here](https://travis-ci.org/mathLab/PyGeM). diff --git a/pygem/gui.py b/pygem/gui.py index 6bff6b0..242c22c 100644 --- a/pygem/gui.py +++ b/pygem/gui.py @@ -54,6 +54,9 @@ def __init__(self): self.label_params = None self.url = 'https://github.com/mathLab/PyGeM' + self.logo_label = None + self.img = None + def _chose_geometry(self): @@ -121,83 +124,87 @@ def _goto_website(self): webbrowser.open(self.url) - def start(self): + def main(self): """ The method inizializes and visualizes the window. """ - + + self.logo_panel = Tkinter.Label() + self.logo_panel.pack(side = "bottom", padx = 5, pady = 5,anchor=Tkinter.SE) image = Image.open('readme/logo_PyGeM_small.png') image = image.resize((50, 50), Image.ANTIALIAS) - img = ImageTk.PhotoImage(image) - panel = Label(self.root, image = img) - panel.pack(side = "bottom", padx = 5, pady = 5,anchor=SE) + self.img = ImageTk.PhotoImage(image) + self.logo_panel.configure(image = self.img) - geo_frame = Frame(self.root) - geo_frame.pack(anchor=W) + geo_frame = Tkinter.Frame(self.root) + geo_frame.pack(anchor=Tkinter.W) # Buttons 1 button_1 = Tkinter.Button(geo_frame, text ="Pick the geometry", command = self._chose_geometry) - button_1.pack(side=LEFT, padx = 5, pady = 5) - self.label_geo=Label(geo_frame, textvariable=self.print_geometry_path, fg='red') + button_1.pack(side=Tkinter.LEFT, padx = 5, pady = 5) + self.label_geo=Tkinter.Label(geo_frame, textvariable=self.print_geometry_path, fg='red') self.print_geometry_path.set("No geometry chosen!") - self.label_geo.pack(side=LEFT, padx = 5, pady = 5) + self.label_geo.pack(side=Tkinter.LEFT, padx = 5, pady = 5) # Button 2 - params_frame = Frame(self.root) - params_frame.pack(anchor=W) + params_frame = Tkinter.Frame(self.root) + params_frame.pack(anchor=Tkinter.W) button_2 = Tkinter.Button(params_frame, text ="Pick the parameters", command = self._chose_parameters) - button_2.pack(side=LEFT, padx = 5, pady = 5) - self.label_params = Label( params_frame, textvariable=self.print_parameter_path, fg='red') + button_2.pack(side=Tkinter.LEFT, padx = 5, pady = 5) + self.label_params = Tkinter.Label( params_frame, textvariable=self.print_parameter_path, fg='red') self.print_parameter_path.set("No parameters file chosen!") - self.label_params.pack(side=LEFT, padx = 5, pady = 5) + self.label_params.pack(side=Tkinter.LEFT, padx = 5, pady = 5) # Entry - entryframe = Frame(self.root) - entryframe.pack(padx = 5, pady = 5, anchor=W) + entryframe = Tkinter.Frame(self.root) + entryframe.pack(padx = 5, pady = 5, anchor=Tkinter.W) - label_geo_out = Label(entryframe, text="Output geometry file") - label_geo_out.pack( side = LEFT) - entry_geo_out = Entry(entryframe, bd =5, textvariable=self.outfilename) - entry_geo_out.pack(side = LEFT) + label_geo_out = Tkinter.Label(entryframe, text="Output geometry file") + label_geo_out.pack( side = Tkinter.LEFT) + entry_geo_out = Tkinter.Entry(entryframe, bd =5, textvariable=self.outfilename) + entry_geo_out.pack(side = Tkinter.LEFT) # Checkboxes - checkframe_orig = Frame(self.root) - checkframe_orig.pack(anchor=W) + checkframe_orig = Tkinter.Frame(self.root) + checkframe_orig.pack(anchor=Tkinter.W) - check_lattice_orig = Checkbutton(checkframe_orig, text = "Dump Original FFD lattice", variable = self.check_var_1, \ + check_lattice_orig = Tkinter.Checkbutton(checkframe_orig, text = "Dump Original FFD lattice", variable = self.check_var_1, \ onvalue = 1, offvalue = 0, height=3, \ width = 20) - check_lattice_orig.pack(side=LEFT) + check_lattice_orig.pack(side=Tkinter.LEFT) - entry_lattice_orig = Entry(checkframe_orig, bd =5, textvariable=self.outfilename_lattice_orig) - entry_lattice_orig.pack(side = LEFT) + entry_lattice_orig = Tkinter.Entry(checkframe_orig, bd =5, textvariable=self.outfilename_lattice_orig) + entry_lattice_orig.pack(side = Tkinter.LEFT) - checkframe_mod = Frame(self.root) - checkframe_mod.pack(anchor=W) + checkframe_mod = Tkinter.Frame(self.root) + checkframe_mod.pack(anchor=Tkinter.W) - check_lattice_mod = Checkbutton(checkframe_mod, text = "Dump Morphed FFD lattice", variable = self.check_var_2, \ + check_lattice_mod = Tkinter.Checkbutton(checkframe_mod, text = "Dump Morphed FFD lattice", variable = self.check_var_2, \ onvalue = 1, offvalue = 0, height=3, \ width = 20) - check_lattice_mod.pack(side=LEFT) + check_lattice_mod.pack(side=Tkinter.LEFT) - entry_lattice_mod = Entry(checkframe_mod, bd =5, textvariable=self.outfilename_lattice_mod) - entry_lattice_mod.pack(side = LEFT) + entry_lattice_mod = Tkinter.Entry(checkframe_mod, bd =5, textvariable=self.outfilename_lattice_mod) + entry_lattice_mod.pack(side = Tkinter.LEFT) # Run button button_run = Tkinter.Button(self.root, text ="Run PyGeM", command = self._run_simulation, bg='#065893', fg='#f19625', font='bold') button_run.pack() # Menu - menubar = Menu(self.root) + menubar = Tkinter.Menu(self.root) - helpmenu = Menu(menubar, tearoff=0) + helpmenu = Tkinter.Menu(menubar, tearoff=0) helpmenu.add_command(label="About...", command=self._goto_website) menubar.add_cascade(label="Help", menu=helpmenu) self.root.config(menu=menubar) + + def start(self): + self.root.mainloop() diff --git a/readme/gui_PyGeM.png b/readme/gui_PyGeM.png new file mode 100644 index 0000000..a118fe6 Binary files /dev/null and b/readme/gui_PyGeM.png differ diff --git a/tests/test_gui.py b/tests/test_gui.py new file mode 100644 index 0000000..771072e --- /dev/null +++ b/tests/test_gui.py @@ -0,0 +1,82 @@ + +from unittest import TestCase +import unittest +import pygem.gui as gui + + +class TestGui(TestCase): + + def test_gui_init_string_1(self): + gui_handler = gui.Gui() + assert gui_handler.root.title() == 'PyGeM' + + + def test_gui_init_string_2(self): + gui_handler = gui.Gui() + assert gui_handler.filename_geometry.get() == '' + + + def test_gui_init_string_3(self): + gui_handler = gui.Gui() + assert gui_handler.filename_parameters.get() == '' + + + def test_gui_init_string_4(self): + gui_handler = gui.Gui() + assert gui_handler.outfilename.get() == '' + + + def test_gui_init_string_5(self): + gui_handler = gui.Gui() + assert gui_handler.outfilename_lattice_orig.get() == '' + + + def test_gui_init_string_6(self): + gui_handler = gui.Gui() + assert gui_handler.outfilename_lattice_mod.get() == '' + + + def test_gui_init_string_7(self): + gui_handler = gui.Gui() + assert gui_handler.print_geometry_path.get() == '' + + + def test_gui_init_string_8(self): + gui_handler = gui.Gui() + assert gui_handler.print_parameter_path.get() == '' + + + def test_gui_init_string_9(self): + gui_handler = gui.Gui() + assert gui_handler.url == 'https://github.com/mathLab/PyGeM' + + + def test_gui_init_int_1(self): + gui_handler = gui.Gui() + assert gui_handler.check_var_1.get() == 0 + + + def test_gui_init_int_2(self): + gui_handler = gui.Gui() + assert gui_handler.check_var_2.get() == 0 + + + def test_gui_init_none_1(self): + gui_handler = gui.Gui() + assert gui_handler.label_geo == None + + + def test_gui_init_none_2(self): + gui_handler = gui.Gui() + assert gui_handler.label_params == None + + + def test_gui_init_all(self): + gui.Gui() + + + def test_gui_main(self): + interface = gui.Gui() + interface.main() + + diff --git a/tests/test_utils.py b/tests/test_utils.py index cbb6f56..4cc6f65 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -9,7 +9,7 @@ import vtk -class TestVtkHandler(TestCase): +class TestUtils(TestCase): def test_utils_write_original_box(self):