日 下 下 下 下下 下 下 下 07:42 115 font_sizes = [8, 9, 10, 11, 12, 14, 18, 20, 22, 24, 30] 116 117 def getExampleEntries(): 118 return [entry[:-3] for entry in os.listdir(demo_dir) if 119 entry.endswith(".py") and entry[0] != '_'] 120 121 help_entries = ( # (help_label, help_doc) 122 ('Turtledemo help', __doc__), 123 ('About turtledemo', about_turtledemo), 124 ('About turtle module', turtle.__doc__), 125 ) 126 127 class DemoWindow(object): 128 129 def __init__(self, filename=None): 130 self.root = root = turtle._root = Tk() 131 root.title('Python turtle-graphics examples') 132 root.wm_protocol("WM_DELETE_WINDOW", self._destroy) 133 134 if darwin: 135 import subprocess 136 # Make sure we are the currently activated OS X application 137 # so that our menu bar appears. 138 p = subprocess.Popen( 139 [ 140 'osascript', 141 '-e', 'tell application "System Events"', 142 '-e', 'set frontmost of the first process whose ' 143 'unix id is {} to true'.format(os.getpid()), 144 '-e', 'end tell', 145 ], 146 stderr=subprocess.DEVNULL, 147 stdout=subprocess.DEVNULL,) 148 149 root.grid_rowconfigure(0, weight=1) 150 root.grid_columnconfigure(0, weight=1) 151 root.grid_columnconfigure(1, minsize=90, weight=1) 152 root.grid_columnconfigure(2, minsize=90, weight=1) 153 root.grid_columnconfigure(3, minsize=90, weight=1) 154 155 self.mBar = Menu(root, relief=RAISED, borderwidth=2) 156 self.mBar.add_cascade(menu=self.makeLoadDemoMenu(self.mBar), 157 label='Examples', underline=0) 158 self.mBar.add_cascade(menu=self.makeFontMenu(self.mBar), 159 label='Fontsize', underline=0) 160 self.mBar.add_cascade(menu=self.makeHelpMenu(self.mBar), 161 label='Help', underline=0) 162 root['menu'] = self.mBar 163 164 pane = PanedWindow(orient=HORIZONTAL, sashwidth=5, 165 sashrelief=SOLID, bg='#ddd') 166 pane.add(self.makeTextFrame(pane)) 167 pane.add(self.makeGraphFrame(pane)) 168 pane.grid(row=0, columnspan=4, sticky='news') 169 170 self.output_lbl = Label(root, height= 1, text=" --- ", bg="#ddf", 171 font=("Arial", 16, 'normal'), borderwidth=2, -3- 45