diff --git a/WKNcharts/libglade.py b/WKNcharts/libglade.py new file mode 100644 index 0000000..2effff3 --- /dev/null +++ b/WKNcharts/libglade.py @@ -0,0 +1,33 @@ +#This requires pygtk2 + +import gettext +import gtk +import gtk.glade + +class GladeWrapper: + """ + Superclass for glade based applications. Just derive from this + and your subclass should create methods whose names correspond to + the signal handlers defined in the glade file. Any other attributes + in your class will be safely ignored. + + This class will give you the ability to do: + subclass_instance.GtkWindow.method(...) + subclass_instance.widget_name... + """ + def __init__(self, Filename, WindowName): + #load glade file. + self.widgets = gtk.glade.XML(Filename, WindowName, gettext.textdomain()) + self.GtkWindow = getattr(self, WindowName) + + instance_attributes = {} + for attribute in dir(self.__class__): + instance_attributes[attribute] = getattr(self, attribute) + self.widgets.signal_autoconnect(instance_attributes) + + def __getattr__(self, attribute): #Called when no attribute in __dict__ + widget = self.widgets.get_widget(attribute) + if widget is None: + raise AttributeError("Widget [" + attribute + "] not found") + self.__dict__[attribute] = widget #add reference to cache + return widget diff --git a/WKNcharts/wknGUI.py b/WKNcharts/wknGUI.py index 763c432..6798455 100644 --- a/WKNcharts/wknGUI.py +++ b/WKNcharts/wknGUI.py @@ -57,12 +57,11 @@ class WknGUI: self.textbuffer = self.outputfield.get_buffer() configs[name] = self.textbuffer.get_text(*self.textbuffer.get_bounds ()) ## checkboxes are also stored in 'configs' - checkboxnames = {"cb_time1":30,"cb_time2":300,"cb_time3":30000,"cb_time4":100000} + checkboxnames = {"cb_time1":30,"cb_time2":300,"cb_time3":10000,"cb_time4":30000,"cb_time5":100000} configs["times"] = [] for name in checkboxnames.keys(): if self.wkngui.get_widget(name).get_active(): configs["times"].append(checkboxnames[name]) - print configs["times"] self.add_log(("configs: %s %s" % (configs.keys(), configs.values())), 3) self.read_wknlist() self.check_dstdir() diff --git a/WKNcharts/wkncharts.glade b/WKNcharts/wkncharts.glade index ab90ab2..6f87a4b 100644 --- a/WKNcharts/wkncharts.glade +++ b/WKNcharts/wkncharts.glade @@ -451,8 +451,8 @@ True - True True + True GDK_EXTENSION_EVENTS_ALL True False @@ -491,8 +491,6 @@ True - True - True True True False @@ -685,10 +683,10 @@ - 5 + 17 True 1 - 4 + 5 False 0 0 @@ -718,7 +716,7 @@ True True - 30 Tage + 3 Monate True GTK_RELIEF_NORMAL True @@ -739,7 +737,7 @@ True True - 300 Tage + 1 Jahr True GTK_RELIEF_NORMAL True @@ -776,9 +774,31 @@ + + + + True + True + 7 Jahre + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 4 + 5 + 0 + 1 + fill + + + - 8 + 0 False False @@ -805,7 +825,6 @@ True - True True GTK_RELIEF_NORMAL True @@ -962,7 +981,7 @@ False - True + False