Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > use of gtk in a nautilus extension

Reply
Thread Tools

use of gtk in a nautilus extension

 
 
Nils
Guest
Posts: n/a
 
      08-18-2010
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/3...n-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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby GTK Fortune Cookies (gtk-fortune-0.1.1) Alex Shulgin Ruby 1 11-21-2007 01:05 AM
GTK+, segmentation fault in gtK-editable_get_chars zombek@gmail.com C Programming 2 05-29-2007 03:27 PM
HEXUS.reviews :: UK Exclusive - Corsair Nautilus 500 Silverstrand Front Page News 0 02-25-2006 10:08 PM
compiling ruby under windows (+ gtk stuff, is the gtk list dead?) Gergely Kontra Ruby 2 06-18-2004 10:20 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57