FAQ
Hi Everyone,

So I've built a UI with Glade and have loaded it using the standard
Python code. In my UI, I have a textfield called txtUsername. How do I
get and set the text in this field from my Python code?

Thanks!
Anthony

--
Anthony Papillion
Advanced Data Concepts
Get real about your software/web development and IT Services
Phone: (918) 919-4624

Does your business need to reduce its phone bill? I can help!
Email me and ask me how!

Search Discussions

  • John Gordon at Jul 11, 2011 at 3:44 am

    In <mailman.877.1310350451.1164.python-list at python.org> Anthony Papillion <papillion at gmail.com> writes:

    So I've built a UI with Glade and have loaded it using the standard
    Python code. In my UI, I have a textfield called txtUsername. How do I
    get and set the text in this field from my Python code?
    I don't know anything about Glade, so I can't answer your question
    definitively. However, as a general rule, you can use the dir() builtin
    function to see what methods are defined by an object.

    So, assuming you have access to an interactive shell within your Glade
    environment, you can do this:

    dir(txtUsername)

    and it will print a list of methods that are defined by that object.
    Hopefully one of them will be called something helpful like set_text()
    or set_property(). Once you know the method name, you might try a Google
    search to determine the exact usage and arguments.

    --
    John Gordon A is for Amy, who fell down the stairs
    gordon at panix.com B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
  • Anthony Papillion at Jul 11, 2011 at 4:09 am

    I don't know anything about Glade, so I can't answer your question
    definitively. However, as a general rule, you can use the dir() builtin
    function to see what methods are defined by an object.
    Hi John,

    Thanks for the input and it looks like it's pretty simple. Basically, I
    can access the properties of objects like:

    self.objectname.property_or_method()

    So, to solve my question, I'd just use:

    self.txtUsername.set_text('Whatever I want')

    or

    enteredText = self.txtUsername.get_text()

    Pretty simple and this actually solves ALL of my Glade problems. I'm
    excited.

    Thanks for the direction!

    Anthony
  • Adam Tauno Williams at Jul 11, 2011 at 10:24 am

    On Mon, 2011-07-11 at 03:44 +0000, John Gordon wrote:
    In <mailman.877.1310350451.1164.python-list at python.org> Anthony Papillion <papillion at gmail.com> writes:
    So I've built a UI with Glade and have loaded it using the standard
    Python code. In my UI, I have a textfield called txtUsername. How do I
    get and set the text in this field from my Python code?
    field.get_text()
    field.set_text(value)

    <http://pygtk.org/docs/pygtk/class-gtkentry.html#method-gtkentry--set-text>
    and it will print a list of methods that are defined by that object.
    Hopefully one of them will be called something helpful like set_text()
    or set_property(). Once you know the method name, you might try a Google
    search to determine the exact usage and arguments.
    -1 -1 -1 Do not "google" [search the Internet] for solutions to pyGtk
    problems. That is just a confusing waste of time. Use the *excellent*
    and well-linked documentation:

    <http://pygtk.org/docs/pygtk/>
    <http://faq.pygtk.org/index.py?req=index>

    The FAQ is extensive and really does cover a lot of the common
    questions. Also there is a list specifically for pygtk questions:

    <http://www.daa.com.au/mailman/listinfo/pygtk>

    Google, or Bing, or even DuckDuckGo, are *not* your friends. They are
    enormous and inefficient time-sinks. They are a *BAD* way to solve
    problems. Use the documentation.
  • John Gordon at Jul 11, 2011 at 2:24 pm

    In <mailman.884.1310380058.1164.python-list at python.org> Adam Tauno Williams <awilliam at whitemice.org> writes:

    Google, or Bing, or even DuckDuckGo, are *not* your friends. They are
    enormous and inefficient time-sinks. They are a *BAD* way to solve
    problems. Use the documentation.
    One would hope that a Google search might lead to the documentation.

    --
    John Gordon A is for Amy, who fell down the stairs
    gordon at panix.com B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
  • Waldek M. at Jul 11, 2011 at 5:03 am
    Dnia Sun, 10 Jul 2011 21:14:10 -0500, Anthony Papillion napisa?(a):
    So I've built a UI with Glade and have loaded it using the standard
    Python code. In my UI, I have a textfield called txtUsername. How do I
    get and set the text in this field from my Python code?
    http://developer.gnome.org/pygtk/stable/
    http://www.learningpython.com/2006/05/07/creating-a-gui-using-pygtk-and-glade/

    Br.
    Waldek

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 11, '11 at 2:14a
activeJul 11, '11 at 2:24p
posts6
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase