I want to make any btn go to a random spot every 3 milisecounds, and when you click the random button it will do something else like print Hi and stop the button from moving. Here is the code:
I tried while a == True:
but it keeps frezzing when i press the "To make a video" button and just frezzes for a while
import time
import os
import tkinter as tk
import random
from tkinter import *
from tkinter import messagebox
from tkinter import Button
import math
from tkinter import Text
from tkinter import Grid
from tkinter import Place
#from tkinter import place
window = tk.Tk()
window.title("There is no game")
window.geometry("494x300")
numberx = random.randint(1,200)
numbery = random.randint(1,200)
##def clickedrandom():
## a = False
def toplayagame():
print("Hi")
a = True
def tomakeavideo():
T.delete('1.0', END)
T.insert(tk.END, "People who are watching go hit that subscribe button and hit that like button also hit that little bell to turn on notifcations")
T.configure(width = 25, height=6)
while a == True:
numberx = random.randint(1,200)
numbery = random.randint(1,200)
int(numberx)
int(numbery)
time.sleep(0.3)
btn.place(x = numberx, y = numbery)
def pressed():
T.delete('1.0', END)
T.insert(tk.END, "Why are you here?")
btn.place(x=190, y=200)
T.configure(width = 17, height=1)
btn.configure(text = "To play a game", width=12,command=toplayagame)
btn1= Button(window, bd=10,text="To make a video",activebackground='White',activeforeground='Black',bg='Grey',fg='White',height=1,width=15,state=ACTIVE,command=tomakeavideo)
btn1.pack()
btn1.place(x=1,y=200)
T = tk.Text(window, height=1, width=10)
T.pack()
T.insert(tk.END, "Hello user")
btn = Button(window, bd=10,text="Hello",activebackground='Black',activeforeground='White',bg='Grey',fg='White',height=1,width=4,state=ACTIVE,command=pressed)
btn.pack()
btn.place(x=215, y=200)
window.mainloop()
Aucun commentaire:
Enregistrer un commentaire