回答編集履歴

1

追記

2020/02/23 02:02

投稿

meg_
meg_

スコア10762

test CHANGED
@@ -3,3 +3,75 @@
3
3
 
4
4
 
5
5
  [tkinterのcanvasのevent時image書き換えで画像が表示されなかったからごり押しした](https://qiita.com/iCyP/items/e76ab6f584851c39f077)
6
+
7
+
8
+
9
+ ---
10
+
11
+
12
+
13
+ 【追記】
14
+
15
+ ```Python
16
+
17
+ import tkinter as tk
18
+
19
+ import tkinter.filedialog as tkfiledialog
20
+
21
+ import cv2
22
+
23
+
24
+
25
+ a=20
26
+
27
+ b=650
28
+
29
+ c='#c0c0c0'
30
+
31
+ root = tk.Tk()
32
+
33
+ root.state('zoomed')
34
+
35
+ root.title("採点支援ソフト「採点切り!!")
36
+
37
+ root.configure(bg='#c0c0c0')
38
+
39
+ #root.iconbitmap(r"C:\Users\shunsuke\Pictures\test.ico")
40
+
41
+ global haruna #追加
42
+
43
+
44
+
45
+
46
+
47
+ def ni():
48
+
49
+ global haruna #追加
50
+
51
+ typ = [('pngファイル','*.png')]
52
+
53
+ dir = 'C:\pg'
54
+
55
+ fle = tkfiledialog.askopenfilename(filetypes = typ, initialdir = dir)
56
+
57
+ haruna = tk.PhotoImage(file=fle)
58
+
59
+ canvas = tk.Canvas(bg="black", width=1000, height=600)
60
+
61
+ canvas.place(x=0, y=0)
62
+
63
+ canvas.create_image(0, 0, image=haruna, anchor=tk.NW)
64
+
65
+
66
+
67
+ btn1 = tk.Button(root, text='1,答案読み込み',command=ni, bg=c, fg='black', width=15)
68
+
69
+ btn1.place(x=a, y=b)
70
+
71
+
72
+
73
+ root.mainloop()
74
+
75
+
76
+
77
+ ```