[pygtk] Dialog hide method doesnt hide at the moment

Pablo Recio Quijano rikutheronin at gmail.com
Sun Jan 31 06:07:57 WST 2010


2010/1/30 Pietro Battiston <toobaz at email.it>

> Il giorno sab, 30/01/2010 alle 20.36 +0100, Pablo Recio Quijano ha
> scritto:
> > Hi.
> >
> >
> > I have a code more or less like:
> >
> >
> > while ...: #some comprobations
> >         # other stuffs
> >         R = round_result.roundResult() #a dialog object
> >         response = R.result_dialog.run()
> >         if response == 13: #13 is the ID of button to close
> >                 R.result_dialog.destroy()
>
> Could you try adding the line
>           gtk.main_iteration(False)
> at the end?
>

It doesn't work neither.

I simplified the code, and reduce it to:

# -*- coding: utf-8 -*-

import gtk
import time

class mainDialog:
    def __init__(self):
        builder = gtk.Builder()
        builder.add_from_file('prueba.glade')

        self.dialog = builder.get_object('main_dialog')
        self.repetir = True

        builder.connect_signals(self)

    def on_btn_repetir_clicked(self, widget, data=None):
        self.dialog.hide()

    def on_btn_salir_clicked(self, widget, data=None):
        self.repetir = False
        self.dialog.destroy()

if __name__ == "__main__":
    band = True
    while band:
        dlg = mainDialog()
        dlg.dialog.run()

        gtk.main_iteration(False)

        time.sleep(5)

The dialog is a simple dialog with 2 buttons. If one is clicked, the dialog
will be hidden and created again in the loop. If the other is clicked should
destroy the dialog.

Seeing the code, looks to me that it must hide/destroy the dialog before the
5 seconds sleep. But the behaviour is the opposite: first waits 5 seconds,
and then hide/destroy the dialog.


>
> Pietro
>
> >
> > The problem is that the dialog doesn't destroy in that moment.
> > Instead, is destroyed in the next loops's iteration. I also tried to
> > map a function to the event trigged by clicking that button, using
> > hide or destroy, but doesn't work either.
> >
> >
> > Is there any way to hide the dialog in the moment I want to? Because I
> > don't understand what's happening.
> >
> >
> > Thanks in advance.
> >
> > --
> > Pablo Recio Quijano
> >
> > Estudiante de Ingeniería Informática (UCA)
> > Becario en Alquimia Proyectos Digitales
> > Alumno colaborador del Departamento de Lenguajes y Sistemas
> > Informáticos
> > Participante del IV Concurso Universitario de Software Libre
> >
> > _______________________________________________
> > pygtk mailing list   pygtk at daa.com.au
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://faq.pygtk.org/
>
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/




-- 
Pablo Recio Quijano

Estudiante de Ingeniería Informática (UCA)
Becario en Alquimia Proyectos Digitales
Alumno colaborador del Departamento de Lenguajes y Sistemas Informáticos
Participante del IV Concurso Universitario de Software Libre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20100130/5aa64a71/attachment.htm 


More information about the pygtk mailing list