diff options
| author | Guido van Rossum <guido@python.org> | 1998-10-10 18:48:31 (GMT) |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 1998-10-10 18:48:31 (GMT) |
| commit | 3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4 (patch) | |
| tree | 1a66ed7c7eec87f31d61a2a083096e5cad89a39c /Tools/idle/HelpWindow.py | |
| parent | dc1adabcb86ee0813c9bae2d5cc59be5cad1ff31 (diff) | |
| download | cpython-3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4.zip cpython-3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4.tar.gz cpython-3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4.tar.bz2 | |
Initial checking of Tk-based Python IDE.
Features: text editor with syntax coloring and undo;
subclassed into interactive Python shell which adds history.
Diffstat (limited to 'Tools/idle/HelpWindow.py')
| -rw-r--r-- | Tools/idle/HelpWindow.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Tools/idle/HelpWindow.py b/Tools/idle/HelpWindow.py new file mode 100644 index 0000000..a1b13c3 --- /dev/null +++ b/Tools/idle/HelpWindow.py @@ -0,0 +1,65 @@ +import os +import sys +from Tkinter import * + + +class HelpWindow: + + helpfile = "help.txt" + helptitle = "Help Window" + + def __init__(self, root=None): + if not root: + import Tkinter + root = Tkinter._default_root + if root: + self.top = top = Toplevel(root) + else: + self.top = top = root = Tk() + + helpfile = self.helpfile + if not os.path.exists(helpfile): + base = os.path.basename(self.helpfile) + for dir in sys.path: + fullname = os.path.join(dir, base) + if os.path.exists(fullname): + helpfile = fullname + break + try: + f = open(helpfile) + data = f.read() + f.close() + except IOError, msg: + data = "Can't open the help file (%s)" % `helpfile` + + top.protocol("WM_DELETE_WINDOW", self.close_command) + top.wm_title(self.helptitle) + + self.close_button = Button(top, text="close", + command=self.close_command) + self.close_button.pack(side="bottom") + + self.vbar = vbar = Scrollbar(top, name="vbar") + self.text = text = Text(top) + + vbar["command"] = text.yview + text["yscrollcommand"] = vbar.set + + vbar.pack(side="right", fill="y") + text.pack(side="left", fill="both", expand=1) + + text.insert("1.0", data) + + text.config(state="disabled") + text.see("1.0") + + def close_command(self): + self.top.destroy() + + +def main(): + h = HelpWindow() + h.top.mainloop() + +if __name__ == "__main__": + main() |
