Thank you for reading this.

I'd like to place a red frame in the centre of the main window.

I've discovered two ways to achieve this using place() and pack(padx, pady). 
Grid() does not give the desired result.

Next I'd like to place some widgets on the frame. Again place() does what I 
want and pack() almost does except the red frame is the size of the padding. It 
now seems to me that this is the way it's supposed to work. I'd like to use 
grid(), but so far, all that I can achieve is to place widgets on the main 
window and not the frame. The frame does not display if I use grid().

I've spent hours on this and an Internet search has not helped at all. However, 
I did learn that grid() and pack() are not compatible, could this be the 
problem? Perhaps I have to let go of the familiar grid() method and use pack() 
instead? Place() does exactly what I want but it's a bit cumbersome to use. The 
more I think about it, the more I think pack() is the go.

Still, I'd like to know, what's the best method?

The following is a summary of what I've tried:

from tkinter import *

class App:
        
    def __init__(self, master):
        master.geometry('400x400+50+50')
        frame = Frame(master, width = 300, height = 300, bg = 'red')
        
        frame.pack(pady = 50)
        #frame.place(x = 50, y = 50)
        
        
        Entry(frame).place(x = 100, y = 100, anchor = CENTER)
        #Entry(frame).pack(padx = 20, pady = 20)
        #Entry(frame).grid(row = 10, column = 1)

        #Entry2 = Entry
        #Entry2(frame).grid(row = 20, column = 1)


root = Tk()
app = App(root)
root.mainloop()

-- 
Regards,
Phil
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to