tkinter grid with OptionMenu

121 Views Asked by At

I would like to align an OptionMenu using the grid in tkinter.

Here is a MWE:

from tkinter import *
from tkinter import ttk

metrics = ["A", "B", "C", "D", "E", "F", "G", "H"]

root = Tk()

root.title("random software")

content = ttk.Frame(root)

A_label = Label(content, text = "A")
A_entry = Entry(content, width = 5)
A_hint = Label(content, text = "lorem")

B_label = Label(content, text = "B")
B_entry = Entry(content, width = 5)
B_hint = Label(content, text = "ipsum")

selected_metric = StringVar()
selected_metric.set(metrics[0])
metric = OptionMenu(root, selected_metric, *metrics)

content.grid(row = 1, column = 0)

metric.grid(row = 5, column = 1)

A_label.grid(row = 6, column = 0)
A_entry.grid(row = 6, column = 1)
A_hint.grid(row = 6, column = 3, sticky = "w")

B_label.grid(row = 7, column = 0)
B_entry.grid(row = 7, column = 1)
B_hint.grid(row = 7, column = 3, sticky = "w")

root.mainloop()

I would like to place the OptionMenu on another row in another column.

No matter what I set as row or column, the OptionMenu remains at the bottom right of the interface. What's wrong?

0

There are 0 best solutions below