• [^] # Re: J'y connais rien...

    Posté par (site web personnel, Mastodon) . En réponse au message Faire disparaitre une fenêtre GTK quand on clique en dehors. Évalué à 1.

    Ma solution :

    Dans le code du widget lui meme (appelé calendar) :

    self.calendar.grab_add()
    #We grab the pointer in the calendar
    gdk.pointer_grab(self.calendar.window, True,gdk.BUTTON1_MASK|gdk.MOD2_MASK)
    #we will close the calendar if the user clic outside
    self.calendar.connect('button-press-event', self.__focus_out)


    def __focus_out(self,w=None,e=None) :
    #We should only close if the pointer clic is out of the calendar !
    p = self.calendar.window.get_pointer()
    s = self.calendar.get_size()
    if not(0 <= p[0] <= s[0] and 0 <= p[1] <= s[1]) :
    self.__close_calendar()

    Mes livres CC By-SA : https://ploum.net/livres.html