JanKanis avatar JanKanis committed 7cdaf02 Draft

Issue #18132: Let buttons in turtledemo be visible even on small screens

Replaced the packed layout of scanvas and btn_frame in the turtledemo window by a gridded layout, so the buttons don't disappear if there is not enough space.

Comments (0)

Files changed (1)

Lib/turtledemo/__main__.py

         #################
         self.left_frame = left_frame = Frame(root)
         self.text_frame = text_frame = Frame(left_frame)
-        self.vbar = vbar =Scrollbar(text_frame, name='vbar')
+        self.vbar = vbar = Scrollbar(text_frame, name='vbar')
         self.text = text = Text(text_frame,
                                 name='text', padx=5, wrap='none',
                                 width=45)
         vbar['command'] = text.yview
         vbar.pack(side=LEFT, fill=Y)
         #####################
-        self.hbar = hbar =Scrollbar(text_frame, name='hbar', orient=HORIZONTAL)
+        self.hbar = hbar = Scrollbar(text_frame, name='hbar', orient=HORIZONTAL)
         hbar['command'] = text.xview
         hbar.pack(side=BOTTOM, fill=X)
         #####################
         text_frame.pack(side=LEFT, fill=BOTH, expand=0)
         left_frame.pack(side=LEFT, fill=BOTH, expand=0)
         self.graph_frame = g_frame = Frame(root)
+        g_frame.grid_columnconfigure(0, weight=1)
+        g_frame.grid_rowconfigure(0, weight=1)
 
         turtle._Screen._root = g_frame
         turtle._Screen._canvas = turtle.ScrolledCanvas(g_frame, 800, 600, 1000, 800)
         #xturtle.RawTurtle.canvases = [self.scanvas]
         turtle.RawTurtle.screens = [_s_]
 
-        self.scanvas.pack(side=TOP, fill=BOTH, expand=1)
+        self.scanvas.grid(row=0, column=0, sticky='news')
 
         self.btn_frame = btn_frame = Frame(g_frame, height=100)
         self.start_btn = Button(btn_frame, text=" START ", font=btnfont, fg = "white",
                                 disabledforeground = "#fed", command = self.clearCanvas)
         self.clear_btn.pack(side=LEFT, fill=X, expand=1)
 
-        self.btn_frame.pack(side=TOP, fill=BOTH, expand=0)
+        self.btn_frame.grid(row=1, column=0, sticky='ew')
         self.graph_frame.pack(side=TOP, fill=BOTH, expand=1)
 
         Percolator(text).insertfilter(ColorDelegator())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.