質問編集履歴
9
削除しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
### 前提・実現したいこと
|
2
2
|
|
3
3
|
「数字を入力するところはここだよ」ってわかるように、数字を入力する入力ボックスに薄い字で誘導するテキストを書きたいです。
|
4
4
|
|
8
削除しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,200 +1,12 @@
|
|
1
|
-
```
|
2
|
-
|
3
|
-
コード
|
4
|
-
|
5
1
|
```### 前提・実現したいこと
|
6
2
|
|
7
3
|
「数字を入力するところはここだよ」ってわかるように、数字を入力する入力ボックスに薄い字で誘導するテキストを書きたいです。
|
8
4
|
|
9
|
-
### 該当のソースコード
|
10
5
|
|
11
6
|
|
12
7
|
|
13
|
-
```Python
|
14
8
|
|
15
|
-
import tkinter
|
16
9
|
|
17
|
-
#数字をランダム出力
|
18
|
-
|
19
|
-
import random
|
20
|
-
|
21
|
-
D = random.randint(0,5)
|
22
|
-
|
23
|
-
#ウィンドウ作成
|
24
|
-
|
25
|
-
root = tkinter.Tk()
|
26
|
-
|
27
|
-
root.title("運勢占い")
|
28
|
-
|
29
|
-
root.minsize(640, 480)
|
30
|
-
|
31
|
-
root.option_add("*font", ["MS Pゴシック", 22])
|
32
|
-
|
33
|
-
#画像読み込み
|
34
|
-
|
35
|
-
getu = tkinter.PhotoImage(file="大吉.png")
|
36
|
-
|
37
|
-
ka = tkinter.PhotoImage(file="凶.png")
|
38
|
-
|
39
|
-
sui = tkinter.PhotoImage(file="吉.png")
|
40
|
-
|
41
|
-
moku = tkinter.PhotoImage(file="小吉.png")
|
42
|
-
|
43
|
-
#画像表示
|
44
|
-
|
45
|
-
canvas = tkinter.Canvas(bg="plum", width=640, height=480)
|
46
|
-
|
47
|
-
canvas.place(x=0, y=0)
|
48
|
-
|
49
|
-
img = tkinter.PhotoImage(file="神社.png")
|
50
|
-
|
51
|
-
canvas.create_image(320, 240, image=img)
|
52
|
-
|
53
|
-
#ラベル01
|
54
|
-
|
55
|
-
question = tkinter.Label(text="あなたが入力した数字で今日の運勢を調べます。\n 0から10の数字を↓に入力してください。", bg="plum")
|
56
|
-
|
57
|
-
question.place(x=27, y=20)
|
58
|
-
|
59
|
-
#ラベル02
|
60
|
-
|
61
|
-
entry = tkinter.Entry(width=2, bd=4, bg="pink")
|
62
|
-
|
63
|
-
entry.place(x=300, y=140)
|
64
|
-
|
65
|
-
#ラベル03
|
66
|
-
|
67
|
-
button = tkinter.Button(text="決定ボタン",bg="peachpuff")
|
68
|
-
|
69
|
-
button.place(x=240, y=400)
|
70
|
-
|
71
|
-
#おみくじ始まり
|
72
|
-
|
73
|
-
def btn_click():
|
74
|
-
|
75
|
-
a = float(entry.get())
|
76
|
-
|
77
|
-
if a > 10:
|
78
|
-
|
79
|
-
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
80
|
-
|
81
|
-
again_text.place(x=105,y=20)
|
82
|
-
|
83
|
-
question.destroy()
|
84
|
-
|
85
|
-
return
|
86
|
-
|
87
|
-
if a < 0:
|
88
|
-
|
89
|
-
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
90
|
-
|
91
|
-
again_text.place(x=105,y=20)
|
92
|
-
|
93
|
-
question.destroy()
|
94
|
-
|
95
|
-
return
|
96
|
-
|
97
|
-
if a+D == 8 or a+D == 9:
|
98
|
-
|
99
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
100
|
-
|
101
|
-
again_text.place(x=100,y=20)
|
102
|
-
|
103
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は大吉です。",fg="red", bg="plum")
|
104
|
-
|
105
|
-
res_text.place(x=115, y=20)
|
106
|
-
|
107
|
-
res_text = tkinter.Label(text="やったね!", bg="plum")
|
108
|
-
|
109
|
-
res_text.place(x=250, y=425)
|
110
|
-
|
111
|
-
canvas.delete("all")
|
112
|
-
|
113
|
-
question.destroy()
|
114
|
-
|
115
|
-
entry.destroy()
|
116
|
-
|
117
|
-
button.destroy()
|
118
|
-
|
119
|
-
canvas.create_image(320, 240, image=getu)
|
120
|
-
|
121
|
-
if 10 <= a+D <= 15:
|
122
|
-
|
123
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
124
|
-
|
125
|
-
again_text.place(x=100,y=20)
|
126
|
-
|
127
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は凶です。",fg="darkviolet",bg="plum")
|
128
|
-
|
129
|
-
res_text.place(x=120, y=20)
|
130
|
-
|
131
|
-
res_text = tkinter.Label(text="ざんねーん", bg="plum")
|
132
|
-
|
133
|
-
res_text.place(x=250, y=425)
|
134
|
-
|
135
|
-
canvas.delete("all")
|
136
|
-
|
137
|
-
question.destroy()
|
138
|
-
|
139
|
-
entry.destroy()
|
140
|
-
|
141
|
-
button.destroy()
|
142
|
-
|
143
|
-
canvas.create_image(320, 240, image=ka)
|
144
|
-
|
145
|
-
if 4 <= a+D <= 7:
|
146
|
-
|
147
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
148
|
-
|
149
|
-
again_text.place(x=100,y=20)
|
150
|
-
|
151
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は吉です。",fg="green",bg="plum")
|
152
|
-
|
153
|
-
res_text.place(x=120, y=24)
|
154
|
-
|
155
|
-
res_text = tkinter.Label(text="おっええやん", bg="plum")
|
156
|
-
|
157
|
-
res_text.place(x=240, y=430)
|
158
|
-
|
159
|
-
canvas.delete("all")
|
160
|
-
|
161
|
-
question.destroy()
|
162
|
-
|
163
|
-
entry.destroy()
|
164
|
-
|
165
|
-
button.destroy()
|
166
|
-
|
167
|
-
canvas.create_image(320, 245, image=sui)
|
168
|
-
|
169
|
-
if 0 <= a+D <= 3:
|
170
|
-
|
171
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
172
|
-
|
173
|
-
again_text.place(x=100,y=20)
|
174
|
-
|
175
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は小吉です。",fg="sienna",bg="plum")
|
176
|
-
|
177
|
-
res_text.place(x=120, y=20)
|
178
|
-
|
179
|
-
res_text = tkinter.Label(text="いいじゃん!", bg="plum")
|
180
|
-
|
181
|
-
res_text.place(x=243, y=425)
|
182
|
-
|
183
|
-
canvas.delete("all")
|
184
|
-
|
185
|
-
question.destroy()
|
186
|
-
|
187
|
-
entry.destroy()
|
188
|
-
|
189
|
-
button.destroy()
|
190
|
-
|
191
|
-
canvas.create_image(320, 240, image=moku)
|
192
|
-
|
193
|
-
button["command"] = btn_click
|
194
|
-
|
195
|
-
root.mainloop()
|
196
|
-
|
197
|
-
```
|
198
10
|
|
199
11
|
|
200
12
|
|
7
書いてあるコードすべて載せました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,8 +12,6 @@
|
|
12
12
|
|
13
13
|
```Python
|
14
14
|
|
15
|
-
```ここに言語を入力
|
16
|
-
|
17
15
|
import tkinter
|
18
16
|
|
19
17
|
#数字をランダム出力
|
@@ -54,7 +52,7 @@
|
|
54
52
|
|
55
53
|
#ラベル01
|
56
54
|
|
57
|
-
question = tkinter.Label(text="あなたが入力した数字で今日の運勢を調べます。\n
|
55
|
+
question = tkinter.Label(text="あなたが入力した数字で今日の運勢を調べます。\n 0から10の数字を↓に入力してください。", bg="plum")
|
58
56
|
|
59
57
|
question.place(x=27, y=20)
|
60
58
|
|
@@ -74,75 +72,75 @@
|
|
74
72
|
|
75
73
|
def btn_click():
|
76
74
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
75
|
+
a = float(entry.get())
|
76
|
+
|
77
|
+
if a > 10:
|
78
|
+
|
79
|
+
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
80
|
+
|
81
|
+
again_text.place(x=105,y=20)
|
82
|
+
|
83
|
+
question.destroy()
|
84
|
+
|
85
|
+
return
|
86
|
+
|
87
|
+
if a < 0:
|
88
|
+
|
89
|
+
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
90
|
+
|
91
|
+
again_text.place(x=105,y=20)
|
92
|
+
|
93
|
+
question.destroy()
|
94
|
+
|
95
|
+
return
|
96
|
+
|
97
|
+
if a+D == 8 or a+D == 9:
|
98
|
+
|
99
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
100
|
+
|
101
|
+
again_text.place(x=100,y=20)
|
102
|
+
|
103
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は大吉です。",fg="red", bg="plum")
|
104
|
+
|
105
|
+
res_text.place(x=115, y=20)
|
106
|
+
|
107
|
+
res_text = tkinter.Label(text="やったね!", bg="plum")
|
108
|
+
|
109
|
+
res_text.place(x=250, y=425)
|
110
|
+
|
111
|
+
canvas.delete("all")
|
112
|
+
|
113
|
+
question.destroy()
|
114
|
+
|
115
|
+
entry.destroy()
|
116
|
+
|
117
|
+
button.destroy()
|
118
|
+
|
119
|
+
canvas.create_image(320, 240, image=getu)
|
120
|
+
|
121
|
+
if 10 <= a+D <= 15:
|
122
|
+
|
123
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
124
|
+
|
125
|
+
again_text.place(x=100,y=20)
|
126
|
+
|
127
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は凶です。",fg="darkviolet",bg="plum")
|
128
|
+
|
129
|
+
res_text.place(x=120, y=20)
|
130
|
+
|
131
|
+
res_text = tkinter.Label(text="ざんねーん", bg="plum")
|
132
|
+
|
133
|
+
res_text.place(x=250, y=425)
|
134
|
+
|
135
|
+
canvas.delete("all")
|
136
|
+
|
137
|
+
question.destroy()
|
138
|
+
|
139
|
+
entry.destroy()
|
140
|
+
|
141
|
+
button.destroy()
|
142
|
+
|
143
|
+
canvas.create_image(320, 240, image=ka)
|
146
144
|
|
147
145
|
if 4 <= a+D <= 7:
|
148
146
|
|
6
書いてあるコードすべて載せました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -74,122 +74,122 @@
|
|
74
74
|
|
75
75
|
def btn_click():
|
76
76
|
|
77
|
-
a = float(entry.get())
|
77
|
+
a = float(entry.get())
|
78
|
-
|
78
|
+
|
79
|
-
if a > 10:
|
79
|
+
if a > 10:
|
80
|
-
|
80
|
+
|
81
|
-
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
81
|
+
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
82
|
-
|
82
|
+
|
83
|
-
again_text.place(x=105,y=20)
|
83
|
+
again_text.place(x=105,y=20)
|
84
|
+
|
85
|
+
question.destroy()
|
86
|
+
|
87
|
+
return
|
88
|
+
|
89
|
+
if a < 0:
|
90
|
+
|
91
|
+
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
92
|
+
|
93
|
+
again_text.place(x=105,y=20)
|
94
|
+
|
95
|
+
question.destroy()
|
96
|
+
|
97
|
+
return
|
98
|
+
|
99
|
+
if a+D == 8 or a+D == 9:
|
100
|
+
|
101
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
102
|
+
|
103
|
+
again_text.place(x=100,y=20)
|
104
|
+
|
105
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は大吉です。",fg="red", bg="plum")
|
106
|
+
|
107
|
+
res_text.place(x=115, y=20)
|
108
|
+
|
109
|
+
res_text = tkinter.Label(text="やったね!", bg="plum")
|
110
|
+
|
111
|
+
res_text.place(x=250, y=425)
|
112
|
+
|
113
|
+
canvas.delete("all")
|
114
|
+
|
115
|
+
question.destroy()
|
116
|
+
|
117
|
+
entry.destroy()
|
118
|
+
|
119
|
+
button.destroy()
|
120
|
+
|
121
|
+
canvas.create_image(320, 240, image=getu)
|
122
|
+
|
123
|
+
if 10 <= a+D <= 15:
|
124
|
+
|
125
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
126
|
+
|
127
|
+
again_text.place(x=100,y=20)
|
128
|
+
|
129
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は凶です。",fg="darkviolet",bg="plum")
|
130
|
+
|
131
|
+
res_text.place(x=120, y=20)
|
132
|
+
|
133
|
+
res_text = tkinter.Label(text="ざんねーん", bg="plum")
|
134
|
+
|
135
|
+
res_text.place(x=250, y=425)
|
136
|
+
|
137
|
+
canvas.delete("all")
|
138
|
+
|
139
|
+
question.destroy()
|
140
|
+
|
141
|
+
entry.destroy()
|
142
|
+
|
143
|
+
button.destroy()
|
144
|
+
|
145
|
+
canvas.create_image(320, 240, image=ka)
|
146
|
+
|
147
|
+
if 4 <= a+D <= 7:
|
148
|
+
|
149
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
150
|
+
|
151
|
+
again_text.place(x=100,y=20)
|
152
|
+
|
153
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は吉です。",fg="green",bg="plum")
|
154
|
+
|
155
|
+
res_text.place(x=120, y=24)
|
156
|
+
|
157
|
+
res_text = tkinter.Label(text="おっええやん", bg="plum")
|
158
|
+
|
159
|
+
res_text.place(x=240, y=430)
|
160
|
+
|
161
|
+
canvas.delete("all")
|
84
162
|
|
85
163
|
question.destroy()
|
86
164
|
|
87
|
-
ret
|
165
|
+
entry.destroy()
|
166
|
+
|
88
|
-
|
167
|
+
button.destroy()
|
168
|
+
|
169
|
+
canvas.create_image(320, 245, image=sui)
|
170
|
+
|
89
|
-
if a <
|
171
|
+
if 0 <= a+D <= 3:
|
90
|
-
|
172
|
+
|
91
|
-
again_text = tkinter.Label(text="
|
173
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
92
|
-
|
174
|
+
|
93
|
-
again_text.place(x=10
|
175
|
+
again_text.place(x=100,y=20)
|
176
|
+
|
177
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は小吉です。",fg="sienna",bg="plum")
|
178
|
+
|
179
|
+
res_text.place(x=120, y=20)
|
180
|
+
|
181
|
+
res_text = tkinter.Label(text="いいじゃん!", bg="plum")
|
182
|
+
|
183
|
+
res_text.place(x=243, y=425)
|
184
|
+
|
185
|
+
canvas.delete("all")
|
94
186
|
|
95
187
|
question.destroy()
|
96
188
|
|
97
|
-
return
|
98
|
-
|
99
|
-
if a+D == 8 or a+D == 9:
|
100
|
-
|
101
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
102
|
-
|
103
|
-
again_text.place(x=100,y=20)
|
104
|
-
|
105
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は大吉です。",fg="red", bg="plum")
|
106
|
-
|
107
|
-
res_text.place(x=115, y=20)
|
108
|
-
|
109
|
-
res_text = tkinter.Label(text="やったね!", bg="plum")
|
110
|
-
|
111
|
-
res_text.place(x=250, y=425)
|
112
|
-
|
113
|
-
canvas.delete("all")
|
114
|
-
|
115
|
-
question.destroy()
|
116
|
-
|
117
189
|
entry.destroy()
|
118
190
|
|
119
191
|
button.destroy()
|
120
192
|
|
121
|
-
canvas.create_image(320, 240, image=getu)
|
122
|
-
|
123
|
-
if 10 <= a+D <= 15:
|
124
|
-
|
125
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
126
|
-
|
127
|
-
again_text.place(x=100,y=20)
|
128
|
-
|
129
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は凶です。",fg="darkviolet",bg="plum")
|
130
|
-
|
131
|
-
res_text.place(x=120, y=20)
|
132
|
-
|
133
|
-
res_text = tkinter.Label(text="ざんねーん", bg="plum")
|
134
|
-
|
135
|
-
res_text.place(x=250, y=425)
|
136
|
-
|
137
|
-
canvas.delete("all")
|
138
|
-
|
139
|
-
question.destroy()
|
140
|
-
|
141
|
-
entry.destroy()
|
142
|
-
|
143
|
-
button.destroy()
|
144
|
-
|
145
|
-
canvas.create_image(320, 240, image=ka)
|
146
|
-
|
147
|
-
if 4 <= a+D <= 7:
|
148
|
-
|
149
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
150
|
-
|
151
|
-
again_text.place(x=100,y=20)
|
152
|
-
|
153
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は吉です。",fg="green",bg="plum")
|
154
|
-
|
155
|
-
res_text.place(x=120, y=24)
|
156
|
-
|
157
|
-
res_text = tkinter.Label(text="おっええやん", bg="plum")
|
158
|
-
|
159
|
-
res_text.place(x=240, y=430)
|
160
|
-
|
161
|
-
canvas.delete("all")
|
162
|
-
|
163
|
-
question.destroy()
|
164
|
-
|
165
|
-
entry.destroy()
|
166
|
-
|
167
|
-
button.destroy()
|
168
|
-
|
169
|
-
canvas.create_image(320, 245, image=sui)
|
170
|
-
|
171
|
-
if 0 <= a+D <= 3:
|
172
|
-
|
173
|
-
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
174
|
-
|
175
|
-
again_text.place(x=100,y=20)
|
176
|
-
|
177
|
-
res_text = tkinter.Label(text="あなたの今日の運勢は小吉です。",fg="sienna",bg="plum")
|
178
|
-
|
179
|
-
res_text.place(x=120, y=20)
|
180
|
-
|
181
|
-
res_text = tkinter.Label(text="いいじゃん!", bg="plum")
|
182
|
-
|
183
|
-
res_text.place(x=243, y=425)
|
184
|
-
|
185
|
-
canvas.delete("all")
|
186
|
-
|
187
|
-
question.destroy()
|
188
|
-
|
189
|
-
entry.destroy()
|
190
|
-
|
191
|
-
button.destroy()
|
192
|
-
|
193
193
|
canvas.create_image(320, 240, image=moku)
|
194
194
|
|
195
195
|
button["command"] = btn_click
|
5
書いてあるコードすべて載せました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
def btn_click():
|
76
76
|
|
77
|
-
|
77
|
+
a = float(entry.get())
|
78
78
|
|
79
79
|
if a > 10:
|
80
80
|
|
4
書いてあるコードすべて載せました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
def btn_click():
|
76
76
|
|
77
|
-
a = float(entry.get())
|
77
|
+
'a = float(entry.get())'
|
78
78
|
|
79
79
|
if a > 10:
|
80
80
|
|
3
書いてあるコードすべて載せました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
```
|
2
|
+
|
3
|
+
コード
|
4
|
+
|
1
|
-
### 前提・実現したいこと
|
5
|
+
```### 前提・実現したいこと
|
2
6
|
|
3
7
|
「数字を入力するところはここだよ」ってわかるように、数字を入力する入力ボックスに薄い字で誘導するテキストを書きたいです。
|
4
8
|
|
2
書いてあるコードすべて載せました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
|
9
9
|
```Python
|
10
10
|
|
11
|
+
```ここに言語を入力
|
12
|
+
|
11
13
|
import tkinter
|
12
14
|
|
13
15
|
#数字をランダム出力
|
@@ -190,6 +192,8 @@
|
|
190
192
|
|
191
193
|
root.mainloop()
|
192
194
|
|
195
|
+
```
|
196
|
+
|
193
197
|
|
194
198
|
|
195
199
|
### 試したこと
|
1
書いてあるコードすべて載せました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,11 +8,187 @@
|
|
8
8
|
|
9
9
|
```Python
|
10
10
|
|
11
|
+
import tkinter
|
12
|
+
|
13
|
+
#数字をランダム出力
|
14
|
+
|
15
|
+
import random
|
16
|
+
|
17
|
+
D = random.randint(0,5)
|
18
|
+
|
19
|
+
#ウィンドウ作成
|
20
|
+
|
21
|
+
root = tkinter.Tk()
|
22
|
+
|
23
|
+
root.title("運勢占い")
|
24
|
+
|
25
|
+
root.minsize(640, 480)
|
26
|
+
|
27
|
+
root.option_add("*font", ["MS Pゴシック", 22])
|
28
|
+
|
29
|
+
#画像読み込み
|
30
|
+
|
31
|
+
getu = tkinter.PhotoImage(file="大吉.png")
|
32
|
+
|
33
|
+
ka = tkinter.PhotoImage(file="凶.png")
|
34
|
+
|
35
|
+
sui = tkinter.PhotoImage(file="吉.png")
|
36
|
+
|
37
|
+
moku = tkinter.PhotoImage(file="小吉.png")
|
38
|
+
|
39
|
+
#画像表示
|
40
|
+
|
41
|
+
canvas = tkinter.Canvas(bg="plum", width=640, height=480)
|
42
|
+
|
43
|
+
canvas.place(x=0, y=0)
|
44
|
+
|
45
|
+
img = tkinter.PhotoImage(file="神社.png")
|
46
|
+
|
47
|
+
canvas.create_image(320, 240, image=img)
|
48
|
+
|
49
|
+
#ラベル01
|
50
|
+
|
51
|
+
question = tkinter.Label(text="あなたが入力した数字で今日の運勢を調べます。\n0から10の数字を入力してください。", bg="plum")
|
52
|
+
|
53
|
+
question.place(x=27, y=20)
|
54
|
+
|
55
|
+
#ラベル02
|
56
|
+
|
11
|
-
entry = tkinter.Entry(width=2, bd=4, bg="
|
57
|
+
entry = tkinter.Entry(width=2, bd=4, bg="pink")
|
12
58
|
|
13
59
|
entry.place(x=300, y=140)
|
14
60
|
|
15
|
-
|
61
|
+
#ラベル03
|
62
|
+
|
63
|
+
button = tkinter.Button(text="決定ボタン",bg="peachpuff")
|
64
|
+
|
65
|
+
button.place(x=240, y=400)
|
66
|
+
|
67
|
+
#おみくじ始まり
|
68
|
+
|
69
|
+
def btn_click():
|
70
|
+
|
71
|
+
a = float(entry.get())
|
72
|
+
|
73
|
+
if a > 10:
|
74
|
+
|
75
|
+
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
76
|
+
|
77
|
+
again_text.place(x=105,y=20)
|
78
|
+
|
79
|
+
question.destroy()
|
80
|
+
|
81
|
+
return
|
82
|
+
|
83
|
+
if a < 0:
|
84
|
+
|
85
|
+
again_text = tkinter.Label(text="0から10の数字を入力してください。",fg="red",bg="plum")
|
86
|
+
|
87
|
+
again_text.place(x=105,y=20)
|
88
|
+
|
89
|
+
question.destroy()
|
90
|
+
|
91
|
+
return
|
92
|
+
|
93
|
+
if a+D == 8 or a+D == 9:
|
94
|
+
|
95
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
96
|
+
|
97
|
+
again_text.place(x=100,y=20)
|
98
|
+
|
99
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は大吉です。",fg="red", bg="plum")
|
100
|
+
|
101
|
+
res_text.place(x=115, y=20)
|
102
|
+
|
103
|
+
res_text = tkinter.Label(text="やったね!", bg="plum")
|
104
|
+
|
105
|
+
res_text.place(x=250, y=425)
|
106
|
+
|
107
|
+
canvas.delete("all")
|
108
|
+
|
109
|
+
question.destroy()
|
110
|
+
|
111
|
+
entry.destroy()
|
112
|
+
|
113
|
+
button.destroy()
|
114
|
+
|
115
|
+
canvas.create_image(320, 240, image=getu)
|
116
|
+
|
117
|
+
if 10 <= a+D <= 15:
|
118
|
+
|
119
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
120
|
+
|
121
|
+
again_text.place(x=100,y=20)
|
122
|
+
|
123
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は凶です。",fg="darkviolet",bg="plum")
|
124
|
+
|
125
|
+
res_text.place(x=120, y=20)
|
126
|
+
|
127
|
+
res_text = tkinter.Label(text="ざんねーん", bg="plum")
|
128
|
+
|
129
|
+
res_text.place(x=250, y=425)
|
130
|
+
|
131
|
+
canvas.delete("all")
|
132
|
+
|
133
|
+
question.destroy()
|
134
|
+
|
135
|
+
entry.destroy()
|
136
|
+
|
137
|
+
button.destroy()
|
138
|
+
|
139
|
+
canvas.create_image(320, 240, image=ka)
|
140
|
+
|
141
|
+
if 4 <= a+D <= 7:
|
142
|
+
|
143
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
144
|
+
|
145
|
+
again_text.place(x=100,y=20)
|
146
|
+
|
147
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は吉です。",fg="green",bg="plum")
|
148
|
+
|
149
|
+
res_text.place(x=120, y=24)
|
150
|
+
|
151
|
+
res_text = tkinter.Label(text="おっええやん", bg="plum")
|
152
|
+
|
153
|
+
res_text.place(x=240, y=430)
|
154
|
+
|
155
|
+
canvas.delete("all")
|
156
|
+
|
157
|
+
question.destroy()
|
158
|
+
|
159
|
+
entry.destroy()
|
160
|
+
|
161
|
+
button.destroy()
|
162
|
+
|
163
|
+
canvas.create_image(320, 245, image=sui)
|
164
|
+
|
165
|
+
if 0 <= a+D <= 3:
|
166
|
+
|
167
|
+
again_text = tkinter.Label(text=" ",fg="red",bg="plum")
|
168
|
+
|
169
|
+
again_text.place(x=100,y=20)
|
170
|
+
|
171
|
+
res_text = tkinter.Label(text="あなたの今日の運勢は小吉です。",fg="sienna",bg="plum")
|
172
|
+
|
173
|
+
res_text.place(x=120, y=20)
|
174
|
+
|
175
|
+
res_text = tkinter.Label(text="いいじゃん!", bg="plum")
|
176
|
+
|
177
|
+
res_text.place(x=243, y=425)
|
178
|
+
|
179
|
+
canvas.delete("all")
|
180
|
+
|
181
|
+
question.destroy()
|
182
|
+
|
183
|
+
entry.destroy()
|
184
|
+
|
185
|
+
button.destroy()
|
186
|
+
|
187
|
+
canvas.create_image(320, 240, image=moku)
|
188
|
+
|
189
|
+
button["command"] = btn_click
|
190
|
+
|
191
|
+
root.mainloop()
|
16
192
|
|
17
193
|
|
18
194
|
|