Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 483529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:12:25+00:00 2026-05-13T01:12:25+00:00

I am trying to write an extension for nautilus, which add an item to

  • 0

I am trying to write an extension for nautilus, which add an item to the menu that appears when you right-click a file (as shown in image)

alt text

However, I would like to add a submenu to my custom menu item.

I downloaded a ‘nautilus-python’ package which includes examples of how to write extensions for Nautilus (and so far it turned out to be the best/only documentation i found). In it, is a file called submenu.py, which contains the following:

import nautilus

class ExampleMenuProvider(nautilus.MenuProvider):

    def get_file_items(self, window, files):
        menuitem = nautilus.MenuItem('ExampleMenuProvider::Foo', 'Foo', '')

        submenu = nautilus.Menu()
        menuitem.set_submenu(submenu)

        menuitem = nautilus.MenuItem('ExampleMenuProvider::Bar','Bar','')
        submenu.append_item(menuitem)

        return menuitem,

    # FIXME: Why isn't this working?
    def get_background_items(self, window, file):
        submenu = nautilus.Menu()
        submenu.append_item(nautilus.MenuItem('ExampleMenuProvider::Bar', 'Bar', ''))

        menuitem = nautilus.MenuItem('ExampleMenuProvider::Foo', 'Foo', '')
        menuitem.set_submenu(submenu)

        return menuitem,

ps: i didn’t add “# FIX ME: Why isnt this working?”. that is actually included in the example

The code doesn’t work. Even if i take out the second function and leave just the first one, it doesn’t work.

Any help would be appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:12:25+00:00Added an answer on May 13, 2026 at 1:12 am

    I found the solution.

    1. you need a init function declared.
    2. had to make some variable name change to the example above

      import nautilus
      
      class ExampleMenuProvider(nautilus.MenuProvider):
          def __init__(self):
              pass
      
          def get_file_items(self, window, files):
              submenu = nautilus.Menu()
      
              item = nautilus.MenuItem('Nautilus::sbi','Nau-T','image')
              item.set_submenu(submenu)
      
              item_two = nautilus.MenuItem('Nautilus::s','www','image')
              submenu.append_item(item_two)
      
              return item,
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an extension method that will add the function HasFactor to
I'm trying to write a Chrome Extension that just adds a CSS file to
I'm trying to write an extension method for objects that will dump the structure
I'm trying to write a Thunderbird extension using XUL, a custom button that accesses
I'm trying to write a chrome extension that is used in the GMail compose
I'm trying to write a Python C extension that processes byte strings, and I
I'm trying to write a Google chrome extension so that I can highlight text
I'm trying to write a WiX script that uses the firewall extension to WiX,
I'm trying to write an extension method that I can use to copy values
I am trying to write an extension that can access the TextUndoHistory of an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.