diff --git a/.travis.yml b/.travis.yml index 6164e05..55da4db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,6 @@ install: - pip install numpy-stl - pip install coveralls - pip install coverage - - pip install Pillow - python setup.py install script: coverage run test.py diff --git a/README.md b/README.md index ef26820..595f8a5 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,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..d293dc5 100644 --- a/pygem/gui.py +++ b/pygem/gui.py @@ -7,7 +7,6 @@ import Tkinter from tkFileDialog import askopenfilename -from PIL import ImageTk, Image import pygem as pg import sys import os @@ -54,6 +53,9 @@ def __init__(self): self.label_params = None self.url = 'https://github.com/mathLab/PyGeM' + self.canvas = None + self.img = None + def _chose_geometry(self): @@ -121,83 +123,60 @@ def _goto_website(self): webbrowser.open(self.url) - def start(self): + def main(self): """ The method inizializes and visualizes the window. """ - - 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) - - geo_frame = Frame(self.root) - geo_frame.pack(anchor=W) + + self.logo_panel = Tkinter.Canvas(self.root, height=60 , width=60) + self.logo_panel.pack(side = "bottom", padx = 5, pady = 5,anchor=Tkinter.SE) + self.img = Tkinter.PhotoImage(master=self.logo_panel, file='readme/logo_PyGeM_gui.gif') + self.logo_panel.create_image(35,35, image=self.img) + + code_frame = Tkinter.Frame(self.root) + code_frame.pack() # 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') + Tkinter.Button(code_frame, text ="Pick the geometry", command = self._chose_geometry).grid(row=0, column=0, padx=3, pady=3) + self.label_geo=Tkinter.Label(code_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.grid(row=0, column=1, padx=3, pady=3) - # Button 2 - params_frame = Frame(self.root) - params_frame.pack(anchor=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 + Tkinter.Button(code_frame, text ="Pick the parameters", command = self._chose_parameters).grid(row=1, column=0, padx=3, pady=3) + self.label_params = Tkinter.Label(code_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.grid(row=1, column=1, padx=3, pady=3) # Entry - entryframe = Frame(self.root) - entryframe.pack(padx = 5, pady = 5, anchor=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) + Tkinter.Label(code_frame, text="Output geometry file").grid(row=2, column=0, padx=3, pady=3) + Tkinter.Entry(code_frame, bd =5, textvariable=self.outfilename).grid(row=2, column=1, padx=3, pady=3) # Checkboxes - checkframe_orig = Frame(self.root) - checkframe_orig.pack(anchor=W) - - check_lattice_orig = Checkbutton(checkframe_orig, text = "Dump Original FFD lattice", variable = self.check_var_1, \ + Tkinter.Checkbutton(code_frame, text = "Dump Original FFD lattice", variable = self.check_var_1, \ onvalue = 1, offvalue = 0, height=3, \ - width = 20) + width = 20).grid(row=3, column=0) + Tkinter.Entry(code_frame, bd =5, textvariable=self.outfilename_lattice_orig).grid(row=3, column=1) - check_lattice_orig.pack(side=LEFT) - - entry_lattice_orig = Entry(checkframe_orig, bd =5, textvariable=self.outfilename_lattice_orig) - entry_lattice_orig.pack(side = LEFT) - - checkframe_mod = Frame(self.root) - checkframe_mod.pack(anchor=W) - - check_lattice_mod = Checkbutton(checkframe_mod, text = "Dump Morphed FFD lattice", variable = self.check_var_2, \ + Tkinter.Checkbutton(code_frame, text = "Dump Morphed FFD lattice", variable = self.check_var_2, \ onvalue = 1, offvalue = 0, height=3, \ - width = 20) - - check_lattice_mod.pack(side=LEFT) - - entry_lattice_mod = Entry(checkframe_mod, bd =5, textvariable=self.outfilename_lattice_mod) - entry_lattice_mod.pack(side = LEFT) + width = 20).grid(row=4, column=0) + Tkinter.Entry(code_frame, bd =5, textvariable=self.outfilename_lattice_mod).grid(row=4, column=1) # Run button - button_run = Tkinter.Button(self.root, text ="Run PyGeM", command = self._run_simulation, bg='#065893', fg='#f19625', font='bold') - button_run.pack() + 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) # 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/logo_PyGeM_gui.gif b/readme/logo_PyGeM_gui.gif new file mode 100644 index 0000000..a20bca9 Binary files /dev/null and b/readme/logo_PyGeM_gui.gif differ diff --git a/start_gui.py b/start_gui.py new file mode 100644 index 0000000..8326ba4 --- /dev/null +++ b/start_gui.py @@ -0,0 +1,7 @@ +import pygem as pg + +interface = pg.gui.Gui() + +interface.main() + +interface.start() 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):