質問編集履歴
1
プログラムにコメントを追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,11 +26,14 @@
|
|
26
26
|
self.x,self.y = x,y
|
27
27
|
self.text = text
|
28
28
|
self.button = tkinter.Button(master=root,text=text,foreground="red",command=self.button_press)
|
29
|
+
# ボタンを押したときの処理
|
29
30
|
def button_press(self):
|
30
31
|
self.button.pack_forget()
|
31
32
|
lb = tkinter.Label(master=root,text=self.text,font=("MS ゴシック",50),fg="blue",bg="red")
|
32
33
|
lb.place(x=100,y=100)
|
34
|
+
# 実行
|
33
35
|
def run(self):
|
36
|
+
# 画面外に出ないように調節
|
34
37
|
if(self.flag_y==True):
|
35
38
|
self.y-=1
|
36
39
|
else:
|
@@ -48,16 +51,17 @@
|
|
48
51
|
self.flag_x=False
|
49
52
|
elif(self.x+self.button.winfo_reqwidth()==400):
|
50
53
|
self.flag_x=True
|
51
|
-
|
54
|
+
# ボタンをコンマ4秒ごとに配置
|
52
55
|
self.button.place(x=self.x,y=self.y)
|
53
56
|
self.button.after(4,lambda: self.run())
|
54
57
|
|
58
|
+
# ウィンドウの情報
|
55
59
|
w,h="400","300"
|
56
60
|
root=tkinter.Tk()
|
57
61
|
ttk.Style().configure("TP.TFrame", background="snow")
|
58
62
|
f=ttk.Frame(master=root,style="TP.TFrame",width=w,height=h)
|
59
63
|
f.pack()
|
60
|
-
|
64
|
+
# TODO/動くボタンをいくつか作成
|
61
65
|
if __name__ == "__main__":
|
62
66
|
th_1 = Move("a").run();
|
63
67
|
th_2 = Move("b").run();
|