New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - 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

Actual exam question for Python Institute's PCPP-32-101 exam
Question #: 46
Topic #: 9
[All PCPP-32-101 Questions]

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

Show Suggested Answer Hide Answer
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

Contribute your Thoughts:

0/2000 characters
Reynalda
2 months ago
I agree with Arlene, w.f ixdim() seems right!
upvoted 0 times
...
Gracia
2 months ago
I thought it was w.resizable(), but now I'm not so sure.
upvoted 0 times
...
Arlene
2 months ago
I'm pretty sure it's w.f ixdim().
upvoted 0 times
...
Reta
3 months ago
Wait, is w.makewindow() even a real method?
upvoted 0 times
...
Yen
3 months ago
Nah, it's definitely w.fixshape().
upvoted 0 times
...
Eun
3 months ago
I don’t recall `w.makewindow()` being a method for fixing dimensions, but it sounds familiar from another context.
upvoted 0 times
...
Xochitl
3 months ago
I’m leaning towards `w.resizable()`, but I’m not confident if that actually sets the dimensions or just allows resizing.
upvoted 0 times
...
Reita
4 months 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.
upvoted 0 times
...
Jolanda
4 months ago
I think the method to fix dimensions might be something like `w.fixshape()`, but I'm not entirely sure.
upvoted 0 times
...
Miss
4 months 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.
upvoted 0 times
...
Lisbeth
4 months 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.
upvoted 0 times
...
Kaycee
4 months ago
Wait, I'm a bit confused. Wouldn't w.resizable() be the way to go to set the window's dimensions?
upvoted 0 times
...
Vivan
5 months ago
I'm pretty sure the answer is B, w.fixdim(). That sounds like the right method to set the main window's dimensions.
upvoted 0 times
...
Frederica
5 months ago
Hmm, this one seems tricky. I'll have to think it through carefully.
upvoted 0 times
...

Save Cancel