Problems With Creating Label In Tkinter
I create simple label in tkinter but it is created with {}, what I don't want to. gameOver=Label(root, text=('Game over!\nYou scored', number, ' points!'),
Solution 1:
('Game over!\nYou scored', number, ' points!')
is a tuple of three items, but text
probably expects a string instead, and does strange things to arguments of other types. Use string concatenation or format
to provide a single string.
gameOver=Label(root, text='Game over!\nYou scored' + str(number) + ' points!',
font=('Arial Black', '26'), bg='red')
Or
gameOver=Label(root, text='Game over!\nYou scored {} points!'.format(number),
font=('Arial Black', '26'), bg='red')
Post a Comment for "Problems With Creating Label In Tkinter"