Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<p align="center">
<img src="readme/gui_PyGeM.png" alt>
</p>
<p align="center">
<em>PyGeM GUI: how it appears when it pops up.</em>
</p>

## Testing
We are using Travis CI for continuous intergration testing. You can check out the current status [here](https://travis-ci.org/mathLab/PyGeM).

Expand Down
77 changes: 42 additions & 35 deletions pygem/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()

Binary file added readme/gui_PyGeM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions tests/test_gui.py
Original file line number Diff line number Diff line change
@@ -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()


2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import vtk


class TestVtkHandler(TestCase):
class TestUtils(TestCase):


def test_utils_write_original_box(self):
Expand Down