From c907a10b4c3c7e689ce3471defc58db3a00c4830 Mon Sep 17 00:00:00 2001 From: phear Date: Thu, 21 Sep 2006 15:43:19 +0000 Subject: [PATCH] das script ist jetzt bis auf nicht gefundene bugs fertig. --- in-gen/in-gen-glade/in-gen-glade.glade | 658 +++++++++++--------- in-gen/in-gen-glade/in-gen-glade.glade.bak | 659 ++++++++++++--------- in-gen/in-gen.py | 63 +- 3 files changed, 813 insertions(+), 567 deletions(-) diff --git a/in-gen/in-gen-glade/in-gen-glade.glade b/in-gen/in-gen-glade/in-gen-glade.glade index a6e7207..a60b501 100644 --- a/in-gen/in-gen-glade/in-gen-glade.glade +++ b/in-gen/in-gen-glade/in-gen-glade.glade @@ -4,7 +4,7 @@ - 216 + 316 True Invoice Number Generator GTK_WINDOW_TOPLEVEL @@ -23,78 +23,395 @@ - - 10 + True False - 15 + 0 - + True - True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT + False + 0 - - 4 - 24 + + 322 True - True - False - False - False - GTK_JUSTIFY_CENTER - GTK_WRAP_NONE - False - 0 - 0 - 0 - 0 - 0 - 0 - Generated Number: - - - - - 0 - True - False - - + False + 15 - - - 72 - True - True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 0 + 0 - - - True - True - False - False - False - GTK_JUSTIFY_CENTER - GTK_WRAP_NONE - False - 0 - 0 - 0 - 0 - 0 - 0 - + + + True + False + 0 + + + + True + please select an available invoice number system below. + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 4 + False + False + + + + + + True + True + + False + True + + + + 0 + True + False + + + + + + + 0 + False + False + + + + + + 107 + True + True + GTK_POLICY_NEVER + GTK_POLICY_NEVER + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + Generated Number + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + 79 + True + True + + + False + True + GTK_JUSTIFY_CENTER + False + True + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + True + True + + + + + + 82 + True + False + 0 + + + + 21 + True + If you used the generated number, then click Yes below. + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + + 7 + True + True + 37 + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-apply + 5 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Yes, this number +has been used. + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-cancel + 5 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + No, this number +has not been used. + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + False + + + + 0 + True + True + @@ -105,224 +422,13 @@ - + True - False - 0 - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - False - False - True - GTK_JUSTIFY_CENTER - GTK_WRAP_WORD - False - 0 - 0 - 0 - 0 - 0 - 0 - If you used the generated number, then click Yes below. - - - - - 0 - True - True - - - - - - 9 - True - True - 37 - - - - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-apply - 5 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Yes, this number -has been used. - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-cancel - 5 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - No, this button -has not been used. - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - - - - 0 - True - True - - + True 0 - True + False False diff --git a/in-gen/in-gen-glade/in-gen-glade.glade.bak b/in-gen/in-gen-glade/in-gen-glade.glade.bak index c1ec21a..a60b501 100644 --- a/in-gen/in-gen-glade/in-gen-glade.glade.bak +++ b/in-gen/in-gen-glade/in-gen-glade.glade.bak @@ -4,7 +4,7 @@ - 216 + 316 True Invoice Number Generator GTK_WINDOW_TOPLEVEL @@ -20,80 +20,398 @@ True False + - - 10 + True False - 15 + 0 - + True - True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT + False + 0 - - 4 - 24 + + 322 True - True - False - False - False - GTK_JUSTIFY_CENTER - GTK_WRAP_NONE - False - 0 - 0 - 0 - 0 - 0 - 0 - Generated Number: - - - - - 0 - True - False - - + False + 15 - - - 72 - True - True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 0 + 0 - - - True - True - False - False - False - GTK_JUSTIFY_CENTER - GTK_WRAP_NONE - False - 0 - 0 - 0 - 0 - 0 - 0 - + + + True + False + 0 + + + + True + please select an available invoice number system below. + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 4 + False + False + + + + + + True + True + + False + True + + + + 0 + True + False + + + + + + + 0 + False + False + + + + + + 107 + True + True + GTK_POLICY_NEVER + GTK_POLICY_NEVER + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + Generated Number + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + 79 + True + True + + + False + True + GTK_JUSTIFY_CENTER + False + True + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + True + True + + + + + + 82 + True + False + 0 + + + + 21 + True + If you used the generated number, then click Yes below. + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + + 7 + True + True + 37 + + + + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-apply + 5 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Yes, this number +has been used. + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-cancel + 5 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + No, this number +has not been used. + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + False + + + + 0 + True + True + @@ -104,224 +422,13 @@ - + True - False - 0 - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - False - False - True - GTK_JUSTIFY_CENTER - GTK_WRAP_WORD - False - 0 - 0 - 0 - 0 - 0 - 0 - If you used the generated number, then click Yes below. - - - - - 0 - True - True - - - - - - 9 - True - True - 37 - - - - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-apply - 5 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Yes, this number -has been used. - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-cancel - 5 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - No, this button -has not been used. - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - - - - 0 - True - True - - + True 0 - True + False False diff --git a/in-gen/in-gen.py b/in-gen/in-gen.py index b5d313f..b061652 100644 --- a/in-gen/in-gen.py +++ b/in-gen/in-gen.py @@ -98,26 +98,49 @@ class gtkgui: self.gui = gtk.glade.XML(gladefile) # set button handlers actions = { "on_OkButton_clicked": self.clicked_ok, - "on_mainwindow_destroy": self.exit } + "on_mainwindow_destroy": self.exit, + "on_SectionComboBox_changed": self.combobox_changed + } # connect the actions to the events self.gui.signal_autoconnect (actions) #load config self.config = SettingsClass() + #display all number systems for selection + self.display_number_systems() + #default section + self.section = "" #display an unused invoice number - self.display_new_number() + #self.display_new_number() + + ############################3 + def display_number_systems(self): + """get all available number systems from configfile, display in combobox.""" + #get all sections + itemlist = self.config.prefs.items() + #remove Main section (not a number system) + if itemlist[0][0] == "Main": + itemlist = itemlist[1:] + #filter section names + sections = [] + for item in itemlist: + sections.append(item[0]) + #now fill widget data + self.cbox = self.gui.get_widget("SectionComboBox") + self.cbox.remove_text(0) + for section in sections: + self.cbox.append_text(section) + - #### functions which get executed on startup def display_new_number(self): #get relevant variables - prefix = self.config[section]["prefix"] - lastnumber = self.config[section]["lastnumber"] - suffix = self.config[section]["suffix"] + prefix = self.config[self.section]["prefix"] + lastnumber = self.config[self.section]["lastnumber"] + suffix = self.config[self.section]["suffix"] newnumber = create_number(prefix, lastnumber, suffix) #display new number in GUI self.outputfield = self.gui.get_widget("NumberDisplay") - self.textbuffer = self.outputfield.get_buffer() - self.textbuffer.set_text(newnumber) + self.outputfield.set_markup(''+newnumber+'') #### implementation of actions @@ -125,16 +148,28 @@ class gtkgui: def clicked_ok(self, widget): """save last generated number in config file""" #update "lastnumber" entry in config - self.config[section]["lastnumber"] = int(self.config[section]["lastnumber"]) + 1 + self.config[self.section]["lastnumber"] = int(self.config[self.section]["lastnumber"]) + 1 #write config to filesystem self.config.safe() - #notify user + number = self.config[self.section]["prefix"] + str(self.config[self.section]["lastnumber"]) + self.config[self.section]["suffix"] + self.outputfield = self.gui.get_widget("StatusBar") + self.outputfield.push(0,"Saved %s as last number." % number) + #display new number in GUI self.outputfield = self.gui.get_widget("NumberDisplay") - self.textbuffer = self.outputfield.get_buffer() - self.textbuffer.set_text("Saved number has been updated.") - + self.outputfield.set_markup("") + def combobox_changed(self,widget): + """display new number if the user has selected a section""" + self.set_section(widget) + self.display_new_number() + + def set_section(self, widget): + """sets current section according to selection in combobox""" + model = widget.get_model() + section = model[widget.get_active()][0] + self.section = section + def exit(self, widget): gtk.main_quit() @@ -153,8 +188,6 @@ def create_number(prefix, lastnumber, suffix): -#section = str(sys.argv[1]) -section = "Handrechnung" app = gtkgui(gtk) gtk.main()