Reputation: 129
I want to be able to add this formula into my tkinter window and then position this whole thing like that into the bottom center of the window. Inside the window I also have a canvas above it that I .pack() in.
My code looks something like this right now
from tkinter import*
root = Tk()
canvas = Canvas(root, width=1200, height=525)
canvas.pack()
text1 = Label(root, text= "P(H|E)=")
text2 = Label(root, text= "SAA + (")
text3 = Label(root, text= "+ [0.34])")
entry1 = Entry(root)
entry2 = Entry(root)
entry3 = Entry(root)
text1.pack()
entry1.pack()
entry2.pack()
text2.pack()
entry3.pack()
text3.pack()
root.mainloop()
Upvotes: 2
Views: 57
Reputation: 13729
You need to break down what you want into neat rows and columns. Then make a Frame for each subunit, and put them together the way you need them.
import tkinter as tk
root = tk.Tk()
leftside = tk.Frame(root)
lbl = tk.Label(leftside, text= "P(H|E)=")
lbl.pack(anchor='c')
leftside.pack(side=tk.LEFT)
rightside = tk.Frame(root)
numerator = tk.Frame(rightside)
entry1 = tk.Entry(numerator, width=5)
entry1.pack(side=tk.LEFT)
lbl = tk.Label(numerator, text='+')
lbl.pack(side=tk.LEFT)
entry2 = tk.Entry(numerator, width=5)
entry2.pack(side=tk.LEFT)
numerator.pack()
division_bar = tk.Frame(rightside, bg='black', height=4)
division_bar.pack(fill=tk.X, expand=True)
denominator = tk.Frame(rightside)
text2 = tk.Label(denominator, text= "SAA + (")
text2.pack(side=tk.LEFT)
entry3 = tk.Entry(denominator, width=5)
entry3.pack(side=tk.LEFT)
text3 = tk.Label(denominator, text= "+ [0.34])")
text3.pack(side=tk.LEFT)
denominator.pack()
rightside.pack(side=tk.LEFT)
root.mainloop()
Upvotes: 2