summaryrefslogtreecommitdiffstats
path: root/Tools/idle/Outline.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-10-10 18:48:31 (GMT)
committerGuido van Rossum <guido@python.org>1998-10-10 18:48:31 (GMT)
commit3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4 (patch)
tree1a66ed7c7eec87f31d61a2a083096e5cad89a39c /Tools/idle/Outline.py
parentdc1adabcb86ee0813c9bae2d5cc59be5cad1ff31 (diff)
downloadcpython-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/Outline.py')
-rw-r--r--Tools/idle/Outline.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/Tools/idle/Outline.py b/Tools/idle/Outline.py
new file mode 100644
index 0000000..194d058
--- /dev/null
+++ b/Tools/idle/Outline.py
@@ -0,0 +1,46 @@
+from Tkinter import *
+
+class Outline:
+
+ def __init__(self, root=None):
+ if not root:
+ import Tkinter
+ root = Tkinter._default_root
+ if not root:
+ root = top = Tk()
+ else:
+ top = Toplevel(root)
+ top.wm_title("Outline")
+ self.canvas = canvas = Canvas(top, width=400, height=300,
+ borderwidth=2, relief="sunken",
+ background="#FFBBBB")
+ canvas.pack(expand=1, fill="both")
+ self.items = []
+
+ def additem(self, level, open, label):
+ x = 15*level + 5
+ y = 15*len(self.items) + 5
+ if open:
+ id1 = self.canvas.create_polygon(x+3, y+3, x+13, y+3, x+8, y+8,
+ outline="black",
+ fill="green")
+ else:
+ id1 = self.canvas.create_polygon(x+3, y+4, x+7, y+8, x+3, y+12,
+ outline="black",
+ fill="red")
+ w = Entry(self.canvas, borderwidth=0, background="#FFBBBB", width=0)
+ w.insert("end", label)
+ id2 = self.canvas.create_window(x+15, y, anchor="nw", window=w)
+ self.items.append((level, open, label, id1, w, id2))
+
+
+def main():
+ o = Outline()
+ o.additem(0, 1, "hello world")
+ o.additem(1, 0, "sub1")
+ o.additem(1, 1, "sub2")
+ o.additem(2, 0, "sub2.a")
+ o.additem(2, 0, "sub2.b")
+ o.additem(1, 0, "sub3")
+
+main()