1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
import tkinter as tk
import tkinter.font as tkFont
fen=tk.Tk()
fen.title("Déplacement de bouton")
fen.geometry('%dx%d+%d+%d' % (600, 600, 0, 0) )
ok=False;
dl=0
def Click():
global ok,dl
ok= not ok
dl+=30
if ok:
B.place(x=10+dl,y=10+dl)
B["text"]="je me suis déplacé"
else:
B["text"]="Déplace moi"
police= tkFont.Font(family='calibri', size=14, weight='bold')
B = tk.Button(fen, text ="Déplace moi",font=police,bg='#EFEBE7', command = Click)
B.config(width=15)
B.place(x=10,y=10)
fen.mainloop() |
Partager