Psyduck - 可達鴨 之 鴨力山大2


Server : LiteSpeed
System : Linux premium217.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User : alloknri ( 880)
PHP Version : 8.1.34
Disable Function : NONE
Directory :  /opt/alt/python33/lib64/python3.3/idlelib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python33/lib64/python3.3/idlelib/ToolTip.py
# general purpose 'tooltip' routines - currently unused in idlefork
# (although the 'calltips' extension is partly based on this code)
# may be useful for some purposes in (or almost in ;) the current project scope
# Ideas gleaned from PySol

from tkinter import *

class ToolTipBase:

    def __init__(self, button):
        self.button = button
        self.tipwindow = None
        self.id = None
        self.x = self.y = 0
        self._id1 = self.button.bind("<Enter>", self.enter)
        self._id2 = self.button.bind("<Leave>", self.leave)
        self._id3 = self.button.bind("<ButtonPress>", self.leave)

    def enter(self, event=None):
        self.schedule()

    def leave(self, event=None):
        self.unschedule()
        self.hidetip()

    def schedule(self):
        self.unschedule()
        self.id = self.button.after(1500, self.showtip)

    def unschedule(self):
        id = self.id
        self.id = None
        if id:
            self.button.after_cancel(id)

    def showtip(self):
        if self.tipwindow:
            return
        # The tip window must be completely outside the button;
        # otherwise when the mouse enters the tip window we get
        # a leave event and it disappears, and then we get an enter
        # event and it reappears, and so on forever :-(
        x = self.button.winfo_rootx() + 20
        y = self.button.winfo_rooty() + self.button.winfo_height() + 1
        self.tipwindow = tw = Toplevel(self.button)
        tw.wm_overrideredirect(1)
        tw.wm_geometry("+%d+%d" % (x, y))
        self.showcontents()

    def showcontents(self, text="Your text here"):
        # Override this in derived class
        label = Label(self.tipwindow, text=text, justify=LEFT,
                      background="#ffffe0", relief=SOLID, borderwidth=1)
        label.pack()

    def hidetip(self):
        tw = self.tipwindow
        self.tipwindow = None
        if tw:
            tw.destroy()

class ToolTip(ToolTipBase):
    def __init__(self, button, text):
        ToolTipBase.__init__(self, button)
        self.text = text
    def showcontents(self):
        ToolTipBase.showcontents(self, self.text)

class ListboxToolTip(ToolTipBase):
    def __init__(self, button, items):
        ToolTipBase.__init__(self, button)
        self.items = items
    def showcontents(self):
        listbox = Listbox(self.tipwindow, background="#ffffe0")
        listbox.pack()
        for item in self.items:
            listbox.insert(END, item)

def main():
    # Test code
    root = Tk()
    b = Button(root, text="Hello", command=root.destroy)
    b.pack()
    root.update()
    tip = ListboxToolTip(b, ["Hello", "world"])
    root.mainloop()

if __name__ == '__main__':
    main()
Name
Size
Permissions
Options
Icons
--
drwxr-xr-x
__pycache__
--
drwxr-xr-x
idle_test
--
drwxr-xr-x
AutoComplete.py
8.869 KB
-rw-r--r--
AutoCompleteWindow.py
17.258 KB
-rw-r--r--
AutoExpand.py
2.425 KB
-rw-r--r--
Bindings.py
3.354 KB
-rw-r--r--
CREDITS.txt
1.821 KB
-rw-r--r--
CallTipWindow.py
5.761 KB
-rw-r--r--
CallTips.py
5.793 KB
-rw-r--r--
ChangeLog
55.071 KB
-rw-r--r--
ClassBrowser.py
6.222 KB
-rw-r--r--
CodeContext.py
8.157 KB
-rw-r--r--
ColorDelegator.py
10.222 KB
-rw-r--r--
Debugger.py
15.983 KB
-rw-r--r--
Delegator.py
0.649 KB
-rw-r--r--
EditorWindow.py
64.753 KB
-rw-r--r--
FileList.py
3.725 KB
-rw-r--r--
FormatParagraph.py
6.998 KB
-rw-r--r--
GrepDialog.py
4.015 KB
-rw-r--r--
HISTORY.txt
10.075 KB
-rw-r--r--
HyperParser.py
10.314 KB
-rw-r--r--
IOBinding.py
19.396 KB
-rw-r--r--
IdleHistory.py
4.021 KB
-rw-r--r--
MultiCall.py
17.118 KB
-rw-r--r--
MultiStatusBar.py
0.765 KB
-rw-r--r--
NEWS.txt
33.61 KB
-rw-r--r--
ObjectBrowser.py
3.661 KB
-rw-r--r--
OutputWindow.py
4.291 KB
-rw-r--r--
ParenMatch.py
6.472 KB
-rw-r--r--
PathBrowser.py
2.811 KB
-rw-r--r--
Percolator.py
2.596 KB
-rw-r--r--
PyParse.py
18.959 KB
-rw-r--r--
PyShell.py
56.521 KB
-rwxr-xr-x
README.txt
2.443 KB
-rw-r--r--
RemoteDebugger.py
11.747 KB
-rw-r--r--
RemoteObjectBrowser.py
0.941 KB
-rw-r--r--
ReplaceDialog.py
5.692 KB
-rw-r--r--
RstripExtension.py
1.025 KB
-rw-r--r--
ScriptBinding.py
7.88 KB
-rw-r--r--
ScrolledList.py
3.903 KB
-rw-r--r--
SearchDialog.py
1.969 KB
-rw-r--r--
SearchDialogBase.py
5.063 KB
-rw-r--r--
SearchEngine.py
7.367 KB
-rw-r--r--
StackViewer.py
3.483 KB
-rw-r--r--
TODO.txt
8.279 KB
-rw-r--r--
ToolTip.py
2.672 KB
-rw-r--r--
TreeWidget.py
14.863 KB
-rw-r--r--
UndoDelegator.py
10.063 KB
-rw-r--r--
WidgetRedirector.py
4.372 KB
-rw-r--r--
WindowList.py
2.414 KB
-rw-r--r--
ZoomHeight.py
1.276 KB
-rw-r--r--
__init__.py
0.036 KB
-rw-r--r--
__main__.py
0.106 KB
-rw-r--r--
aboutDialog.py
6.421 KB
-rw-r--r--
config-extensions.def
2.723 KB
-rw-r--r--
config-highlight.def
1.699 KB
-rw-r--r--
config-keys.def
7.348 KB
-rw-r--r--
config-main.def
2.455 KB
-rw-r--r--
configDialog.py
51.611 KB
-rw-r--r--
configHandler.py
28.636 KB
-rw-r--r--
configHelpSourceEdit.py
6.567 KB
-rw-r--r--
configSectionNameDialog.py
4.213 KB
-rw-r--r--
dynOptionMenuWidget.py
1.277 KB
-rw-r--r--
extend.txt
3.557 KB
-rw-r--r--
help.txt
11.713 KB
-rw-r--r--
idle.py
0.391 KB
-rw-r--r--
idle.pyw
0.655 KB
-rw-r--r--
idlever.py
0.022 KB
-rw-r--r--
keybindingDialog.py
12.136 KB
-rw-r--r--
macosxSupport.py
7.004 KB
-rw-r--r--
rpc.py
20.462 KB
-rw-r--r--
run.py
13.373 KB
-rw-r--r--
tabbedpages.py
17.741 KB
-rw-r--r--
textView.py
3.462 KB
-rw-r--r--