I am new to programming and just started learning python and Tkinter. Since I am more of a visual and try and error learner I made a personal project which is a Scoreboard. I created the interface and know that i need to change the label textvariables. The problem where I am stuck is that I just cant get to understand how to get numbers that appear above the ok btn to display final score and clear once the ok btn is pressed. Another problem thatI have is that when the - btn is choosen how do I put the - before the int even though it is pressed after a number has been inserted and then subtracted from final score. I know code is a bit rough and could def be done better, but i repeat it is a 1st personal project.
Thank You
from tkinter import \*
import tkinter as tk
import ttkbootstrap as ttk
from ttkbootstrap.constants import \*
root = ttk.Window(themename="darkly")
root.resizable(0, 0)
def btn_click(item):
global expression
expression = expression + str(item)
input_text.set(expression)
def bt_clear():
global expression
expression = ""
input_text.set("")
expression = ""
input_text = StringVar()
root.title("")
root.iconbitmap("")
lbl_title = Label(root, text="",font=("", 14))
lbl_title.grid(row=0, column=6)
\#CLR SCOREBOARD
clr_scoreboard = Button(root, text="CLEAR SCOREBOARD", command=NONE).grid(row=6, column=6)
\#PLAYER1SIDE SETUP
\#PLAYER1SCORE
lbl_p1score = tk.Label(root, textvariable=p1score, font=("", 110))
lbl_p1score.grid(row=1, columnspan=3)
\#PLAYER1 INPUT
lbl1_p1points = Label(root, textvariable= input_text, font=("", 50))
lbl1_p1points.grid(row=3, column=4)
\#PLAYER1 BTNS
p1btn1 = Button(root, text = "1", font=("", 14), command = lambda: btn_click(1), height=4, width=8)
p1btn1.grid(row=2, column=0, padx=1, pady=1)
p1btn2 = Button(root, text = "2", font=("", 14), command = lambda: btn_click(2), height=4, width=8)
p1btn2.grid(row=2, column=1, padx=1, pady=1)
p1btn3 = Button(root, text = "3", font=("", 14), command = lambda: btn_click(3), height=4, width=8)
p1btn3.grid(row=2, column=2, padx=1, pady=1)
p1btn4 = Button(root, text = "4", font=("", 14), command = lambda: btn_click(4), height=4, width=8)
p1btn4.grid(row=3, column=0, padx=1, pady=1)
p1btn5 = Button(root, text = "5", font=("", 14), command = lambda: btn_click(5), height=4, width=8)
p1btn5.grid(row=3, column=1, padx=1, pady=1)
p1btn6 = Button(root, text = "6", font=("", 14), command = lambda: btn_click(6), height=4, width=8)
p1btn6.grid(row=3, column=2, padx=1, pady=1)
p1btn7 = Button(root, text = "7", font=("", 14), command = lambda: btn_click(7), height=4, width=8)
p1btn7.grid(row=4, column=0, padx=1, pady=1)
p1btn8 = Button(root, text = "8", font=("", 14), command = lambda: btn_click(8), height=4, width=8)
p1btn8.grid(row=4, column=1, padx=1, pady=1)
p1btn9 = Button(root, text = "9", font=("", 14), command = lambda: btn_click(9), height=4, width=8)
p1btn9.grid(row=4, column=2, padx=1, pady=1)
p1btn0 = Button(root, text = "0", font=("", 14), command = lambda: btn_click(0), height=4, width=8)
p1btn0.grid(row=5, column=1, padx=1, pady=1)
p1btnclear = Button(root, text = "C", font=("", 14), command = bt_clear, height=4, width=8)
p1btnclear.grid(row=5, column=2, padx=1, pady=1)
p1btnminus = Button(root, text = "-", font=("", 14), command = lambda: btn_click("-"), height=4, width=8)
p1btnminus.grid(row=5, column=0, padx=1, pady=1)
\#PLAYER1 OK BTN INPUT
p1btnok = Button(root, text = "OK", font=("", 14), command = lambda: p1_score, height=4, width=8, padx=100)
p1btnok.grid(row=5, column=4, padx=1, pady=1)
\#PLAYER1 SET INDICATORS
lbl_setp1= Label(root, text="0", font=("", 14))
lbl_setp1.grid(row=1, column=5)
btn_setp1plus = Button(root, text = "+", command = None, height=2, width=4)
btn_setp1plus.grid(row = 2, column = 5)
btn_setp1minus = Button(root, text = "-", command = None, height=2, width=4)
btn_setp1minus.grid(row = 3, column = 5)
lbl_set=Label(root, text="SET", font=("", 14))
lbl_set.grid(row=1, column=6)
\#PLAYER 2 SIDE SETUP
\#PLAYER2 SET INDICATORS
lbl_setp2= Label(root, text="0", font=("", 14))
lbl_setp2.grid(row=1, column=7)
btn_setp2plus = Button(root, text = "+", command = None, height=2, width=4)
btn_setp2plus.grid(row = 2, column = 7)
btn_setp2minus = Button(root, text = "-", command = None, height=2, width=4)
btn_setp2minus.grid(row = 3, column = 7)
\#PLAYER2 POINTS
lbl2_p1points = Label(root, text="112", font=("", 50))
lbl2_p1points.grid(row=3, column=8)
\#PLAYER2 OK BTN INPUT
p2btnok = Button(root, text = "OK", font=("", 14), command = None, height=4, width=8, padx=100)
p2btnok.grid(row=5, column=8, padx=1, pady=1)
\#PLAYER2 SCORE
lbl_p2score = Label(root, text="500", font=("", 110))
lbl_p2score.config(fg="yellow")
lbl_p2score.grid(row=1, column=9, columnspan=11)
\#PLAYER2 BTNS
p2btn1 = Button(root, text = "1", font=("", 14), command = None, height=4, width=8)
p2btn1.grid(row=2, column=9, padx=1, pady=1)
p2btn2 = Button(root, text = "2", font=("", 14), command = None, height=4, width=8)
p2btn2.grid(row=2, column=10, padx=1, pady=1)
p2btn3 = Button(root, text = "3", font=("", 14), command = None, height=4, width=8)
p2btn3.grid(row=2, column=11, padx=1, pady=1)
p2btn4 = Button(root, text = "4", font=("", 14), command = None, height=4, width=8)
p2btn4.grid(row=3, column=9, padx=1, pady=1)
p2btn5 = Button(root, text = "5", font=("", 14), command = None, height=4, width=8)
p2btn5.grid(row=3, column=10, padx=1, pady=1)
p2btn6 = Button(root, text = "6", font=("", 14), command = None, height=4, width=8)
p2btn6.grid(row=3, column=11, padx=1, pady=1)
p2btn7 = Button(root, text = "7", font=("", 14), command = None, height=4, width=8)
p2btn7.grid(row=4, column=9, padx=1, pady=1)
p2btn8 = Button(root, text = "8", font=("", 14), command = None, height=4, width=8)
p2btn8.grid(row=4, column=10, padx=1, pady=1)
p2btn9 = Button(root, text = "9", font=("", 14), command = None, height=4, width=8)
p2btn9.grid(row=4, column=11, padx=1, pady=1)
p2btn0 = Button(root, text = "0", font=("", 14), command = None, height=4, width=8)
p2btn0.grid(row=5, column=10, padx=1, pady=1)
p2btnclear = Button(root, text = "C", font=("", 14), command = None, height=4, width=8)
p2btnclear.grid(row=5, column=9, padx=1, pady=1)
p2btnminus = Button(root, text = "-", font=("", 14), command = None, height=4, width=8)
p2btnminus.grid(row=5, column=11, padx=1, pady=1)
root.mainloop()