# 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 . 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()