Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
turtledemo.__main__.DemoWindow Class Reference
Inheritance diagram for turtledemo.__main__.DemoWindow:
Inheritance graph
[legend]
Collaboration diagram for turtledemo.__main__.DemoWindow:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def configGUI
def makeLoadDemoMenu
def makeHelpMenu
def refreshCanvas
def loadfile
def startDemo
def clearCanvas
def stopIt

Public Attributes

 root
 mBar
 ExamplesBtn
 OptionsBtn
 left_frame
 text_frame
 vbar
 text
 hbar
 output_lbl
 graph_frame
 screen
 dirty
 module
 state
 exitflag
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

string disabledforeground = "#fed"

Private Member Functions

def _destroy

Detailed Description

Definition at line 42 of file __main__.py.


Constructor & Destructor Documentation

def turtledemo.__main__.DemoWindow.__init__ (   self,
  filename = None 
)

Definition at line 44 of file __main__.py.

00044 
00045     def __init__(self, filename=None):   #, root=None):
00046         self.root = root = turtle._root = Tk()
00047         root.wm_protocol("WM_DELETE_WINDOW", self._destroy)
00048 
00049         #################
00050         self.mBar = Frame(root, relief=RAISED, borderwidth=2)
00051         self.mBar.pack(fill=X)
00052 
00053         self.ExamplesBtn = self.makeLoadDemoMenu()
00054         self.OptionsBtn = self.makeHelpMenu()
00055         self.mBar.tk_menuBar(self.ExamplesBtn, self.OptionsBtn) #, QuitBtn)
00056 
00057         root.title('Python turtle-graphics examples')
00058         #################
00059         self.left_frame = left_frame = Frame(root)
00060         self.text_frame = text_frame = Frame(left_frame)
00061         self.vbar = vbar =Scrollbar(text_frame, name='vbar')
00062         self.text = text = Text(text_frame,
00063                                 name='text', padx=5, wrap='none',
00064                                 width=45)
00065         vbar['command'] = text.yview
00066         vbar.pack(side=LEFT, fill=Y)
00067         #####################
00068         self.hbar = hbar =Scrollbar(text_frame, name='hbar', orient=HORIZONTAL)
00069         hbar['command'] = text.xview
00070         hbar.pack(side=BOTTOM, fill=X)
00071         #####################
00072         text['yscrollcommand'] = vbar.set
00073         text.config(font=txtfont)
00074         text.config(xscrollcommand=hbar.set)
00075         text.pack(side=LEFT, fill=Y, expand=1)
00076         #####################
00077         self.output_lbl = Label(left_frame, height= 1,text=" --- ", bg = "#ddf",
00078                                 font = ("Arial", 16, 'normal'))
00079         self.output_lbl.pack(side=BOTTOM, expand=0, fill=X)
00080         #####################
00081         text_frame.pack(side=LEFT, fill=BOTH, expand=0)
00082         left_frame.pack(side=LEFT, fill=BOTH, expand=0)
00083         self.graph_frame = g_frame = Frame(root)
00084 
00085         turtle._Screen._root = g_frame
00086         turtle._Screen._canvas = turtle.ScrolledCanvas(g_frame, 800, 600, 1000, 800)
00087         #xturtle.Screen._canvas.pack(expand=1, fill="both")
        self.screen = _s_ = turtle.Screen()

Here is the caller graph for this function:


Member Function Documentation

def turtledemo.__main__.DemoWindow._destroy (   self) [private]

Definition at line 120 of file __main__.py.

00120 
00121     def _destroy(self):
00122         self.root.destroy()
00123         sys.exit()

Definition at line 228 of file __main__.py.

00228 
00229     def clearCanvas(self):
00230         self.refreshCanvas()
00231         self.screen._delete("all")
00232         self.scanvas.config(cursor="")
00233         self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.__main__.DemoWindow.configGUI (   self,
  menu,
  start,
  stop,
  clear,
  txt = "",
  color = "blue" 
)

Definition at line 124 of file __main__.py.

00124 
00125     def configGUI(self, menu, start, stop, clear, txt="", color="blue"):
00126         self.ExamplesBtn.config(state=menu)
00127 
00128         self.start_btn.config(state=start)
00129         if start == NORMAL:
00130             self.start_btn.config(bg="#d00")
00131         else:
00132             self.start_btn.config(bg="#fca")
00133 
00134         self.stop_btn.config(state=stop)
00135         if stop == NORMAL:
00136             self.stop_btn.config(bg="#d00")
00137         else:
00138             self.stop_btn.config(bg="#fca")
00139         self.clear_btn.config(state=clear)
00140 
00141         self.clear_btn.config(state=clear)
00142         if clear == NORMAL:
00143             self.clear_btn.config(bg="#d00")
00144         else:
00145             self.clear_btn.config(bg="#fca")
00146 
00147         self.output_lbl.config(text=txt, fg=color)
00148 

Here is the caller graph for this function:

def turtledemo.__main__.DemoWindow.loadfile (   self,
  filename 
)

Definition at line 186 of file __main__.py.

00186 
00187     def loadfile(self, filename):
00188         self.refreshCanvas()
00189         modname = 'turtledemo.' + filename
00190         __import__(modname)
00191         self.module = sys.modules[modname]
00192         with open(self.module.__file__, 'r') as f:
00193             chars = f.read()
00194         self.text.delete("1.0", "end")
00195         self.text.insert("1.0", chars)
00196         self.root.title(filename + " - a Python turtle graphics example")
00197         reload(self.module)
00198         self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED,
00199                        "Press start button", "red")
00200         self.state = READY

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 165 of file __main__.py.

00165 
00166     def makeHelpMenu(self):
00167         CmdBtn = Menubutton(self.mBar, text='Help', underline=0, font=menufont)
00168         CmdBtn.pack(side=LEFT, padx='2m')
00169         CmdBtn.menu = Menu(CmdBtn)
00170 
00171         CmdBtn.menu.add_command(label='About turtle.py', font=menufont,
00172                                 command=showAboutTurtle)
00173         CmdBtn.menu.add_command(label='turtleDemo - Help', font=menufont,
00174                                 command=showDemoHelp)
00175         CmdBtn.menu.add_command(label='About turtleDemo', font=menufont,
00176                                 command=showAboutDemo)
00177 
00178         CmdBtn['menu'] = CmdBtn.menu
00179         return CmdBtn

Definition at line 149 of file __main__.py.

00149 
00150     def makeLoadDemoMenu(self):
00151         CmdBtn = Menubutton(self.mBar, text='Examples', underline=0, font=menufont)
00152         CmdBtn.pack(side=LEFT, padx="2m")
00153         CmdBtn.menu = Menu(CmdBtn)
00154 
00155         for entry in getExampleEntries():
00156             def loadexample(x):
00157                 def emit():
00158                     self.loadfile(x)
00159                 return emit
00160             CmdBtn.menu.add_command(label=entry, underline=0,
00161                                     font=menufont, command=loadexample(entry))
00162 
00163         CmdBtn['menu'] = CmdBtn.menu
00164         return CmdBtn

Here is the call graph for this function:

Definition at line 180 of file __main__.py.

00180 
00181     def refreshCanvas(self):
00182         if not self.dirty: return
00183         self.screen.clear()
00184         #self.screen.mode("standard")
00185         self.dirty=False

Here is the caller graph for this function:

Definition at line 201 of file __main__.py.

00201 
00202     def startDemo(self):
00203         self.refreshCanvas()
00204         self.dirty = True
00205         turtle.TurtleScreen._RUNNING = True
00206         self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
00207                        "demo running...", "black")
00208         self.screen.clear()
00209         self.screen.mode("standard")
00210         self.state = RUNNING
00211 
00212         try:
00213             result = self.module.main()
00214             if result == "EVENTLOOP":
00215                 self.state = EVENTDRIVEN
00216             else:
00217                 self.state = DONE
00218         except turtle.Terminator:
00219             self.state = DONE
00220             result = "stopped!"
00221         if self.state == DONE:
00222             self.configGUI(NORMAL, NORMAL, DISABLED, NORMAL,
00223                            result)
00224         elif self.state == EVENTDRIVEN:
00225             self.exitflag = True
00226             self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
00227                            "use mouse/keys or STOP", "red")

Here is the call graph for this function:

Definition at line 234 of file __main__.py.

00234 
00235     def stopIt(self):
00236         if self.exitflag:
00237             self.clearCanvas()
00238             self.exitflag = False
00239             self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED,
00240                            "STOPPED!", "red")
00241             turtle.TurtleScreen._RUNNING = False
00242             #print "stopIT: exitflag = True"
00243         else:
00244             turtle.TurtleScreen._RUNNING = False
00245             #print "stopIt: exitflag = False"

Here is the call graph for this function:


Member Data Documentation

Definition at line 184 of file __main__.py.

Definition at line 99 of file __main__.py.

Definition at line 52 of file __main__.py.

Definition at line 224 of file __main__.py.

Definition at line 82 of file __main__.py.

Definition at line 67 of file __main__.py.

Definition at line 58 of file __main__.py.

Definition at line 49 of file __main__.py.

Definition at line 190 of file __main__.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 53 of file __main__.py.

Definition at line 76 of file __main__.py.

Definition at line 45 of file __main__.py.

Definition at line 87 of file __main__.py.

Definition at line 199 of file __main__.py.

Definition at line 61 of file __main__.py.

Definition at line 59 of file __main__.py.

Definition at line 60 of file __main__.py.


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