[Tutor] Glade + python dialogs

Alan Gauld alan.gauld at btinternet.com
Tue May 22 21:58:50 CEST 2007


"Antonio Diaz" <minyie at hotmail.com> wrote

> hello, i have a problem, i created a main window on Glade.

You might get better results asking on the wxPython mailing list.
There could well be Glade experts here but its more by luck than
good reason, tutor is really aimed at learning Python itself.

Also it would help if you can avoid HTML email, I know
that's not always possible but the mess below is barely
decipherable in my version of Outlook Express...

Alan G.

# -*- coding: utf-8 -*-import gtkimport gtk.gladeimport Imageimport 
ImageDrawimport osclass wndBase:    "Clase base para manejar todas las 
ventanas, contiene las caracter�icas principales"    windowname = '' 
def __init__(self):        "Constructor base de las ventanas" 
#Obtiene el nombre de la ventana del nombre de la clase que se 
est�tilizando        self.windowname = 
str(self.__class__).split(".")[1]        if self.windowname: 
self.wTree = gtk.glade.XML("proyecto1.glade", self.windowname) 
self.win = self.wTree.get_widget(self.windowname) 
self.wTree.signal_autoconnect(self) 
self.win.connect("destroy", self.destroy)        self.post_init() 
def init(self):        "Funci�irtual que debe ser sobreescrita para 
especificar los valores de arranque del formulario"        pass    def 
post_init(self):        "Funci�ue se ejecuta luego de haber creado el 
formulario base y conectado las se�s"        pass    def show(self): 
"Llama al m�do show del widget correspondiente a la ventana"        if 
self.win:            self.win.show()    def hide(self):        if 
self.win:            self.win.hide()    def set_modal(self, bool = 
False):        self.win.set_modal(bool)    def destroy(self, *args): 
self.win.destroy()    def set_parent(self, parent):        "Establece 
la clase padre y la ventana padre para el objeto actual"        if 
parent:            self.parent = parent 
self.win.set_transient_for(parent.win)            def maximize(self, 
*args):            self.win.maximize()    def set_modal(self, bool = 
False):        self.win.set_modal(bool)class Main(wndBase):    def 
destroy(self, *args):        gtk.main_quit()    def 
on_button_open_activate(self, widget, *args):        def 
respuesta(widget, response):            if response == 
gtk.RESPONSE_OK:                self.archivo = widget.get_filename() 
archivo_temporal = "/tmp/" + os.path.basename(self.archivo) 
self.img=Image.open(self.archivo) 
self.img.save(archivo_temporal) 
self.wTree.get_widget('imagen_principal').set_from_file(archivo_temporal) 
widget.destroy()            else:                widget.destroy() 
abrir = gtk.FileSelection()        abrir.connect("response", 
respuesta)        abrir.run()    def on_rotate_activate(self, widget, 
*args):        window_rotate=edit_rotate()    def 
on_button_font_clicked(self, widget, *args): 
font_vent=fontselectiondialog1()        font_vent.show()        class 
fontselectiondialog1(wndBase):    passclass edit_rotate(wndBase): 
def my_response(self, widget, respuesta):        if respuesta == 
gtk.RESPONSE_OK:            #print 
self.wTree.get_widget("entry_rotate").get_text() 
rotate_value=int(self.wTree.get_widget("entry_rotate").get_text()) 
archivo_temporal = "/tmp/" + os.path.basename(Main.archivo) 
print archivo_temporal 
self.img=Image.open(archivo_temporal) 
self.img.rotate(rotate_value) 
self.img.save(archivo_temporal) 
self.wTree.get_widget('imagen_principal').set_from_file(archivo_temporal) 
widget.destroy()        else:            widget.destroy() 
ventana1=Main()ventana1.maximize()ventana1.show()gtk.main()
> _________________________________________________________________
> Create the ultimate e-mail address book. Import your contacts to 
> Windows Live Hotmail.
> www.windowslive-hotmail.com/learnmore/managemail2.html?locale=en-us&ocid=TXT_TAGLM_HMWL_reten_impcont_0507



> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




More information about the Tutor mailing list