[pygtk] not enough arguments?
Felix Rabe (public)
public at felixrabe.textdriven.com
Sat Aug 5 22:46:27 WST 2006
Christopher Spears wrote:
> Okay, I got the get_path function to print.
>
> Is there way to get return values? I was hoping to be
> able to write get_path and get_pattern functions and
> then use these functions inside the glob_files
> function.
You use get_path as a callback, which by definition is just a way for
you to react to something. The caller of your callback function (i.e.,
the GTK machinery) is not interested in your return value (unless it is
called in response to an event, such as delete-event).
You need to call the processing functions from the callback and then
either write the result using print or to something like a TextView:
def __init__(self):
...
self.pattern_entry = self.wTree.get_widget("pattern_entry")
self.textview = self.wTree.get_widget("textview1")
# you better connect to "on_path_entry_activate" as well
dic = { ... "on_pattern_entry_activate": self.cb_pattern_activate ... }
...
def cb_pattern_activate(self, entry):
matched_files = glob.glob(self.pattern_entry.get_text())
buf = self.textview.get_buffer()
buf.set_text("\n".join(matched_files))
There are many questions remaining about your code that make responding
in a way that solves your problem difficult:
You use Glade, what does your GUI look like?
Where do glob_files and print_dict get called from?
Where do you assign a value to the "pattern" variable that is used in
create_dict?
... and so on
I hope you can use my few lines of code, though. Browse the
documentation and tutorial on www.pygtk.org deeply to find out more, it
is complete. If questions are remaining, just ask.
Greetings,
Felix
More information about the pygtk
mailing list