Skip to content
Advertisement

TKinter labels not moving further than a certain point on my window

I am new to tkinter and I am trying to make a tabbed page however I am struggling to move the labels around. They dont seem to be listening to the rows and columns I enter completely. They move to a certain extent but for example, the premium paper label doesnt move any further than about a third across the page. What am I doing wrong?

 style = ttk.Style()
    style.theme_create("yummy", parent="alt", settings={
        "TFrame": {"configure": {"background": '#94B3BD'}},
        "TNotebook": {
            "configure": {"background": "#5D7881"}},
        "TNotebook.Tab": {
            "configure": {"padding": [10, 4], "background": "#94B3BD"}}})

    style.theme_use("yummy")
    customisationWindow = tk.Toplevel(mainWindow)
    customisationWindow.geometry("1000x600")
    customisationWindow.title("DIY Store Quote System")
    tabControl = ttk.Notebook(customisationWindow)

    tab1 = ttk.Frame(tabControl)
    tab2 = ttk.Frame(tabControl)
    tab3 = ttk.Frame(tabControl)
    tab4 = ttk.Frame(tabControl)
    tab5 = ttk.Frame(tabControl)

    tabControl.add(tab1, text='Select Wallpaper')
    tabControl.add(tab2, text='Select Colour')
    tabControl.add(tab3, text='Select Detailing')
    tabControl.add(tab4, text='Add Adhesive/Lining')
    tabControl.add(tab5, text='View Basket')
    tabControl.pack(expand=1, fill="both")
    standard = Label(tab1, text="Standard Paper", bg="#94B3BD").grid(row=20, column=5)
    standard2 = Label(tab1, text="Premium Paper", bg="#94B3BD").grid(row=2, column=200)
    standard3 = Label(tab1, text="Position 3").grid(row=30, column=70)
    standard4 = Label(tab1, text="Position 4").grid(row=1, column=4)

Advertisement

Answer

Rows and columns with nothing in them have a size of zero. You could put something at row 10, 100, 100, or 10000 and it will be in the same place if the other columns are empty.

It’s unclear exactly what you want to have happen in this case, so it’s impossible to give a good solution. It depends on if you want the page to have 5 evenly spaced columns, 200 columns of varying width, or columns with a specific size and then one or more columns that take up the extra space. grid provides a mechanism for all of those scenarios.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement