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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:58:41+00:00 2026-06-14T19:58:41+00:00

I wrote global shortcut example for hide and show my windows with key like

  • 0

I wrote global shortcut example for hide and show my windows with key like ‘F12’, I used python-xlib and some script named ‘pyxhook’ everything works fine except when i want to hide() and show() window few times my proccess turning a zombie, but same code working with hiding and showing just button.

#!/usr/bin/python
# -*- coding: utf-8; -*-
from gi.repository import Gtk, GObject
from pyxhook import HookManager
GObject.threads_init()
class Win(Gtk.Window):

    def __init__(self):
        super(Win, self).__init__()
        self.connect('destroy', Gtk.main_quit)
        self.button = Gtk.Button()
        self.add(self.button)
        self.resize(200,150)
        self.show_all()

    def handle_global_keypress(self, event):
        if event.Key == 'F12':
            if self.get_visible():
                self.hide()
            else:
                self.show()

            ### this part works fine with button

            #if self.button.get_visible():
            #    self.button.hide()
            #else:
            #    self.button.show()

def main():
    app = Win()
    hm = HookManager()
    hm.HookKeyboard()
    hm.KeyDown = app.handle_global_keypress
    hm.start()
    Gtk.main()

    hm.cancel()

if __name__ == "__main__":    
    main()

edit: i solved my problem using Keybinder library instead of coding pure python keybinder.
http://kaizer.se/wiki/keybinder/

  • 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-06-14T19:58:42+00:00Added an answer on June 14, 2026 at 7:58 pm

    I’m unable to answer your specific question but I might suggest another option. Guake console implements this very same behavior but using dbus:

    http://guake.org/

    In the dbusiface.py file you can find:

    import dbus
    import dbus.service
    import dbus.glib
    import gtk
    import guake.common
    dbus.glib.threads_init()
    
    DBUS_PATH = '/org/guake/RemoteControl'
    DBUS_NAME = 'org.guake.RemoteControl'
    
    class DbusManager(dbus.service.Object):
        def __init__(self, guakeinstance):
            self.guake = guakeinstance
            self.bus = dbus.SessionBus()
            bus_name = dbus.service.BusName(DBUS_NAME, bus=self.bus)
            super(DbusManager, self).__init__(bus_name, DBUS_PATH)
    
        @dbus.service.method(DBUS_NAME)
        def show_hide(self):
            self.guake.show_hide()
    

    Among others methods. This is worth to explore. Please also note that Guake is developed using PyGtk and not PyGObject, but anyway you can get some ideas.

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

Sidebar

Related Questions

I'd like to record some dynamic behaviors into some global variables. So I wrote
I wrote some script in a site. The script makes a new spreadsheet and
I wrote a CPU monitoring program in Python. For some reason sometimes the the
I wrote some kind of global logger class for a project and want to
I wrote a javascript like following: <script language=javascript type=text/javascript> var name = new Array();
I wrote a python script which just stopped working suddenly. I'm not sure why
I wrote a simple script, using VBA. (I need to optimize some work with
I wrote a python script that: 1. submits search queries 2. waits for the
Possible Duplicate: Global variables in R ad the beginning of the file I wrote:
are there any libraries for Linux wrote with C++, that could register global hotkeys

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.