Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
idlelib.CallTipWindow.CallTip Class Reference

List of all members.

Public Member Functions

def __init__
def position_window
def showtip
def checkhide_event
def hide_event
def hidetip
def is_active

Public Attributes

 widget
 tipwindow
 label
 parenline
 parencol
 lastline
 hideid
 checkhideid
 text

Detailed Description

Definition at line 17 of file CallTipWindow.py.


Constructor & Destructor Documentation

def idlelib.CallTipWindow.CallTip.__init__ (   self,
  widget 
)

Definition at line 19 of file CallTipWindow.py.

00019 
00020     def __init__(self, widget):
00021         self.widget = widget
00022         self.tipwindow = self.label = None
00023         self.parenline = self.parencol = None
00024         self.lastline = None
00025         self.hideid = self.checkhideid = None

Here is the caller graph for this function:


Member Function Documentation

def idlelib.CallTipWindow.CallTip.checkhide_event (   self,
  event = None 
)

Definition at line 92 of file CallTipWindow.py.

00092 
00093     def checkhide_event(self, event=None):
00094         if not self.tipwindow:
00095             # If the event was triggered by the same event that unbinded
00096             # this function, the function will be called nevertheless,
00097             # so do nothing in this case.
00098             return
00099         curline, curcol = map(int, self.widget.index("insert").split('.'))
00100         if curline < self.parenline or \
00101            (curline == self.parenline and curcol <= self.parencol) or \
00102            self.widget.compare("insert", ">", MARK_RIGHT):
00103             self.hidetip()
00104         else:
00105             self.position_window()
00106             self.widget.after(CHECKHIDE_TIME, self.checkhide_event)

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.CallTipWindow.CallTip.hide_event (   self,
  event 
)

Definition at line 107 of file CallTipWindow.py.

00107 
00108     def hide_event(self, event):
00109         if not self.tipwindow:
00110             # See the explanation in checkhide_event.
00111             return
00112         self.hidetip()

Here is the call graph for this function:

Definition at line 113 of file CallTipWindow.py.

00113 
00114     def hidetip(self):
00115         if not self.tipwindow:
00116             return
00117 
00118         for seq in CHECKHIDE_SEQUENCES:
00119             self.widget.event_delete(CHECKHIDE_VIRTUAL_EVENT_NAME, seq)
00120         self.widget.unbind(CHECKHIDE_VIRTUAL_EVENT_NAME, self.checkhideid)
00121         self.checkhideid = None
00122         for seq in HIDE_SEQUENCES:
00123             self.widget.event_delete(HIDE_VIRTUAL_EVENT_NAME, seq)
00124         self.widget.unbind(HIDE_VIRTUAL_EVENT_NAME, self.hideid)
00125         self.hideid = None
00126 
00127         self.label.destroy()
00128         self.label = None
00129         self.tipwindow.destroy()
00130         self.tipwindow = None
00131 
00132         self.widget.mark_unset(MARK_RIGHT)
00133         self.parenline = self.parencol = self.lastline = None

Here is the caller graph for this function:

Definition at line 134 of file CallTipWindow.py.

00134 
00135     def is_active(self):
00136         return bool(self.tipwindow)
00137 
00138 

Check if needs to reposition the window, and if so - do it.

Definition at line 26 of file CallTipWindow.py.

00026 
00027     def position_window(self):
00028         """Check if needs to reposition the window, and if so - do it."""
00029         curline = int(self.widget.index("insert").split('.')[0])
00030         if curline == self.lastline:
00031             return
00032         self.lastline = curline
00033         self.widget.see("insert")
00034         if curline == self.parenline:
00035             box = self.widget.bbox("%d.%d" % (self.parenline,
00036                                               self.parencol))
00037         else:
00038             box = self.widget.bbox("%d.0" % curline)
00039         if not box:
00040             box = list(self.widget.bbox("insert"))
00041             # align to left of window
00042             box[0] = 0
00043             box[2] = 0
00044         x = box[0] + self.widget.winfo_rootx() + 2
00045         y = box[1] + box[3] + self.widget.winfo_rooty()
00046         self.tipwindow.wm_geometry("+%d+%d" % (x, y))

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.CallTipWindow.CallTip.showtip (   self,
  text,
  parenleft,
  parenright 
)
Show the calltip, bind events which will close it and reposition it.

Definition at line 47 of file CallTipWindow.py.

00047 
00048     def showtip(self, text, parenleft, parenright):
00049         """Show the calltip, bind events which will close it and reposition it.
00050         """
00051         # truncate overly long calltip
00052         if len(text) >= 79:
00053             textlines = text.splitlines()
00054             for i, line in enumerate(textlines):
00055                 if len(line) > 79:
00056                     textlines[i] = line[:75] + ' ...'
00057             text = '\n'.join(textlines)
00058         self.text = text
00059         if self.tipwindow or not self.text:
00060             return
00061 
00062         self.widget.mark_set(MARK_RIGHT, parenright)
00063         self.parenline, self.parencol = map(
00064             int, self.widget.index(parenleft).split("."))
00065 
00066         self.tipwindow = tw = Toplevel(self.widget)
00067         self.position_window()
00068         # remove border on calltip window
00069         tw.wm_overrideredirect(1)
00070         try:
00071             # This command is only needed and available on Tk >= 8.4.0 for OSX
00072             # Without it, call tips intrude on the typing process by grabbing
00073             # the focus.
00074             tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
00075                        "help", "noActivates")
00076         except TclError:
00077             pass
00078         self.label = Label(tw, text=self.text, justify=LEFT,
00079                            background="#ffffe0", relief=SOLID, borderwidth=1,
00080                            font = self.widget['font'])
00081         self.label.pack()
00082 
00083         self.checkhideid = self.widget.bind(CHECKHIDE_VIRTUAL_EVENT_NAME,
00084                                             self.checkhide_event)
00085         for seq in CHECKHIDE_SEQUENCES:
00086             self.widget.event_add(CHECKHIDE_VIRTUAL_EVENT_NAME, seq)
00087         self.widget.after(CHECKHIDE_TIME, self.checkhide_event)
00088         self.hideid = self.widget.bind(HIDE_VIRTUAL_EVENT_NAME,
00089                                        self.hide_event)
00090         for seq in HIDE_SEQUENCES:
00091             self.widget.event_add(HIDE_VIRTUAL_EVENT_NAME, seq)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 24 of file CallTipWindow.py.

Definition at line 24 of file CallTipWindow.py.

Definition at line 21 of file CallTipWindow.py.

Definition at line 23 of file CallTipWindow.py.

Definition at line 22 of file CallTipWindow.py.

Definition at line 22 of file CallTipWindow.py.

Definition at line 57 of file CallTipWindow.py.

Definition at line 21 of file CallTipWindow.py.

Definition at line 20 of file CallTipWindow.py.


The documentation for this class was generated from the following file: