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

  • SEARCH
  • Home
  • 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 3341214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:41:49+00:00 2026-05-18T00:41:49+00:00

Alright, first off I’m not quite sure how to phrase my problem. This could

  • 0

Alright, first off I’m not quite sure how to phrase my problem. This could be lack of sleep, or being pretty new to Python and GTK, or a combination. To aid me, I have written a complete bare-bones example with the help of zetcode.com’s tutorials.

The problem, as well as I can put it, is a menu item – with no sub-menus – takes two clicks to activate. Unlike a sub-menu item activating on a single click. This is mildly annoying (and likely to confuse future users), but not really causing any problems with my application. I would, however, like to resolve it.

My actual application is being created with the help of Ubuntu Quickly – but the problem exists while using gtkBuilder or straight-gtk.

Here is the bare-bones example:

#!/usr/bin/python

import gtk


class MenuTest(gtk.Window):

    def __init__(self):
        super(MenuTest, self).__init__()

        self.set_title("Menus, how do they work?!")
        self.set_size_request(350, 200)
        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(6400, 6400, 6440))
        self.set_position(gtk.WIN_POS_CENTER)

        mb = gtk.MenuBar()

        filemenu = gtk.Menu()
        filem = gtk.MenuItem("Some Action")
        filem.connect("activate", self.on_file_activate)

        mb.append(filem)

        vbox = gtk.VBox(False, 2)
        vbox.pack_start(mb, False, False, 0)

        self.add(vbox)

        self.connect("destroy", gtk.main_quit)
        self.show_all()

    def on_file_activate(self, widget):
        md = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, "herp derp, took two clicks to show me")
        md.run()
        md.destroy()


MenuTest()
gtk.main()

Hopefully someone can help, and not completely confuse this noob at the same time.

  • 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-18T00:41:50+00:00Added an answer on May 18, 2026 at 12:41 am

    You can solve your problem by connecting to the 'button-press-event' signal instead of the 'activate' signal, and making your callback like this:

    def on_file_activate(self, widget, event):
        if event.button != 1:
            return False  #only intercept left mouse button
        md = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, "herp derp, I only needed one click")
        md.run()
        md.destroy()
        return True
    

    However, why would you want to do that? I’m not surprised that your original code didn’t work as expected, because that’s not really what menus are for. You’d be better off using a toolbar button, or a regular button. I think misusing a menu as a button is more likely to confuse future users.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright. First off, I am new to Rails and this is the first project
Alright, I'm at my wit's end on this issue. First, backstory. I'm working on
Alright, Ill try to explain this as best as I can first... My program
First off I'd like to say this is the only java experience I've had.
At first I should mention that this problem only occurs in windows forms applications
Alright let me explain my situation first: I am part of an organization that
Alright, so here is what I'm hoping for... Any request to this http://www.fileorchard.com/3451928347592 will
Alright, first you'll need to grab a barf bag. I've been tasked with optimizing
Alright, I have two files. They are the EXACT SAME. The first file is:
Alright, so I'm new to Android programming, so far my experience has been quite

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.