How to pass the value to a function? (gtk.entry)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to pass the value to a function? (gtk.entry)

bakabonpapa
Hello.
This is my 10th day of learning python and pygtk.

Right now, I'm building a gui program using pygtk.
And there is an entry box using "gtk.Entry" and its "get_text".

I'v been trying to pass its parameter to a function as a parameter,
but strugling for long hours without succsess.

Can anyone give me some hints, please?

The code looks like below.

--------------------------------------------
#!/usr/bin/env python
# coding: utf-8
import pygtk
pygtk.require('2.0')
import gtk

# function to which I wanna pass the value as augument.
def functionA(x):
    result = ''
    for i in range(1, 1 + 100*x):
        ・
        ・
    return result
        ・
        ・
class gui:
    def __init__(self):
        self.window = gtk.Window()
        ・
        ・
        # the entry box to which user will enter the value.
        self.entry = gtk.Entry()
        self.entry.get_text() # How to pass the value of "get_text()"?
        ・
        ・

--------------------------------------------






_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: How to pass the value to a function? (gtk.entry)

Hrvoje Niksic-2
On 04/25/2014 07:18 AM, bakabonpapa wrote:
> Right now, I'm building a gui program using pygtk.
> And there is an entry box using "gtk.Entry" and its "get_text".
>
> I'v been trying to pass its parameter to a function as a parameter,
> but strugling for long hours without succsess.

Please describe what you actually want to accomplish. There is little
use in calling get_text() on a newly created gtk.Entry, since the entry
will certainly be empty.

Passing "its parameter to a function as a parameter" doesn't make much
sense, either - maybe you mean passing its return value? For example,
functionA(self.entry.get_text()). But that should likely be done when
the entry is changed or activated, again depending on what you want the
program to do.

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/