use of gtk in a nautilus extension

N

Nils

Hi,
I am having some trouble opening a simple message/dialog to the user
from a natilus extension..

I have written a simple nautilus extension using python. It adds one
MenuItem to the context menu.
for testing I wanted to open a simple dialog when the user clicks this
menuitem.
(The code can be found - with some nice formatting here:
http://stackoverflow.com/questions/3325772/use-gtk-in-a-nautilus-extension-using-python)

The code is as follows:
--- cut ---
import gtk
import nautilus
import os
def alert(message):
"""A function to debug"""
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, message)
dialog.run()
dialog.destroy()

class TestExtension(nautilus.MenuProvider):
def __init__(self):
pass

def get_file_items(self, window, files):
items = []
"""Called when the user selects a file in Nautilus."""
item = nautilus.MenuItem("NautilusPython::test_item", "Test",
"Test")
item.connect("activate", self.menu_activate_cb, files)
items.append(item)
return items

def menu_activate_cb(self, menu, files):
"""Called when the user selects the menu."""
for name in files:
alert(name)
--- cut ---

When I click on the menuitem nothing happens...
But when I replace def alert(message) like this:
def alert(message):
"""A function to debug"""
easygui.msgbox(message)
and obviously drop import gtk and add import easygui,

The dialog does appear. Can someone tell me why this is ??

Yours,
Nils
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top