PyGTK, Glade/libglade. What am I doing wrong?

craf pyclutter at gmail.com
Fri May 6 23:47:42 EDT 2011


On May 6, 2011 7:05 PM, "Даниил Рыжков" <daniil.re at gmail.com> wrote:
>
> Sorry for my English (I could not find help in the Russian community)
> I'm trying to learn PyGTK and Glade. I made test window in Glade and
> saved it as "test.glade" (attached). Then I wrote script
> "test.py"(attached, http://pastebin.com/waKytam3). I tried to run it.
> While the script was executed, console did not show anything and
> window wasn't displayed. When I pressed CTRL+С console displayed
> trackback:
> ---
> CTraceback (most recent call last):
>  File "test.py", line 32, in <module>
>    gtk.main()
> KeyboardInterrupt
> ---
> So what am I doing wrong?
>

>I haven't used gtk before, but is there a show method or something
>similar you need, to actually make the window appear? The
>KeyboardInterrupt is normal. That's how control-c works.
> --
> Best wishes,
> Daniil
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Hi.

Try this:

#!/usr/bin/env python

import gtk.glade

class TestPyGtk:
    """This is an Hello World GTK application"""

    def __init__(self):

        #Set the Glade file
        self.gladefile = "test.glade"
        self.glade = gtk.glade.XML(self.gladefile)

        self.MainWindow = self.glade.get_widget('MainWindow')
        self.MainWindow.show()
        self.MainWindow.connect('destroy', lambda e:gtk.main_quit())



TestPyGtk()
gtk.main()

Regards.

Cristian.

List of Pygtk: http://www.daa.com.au/mailman/listinfo/pygtk








More information about the Python-list mailing list