PyGTK Hotkey Toggle Pin/Unpin -


i'm still learning pygtk, , i'm trying figure out how can tell window pin/unpin (aka toggle on top) each time press f1 key.

this got far.

#!/usr/bin/env python  import gtk  class app(gtk.window):    def pinning(self, widget, event) :    if event.keyval == gtk.keysyms.f1 :     self.set_keep_above(true)    def __init__(self):     super(app, self).__init__()     self.set_position(gtk.win_pos_center)     self.set_title("testapp")     self.set_default_size(320, 200)     self.connect("destroy", gtk.main_quit)     self.connect("key-press-event", self.pinning)     self.show_all()  app() gtk.main() 

unfortunately, there no get_keep_above() method. have connect window's window-state-event signal; in event parameter, read new_window_state field see if sticky flag set or not, keep track of yourself, example in self.is_kept_above.

then can do

if self.is_kept_above:     self.set_keep_above(false) else:     self.set_keep_above(true) 

in f1 handler.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -