From 6ff5968c0014026a8e8f28ba989b7ba9f29c627c Mon Sep 17 00:00:00 2001 From: fsalmoir Date: Mon, 30 May 2016 16:46:38 +0200 Subject: [PATCH 1/4] # This is a combination of 4 commits. # The first commit's message is: tests added for gui init # The 2nd commit message will be skipped: # tests added for gui init # The 3rd commit message will be skipped: # test for the main part of gui code # The 4th commit message will be skipped: # test for the main part of gui code --- pygem/gui.py | 77 +++++++++++++++++++++++------------------- tests/test_gui.py | 82 +++++++++++++++++++++++++++++++++++++++++++++ tests/test_utils.py | 2 +- 3 files changed, 125 insertions(+), 36 deletions(-) create mode 100644 tests/test_gui.py diff --git a/pygem/gui.py b/pygem/gui.py index 6bff6b09..242c22cc 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/tests/test_gui.py b/tests/test_gui.py new file mode 100644 index 00000000..771072e8 --- /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 cbb6f566..4cc6f65f 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): From 8eb96df2db42d3a21f64f413b14a58531d78472a Mon Sep 17 00:00:00 2001 From: fsalmoir Date: Wed, 20 Jul 2016 16:43:30 +0200 Subject: [PATCH 2/4] trying to solve conflicts --- .travis.yml | 4 +++- README.md | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6164e050..b7f67502 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 ef268204..595f8a50 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). From 9183da2501e66f92b0e9ae9a1aa4957fa0035043 Mon Sep 17 00:00:00 2001 From: fsalmoir Date: Thu, 21 Jul 2016 10:17:39 +0200 Subject: [PATCH 3/4] removed pillow from packages --- pygem/gui.py | 74 ++++++++++++-------------------------- readme/logo_PyGeM_gui.gif | Bin 0 -> 1668 bytes start_gui.py | 7 ++++ 3 files changed, 30 insertions(+), 51 deletions(-) create mode 100644 readme/logo_PyGeM_gui.gif create mode 100644 start_gui.py diff --git a/pygem/gui.py b/pygem/gui.py index 242c22cc..d293dc59 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,7 +53,7 @@ def __init__(self): self.label_params = None self.url = 'https://github.com/mathLab/PyGeM' - self.logo_label = None + self.canvas = None self.img = None @@ -129,70 +128,43 @@ def main(self): The method inizializes and visualizes the window. """ - self.logo_panel = Tkinter.Label() + self.logo_panel = Tkinter.Canvas(self.root, height=60 , width=60) 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) - self.img = ImageTk.PhotoImage(image) - self.logo_panel.configure(image = self.img) - - geo_frame = Tkinter.Frame(self.root) - geo_frame.pack(anchor=Tkinter.W) + 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=Tkinter.LEFT, padx = 5, pady = 5) - self.label_geo=Tkinter.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=Tkinter.LEFT, padx = 5, pady = 5) + self.label_geo.grid(row=0, column=1, padx=3, pady=3) - # Button 2 - 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=Tkinter.LEFT, padx = 5, pady = 5) - self.label_params = Tkinter.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=Tkinter.LEFT, padx = 5, pady = 5) + self.label_params.grid(row=1, column=1, padx=3, pady=3) # Entry - entryframe = Tkinter.Frame(self.root) - entryframe.pack(padx = 5, pady = 5, anchor=Tkinter.W) - - 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) + 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 = Tkinter.Frame(self.root) - checkframe_orig.pack(anchor=Tkinter.W) - - check_lattice_orig = Tkinter.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=Tkinter.LEFT) - - entry_lattice_orig = Tkinter.Entry(checkframe_orig, bd =5, textvariable=self.outfilename_lattice_orig) - entry_lattice_orig.pack(side = Tkinter.LEFT) - - checkframe_mod = Tkinter.Frame(self.root) - checkframe_mod.pack(anchor=Tkinter.W) - - check_lattice_mod = Tkinter.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=Tkinter.LEFT) - - entry_lattice_mod = Tkinter.Entry(checkframe_mod, bd =5, textvariable=self.outfilename_lattice_mod) - entry_lattice_mod.pack(side = Tkinter.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 = Tkinter.Menu(self.root) diff --git a/readme/logo_PyGeM_gui.gif b/readme/logo_PyGeM_gui.gif new file mode 100644 index 0000000000000000000000000000000000000000..a20bca94e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mUv>Wcs-XKPte_2%xZ-`7;5Y}Zez8Az=I6{)UQ%R$ zkRipALAW%c-FF4`<-i6AX<^@jz6dc9OuaZTlVD>sCnl)))HkTuXXCn<&^ zH$yZ8jVcFuAcrsB5hzfF4gdp~L6g8G5DrvYV2}=_%#@3YIwnR_Xa=EJ&;(YPHj^j3 zQK=A2%nam$eNG^BK?-ifVxJZSv9u>aAr0igg1`78nU|0lOsSrK9%eA0m+nm%MhbvbcLPzfkX!&yPp#5SV?z9zK6 z5Bq3vtZ>iHm~6BVO-t>j1+n4Jw*J`TEJB(fBMdS!8aXa90|kK$GQPA)kRbjDq))sD zA#=(==pK{;BFM0Z%PRRoD-gT_CF2h{?X<(iBMFZZume~Lq=_(^2$X^!$Q&Y&FaSqq z5Wx;N*100VW{$bL*OLDcw@kHyG{ zA&}P&Fun3X7dzkxWHNz9?IJ-MXycEZ1o@Mz176t6L?`*~U5Y2jT(HI{88Gd@2)H2g z>fece@PR>V;|&@?gR%z!1Xb~N!Rhk}WUUDCT=K}Z9yip1Kg7{qv+fiL06+l12QU2a O#20V;@xlKS5CA(-U<2j= literal 0 HcmV?d00001 diff --git a/start_gui.py b/start_gui.py new file mode 100644 index 00000000..8326ba40 --- /dev/null +++ b/start_gui.py @@ -0,0 +1,7 @@ +import pygem as pg + +interface = pg.gui.Gui() + +interface.main() + +interface.start() From ba0c1f2cec6c3fbad551aa70782c5e54f078de87 Mon Sep 17 00:00:00 2001 From: fsalmoir Date: Thu, 21 Jul 2016 10:33:14 +0200 Subject: [PATCH 4/4] removed pillow from travis installation --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7f67502..55da4db9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,9 +50,6 @@ install: - pip install numpy-stl - pip install coveralls - pip install coverage - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - pip install Pillow; - fi - python setup.py install script: coverage run test.py