using gtk from nautilus plugin



Hi.
I have asked this question in some places, but never got an anwer..
I created an (python) extension like this:

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)

however the gtk.MessageDialog never appears.
If I change the use from gtk to say easygui like this:

import easygui
import nautilus
import os

def alert(message):
    """A function to debug"""
    easygui.msgbox(message)

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)

All is fine.

Can someone explain to me why the gtk.MessageDialog is not working in this code?

Yours,
Nils


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]