I have a function that print the results of scoreboard game in terminal (see the picture below). I want to modify the function in a way to print the result on GUI interface using python -tkinter or other technique. I don't have any experince in GUI with python. Can some one help me?
Here is the function that print the scoreboard result after the user enter the score in the terminal for the corresponding frame:
def print_scoreboard(self):
print()
print("Scoreboard")
# print heading
print("----------------------------------------------------------------------------")
heading = self.fixed_width("Frames") + "|"
for frame in self.frames:
heading = heading + self.fixed_width(str(frame), 5) + "|"
print(heading)
print("----------------------------------------------------------------------------")
# print results
for player in self.players:
results = ''
for frame, res in player.results.items():
results = results + self.fixed_width(res['roll_1'] + " " + res['roll_2'] + " " + res['roll_3'], 5) + "|"
print(self.fixed_width(player.name) + "|" + results)
scores = ''
for frame, s in player.scores.items():
scores = scores + self.fixed_width(str(s['frame_score']), 5) + "|"
print(self.fixed_width("Frame Scores") + "|" + scores)
totals = ''
for frame, s in player.scores.items():
totals = totals + self.fixed_width(str(s['running_total']), 5) + "|"
print(self.fixed_width("Running Total") + "|" + totals)
print("----------------------------------------------------------------------------")
print()
After i did some research, i got with the following example in python - tkinter. This example takes a variable value as input and display it in a gui window:
from tkinter import *
import tkinter
from tkinter import messagebox
number = 0
# object of tkinter
# and background set for light grey
master = Tk()
master.configure(bg='light grey')
master.title("Programme")
master.geometry('500x650')
# Variable Classes in tkinter
score = StringVar();
# Creating label for each information
# name using widget Label
label = Label(master, text="The total score is :" + str(number) ,font=("Arial", 25) ,bg = "light grey").grid(row=2, sticky=W)
# Creating lebel for class variable
# name using widget Entry
Label(master, text="", textvariable= score ,bg = "light grey").grid(row=2,column=1, sticky=W)
StringVar(master=master)
master.mainloop()
To make it clear, in the following image you find a producable example in terminal. I want to display the same content of this image (terminal) in GUI interface enter image description here