2009-11-03 2 views
1

나는 창문에 있으며 pygtk 앱을 개발 중입니다. 나는 창을 다른 창에 표시하거나 숨길 때를 알아야합니다. 무거운 드로잉 프로세스를 중지하려면.pyGTK의 Visibility_notify 이벤트

http://www.pygtk.org/docs/pygtk/class-gtkwidget.html#signal-gtkwidget--visibility-notify-event

나는 창문 가시성 상태 변경에 통보 할 visibility_notify_event를 사용합니다. 나는 gtk.gdk.VISIBILITY_FULLY_OBSCURED, gtk.gdk.VISIBILITY_PARTIAL을 얻어야한다 또는 gtk.gdk.VISIBILITY_UNOBSCURED

http://www.pygtk.org/docs/pygtk/class-gdkevent.html

여기에 이벤트가 발생했을 때 메시지를 표시 샘플입니다.

#!/usr/bin/env python 

import pygtk 
pygtk.require('2.0') 
import gtk 

class EventBoxExample: 
    def __init__(self): 
     window = gtk.Window(gtk.WINDOW_TOPLEVEL) 
     window.set_title("Test") 
     window.connect("destroy", lambda w: gtk.main_quit()) 
     window.set_border_width(10) 

     # Create an EventBox and add it to our toplevel window 
     self.event_box = gtk.EventBox() 

     window.add(self.event_box)   
     self.event_box.show() 

     #we want all events 
     self.event_box.set_events(gtk.gdk.ALL_EVENTS_MASK) 

     #connect events 
     self.event_box.connect ("map_event", self.Map) 
     self.event_box.connect ("unmap_event", self.unMap) 
     self.event_box.connect ("configure_event", self.Configure) 
     self.event_box.connect ("expose_event", self.Expose) 
     self.event_box.connect ("visibility_notify_event", self.Visibility) 
     self.event_box.connect ("key_press_event", self.KeyPress) 
     self.event_box.connect ("button_press_event", self.ButtonPress) 
     self.event_box.connect ("button_release_event", self.ButtonRelease) 
     self.event_box.connect ("motion_notify_event", self.MouseMotion) 
     self.event_box.connect ("destroy", self.Destroy) 
     self.event_box.connect ("enter_notify_event", self.Enter) 
     self.event_box.connect ("leave_notify_event", self.Leave) 
     self.event_box.connect ("delete_event", self.Destroy) 

     window.show() 

    def Map (self, *args): 
     print "Map ", args   
     return True 

    def unMap (self, *args): 
     print "unMap ", args   
     return True 

    def Configure (self, *args): 
     print "Configure" 
     return True 

    def Expose (self, *args): 
     print "Expose" 
     return True 

    def Visibility (self, *args): 
     print "Visibility" 
     return True 

    def KeyPress (self, *args): 
     print "KeyPress" 
     return True 

    def ButtonPress (self, *args): 
     print "ButtonPress" 
     return True 

    def ButtonRelease (self, *args): 
     print "ButtonRelease" 
     return True 

    def MouseMotion (self, *args): 
     print "MouseMotion" 
     return True 

    def Enter (self, *args): 
     print "Enter" 
     self.event_box.grab_focus() 
     return True 

    def Leave (self, *args): 
     print "Leave" 
     return True 

    def Destroy (self, *args): 
     print "Destroy" 

def main(): 
    gtk.main() 
    return 0 

if __name__ == "__main__": 
    EventBoxExample() 
    main() 

visibility_notify_event를 얻을 수없는 이유는 누구입니까?

들으

답변

2

그것은 기본 GDK 층 단순히 Windows에서 "충분히 좋은"아니라는 것을 매우 가능성이 높습니다. Windows 로의 GTK + 툴킷의 포트는 기능면에서 조금 뒤쳐져 있고 세련된 것으로 알려져 있습니다.

Linux 컴퓨터에서 동일한 프로그램을 시도해보고 거기에서 작동하면 Windows 포트 제한이라는 것을 확실히 알 수 있습니다.

+0

친구가 Linux에서 시도한 결과 공개 이벤트가 발생했습니다. 당신이 맞아 그것은 Windows 포트에서 구현되지 않는 것 같습니다 – rapdum