Help with Python+Glade

Suggest, post, or discuss plugins for Deluge
Post Reply
SatNav
Member
Member
Posts: 25
Joined: Sat Jun 02, 2007 9:52 pm
Location: Lincoln, UK

Help with Python+Glade

Post 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
Attachments
RSS.tar.gz
(2.36 KiB) Downloaded 325 times
loutr

Re: Help with Python+Glade

Post 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.
orra
New User
New User
Posts: 3
Joined: Sat Jun 09, 2007 8:19 pm

Re: Help with Python+Glade

Post 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.
Post Reply