Yay! We have a first step towards a GTK implementation! I'm commiting this code in a few minutes.
---------- Forwarded message ---------- From: Felipe Sanches <[EMAIL PROTECTED]> Date: Feb 1, 2008 1:23 AM Subject: abstk initial gtk support To: "Lucas C. Villa Real" <[EMAIL PROTECTED]> just for fun I wrote this little piece of code that implements only a tiny part of everything that is actually needed Currently it only suports a Label (and doesnt have getValue yet) works for the minimalist-test.py Felipe C. da S. Sanches (a.k.a. "Juca") -- Lucas powered by /dev/dsp
# -*- encoding iso-8859-1 -*- #!/usr/bin/python import gtk from wizard import * class AbsGtkWizard(AbsWizard) : def __init__(self, name = '') : self.main_window = gtk.Window() self.main_window.set_title(name) self.vbox = gtk.VBox() self.main_window.add(self.vbox) def do_prev(self, w): #TODO: fix addScreen and then here remove current # screen widget and add the correct one pass def do_next(self, w): #TODO: similar to do_prev pass def start(self) : self.main_window.show_all() self.main_window.connect("destroy", gtk.main_quit) bottom_buttons = gtk.HBox() cancel = gtk.Button("Cancel") cancel.connect("clicked", gtk.main_quit) prev = gtk.Button("Previous") prev.connect("clicked", self.do_prev) next = gtk.Button("Next") next.connect("clicked", self.do_next) #TODO: align buttons to the right bottom_buttons.pack_end(cancel) bottom_buttons.pack_end(next) bottom_buttons.pack_end(prev) bottom_buttons.show_all() self.vbox.add(bottom_buttons) return gtk.main() def addScreen(self, screen, pos = 0) : #TODO: this shouldn't be done this way! # should setup a screens list to wich this screen would be appended self.vbox.add(screen.frame) class AbsGtkScreen(AbsScreen) : def __init__(self, title="WARNING: I DON'T HAVE A TITLE!") : self.fields = {} self.widgets = [] self.main_vbox = gtk.VBox() self.frame = gtk.Frame(title) self.frame.add(self.main_vbox) self.frame.show_all() def __registerField(self, name, widget) : self.fields[name] = widget def setTitle(self, title) : self.frame.set_title(title) def __addWidget(self, fieldName, w = None): if fieldName : self.__registerField(fieldName, w) self.widgets.append(w) #TODO: align to the left self.main_vbox.pack_start(w, False, False) def addLabel(self, fieldName, label, defaultValue = '', tooltip = "I DON'T HAVE A TOOLTIP", callBack = None) : w = gtk.Label(label) w.show() self.__addWidget(fieldName, w)
#!/usr/bin/python # -*- coding: iso-8859-1 -*- import sys mode = sys.argv[1] if mode == 'curses' : from cwizard import * Wizard = AbsCursesWizard Screen = AbsCursesScreen elif mode == 'qt' : from qtwizard import * Wizard = AbsQtWizard Screen = AbsQtScreen elif mode == 'gtk' : from gtkwizard import * Wizard = AbsGtkWizard Screen = AbsGtkScreen w = Wizard('AbsTk Minimalist Test') scr1 = Screen('First Screen') scr1.addLabel('Parameter1', '1234') scr1.addLabel('Parameter2', 'abcd') scr1.addLabel('Parameter3', 'xyz') w.addScreen(scr1) w.start()
_______________________________________________ gobolinux-devel mailing list gobolinux-devel@lists.gobolinux.org http://lists.gobolinux.org/mailman/listinfo/gobolinux-devel