我正在尝试编写一个打印出时间表的 tkinter 程序。为此,我必须编辑一个文本小部件以将答案显示在屏幕上。所有的总和都紧挨着没有空格,当我在它们之间添加一个空格时,我的空格周围会出现花括号。我怎样才能摆脱那些花括号?
PS这是我的代码:
#############
# Times Tables
#############
# Imported Libraries
from tkinter import *
# Functions
def function ():
whichtable = int(tableentry.get())
howfar = int(howfarentry.get())
a = 1
answer.delete("1.0",END)
while a <= howfar:
text = (whichtable, "x", howfar, "=", howfar*whichtable, ", ")
answer.insert("1.0", text)
howfar = howfar - 1
# Window
root = Tk ()
# Title Label
title = Label (root, text="Welcome to TimesTables.py", font="Ubuntu")
title.pack ()
# Which Table Label
tablelabel = Label (root, text="Which Times Table would you like to use?")
tablelabel.pack (anchor="w")
# Which Table Entry
tableentry = Entry (root, textvariable=StringVar)
tableentry.pack ()
# How Far Label
howfarlabel = Label (root, text="How far would you like to go in that times table?")
howfarlabel.pack (anchor="w")
# How Far Entry
howfarentry = Entry (root, textvariable=StringVar)
howfarentry.pack ()
# Go Button
go = Button (root, text="Go", bg="green", width="40", command=function)
go.pack ()
# Answer Text
answer = Text (root, bg="cyan", height="3", width="32", font="Ubuntu")
answer.pack ()
# Loop
root.mainloop ()