コード例 #1
0
ファイル: GUI.py プロジェクト: rozhinst/Simple-Calculator
frame = tk.Tk()
frame.title("Calculator")
frame.geometry("354x460")
frameLabel = tk.Label(frame, text="CALCULATOR", bg='Black', font=("Lucida Calligraphy", 25, 'bold'), fg='White').pack(side=tk.TOP)
frame.config(background='Black')

# creating the entry field for user input
text_in = tk.StringVar()
text_in.set(" ")
e1 = tk.Entry(frame, textvar=text_in, width=40).pack()

#  connecting gui to logic
logic = Logic(text_in)

# creating buttons
but1 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(1), text="1", font=("Courier New", 16, 'bold'))
but1.place(x=10, y=100)

but2 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(2), text="2", font=("Courier New", 16, 'bold'))
but2.place(x=10, y=170)

but3 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(3), text="3", font=("Courier New", 16, 'bold'))
but3.place(x=10, y=240)

but4 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(4), text="4", font=("Courier New", 16, 'bold'))
but4.place(x=75, y=100)

but5 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(5), text="5", font=("Courier New", 16, 'bold'))
but5.place(x=75, y=170)

but6 = tk.Button(frame, padx=14, pady=14, bd=4, bg='white', command=lambda: logic.click_button(6), text="6", font=("Courier New", 16, 'bold'))