diff options
Diffstat (limited to 'Demo')
46 files changed, 89 insertions, 72 deletions
diff --git a/Demo/comparisons/patterns b/Demo/comparisons/patterns index f4da846..f4da846 100755..100644 --- a/Demo/comparisons/patterns +++ b/Demo/comparisons/patterns diff --git a/Demo/curses/ncurses.py b/Demo/curses/ncurses.py index 0bdc1a9..0bdc1a9 100644..100755 --- a/Demo/curses/ncurses.py +++ b/Demo/curses/ncurses.py diff --git a/Demo/curses/rain.py b/Demo/curses/rain.py index 9d46e6e..9d46e6e 100644..100755 --- a/Demo/curses/rain.py +++ b/Demo/curses/rain.py diff --git a/Demo/curses/tclock.py b/Demo/curses/tclock.py index 8058d9a..8058d9a 100644..100755 --- a/Demo/curses/tclock.py +++ b/Demo/curses/tclock.py diff --git a/Demo/md5test/foo b/Demo/md5test/foo index f2ba8f8..f2ba8f8 100755..100644 --- a/Demo/md5test/foo +++ b/Demo/md5test/foo diff --git a/Demo/newmetaclasses/Eiffel.py b/Demo/newmetaclasses/Eiffel.py index 730a85d..f3f116f 100644 --- a/Demo/newmetaclasses/Eiffel.py +++ b/Demo/newmetaclasses/Eiffel.py @@ -29,7 +29,7 @@ class EiffelBaseMetaClass(type): pre = dict.get("%s_pre" % m) post = dict.get("%s_post" % m) if pre or post: - dict[k] = cls.make_eiffel_method(dict[m], pre, post) + dict[m] = cls.make_eiffel_method(dict[m], pre, post) class EiffelMetaClass1(EiffelBaseMetaClass): # an implementation of the "eiffel" meta class that uses nested functions diff --git a/Demo/scripts/newslist.doc b/Demo/scripts/newslist.doc index 87fd9ba..87fd9ba 100755..100644 --- a/Demo/scripts/newslist.doc +++ b/Demo/scripts/newslist.doc diff --git a/Demo/tix/bitmaps/about.xpm b/Demo/tix/bitmaps/about.xpm index 33ffcc0..33ffcc0 100755..100644 --- a/Demo/tix/bitmaps/about.xpm +++ b/Demo/tix/bitmaps/about.xpm diff --git a/Demo/tix/bitmaps/bold.xbm b/Demo/tix/bitmaps/bold.xbm index ebff8d1..ebff8d1 100755..100644 --- a/Demo/tix/bitmaps/bold.xbm +++ b/Demo/tix/bitmaps/bold.xbm diff --git a/Demo/tix/bitmaps/capital.xbm b/Demo/tix/bitmaps/capital.xbm index fb4e070..fb4e070 100755..100644 --- a/Demo/tix/bitmaps/capital.xbm +++ b/Demo/tix/bitmaps/capital.xbm diff --git a/Demo/tix/bitmaps/centerj.xbm b/Demo/tix/bitmaps/centerj.xbm index 9d2c064..9d2c064 100755..100644 --- a/Demo/tix/bitmaps/centerj.xbm +++ b/Demo/tix/bitmaps/centerj.xbm diff --git a/Demo/tix/bitmaps/combobox.xbm b/Demo/tix/bitmaps/combobox.xbm index f5947f5..f5947f5 100755..100644 --- a/Demo/tix/bitmaps/combobox.xbm +++ b/Demo/tix/bitmaps/combobox.xbm diff --git a/Demo/tix/bitmaps/combobox.xpm b/Demo/tix/bitmaps/combobox.xpm index d0234ab..d0234ab 100755..100644 --- a/Demo/tix/bitmaps/combobox.xpm +++ b/Demo/tix/bitmaps/combobox.xpm diff --git a/Demo/tix/bitmaps/combobox.xpm.1 b/Demo/tix/bitmaps/combobox.xpm.1 index 63792a4..63792a4 100755..100644 --- a/Demo/tix/bitmaps/combobox.xpm.1 +++ b/Demo/tix/bitmaps/combobox.xpm.1 diff --git a/Demo/tix/bitmaps/drivea.xbm b/Demo/tix/bitmaps/drivea.xbm index 83c636c..83c636c 100755..100644 --- a/Demo/tix/bitmaps/drivea.xbm +++ b/Demo/tix/bitmaps/drivea.xbm diff --git a/Demo/tix/bitmaps/drivea.xpm b/Demo/tix/bitmaps/drivea.xpm index 4d274b9..4d274b9 100755..100644 --- a/Demo/tix/bitmaps/drivea.xpm +++ b/Demo/tix/bitmaps/drivea.xpm diff --git a/Demo/tix/bitmaps/exit.xpm b/Demo/tix/bitmaps/exit.xpm index 505a07b..505a07b 100755..100644 --- a/Demo/tix/bitmaps/exit.xpm +++ b/Demo/tix/bitmaps/exit.xpm diff --git a/Demo/tix/bitmaps/filebox.xbm b/Demo/tix/bitmaps/filebox.xbm index c8f7ac2..c8f7ac2 100755..100644 --- a/Demo/tix/bitmaps/filebox.xbm +++ b/Demo/tix/bitmaps/filebox.xbm diff --git a/Demo/tix/bitmaps/filebox.xpm b/Demo/tix/bitmaps/filebox.xpm index 7377ee6..7377ee6 100755..100644 --- a/Demo/tix/bitmaps/filebox.xpm +++ b/Demo/tix/bitmaps/filebox.xpm diff --git a/Demo/tix/bitmaps/italic.xbm b/Demo/tix/bitmaps/italic.xbm index 169c3cb..169c3cb 100755..100644 --- a/Demo/tix/bitmaps/italic.xbm +++ b/Demo/tix/bitmaps/italic.xbm diff --git a/Demo/tix/bitmaps/justify.xbm b/Demo/tix/bitmaps/justify.xbm index bba660a..bba660a 100755..100644 --- a/Demo/tix/bitmaps/justify.xbm +++ b/Demo/tix/bitmaps/justify.xbm diff --git a/Demo/tix/bitmaps/leftj.xbm b/Demo/tix/bitmaps/leftj.xbm index 5f8e006..5f8e006 100755..100644 --- a/Demo/tix/bitmaps/leftj.xbm +++ b/Demo/tix/bitmaps/leftj.xbm diff --git a/Demo/tix/bitmaps/netw.xbm b/Demo/tix/bitmaps/netw.xbm index a684d65..a684d65 100755..100644 --- a/Demo/tix/bitmaps/netw.xbm +++ b/Demo/tix/bitmaps/netw.xbm diff --git a/Demo/tix/bitmaps/netw.xpm b/Demo/tix/bitmaps/netw.xpm index fff6593..fff6593 100755..100644 --- a/Demo/tix/bitmaps/netw.xpm +++ b/Demo/tix/bitmaps/netw.xpm diff --git a/Demo/tix/bitmaps/optmenu.xpm b/Demo/tix/bitmaps/optmenu.xpm index 63bab81..63bab81 100755..100644 --- a/Demo/tix/bitmaps/optmenu.xpm +++ b/Demo/tix/bitmaps/optmenu.xpm diff --git a/Demo/tix/bitmaps/rightj.xbm b/Demo/tix/bitmaps/rightj.xbm index 1d438e0..1d438e0 100755..100644 --- a/Demo/tix/bitmaps/rightj.xbm +++ b/Demo/tix/bitmaps/rightj.xbm diff --git a/Demo/tix/bitmaps/select.xpm b/Demo/tix/bitmaps/select.xpm index 392e5a0..392e5a0 100755..100644 --- a/Demo/tix/bitmaps/select.xpm +++ b/Demo/tix/bitmaps/select.xpm diff --git a/Demo/tix/bitmaps/underline.xbm b/Demo/tix/bitmaps/underline.xbm index f07bb46..f07bb46 100755..100644 --- a/Demo/tix/bitmaps/underline.xbm +++ b/Demo/tix/bitmaps/underline.xbm diff --git a/Demo/tkinter/guido/canvasevents.py b/Demo/tkinter/guido/canvasevents.py index 74ed76f..74ed76f 100644..100755 --- a/Demo/tkinter/guido/canvasevents.py +++ b/Demo/tkinter/guido/canvasevents.py diff --git a/Demo/tkinter/guido/newmenubardemo.py b/Demo/tkinter/guido/newmenubardemo.py index 57bf13c..57bf13c 100644..100755 --- a/Demo/tkinter/guido/newmenubardemo.py +++ b/Demo/tkinter/guido/newmenubardemo.py diff --git a/Demo/tkinter/guido/sortvisu.py b/Demo/tkinter/guido/sortvisu.py index 9148b73..9148b73 100644..100755 --- a/Demo/tkinter/guido/sortvisu.py +++ b/Demo/tkinter/guido/sortvisu.py diff --git a/Demo/turtle/demohelp.txt b/Demo/turtle/demohelp.txt index d565691..d364e94 100644 --- a/Demo/turtle/demohelp.txt +++ b/Demo/turtle/demohelp.txt @@ -2,7 +2,7 @@ ---------------------------------------------- - xturtleDemo - Help + turtleDemo - Help ---------------------------------------------- @@ -53,23 +53,29 @@ (2) How to add your own demos to the demo repository - - scriptname: must begin with tdemo_ , + - The script name must begin with tdemo_ , so it must have the form tdemo_<your-script-name>.py - - place: same directory as xturtleDemo.py or some - subdirectory, the name of which must also begin with - tdemo_..... - - - requirements on source code: - code must contain a main() function which will - be executed by the viewer (see provided example scripts) - main() may return a string which will be displayed - in the Label below the source code window (when execution - has finished.) - - !! For programs, which are EVENT DRIVEN, main must return - !! the string "EVENTLOOP". This informs the viewer, that the - !! script is still running and must be stopped by the user! - - - + - The code must contain a main() function which will + be executed by the viewer (see provided example scripts). + It may return a string which will be displayed in the Label below + the source code window (when execution has finished.) + + - In order to run mydemo.py by itself, such as during development, + add the following at the end of the file: + + if __name__ == '__main__': + main() + mainloop() # keep window + + python -m turtledemo.mydemo # will then run it + + - If the demo is EVENT DRIVEN, main must return the string + "EVENTLOOP". This informs the demo viewer that the script is + still running and must be stopped by the user! + + If an "EVENTLOOP" demo runs by itself, as with clock, which uses + ontimer, or minimal_hanoi, which loops by recursion, then the + code should catch the turtle.Terminator exception that will be + raised when the user presses the STOP button. (Paint is not such + a demo; it only acts in response to mouse clicks and movements.) diff --git a/Demo/turtle/tdemo_I_dontlike_tiltdemo.py b/Demo/turtle/tdemo_I_dontlike_tiltdemo.py index c9e6e65..c9e6e65 100644..100755 --- a/Demo/turtle/tdemo_I_dontlike_tiltdemo.py +++ b/Demo/turtle/tdemo_I_dontlike_tiltdemo.py diff --git a/Demo/turtle/tdemo_bytedesign.py b/Demo/turtle/tdemo_bytedesign.py index bed671d..bed671d 100644..100755 --- a/Demo/turtle/tdemo_bytedesign.py +++ b/Demo/turtle/tdemo_bytedesign.py diff --git a/Demo/turtle/tdemo_clock.py b/Demo/turtle/tdemo_clock.py index b6280bb..d4e0686 100644..100755 --- a/Demo/turtle/tdemo_clock.py +++ b/Demo/turtle/tdemo_clock.py @@ -11,6 +11,7 @@ and time ------------------------------------ """ from turtle import * +from turtle import Terminator # not in __all__ from datetime import datetime mode("logo") @@ -102,22 +103,25 @@ def tick(): sekunde = t.second + t.microsecond*0.000001 minute = t.minute + sekunde/60.0 stunde = t.hour + minute/60.0 - tracer(False) - writer.clear() - writer.home() - writer.forward(65) - writer.write(wochentag(t), - align="center", font=("Courier", 14, "bold")) - writer.back(150) - writer.write(datum(t), - align="center", font=("Courier", 14, "bold")) - writer.forward(85) - tracer(True) - second_hand.setheading(6*sekunde) - minute_hand.setheading(6*minute) - hour_hand.setheading(30*stunde) - tracer(True) - ontimer(tick, 100) + try: + tracer(False) # Terminator can occur here + writer.clear() + writer.home() + writer.forward(65) + writer.write(wochentag(t), + align="center", font=("Courier", 14, "bold")) + writer.back(150) + writer.write(datum(t), + align="center", font=("Courier", 14, "bold")) + writer.forward(85) + tracer(True) + second_hand.setheading(6*sekunde) # or here + minute_hand.setheading(6*minute) + hour_hand.setheading(30*stunde) + tracer(True) + ontimer(tick, 100) + except Terminator: + pass # turtledemo user pressed STOP def main(): tracer(False) diff --git a/Demo/turtle/tdemo_fractalcurves.py b/Demo/turtle/tdemo_fractalcurves.py index 2ac8ecd..2ac8ecd 100644..100755 --- a/Demo/turtle/tdemo_fractalcurves.py +++ b/Demo/turtle/tdemo_fractalcurves.py diff --git a/Demo/turtle/tdemo_lindenmayer_indian.py b/Demo/turtle/tdemo_lindenmayer_indian.py index 92c8cff..92c8cff 100644..100755 --- a/Demo/turtle/tdemo_lindenmayer_indian.py +++ b/Demo/turtle/tdemo_lindenmayer_indian.py diff --git a/Demo/turtle/tdemo_minimal_hanoi.py b/Demo/turtle/tdemo_minimal_hanoi.py index 8a1caa8..3cb9efc 100644..100755 --- a/Demo/turtle/tdemo_minimal_hanoi.py +++ b/Demo/turtle/tdemo_minimal_hanoi.py @@ -18,6 +18,7 @@ stretched to rectangles by shapesize() --------------------------------------- """ from turtle import * +from turtle import Terminator # not in __all__ class Disc(Turtle): def __init__(self, n): @@ -50,9 +51,12 @@ def hanoi(n, from_, with_, to_): def play(): onkey(None,"space") clear() - hanoi(6, t1, t2, t3) - write("press STOP button to exit", - align="center", font=("Courier", 16, "bold")) + try: + hanoi(6, t1, t2, t3) + write("press STOP button to exit", + align="center", font=("Courier", 16, "bold")) + except Terminator: + pass # turtledemo user pressed STOP def main(): global t1, t2, t3 diff --git a/Demo/turtle/tdemo_paint.py b/Demo/turtle/tdemo_paint.py index e1d6303..105a06b 100644..100755 --- a/Demo/turtle/tdemo_paint.py +++ b/Demo/turtle/tdemo_paint.py @@ -3,11 +3,15 @@ tdemo_paint.py -A simple eventdriven paint program +A simple event-driven paint program -- use left mouse button to move turtle -- middle mouse button to change color -- right mouse button do turn filling on/off +- left mouse button moves turtle +- middle mouse button changes color +- right mouse button toogles betweem pen up +(no line drawn when the turtle moves) and +pen down (line is drawn). If pen up follows +at least two pen-down moves, the polygon that +includes the starting point is filled. ------------------------------------------- Play around by clicking into the canvas using all three mouse buttons. diff --git a/Demo/turtle/tdemo_peace.py b/Demo/turtle/tdemo_peace.py index 13044c9..8bfa920 100644..100755 --- a/Demo/turtle/tdemo_peace.py +++ b/Demo/turtle/tdemo_peace.py @@ -3,14 +3,10 @@ tdemo_peace.py -A very simple drawing suitable as a beginner's -programming example. - -Uses only commands, which are also available in -old turtle.py. - -Intentionally no variables are used except for the -colorloop: +A simple drawing suitable as a beginner's +programming example. Aside from the +peacecolors assignment and the for loop, +it only uses turtle commands. """ from turtle import * @@ -21,7 +17,7 @@ def main(): "royalblue1", "dodgerblue4") reset() - s = Screen() + Screen() up() goto(-320,-195) width(70) @@ -58,7 +54,7 @@ def main(): up() goto(0,300) # vanish if hideturtle() is not available ;-) - return "Done!!" + return "Done!" if __name__ == "__main__": main() diff --git a/Demo/turtle/tdemo_penrose.py b/Demo/turtle/tdemo_penrose.py index f5824d7..f5824d7 100644..100755 --- a/Demo/turtle/tdemo_penrose.py +++ b/Demo/turtle/tdemo_penrose.py diff --git a/Demo/turtle/tdemo_planet_and_moon.py b/Demo/turtle/tdemo_planet_and_moon.py index 223d87b..a0280d7 100644..100755 --- a/Demo/turtle/tdemo_planet_and_moon.py +++ b/Demo/turtle/tdemo_planet_and_moon.py @@ -12,9 +12,9 @@ very light moon! Planet has a circular orbit, moon a stable orbit around the planet. -You can hold the movement temporarily by pressing -the left mouse button with mouse over the -scrollbar of the canvas. +You can hold the movement temporarily by +pressing the left mouse button with the +mouse over the scrollbar of the canvas. """ from turtle import Shape, Turtle, mainloop, Vec2D as Vec @@ -108,6 +108,5 @@ def main(): return "Done!" if __name__ == '__main__': - msg = main() - print msg + main() mainloop() diff --git a/Demo/turtle/tdemo_tree.py b/Demo/turtle/tdemo_tree.py index 6fc8735..6c6121a 100644..100755 --- a/Demo/turtle/tdemo_tree.py +++ b/Demo/turtle/tdemo_tree.py @@ -11,9 +11,9 @@ Uses: (1) a tree-generator, where the drawing is quasi the side-effect, whereas the generator always yields None. -(2) Turtle-cloning: At each branching point the -current pen is cloned. So in the end there -are 1024 turtles. +(2) Turtle-cloning: At each branching point +the current pen is cloned. So in the end +there are 1024 turtles. """ from turtle import Turtle, mainloop from time import clock diff --git a/Demo/turtle/tdemo_yinyang.py b/Demo/turtle/tdemo_yinyang.py index 04dd758..04dd758 100644..100755 --- a/Demo/turtle/tdemo_yinyang.py +++ b/Demo/turtle/tdemo_yinyang.py diff --git a/Demo/turtle/turtleDemo.py b/Demo/turtle/turtleDemo.py index 30b5e5b..88b9b20 100644..100755 --- a/Demo/turtle/turtleDemo.py +++ b/Demo/turtle/turtleDemo.py @@ -5,11 +5,17 @@ import os from Tkinter import * from idlelib.Percolator import Percolator from idlelib.ColorDelegator import ColorDelegator -from idlelib.textView import TextViewer +from idlelib.textView import view_file import turtle import time +demo_dir = os.getcwd() +if "turtleDemo.py" not in os.listdir(demo_dir): + print "Directory of turtleDemo must be current working directory!" + print "But in your case this is", demo_dir + sys.exit() + STARTUP = 1 READY = 2 RUNNING = 3 @@ -21,12 +27,7 @@ btnfont = ("Arial", 12, 'bold') txtfont = ('Lucida Console', 8, 'normal') def getExampleEntries(): - cwd = os.getcwd() - if "turtleDemo.py" not in os.listdir(cwd): - print "Directory of turtleDemo must be current working directory!" - print "But in your case this is", cwd - sys.exit() - entries1 = [entry for entry in os.listdir(cwd) if + entries1 = [entry for entry in os.listdir(demo_dir) if entry.startswith("tdemo_") and not entry.endswith(".pyc")] entries2 = [] @@ -34,7 +35,7 @@ def getExampleEntries(): if entry.endswith(".py"): entries2.append(entry) else: - path = os.path.join(cwd,entry) + path = os.path.join(demo_dir, entry) sys.path.append(path) subdir = [entry] scripts = [script for script in os.listdir(path) if @@ -44,13 +45,16 @@ def getExampleEntries(): return entries2 def showDemoHelp(): - TextViewer(demo.root, "Help on turtleDemo", "demohelp.txt") + view_file(demo.root, "Help on turtleDemo", + os.path.join(demo_dir, "demohelp.txt")) def showAboutDemo(): - TextViewer(demo.root, "About turtleDemo", "about_turtledemo.txt") + view_file(demo.root, "About turtleDemo", + os.path.join(demo_dir, "about_turtledemo.txt")) def showAboutTurtle(): - TextViewer(demo.root, "About the new turtle module", "about_turtle.txt") + view_file(demo.root, "About the new turtle module.", + os.path.join(demo_dir, "about_turtle.txt")) class DemoWindow(object): diff --git a/Demo/turtle/turtledemo_two_canvases.py b/Demo/turtle/turtledemo_two_canvases.py index 5a9831d..5a9831d 100644..100755 --- a/Demo/turtle/turtledemo_two_canvases.py +++ b/Demo/turtle/turtledemo_two_canvases.py |