Tkinter: grid() resize
Solved
modefee
-
modefee -
modefee -
Hello,
I built a Python interface arranged with place().
As a project improvement, I plan to place all my elements with grid().
I'm having a problem with the size of my entry elements which I had formed as large squares in the window but I can't resize my entries with grid() except by changing the font size. Stretching it across multiple columns or rows doesn't work. How else can I do it?
I built a Python interface arranged with place().
As a project improvement, I plan to place all my elements with grid().
I'm having a problem with the size of my entry elements which I had formed as large squares in the window but I can't resize my entries with grid() except by changing the font size. Stretching it across multiple columns or rows doesn't work. How else can I do it?
5 answers
Hello,
We would have a clearer view if you displayed your code here, and with code tags:
https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
We would have a clearer view if you displayed your code here, and with code tags:
https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
Here is my translation of your code block into English, preserving structure and HTML tags:
import tkinter as tk from tkinter import * screen1 = Tk()# definition of the window screen1.geometry('1200x700') # window size screen1.title('Draft')# window title screen1.configure(bg='#F2E7BF') # default window color screen1.resizable(width=True, height=True)# allows resizing of the window Button = Button(screen1, text="Button",relief=RAISED,background="#FFC24B",foreground="white") # button that calls the getEntry function Button.grid(row=0,column=0) paragraph= Label(screen1,text="text ") # text paragraph.grid(row=1, column =18, rowspan=1, columnspan= 8) scrollbar = Scrollbar(screen1, orient=HORIZONTAL) # user input scrollbar.grid(row=5, column=8, columnspan=10 ) myEntry = Entry(screen1, xscrollcommand=scrollbar.set) # user input myEntry.grid(row=0, column = 6, rowspan= 5, columnspan=5) myEntry.config(font='arial 24') scrollbar.config(command= myEntry.xview) screen1.mainloop()# loop to keep the window open.
Hello,
Your button does not call any function, to call a function with a button, you must write:
Where is the getEntry function???
Otherwise, for the size of an Entry, it’s more like this, with ipadx, ipady:
Line 1 is useless ...
# button that calls the getEntry function Button = Button(screen1, text="Bouton", relief=RAISED, background="#FFC24B", foreground="white")
Your button does not call any function, to call a function with a button, you must write:
Bouton = Button(screen1, text="Bouton", relief=RAISED, background="#FFC24B", foreground="white", command = nom_de_la_fonction)
Where is the getEntry function???
Otherwise, for the size of an Entry, it’s more like this, with ipadx, ipady:
myEntry.grid(row=0, column = 6, rowspan= 5, columnspan=5, ipady = 10)
Line 1 is useless ...