Ejemplo n.º 1
0
 def timeoutEvent(self, *event):
     if self.highlight_items:
         state = self.highlight_items[0].cget('state')
         if state in ('', 'normal'):
             state = 'hidden'
             self.timer = after(self, self.hidden_timeout,
                                self.timeoutEvent)
         else:
             state = 'normal'
             self.timer = after(self, self.normal_timeout,
                                self.timeoutEvent)
         for item in self.highlight_items:
             item.config(state=state)
Ejemplo n.º 2
0
 def _enter(self, *event):
     after_cancel(self.timer)
     after_cancel(self.cancel_timer)
     self.cancel_timer = None
     if time.time() - MfxTooltip.last_leave_time < self.leave_timeout/1000.:
         self._showTip()
     else:
         self.timer = after(self.widget, self.timeout, self._showTip)
Ejemplo n.º 3
0
 def enterEvent(self, suit, rank, rect, group):
     ##print 'enterEvent', suit, rank, self.busy
     if self.busy: return
     if self.game.demo: return
     self.busy = True
     self.highlight_items = self.game.highlightCard(suit, rank)
     if not self.highlight_items:
         self.highlight_items = []
     if self.highlight_items:
         self.timer = after(self, self.normal_timeout, self.timeoutEvent)
     rect.config(state='normal')
     self.canvas.update_idletasks()
     self.busy = False
Ejemplo n.º 4
0
 def mainloop(self, focus=None, timeout=0):
     bind(self.top, "<Escape>", self.mCancel)
     if focus is not None:
         focus.focus()
     setTransient(self.top, self.parent)
     try:
         self.top.grab_set()
     except Tkinter.TclError:
         pass
     if timeout > 0:
         self.timer = after(self.top, timeout, self.mTimeout)
     try:
         self.top.mainloop()
     except SystemExit:
         pass
     self.destroy()
Ejemplo n.º 5
0
 def mainloop(self, focus=None, timeout=0, transient=True):
     bind(self.top, "<Escape>", self.mCancel)
     bind(self.top, '<Alt-Key>', self.altKeyEvent) # for accelerators
     if focus is not None:
         focus.focus()
     if transient:
         setTransient(self.top, self.parent)
         try:
             self.top.grab_set()
         except Tkinter.TclError:
             if traceback: traceback.print_exc()
             pass
         if timeout > 0:
             self.timer = after(self.top, timeout, self.mTimeout)
         try: self.top.mainloop()
         except SystemExit:
             pass
         self.destroy()
Ejemplo n.º 6
0
    def _showTip(self):
        self.timer = None
        if self.tooltip or not self.text:
            return
##         if isinstance(self.widget, (Tkinter.Button, Tkinter.Checkbutton)):
##             if self.widget["state"] == 'disabled':
##                 return
        ##x = self.widget.winfo_rootx()
        x = self.widget.winfo_pointerx()
        y = self.widget.winfo_rooty() + self.widget.winfo_height()
        x += self.xoffset
        y += self.yoffset
        self.tooltip = Tkinter.Toplevel()
        self.tooltip.wm_iconify()
        self.tooltip.wm_overrideredirect(1)
        self.tooltip.wm_protocol("WM_DELETE_WINDOW", self.destroy)
        self.label = Tkinter.Label(self.tooltip, text=self.text,
                                   relief=self.relief, justify=self.justify,
                                   fg=self.fg, bg=self.bg, bd=1, takefocus=0)
        self.label.pack(ipadx=1, ipady=1)
        self.tooltip.wm_geometry("%+d%+d" % (x, y))
        self.tooltip.wm_deiconify()
        self.cancel_timer = after(self.widget, self.cancel_timeout, self._leave)
Ejemplo n.º 7
0
 def _enter(self, *event):
     after_cancel(self.timer)
     self.timer = after(self.widget, self.time, self._showTip)