- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to stop Tkinter Message widget from resizing?
Tkinter Message widget is generally used to display text messages in a tkinter window. The Tkinter Message widget can also be configured by adding different properties to it, for example, font-properties, background and foreground color properties, and padding to widen the corners of the box, etc.
Let us assume that we want to stop the Message widget from resizing, then we can use the fill=BOTH property in pack geometry manager while packing the Message widget. Let's take an example to demonstrate how it works.
# Import the required library from tkinter import * # Create an instance of tkinter frame or widget win = Tk() # Size of the window win.geometry("700x350") # Create a Non-resizable messagebox msg=Message(win, text="Hi, how are you doing?") msg.config(bg='yellow', font=('Calibri', 16), borderwidth=2) msg.pack(fill=BOTH) # Run the mainloop win.mainloop()
It will produce the following output −
Here, if you stretch the window, the Messagebox will resize automatically.
Without the fill=BOTH parameter, the same code will produce the following output −
In this case, the width of the Messagebox will remain fixed irrespective of the size of the window.
- How to stop copy, paste, and backspace in text widget in tkinter?
- How to remove focus from a Tkinter widget?
- How to control automated window resizing in Tkinter?
- How to erase everything from the Tkinter text widget?
- How to erase everything from a Tkinter text widget?
- How to stop Tkinter after function?
- How to get the input from the Tkinter Text Widget?
- How to center a Tkinter widget?
- Resizing pictures in PIL in Tkinter
- Resizing images with ImageTk.PhotoImage with Tkinter
- How to stop Tkinter Frame from shrinking to fit its contents?
- How to stop a loop with a stop button in Tkinter?
- How to make a Tkinter widget invisible?
- How to set focus for Tkinter widget?
- Notebook widget in Tkinter