diff options
Diffstat (limited to 'lidt/__init__.py')
-rw-r--r-- | lidt/__init__.py | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/lidt/__init__.py b/lidt/__init__.py new file mode 100644 index 0000000..5966a98 --- /dev/null +++ b/lidt/__init__.py @@ -0,0 +1,95 @@ +# LIDT +# Copyright (C) 2016 Karel Kočí +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import os +import sys + +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk + +#from . import lidt +import lidt +#from . import plotout +import plotout + +L = None +builder = None + +label_list = [ + "actarea", + "spotzise", + "numspots", + "disttestsitess", + "disttestsitesshex", + "numpulsperstep", + "numsitespulsstep", + "numofsiteseng", + "numengavsample", + "numofneededsites", + "numofneededsitesbool" + ] + +def updategtk(): + if builder is None: + return + #print("render") + for edt in label_list: + #print(edt) + edtobj = builder.get_object(edt) + edtobj.set_text(str(eval("L." + edt))) + +class Handler: + def __init__(self, lidt): + self.lidt = lidt + + def onDeleteWindow(self, *args): + Gtk.main_quit(*args) + + def onRootChange(self, editable): + #print("signal " + Gtk.Buildable.get_name(editable)) + try: + eval("self.lidt.set_" + Gtk.Buildable.get_name(editable) + "(float(editable.get_text()))") + self.lidt.calc() + except ValueError: + print("Invalid input!") + + def render_click(widg, _): + plotout.grid_render(window, L.disttestsitess, L.beamdia) + + +def main(): + global L + L = lidt.Lidt(updategtk) + + glade_file = os.path.join(os.path.dirname(__file__), "form.glade") + + global builder + builder = Gtk.Builder() + builder.add_from_file(glade_file) + builder.connect_signals(Handler(L)) + + updategtk() + + global window + window = builder.get_object("window") + window.show_all() + + Gtk.main() + + +if __name__ == "__main__": + main() |