Answer the question
In order to leave comments, you need to log in
What's wrong with the number generator?
Hello everyone, I just now registered on the toaster, and I want to ask experienced people for help.
I have a working random number generator, here is its code:
from tkinter import *
import random
h = random.randint(1,100)
r = str(h)
tk = Tk()
b = Button(text = "Сгенерировать")
l = Label (width = 20, bg = 'black', fg = "white")
def randomiz(event):
l["text"]=' '.join(r)
b.bind ("<Button-1>", randomiz)
b.pack()
l.pack()
tk.mainloop()
from tkinter import *
import random
tk = Tk()
b = Button(text = "Сгенерировать")
l = Label (width = 20, bg = 'black', fg = "white")
def randomize(event):
r = random.randint(1,100)
s = str(r)
l["text"] = "".join(s)
b.bind ("<Button-1>", randomize)
b.pack()
l.pack()
tk.mainloop()
Answer the question
In order to leave comments, you need to log in
But now it gives an error on line 9 (l["text"] = "".join(s)), why is that?
from tkinter import *
import random
tk = Tk()
b = Button(text = "Сгенерировать")
l = Label (width = 20, bg = 'black', fg = "white")
def randomize(event):
r = random.randint(1,100)
s = str(r)
l["text"] = "".join(s)
b.bind ("<Button-1>", randomize)
b.pack()
l.pack()
tk.mainloop()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question