Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:07:19+00:00 2026-06-17T19:07:19+00:00

I am writing a basic gui for my log parsing script. Im using GTK

  • 0

I am writing a basic gui for my log parsing script. Im using GTK 2x, Glade and Python 2.7.3.

I have some global variables defined and need to change those according the user input in the gui text boxes. The whole layout is made in glade. Any tips how to pass strings and values from widgets to functions outside the GUI class?

Sample text box definition from a glade file:

<child>
      <object class="GtkEntry" id="serverIDtext">
        <property name="visible">True</property>
        <property name="can_focus">True</property>
        <property name="invisible_char">●</property>
        <property name="text" translatable="yes">Server name.</property>
        <property name="primary_icon_activatable">False</property>
        <property name="secondary_icon_activatable">False</property>
        <property name="primary_icon_sensitive">True</property>
        <property name="secondary_icon_sensitive">True</property>
      </object>
      <packing>
        <property name="top_attach">2</property>
        <property name="bottom_attach">3</property>
      </packing>
    </child>

GUI class:

import pygtk
import gtk
import gtk.glade

from pyParse2 import *

class GUI:
  def __init__(self):    
    builder = gtk.Builder()
    builder.add_from_file("parsergui.glade")
    self.window = builder.get_object("window1")
    builder.connect_signals(self)

  def on_window_destroy(self, widget, data = None):
    gtk.main_quit()

  def parseButton(self, widget, data = None):
    parseLaunch()

EDIT as per MG. advice:
I tried your first advice and prepared something like this:

import pygtk
import gtk
import gtk.glade

from pyParse2 import *

class GUI:
  def __init__(self):    
    builder = gtk.Builder()
    builder.add_from_file("parsergui.glade")
    self.window = builder.get_object("window1")
    builder.connect_signals(self)
    self.sID = builder.get_object("serverIDtext")

  def on_window_destroy(self, widget, data = None):
    gtk.main_quit()

  def parseButton(self, widget, data = None):
    global serverID
    serverID = self.sID
    print serverID
    parseLaunch()

And got this:

<gtk.Entry object at 0x2a97a58 (GtkEntry at 0x20e9118)>

As I understand it (and I am most probably wrong), I cant use get_text, but have to do get_object, which doesnt return a string. Is there a way to go around this?

O_O

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:07:21+00:00Added an answer on June 17, 2026 at 7:07 pm

    You can access the entry by the Builder class as you do with the window.

    # in __init__
    self.entry = builder.get_object('serverIDtext')
    

    There is an alternative but a cause of a bug or a misconception on how it works, or how it should work, requires a bit of tests to make it work. Basically you can pass the reference of the text box to the handler via the User data parameter. In glade when you associate the parseButton handler to a signal, set the User data to the text box. Now the tricky part: I don’t remember if the text box is passed as widget parameter or data parameter and the Swap checkbox control this behavior.

    When you have a reference to the text box you can easily retrieve the string calling the get_text() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a basic jQuery form validation script and I have something like
I have been writing some basic code for an application I am designing. I
I'm writing a basic GUI application that essentially invokes other processes given some parameters,
I am writing a basic screen scraping script using Mechanize and BeautifulSoup (BS) in
I'm writing a basic war-driving program. I have gotten it to loop the command
I am writing a basic program in Python that prompts the user to enter
I'm a newbie with a little experience writing in BASIC, Python and, of all
I am writing a basic toon shader in OpenGL. I am using MSVC 2008.
I'm occurring some trouble writing a basic webserver in JAVA. It's currently working fine
I'm writing a pretty basic application in python (it's only one file at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.