Results 1 to 6 of 6

Thread: gtk.main() does nothing?

  1. #1
    Join Date
    Feb 2007
    Location
    Nowhere important
    Beans
    1,198
    Distro
    Ubuntu 12.04 Precise Pangolin

    gtk.main() does nothing?

    Hello,
    I've build a glade file and a python one, but when I run the python file, nothing happens!

    pyhelloworld.glade:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
    <!--Generated with glade3 3.4.5 on Sun Aug 31 20:28:23 2008 -->
    <glade-interface>
      <widget class="GtkWindow" id="window1">
        <signal name="destroy" handler="on_window1_destroy"/>
        <child>
          <widget class="GtkLabel" id="label1">
            <property name="visible">True</property>
            <property name="label" translatable="yes">Hello world!</property>
            <property name="justify">GTK_JUSTIFY_CENTER</property>
          </widget>
        </child>
      </widget>
    </glade-interface>
    PyHelloWorld.py:
    Code:
    #!/usr/bin/python
    import gtk
    import gtk.glade
    import gnome.ui
    
    def DestroyFunction(obj):
    	gtk.main_quit()
    
    widgetTree = gtk.glade.XML("pyhelloworld.glade")
    
    dic = { "on_window1_destroy" : DestroyFunction }
    
    widgetTree.signal_autoconnect (dic)
    
    gtk.main()
    Anyone, please?
    ➙ Synchronize all your files across Windows, Linux and Mac OS with Dropbox (2GB free storage!). By signing up via this link I'll get some extra space also, thanks!

    Multiseat on Ubuntu 10.04

  2. #2

    Re: gtk.main() does nothing?

    You need to get a ref to the window, and show it (window.showAll() to show the children too)

  3. #3
    Join Date
    Feb 2007
    Location
    Nowhere important
    Beans
    1,198
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: gtk.main() does nothing?

    I'm a complete newbie. Could you tell me how to do this?
    ➙ Synchronize all your files across Windows, Linux and Mac OS with Dropbox (2GB free storage!). By signing up via this link I'll get some extra space also, thanks!

    Multiseat on Ubuntu 10.04

  4. #4

    Re: gtk.main() does nothing?

    In pseudocode:

    Glade xml = Glade.load("file")
    Window w = xml:getWidget("yourwidgetname")
    w:showAll()

  5. #5
    Join Date
    Feb 2007
    Location
    Nowhere important
    Beans
    1,198
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: gtk.main() does nothing?

    Thank you, but the problem was:

    <property name="visible">True</property>
    ➙ Synchronize all your files across Windows, Linux and Mac OS with Dropbox (2GB free storage!). By signing up via this link I'll get some extra space also, thanks!

    Multiseat on Ubuntu 10.04

  6. #6

    Re: gtk.main() does nothing?

    Quote Originally Posted by Martje_001 View Post
    Thank you, but the problem was:

    <property name="visible">True</property>
    Nice. The show method would set the property visible to TRUE too =).

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •