moritzg
moritzg

Reputation: 4396

Tkinter paragraphs

This shows what I have and want:

image showing tkinter layout desired

So yeah as you can see I want a paragraph exactly where the red line is. The buttons should appear beneath the 2 text boxes.

Current bit of code:

window = Tk()
window.title("Taschenrechner")

window.label_zahl1 = Label(window, text = 'Zahl 1:', anchor = W, justify = LEFT)
window.label_zahl1.pack(side=LEFT)
window.entry_zahl1 = Entry()
window.entry_zahl1.pack(side=LEFT)

window.label = Label(window, text = '\n')
window.label.pack(side=LEFT)

window.label_zahl2 = Label(window, text = 'Zahl 2:')
window.label_zahl2.pack(side=LEFT)
window.entry_zahl2 = Entry()
window.entry_zahl2.pack(side=LEFT)

window.button_plus = Button(window, text = "+")
window.button_plus.pack(side=LEFT)

window.button_minus = Button(window, text = "-")
window.button_minus.pack(side=LEFT)

window.button_divi = Button(window, text = "/")
window.button_divi.pack(side=RIGHT)

window.button_mal = Button(window, text = "*")
window.button_mal.pack(side=RIGHT)

window.ausgabe = Label(master = window, text = "")                     
window.ausgabe.pack()
window.mainloop()

Upvotes: 0

Views: 2013

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385970

For this particular problem, the easy solution is to use grid which will allow to specify a row and column for each widget.

Another simple solution is to use to separate frames. Put the labels and entries in one, and use pack as you are doing now. Then, in a second frame put h buttons, again using pack in a similar fashion. Finally, use pack to put the first frame on top, then use pack again to place the second frame below the first.

Upvotes: 2

Related Questions