Unerklärliches am Rande

Im Moment beschäftige ich mich ein wenig mit Python und GTK. GTK kenn ich schon ein wenig länger, aber Python programmiere ich erst seit einer Woche und ich muß sagen, es macht wirklich Spaß und produziert im Gegensatz zu Perl sehr gut lesbaren Code:)
Nun schreibe ich gerade ein kleines Notizbuch, dass auch einen Platz im System Tray haben soll. Also mal in der GTK Referenz irgendwas in der Richtung Window.visible() gesucht aber Fehlanzeige.
Da ich auch durch googlen nichts manierliches gefunden habe hier meine kleine Interpretation des Problems in Python. HF:)
#!/usr/bin/env python import < a class = "zem_slink freebase/guid/9202a8c04000641f80000000003991b6" title= "PyGTK" rel= "homepage" href= "http://www.pygtk.org/" > pygtk < /a > pygtk. require ( '2.0' ) import gtk import egg. trayicon class PythonTray: def __init__ ( self , icon, #Pfadangabe zu einem Bild (String) tooltip, #Tooltiptext (String) event_handler #Eventhandler fuer das Trayzeichen mitgeben ) : """ Erzeugt das Trayicon """ tray_object = egg. trayicon . TrayIcon ( tooltip ) tray_object. set_tooltip_text ( tooltip ) #bild laden + skalieren image_widget = gtk. Image ( ) ; pixbuf = gtk. gdk . pixbuf_new_from_file ( icon ) scaled_buf = pixbuf. scale_simple ( 32 , 32 ,gtk. gdk . INTERP_BILINEAR ) image_widget. set_from_pixbuf ( scaled_buf ) event_box = gtk. EventBox ( ) event_box. add ( image_widget ) event_box. connect ( 'button_press_event' , event_handler ) tray_object. add ( event_box ) tray_object. show_all ( ) def showWindow ( self , """ Blendet ein Fenster ein und aus """ window #handle fuer's Fenster ) : if not ( window. is_active ( ) ) : window. show_now ( ) window. present ( ) else : window. hide ( ) class Trayexample: tray = PythonTray #kill den shit def destroy ( self , widget, data= None ) : gtk. main_quit ( ) ###delete event ueberschreiben def delete_event ( self , widget, event, data = None ) : self . window . hide ( ) return True def applet_face_click ( self , window, event, * data ) : if event. button == 1 : #haesslich self . tray . showWindow ( window= self . window ) #self.showWindow() if event. button == 3 : self . destroy ( self . window ) def __init__ ( self ) : #Konstruktor #neues Fenster erzeugen self . window = gtk. Window ( gtk. WINDOW_TOPLEVEL ) self . window . connect ( "delete_event" , self . delete_event ) ###Das X wird ignoriert :) self . window . set_size_request ( 640 , 480 ) ###fenstergroesse self . window . set_title ( 'SystemTray Example' ) self . window . connect ( "destroy" , self . destroy ) self . window . set_icon_from_file ( '/usr/share/icons/gnome/scalable/apps/im-aim.svg' ) #Tray Krams self . tray = PythonTray ( "/usr/share/icons/gnome/scalable/apps/im-aim.svg" , "MyTray" , self . applet_face_click ) #self.window.show() def main ( self ) : gtk. main ( ) if __name__ == "__main__" : hello = Trayexample ( ) hello. main ( )schmiddi.co.cc, Unerklärliches am Rande, Mar 2010