質問編集履歴

2

自分用の参考記入(#マーク)が邪魔しているようですので、外しました。

2020/08/12 07:03

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,6 @@
1
+ **ボールドテキスト**
2
+
1
- **ボールドテキスト**```ここに質問の内容を詳しく書いてください。
3
+ ```ここに質問の内容を詳しく書いてください。
2
4
 
3
5
  開発環境:W10 x64、 Python3.7.3
4
6
 
@@ -30,7 +32,7 @@
30
32
 
31
33
  `Python 3.7.3
32
34
 
33
- import os # pathの指定用に使う
35
+ import os
34
36
 
35
37
  import tkinter as tk
36
38
 
@@ -106,68 +108,50 @@
106
108
 
107
109
  def show_item(event):
108
110
 
109
- # リストクリック時に実行するメソッド
110
-
111
- item_index = listbox_JIS.curselection() # sellected listbox item
111
+ item_index = listbox_JIS.curselection()
112
-
112
+
113
- # print(f'iso:item_index={item_index}') # iso:item_index=(0,) 正解のとき
113
+ # print(f'iso:item_index={item_index}')
114
-
114
+
115
- # print(f'iso:len ={len(item_index)}') # iso:len =1 messageに使うようだ
115
+ # print(f'iso:len ={len(item_index)}')
116
116
 
117
117
 
118
118
 
119
119
  if len(item_index) >= 1:
120
120
 
121
- selected_name = dizney[0][:-4] # パス変数[0]: おーろらひめ 常に画像の名前をprintしている
121
+ selected_name = dizney[0][:-4]
122
122
 
123
123
  print(selected_name)
124
124
 
125
125
  lable_name["text"] = listbox_JIS.get(item_index)
126
126
 
127
- # print(listbox_JIS.get(item_index)) # おーろらひめ 正解のとき
128
-
129
- # 画像と選んだ名前が合致したら、textbox_isoに説明を付ける
130
-
131
127
  if dizney[0][:-4] == listbox_JIS.get(item_index):
132
128
 
133
- lable_name["text"] = dizney[0][:-4] # listbox_JIS.get(item_index)
129
+ lable_name["text"] = dizney[0][:-4]
134
-
135
- # textbox_story.insert(tk.END, selected_name) # OK
130
+
136
-
137
-
138
-
131
+
132
+
139
- message = stars[dizney[0][:-4]]
133
+ message = stars[dizney[0][:-4]]
140
-
141
- # print(message)
134
+
142
-
143
- textbox_story.insert(tk.END, message) # OK
135
+ textbox_story.insert(tk.END, message)
144
136
 
145
137
 
146
138
 
147
139
  else:
148
140
 
149
- lable_name["text"] = "" # OK
141
+ lable_name["text"] = ""
150
-
142
+
151
- textbox_story.delete("1.0", "end") # OK
143
+ textbox_story.delete("1.0", "end")
152
144
 
153
145
 
154
146
 
155
147
  def push_next():
156
148
 
157
- lable_name['text'] = '' #(0, tkEND)
149
+ lable_name['text'] = ''
158
-
150
+
159
- label2_jpg_img.configure(image='') # 画像を消す時はimage=''とすること
151
+ label2_jpg_img.configure(image='')
160
152
 
161
153
  textbox_story.delete('1.0', 'end')
162
154
 
163
- #lable_name.delete(0, tk.END) # # これは不動作
164
-
165
- #textbox_story.delete(0, tk.END) # これは不動作
166
-
167
- #label2_jpg_img.delete(0, tk.END) # これは不動作
168
-
169
- #button1 = tk.Button(root, command=push_next)
170
-
171
155
 
172
156
 
173
157
  path = "./holder_jpg"
@@ -176,7 +160,7 @@
176
160
 
177
161
  dizney = random.sample(dizneys, 1)
178
162
 
179
- # print(dizney[0]) #boot時に一回だけ動作する OK
163
+
180
164
 
181
165
  img = Image.open('./holder_jpg/' + dizney[0])
182
166
 
@@ -218,8 +202,6 @@
218
202
 
219
203
 
220
204
 
221
- # ボタン「終わる」が押されたときの処理
222
-
223
205
  def destroy():
224
206
 
225
207
  root.destroy()

1

import os # pathの指定用に使う import tkinter as tk import random from PIL import Image, ImageTk root =

2020/08/12 07:03

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
 
30
30
 
31
- ```Python 3.7.3
31
+ `Python 3.7.3
32
32
 
33
33
  import os # pathの指定用に使う
34
34
 
@@ -234,7 +234,7 @@
234
234
 
235
235
  root.mainloop()
236
236
 
237
- ```
237
+ `
238
238
 
239
239
 
240
240