2
votes

Can you please take a look at this demo and let me know why I am not able to apply Geometry Grid setting to the Notebook Tab widgets:

As you can see I tried this on lb1

lb1.grid(row=1, column=1, sticky='W', padx=5, pady=5, ipadx=5, ipady=5)

but the label still is in the middle of the tab page

import Tkinter
from Tkinter import *
import ttk
from ttk import *

app = Tk()
app.configure(background='DimGray')
app.geometry('600x600')
app.resizable(width=False, height=False)

note = Notebook(app)

tab1 = Frame(note)
tab2 = Frame(note)
tab3 = Frame(note)

note.add(tab1, text = "Tracing", compound=TOP)
note.add(tab2, text = "Network Details")
note.add(tab3, text = "Tab Three")
note.pack(fill=BOTH, expand=True)

lb1 = Label(tab1,  text="Trace Object")
lb1.grid(row=1, column=1, sticky='E', padx=5, pady=5, ipadx=5, ipady=5)
lb1.pack()

variable = StringVar(app)
variable.set("Select From List")

cm = ttk.Combobox(tab1, textvariable=variable)
cm.config(values =('Select From Phase A', 'Select From Phase B'))
cm.grid(row=1, column=2, sticky='E', padx=5, pady=5, ipadx=5, ipady=5)
cm.pack()

app.mainloop()

This is what I am hoping to achieve

enter image description here

2
where do you expect it to be? Also, isn't the error telling you exactly what the problem is? - Bryan Oakley
at left-top of the page - Suffii
I just update the post with an image of what I am hoping to get - Suffii

2 Answers

3
votes

You can not use more than one geometry manager at the same time.

Well, I saw answers stating the same thing, but in reality you can if you do not misuse them. And this is your situation: you use more than one geometry manager but in a wrong way.

You have two options:

  • Option 1:

As fir note, you want to use the pack() geometry manager for tab1 widget. This means you have to remove away these 2 lines:

lb1.grid(row=1, column=1, sticky='E', padx=5, pady=5, ipadx=5, ipady=5)

and:

cm.grid(row=1, column=2, sticky='E', padx=5, pady=5, ipadx=5, ipady=5)
  • Option 2:

You want to use the pack() geometry manager for the note widget but you want to use grid() for tab1. You can do that safely and without confusing the Python interpreter by removing these 2 lines and keeping the former ones I mentioned above:

lb1.pack()

and:

cm.pack()
1
votes

Try

lbl.pack(side=left)

and

cm.pack(side=left)

that should put both widgets to the left