Я пишу приложение для калькулятора и использую Tkinter, а также Python 3.7. Я в настоящее время застрял, как при попытке запустить его, все работает, за исключением того, что он не показывает «Начать расчет ...» на экране. Кто-нибудь может помочь, пожалуйста?
Я попытался вызвать функцию, использованную в конце, но это не сработало. Я не уверен, что еще попробовать.
from tkinter import *
def btn(numbers):
global operator
operator = operator + str(numbers)
root = Tk()
root.title("Calculator")
operator = ''
txt_input = StringVar(value='Start Calculating...')
#========================Screen=======================
Display = Entry(root, fg='white', bg='white',
justify='right', bd=28, textvariable=txt_input)
Display.grid(columnspan=5, sticky='NSEW')
#=======================Row1==========================
b7 = Button(root, padx=30, pady=15, bd=8, fg='black', text='7', highlightbackground='white', highlightthickness=0.0001).grid(row=1, column=0, sticky='NSEW')
b8 = Button(root, padx=30, pady=15, bd=8, fg='black', text='8', highlightbackground='white', highlightthickness=0.0001).grid(row=1, column=1, sticky='NSEW')
b9 = Button(root, padx=30, pady=15, bd=8, fg='black', text='9', highlightbackground='white', highlightthickness=0.0001).grid(row=1, column=2, sticky='NSEW')
clear = Button(root, padx=30, pady=15, bd=8, fg='black', text='C', highlightbackground='green', highlightthickness=0.0001).grid(row=1, column=3, sticky='NSEW')
#=======================Row2==========================
b4 = Button(root, padx=30, pady=15, bd=8, fg='black', text='4', highlightbackground='white', highlightthickness=0.0001).grid(row=2, column=0, sticky='NSEW')
b5 = Button(root, padx=30, pady=15, bd=8, fg='black', text='5', highlightbackground='white', highlightthickness=0.0001).grid(row=2, column=1, sticky='NSEW')
b6 = Button(root, padx=30, pady=15, bd=8, fg='black', text='6', highlightbackground='white', highlightthickness=0.0001).grid(row=2, column=2, sticky='NSEW')
plus = Button(root, padx=30, pady=15, bd=8, fg='black', text='+', highlightbackground='orange', highlightthickness=0.0001).grid(row=2, column=3, sticky='NSEW')
#=======================Row3==========================
b1 = Button(root, padx=30, pady=15, bd=8, fg='black', text='1', highlightbackground='white', highlightthickness=0.0001).grid(row=3, column=0, sticky='NSEW')
b2 = Button(root, padx=30, pady=15, bd=8, fg='black', text='2', highlightbackground='white', highlightthickness=0.0001).grid(row=3, column=1, sticky='NSEW')
b3 = Button(root, padx=30, pady=15, bd=8, fg='black', text='3', highlightbackground='white', highlightthickness=0.0001).grid(row=3, column=2, sticky='NSEW')
minus = Button(root, padx=30, pady=15, bd=8, fg='black', text='-', highlightbackground='orange', highlightthickness=0.0001).grid(row=3, column=3, sticky='NSEW')
#=======================Row4==========================
b0 = Button(root, padx=30, pady=15, bd=8, fg='black', text='0', highlightbackground='white', highlightthickness=0.0001).grid(row=4, column=0, sticky='NSEW')
dot = Button(root, padx=30, pady=15, bd=8, fg='black', text='.', highlightbackground='orange', highlightthickness=0.0001).grid(row=4, column=1, sticky='NSEW')
div = Button(root, padx=30, pady=15, bd=8, fg='black', text='/', highlightbackground='orange', highlightthickness=0.0001).grid(row=4, column=2, sticky='NSEW')
times = Button(root, padx=30, pady=15, bd=8, fg='black', text='x', highlightbackground='orange', highlightthickness=0.0001).grid(row=4, column=3, sticky='NSEW')
#=======================Row5==========================
equals = Button(root, padx=95, pady=15, bd=8, fg='black', text='=', highlightbackground='green', highlightthickness=0.0001).grid(row=5, columnspan=2)
bracket1 = Button(root, padx=35, pady=15, bd=8, fg='black', text='(', highlightbackground='orange', highlightthickness=0.0001).grid(row=5, column=2)
bracket2 = Button(root, padx=38, pady=15, bd=8, fg='black', text=')', highlightbackground='orange', highlightthickness=0.0001).grid(row=5, column=3)
root.mainloop()