Page 1 of 1

Help with Python+Glade

Posted: Sun Jun 03, 2007 8:07 pm
by SatNav
Hi, I've started making an RSS plugin for deluge, since for me that's the killer feature this program is missing. I'm also using the experience to learn python, so it might be slow going - but I'm fairly confident.

I intend it to be similar in look and feel to the RSS downloader in uTorrent, since I'm familiar with that one.

Anyway, I'm just working on setting up the interface atm, and I've run into a stumbling block. I've set up a dialog for adding and removing feeds from a list, modelling it quite closely on the 'Search' plugin. I've set up event handlers in the Glade interface, but for some reason they don't seem to be connecting to their associated functions in plugin.py. Here's what I've got:

Code: Select all

self.glade = gtk.glade.XML(path + "/rss.glade")
...
self.name_entry = glade.get_widget("name_entry")      
self.url_entry = glade.get_widget("url_entry")
...
self.glade.signal_autoconnect({"add_clicked": self.add_clicked,
      "del_clicked": self.del_clicked,
      "row_clicked": self.row_clicked,
      feedtext_changed": self.feedtext_changed })
...
def add_clicked(self, args):
      #self.feeds_view.get_model().append([self.name_entry.get_text(),
      #self.url_entry.get_text()])
      self.name_entry.set_text("")
      self.url_entry.set_text("")


I type a little text into one of the entry boxes, then press add (hoping to see the text disappear), but nothing happens. I've attached the py and glade files for a better picture of what I'm talking about. Any help appreciated :D

Mark

Re: Help with Python+Glade

Posted: Tue Jun 05, 2007 9:44 am
by loutr
Hi,

I think your problem is that you commented out the text_changed code, but left the function declaration, so python expects an indented block of code but instead finds another declaration. I haven't tested your code in deluge, but I guess deluge catches python errors triggered by plugins, so your code fails silently.

Re: Help with Python+Glade

Posted: Sat Jun 09, 2007 8:28 pm
by orra
Hi,

loutr was partly right. You've got functions which are entirely commented out, and so Python errors which it finds the next function. More "pass"es are necessary.

Also, it errors without the icon, so you'll have to comment out that line, or add an icon.

And finally: in the top function, you need to change four instances of:
glade.get_widget
to
self.glade.get_widget

Doing all that got the add button working for me.

Here's a tip: run Deluge from the terminal. That way you'll see all the error messages.


Regards.