Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-22-2007, 09:23 PM   #1
LQ Newbie
Registered: Jan 2001
Location: Norfolk, UK
Posts: 3

Rep: Reputation: 0
Python / Glade / GTK problem with accessing widget properties

Hi there,

I am very new to Python and am trying to code a Python / Glade app to dump the user input into an XML file. As I intend to use the field name associated with the widget as the XML tag, I want to extract the widget name and the content or state of the widget (toggled or untoggled in the case of radio buttons and check boxes) by looping through the widgets using wTree. This does not provide the outcome I was hoping for:


  #!/usr/bin/env python

  import sys
      import pygtk
      import gtk
  class FormGenGTK:
      def __init__(self):
          self.gladefile = ""  
          self.wTree = 
          dic = { "on_button1_clicked" : self.on_button1_clicked, 
                  "on_button2_clicked" : gtk.main_quit ,
                  "on_window1_destroy" : gtk.main_quit }
      def on_button1_clicked(self, widget):
          text = {}    
          for x in range(1,5):
              entry = "entry%s" % (x)    
              text[x] = self.wTree.get_widget(entry)        
              print text[x] 
  if __name__ == "__main__":
      hwg = FormGenGTK()

However, this results in the following output even when the fields entry1 .... 5 are populated:


 <gtk.Entry object at 0x82687d4 (GtkEntry at 0x84cf660)>
 <gtk.Entry object at 0x8268af4 (GtkEntry at 0x84cf710)>
 <gtk.Entry object at 0x8268b1c (GtkEntry at 0x84d6008)>
 <gtk.Entry object at 0x8268b44 (GtkEntry at 0x84d60b8)>
I am guessing that by calling self.wTree.signal_autoconnect(dic) I am loading the buttons and window widgets and overwriting the widgets defined in the XML file.

Can anyone suggest an elegant solution to access a widget without knowing its name and displaying its content?

Many thanks in advance.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with python David the H. Linux - Software 2 02-08-2007 09:18 AM
Gtk widget problem iali Linux - General 0 01-21-2006 01:56 AM
Is there Paint like program or widget in Glade+GTK+ santhosh.linux Programming 1 01-12-2006 04:55 AM
python/glade attach window content in gtk.fixed() a10392 Linux - Software 3 10-08-2004 10:19 AM
How to program for CTree widget in Glade 2.0 swaviswa Programming 0 03-27-2004 02:50 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration