mardi 1 janvier 2019

how can i randomise the location of a widget on a window to make it different every time

i am trying to make a button widget that is created in a random position and everytime i click it it moves to another random position.

i have tried using the random function in the pack() parenthesis:

w= tkinter.Tk()
w.configure(background= 'steelblue1')
mb= tkinter.Button(w, text= 'o_o')
mb.pack(random)


w.mainloop()

i didn't expect this to work but was just trying it out, and this resulted in: object of type 'module' has no len() what would the len() be and how do i correctly use random?




Aucun commentaire:

Enregistrer un commentaire