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 6963979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:51:55+00:00 2026-05-27T15:51:55+00:00

The code below is a simplified version of my task bar icon class, I

  • 0

The code below is a simplified version of my task bar icon class, I haven’t checked the GetKeyCode() value to see if it’s a ctrl as the key press events aren’t being fired. Should I be binding key presses to somewhere else?

class TBI(wx.TaskBarIcon):
    TBMENU_CTRLCLICK= wx.NewId()

    def __init__(self,frame):
        wx.TaskBarIcon.__init__(self)
        self.frame=frame
        self.ctrl_down=False

        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
        self.Bind(wx.EVT_MENU, self.OnCtrlClick, id=self.TBMENU_CTRLCLICK)

    def CreatePopupMenu(self):
        menu= wx.Menu()
        if self.ctrl_down:
            menu.Append(self.TBMENU_CTRLCLICK, "Ctrl Click")
            menu.AppendSeparator()
        menu.Append(wx.ID_EXIT, "Exit")
        return menu

    def OnKeyDown(self,event):
        self.ctrl_down=True
        event.Skip()

    def OnKeyUp(self,event):
        self.ctrl_down=False
        event.Skip()
  • 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-27T15:51:56+00:00Added an answer on May 27, 2026 at 3:51 pm

    Use wx.GetKeyState as so:

    import wx
    
    class TBI(wx.TaskBarIcon):
        def __init__(self):
            wx.TaskBarIcon.__init__(self)
            icon = wx.ArtProvider.GetIcon(wx.ART_FILE_OPEN, wx.ART_TOOLBAR)
            self.SetIcon(icon, "Icon")
            self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.on_right_up)
    
        def on_right_up(self, event):
             if wx.GetKeyState(wx.WXK_CONTROL):
                 print 'ctrl was pressed!'
    
    
    app = wx.App(redirect=False)
    icon = TBI()
    app.MainLoop()
    

    Right click the taskbar icon and then try with ctrl held down to see it in action.

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

Sidebar

Related Questions

Below is a simplified version of code I've written to override a class method
Ok, here is setup. Note the code below is SIMPLIFIED version. PHP 5.2 ENGINE:
The code below is a simplified version of the pattern my project is using.
Below is a simplified version of a segment of code that I'm working on
I have a method (the code below is a simplified version) that parses small
A simplified version of the code is posted below (white space, comments, etc. removed
Code below is working well as long as I have class ClassSameAssembly in same
The code below gives an error: Property 'Int32 Key' is not defined for type
The following code snippet is a simplified version of my issue. Basically I'm trying
I have two data structure classes (this is a simplified version of my code)

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.