teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードを枠内にいれました

2021/03/25 14:01

投稿

t.k.k
t.k.k

スコア1

title CHANGED
File without changes
body CHANGED
@@ -6,7 +6,71 @@
6
6
  ```
7
7
  エラーメッセージ
8
8
  ```
9
+ ```python
10
+ import tkinter
11
+ from PIL import Image, ImageTk
12
+ from time import sleep
13
+ import random
14
+ import tkinter as tk
15
+ import tkinter.font as f
16
+ import tkinter.ttk as ttk
17
+ import sys
9
18
 
19
+
20
+ # windowを描画
21
+ window = tkinter.Tk()
22
+ # windowサイズを変更
23
+ window.geometry("1200x800")
24
+
25
+ # windowタイトルを設定
26
+ window.title("トランプ(スピード)")
27
+
28
+
29
+ # 画像を表示するためのキャンバスの作成(黒で表示)
30
+ canvas = tkinter.Canvas(bg = "white", width=1200, height=800)
31
+ canvas.place(x=0, y=0) # 左上の座標を指定
32
+
33
+
34
+ def settei_1():
35
+ global en
36
+ print("123")
37
+ val_en=en.get()#enを値を取得し、val_enに代入
38
+ print(val_en)
39
+
40
+
41
+ def settei():
42
+ global en
43
+ start_1.place_forget()
44
+ start_button_2.place_forget()
45
+ start_button_3.place_forget()
46
+ start_button_4.place_forget()
47
+
48
+ settei_1 = tk.Label(window, text="プレイヤー名", font=("MSゴシック", "15", "bold"), background='white')#テスト用
49
+ settei_1.place(x=200,y=100)
50
+ en=tk.Entry(text="player.1")
51
+ bt=tk.Button(text="ボタン",command = settei_1)
52
+
53
+ en.place(x=400,y=70)#テキストボックス配置
54
+ en.focus_set()#テキストボックスにフォーカスを当てる
55
+ bt.place(x=400,y=400)
56
+
57
+
58
+ start_1 = tk.Label(window, text="ゲーム", font=("MSゴシック", "30", "bold"), background='white')#テスト用
59
+ start_1.place(x=400,y=300)
60
+ start_button_2 = tk.Button(window, text='始める', font=("MSゴシック", "25", "bold"), foreground='red', background='white',command = window.destroy)
61
+ start_button_2.place(x=490, y=450)
62
+ start_button_3 = tk.Button(window, text='設定', font=("MSゴシック", "15", "bold"), background='white',command = settei)
63
+ start_button_3.place(x=470, y=550)
64
+ start_button_4 = tk.Button(window, text='終わる', font=("MSゴシック", "15", "bold"), foreground='blue', background='white',command = window.destroy)
65
+ start_button_4.place(x=570, y=550)
66
+
67
+
68
+
69
+
70
+ window.mainloop()
71
+
72
+
73
+ ```
10
74
  ### 該当のソースコード
11
75
  import tkinter
12
76
  from PIL import Image, ImageTk
@@ -15,6 +79,10 @@
15
79
  import tkinter as tk
16
80
  import tkinter.font as f
17
81
  import tkinter.ttk as ttk
82
+ コード
83
+ ```
84
+ コード
85
+ ```
18
86
  import sys
19
87
 
20
88