Jul-15-2020, 07:02 PM
Hello Python Users:
I am a beginner with Python & Tkinter. I created 3 rows of labels and command buttons with the following code. I am kind of happy with the middle row. Sorry I couldn't figure out how to copy the screen so I could show you the result of running the program.
In the top how how do I the labels and buttons to expand so that 1)there is no space between them 2) their widths expand so that the 3 buttons take the entire width. -similar to the middle row?
In the 3rd row I would like the 2 command buttons to be centered all the way across.
I am a little familiar with pack and grid. Should I learn place?
I am a beginner with Python & Tkinter. I created 3 rows of labels and command buttons with the following code. I am kind of happy with the middle row. Sorry I couldn't figure out how to copy the screen so I could show you the result of running the program.
In the top how how do I the labels and buttons to expand so that 1)there is no space between them 2) their widths expand so that the 3 buttons take the entire width. -similar to the middle row?
In the 3rd row I would like the 2 command buttons to be centered all the way across.
I am a little familiar with pack and grid. Should I learn place?
from tkinter import * root = Tk() TL = Label(root, text="Top Left", bg="pale turquoise") TL.grid(row =1, column = 0)] TM= Button(root, text="Top Middle", bg="White") TM.grid( row =1, column = 1) TR = Button(root, text="Top Right", bg="turquoise") TR.grid( row =1, column = 2,) ML = Button(root, text="Middle Left", bg="grey") ML.grid( row =2, column = 0) MMa = Button(root, text="MiddelMiddleA", bg="yellow") MMa.grid( row =2, column = 1) MMb = Button(root, text="MiddleMiddleb", bg="yellow") MMb.grid( row =2, column = 2) MMc = Button(root, text="MiddleMiddlec", bg="yellow") MMc.grid(row =2, column = 3) MMd = Button(root, text="MiddleMiddled", bg="yellow") MMd.grid( row =2, column = 4) MMe = Button(root, text="MiddleMiddlee", bg="yellow") MMe.grid( row =2, column = 5) BottomLeft = Button(root, text="BottomLeft", bg="deep pink") BottomLeft.grid( row =3, column = 0) BottomRight = Button(root, text="BottomRight", bg="red") BottomRight.grid( row =3, column = 1) root.mainloop()