BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute PCPP-32-101 Exam - Topic 9 Question 46 Discussion

Posted by Kaycee on Mar 03, 2025 at 11:19 PM

If w is a correctly created main application window, which method would you use to foe both of the main window's dimensions?

Suggested Answer: C

1. w.resizable()

Theresizable()method takes two Boolean arguments,widthandheight, that specify whether the main window can be resized in the corresponding directions. PassingFalseto both arguments makes the main window non-resizable, whereas passingTrueto both arguments (or omitting them) makes the window resizable.

Here is an example that sets the dimensions of the main window to 500x400 pixels and makes it non-resizable:

import tkinter as tk

root = tk.Tk()

root.geometry('500x400')

root.resizable(False, False)

root.mainloop()


Tkinter documentation:https://docs.python.org/3/library/tk.html

Tkinter tutorial:https://www.python-course.eu/python_tkinter.php

The resizable () method of a tkinter window object allows you to specify whether the window can be resized by the user in the horizontal and vertical directions. You can pass two boolean arguments to this method, such as w.resizable (False, False), to prevent both dimensions from being changed.Alternatively, you can pass 0 or 1 as arguments, such as w.resizable (0, 0), to achieve the same effect1.

1: https://stackoverflow.com/questions/36575890/how-to-set-a-tkinter-window-to-a-constant-size

Other methods that can be used to control the window size are:

w.geometry () : This method allows you to set the initial size and position of the window by passing a string argument in the format ''widthxheight+x+y'', such as w.geometry (''500x500+100+100'')12.

w.minsize () and w.maxsize (): These methods allow you to set the minimum and maximum size of the window in pixels, such as w.minsize (500, 500) and w.maxsize (1000, 1000)12.

w.pack_propagate () and w.grid_propagate (): These methods allow you to enable or disable the propagation of the size of the widgets inside the window to the window itself. By default, these methods are set to True, which means that the window will adjust its size according to the widgets it contains. You can set these methods to False or 0 to prevent this behavior, such as w.pack_propagate (0) or w.grid_propagate (0).

w.place (): This method allows you to place the window at a specific position and size relative to its parent window or screen. You can use keyword arguments such as x, y, width, height, relx, rely, relwidth, and relheight to specify the coordinates and dimensions of the window in absolute or relative terms, such as w.place (x=0, y=0, relwidth=1, relheight=1).

2: https://stackoverflow.com/questions/25690423/set-window-dimensions-in-tkinter-python-3 : https://stackoverflow.com/questions/36575890/how-to-set-a-tkinter-window-to-a-constant-size/36576068#36576068 : https://www.skotechlearn.com/2020/06/tkinter-window-position-size-center-screen-in-python.html

Get Premium PCPP-32-101 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
14 comments · newest first
RE
Reynalda 11 months ago
I agree with Arlene, w.f ixdim() seems right!
GR
Gracia 11 months ago
I thought it was w.resizable(), but now I'm not so sure.
AR
Arlene 11 months ago
I'm pretty sure it's w.f ixdim().
RE
Reta 12 months ago
Wait, is w.makewindow() even a real method?
YE
Yen 12 months ago
Nah, it's definitely w.fixshape().
EU
Eun 1 year ago
I don’t recall `w.makewindow()` being a method for fixing dimensions, but it sounds familiar from another context.
XO
Xochitl 1 year ago
I’m leaning towards `w.resizable()`, but I’m not confident if that actually sets the dimensions or just allows resizing.
RE
Reita 1 year ago
I remember practicing with similar questions, and I feel like `w.f ixdim()` could be the right one, but it sounds a bit off.
JO
Jolanda 1 year ago
I think the method to fix dimensions might be something like `w.fixshape()`, but I'm not entirely sure.
MI
Miss 1 year ago
I've got it! The answer is B, w.fixdim(). That's the method that will set both the width and height of the main window.
LI
Lisbeth 1 year ago
Okay, let me re-read the question. I think the key is that we need to set both the width and height of the main window, so B seems like the best option.
KA
Kaycee 1 year ago
Wait, I'm a bit confused. Wouldn't w.resizable() be the way to go to set the window's dimensions?
VI
Vivan 1 year ago
I'm pretty sure the answer is B, w.fixdim(). That sounds like the right method to set the main window's dimensions.
FR
Frederica 1 year ago
Hmm, this one seems tricky. I'll have to think it through carefully.
0/2000 characters

Save Cancel