質問編集履歴
2
修正ソースの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -101,3 +101,69 @@
|
|
101
101
|
Windows 10
|
102
102
|
|
103
103
|
python 3.8.2
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
###修正後ソース
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
```python
|
112
|
+
|
113
|
+
import tkinter as tk
|
114
|
+
|
115
|
+
import tkinter.filedialog as fd
|
116
|
+
|
117
|
+
import PIL.Image
|
118
|
+
|
119
|
+
import PIL.ImageTk
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
def dispPhoto(path):
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
newImage = PIL.Image.open(path).resize((300,300))
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
imageData = PIL.ImageTk.PhotoImage(newImage)
|
134
|
+
|
135
|
+
imageLabel.configure(image = imageData)
|
136
|
+
|
137
|
+
imageLabel.image = imageData
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
def openFile():
|
142
|
+
|
143
|
+
fpath = fd.askopenfilename()
|
144
|
+
|
145
|
+
if fpath:
|
146
|
+
|
147
|
+
dispPhoto(fpath)
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
root = tk.Tk()
|
152
|
+
|
153
|
+
root.geometry("400x350")
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
btn=tk.Button(text="ファイルを開く",command=openFile)
|
158
|
+
|
159
|
+
imageLabel = tk.Label()
|
160
|
+
|
161
|
+
btn.pack()
|
162
|
+
|
163
|
+
imageLabel.pack()
|
164
|
+
|
165
|
+
tk.mainloop()
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
```
|
1
ソースコードを```の中に書きました!よろしくお願いします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -31,6 +31,8 @@
|
|
31
31
|
|
32
32
|
|
33
33
|
|
34
|
+
|
35
|
+
```python
|
34
36
|
|
35
37
|
import tkinter as tk
|
36
38
|
|
@@ -92,6 +94,8 @@
|
|
92
94
|
|
93
95
|
|
94
96
|
|
97
|
+
```
|
98
|
+
|
95
99
|
### 補足情報(FW/ツールのバージョンなど)
|
96
100
|
|
97
101
|
Windows 10
|