回答編集履歴
9
もっといい方法がみつかりました
test
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
追記: もっといい方法がみつかりました。
|
2
|
+
|
3
|
+
```py
|
4
|
+
import tkinter as tk
|
5
|
+
|
6
|
+
#新規ウィンドウを作成
|
7
|
+
root = tk.Tk()
|
8
|
+
root.title("sample")
|
9
|
+
root.attributes("-fullscreen", True)
|
10
|
+
|
11
|
+
width = root.winfo_screenwidth()
|
12
|
+
height = root.winfo_screenheight()
|
13
|
+
|
14
|
+
frame = tk.Frame(root)
|
15
|
+
frame.pack()
|
16
|
+
canvas = tk.Canvas(frame, width=width, height=height, bg='black', highlightthickness=0, relief='ridge')
|
17
|
+
canvas.pack()
|
18
|
+
|
19
|
+
root.after(3000, root.quit)
|
20
|
+
root.mainloop()
|
21
|
+
```
|
22
|
+
|
23
|
+
|
1
24
|
pack ではなく place を使ってみました。
|
2
25
|
|
3
26
|
```python
|
8
ずらし幅を大きめに修正(canvas描画時にずらした部分が表示されないのでご注意ください)
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
frame = tk.Frame(root)
|
15
15
|
frame.place(width=width, height=height)
|
16
16
|
canvas = tk.Canvas(frame, bg='black')
|
17
|
-
canvas.place(x=-
|
17
|
+
canvas.place(x=-5, y=-5, width=width + 10, height=height + 10)
|
18
18
|
|
19
19
|
root.after(3000, root.quit)
|
20
20
|
root.mainloop()
|
7
最小限の指定に変更
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
height = root.winfo_screenheight()
|
13
13
|
|
14
14
|
frame = tk.Frame(root)
|
15
|
-
frame.place(
|
15
|
+
frame.place(width=width, height=height)
|
16
|
-
canvas = tk.Canvas(frame,
|
16
|
+
canvas = tk.Canvas(frame, bg='black')
|
17
|
-
canvas.place(x=
|
17
|
+
canvas.place(x=-1, y=-1, width=width + 2, height=height + 2)
|
18
18
|
|
19
19
|
root.after(3000, root.quit)
|
20
20
|
root.mainloop()
|
6
位置調整
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
height = root.winfo_screenheight()
|
13
13
|
|
14
14
|
frame = tk.Frame(root)
|
15
|
-
frame.place(x=-
|
15
|
+
frame.place(x=-1, y=-1, width=width + 1, height=height + 1)
|
16
16
|
canvas = tk.Canvas(frame, width=width, height=height, bg='black')
|
17
|
-
canvas.place(x=0, y=0, width=width +
|
17
|
+
canvas.place(x=0, y=0, width=width + 2, height=height + 2)
|
18
18
|
|
19
19
|
root.after(3000, root.quit)
|
20
20
|
root.mainloop()
|
5
位置調整
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
height = root.winfo_screenheight()
|
13
13
|
|
14
14
|
frame = tk.Frame(root)
|
15
|
-
frame.place(x=-5, y=-5, width=width +
|
15
|
+
frame.place(x=-5, y=-5, width=width + 10, height=height + 10)
|
16
16
|
canvas = tk.Canvas(frame, width=width, height=height, bg='black')
|
17
17
|
canvas.place(x=0, y=0, width=width + 10, height=height + 10)
|
18
18
|
|
4
位置調整
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
height = root.winfo_screenheight()
|
13
13
|
|
14
14
|
frame = tk.Frame(root)
|
15
|
-
frame.place(x=-5, y=-5, width=width +
|
15
|
+
frame.place(x=-5, y=-5, width=width + 5, height=height + 5)
|
16
16
|
canvas = tk.Canvas(frame, width=width, height=height, bg='black')
|
17
17
|
canvas.place(x=0, y=0, width=width + 10, height=height + 10)
|
18
18
|
|
3
pack を place に変更
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
pack
|
1
|
+
pack ではなく place を使ってみました。
|
2
2
|
|
3
3
|
```python
|
4
4
|
import tkinter as tk
|
@@ -8,12 +8,13 @@
|
|
8
8
|
root.title("sample")
|
9
9
|
root.attributes("-fullscreen", True)
|
10
10
|
|
11
|
+
width = root.winfo_screenwidth()
|
12
|
+
height = root.winfo_screenheight()
|
13
|
+
|
11
14
|
frame = tk.Frame(root)
|
12
|
-
frame.pac
|
15
|
+
frame.place(x=-5, y=-5, width=width + 10, height=height + 10)
|
13
|
-
canvas = tk.Canvas(frame, width=
|
16
|
+
canvas = tk.Canvas(frame, width=width, height=height, bg='black')
|
14
|
-
height=root.winfo_screenheight(),
|
15
|
-
bg='black')
|
16
|
-
canvas.pac
|
17
|
+
canvas.place(x=0, y=0, width=width + 10, height=height + 10)
|
17
18
|
|
18
19
|
root.after(3000, root.quit)
|
19
20
|
root.mainloop()
|
2
Canvasを使うように修正しました
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
pack する際に padx と pady を 0 にしてみてください。
|
2
2
|
|
3
3
|
```python
|
4
4
|
import tkinter as tk
|
@@ -8,10 +8,12 @@
|
|
8
8
|
root.title("sample")
|
9
9
|
root.attributes("-fullscreen", True)
|
10
10
|
|
11
|
-
frame = tk.Frame(root
|
11
|
+
frame = tk.Frame(root)
|
12
|
-
height=root.winfo_screenheight(),
|
13
|
-
bg='green')
|
14
12
|
frame.pack()
|
13
|
+
canvas = tk.Canvas(frame, width=root.winfo_screenwidth(),
|
14
|
+
height=root.winfo_screenheight(),
|
15
|
+
bg='black')
|
16
|
+
canvas.pack(padx=0, pady=0)
|
15
17
|
|
16
18
|
root.after(3000, root.quit)
|
17
19
|
root.mainloop()
|
1
不要行削除
test
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
root = tk.Tk()
|
8
8
|
root.title("sample")
|
9
9
|
root.attributes("-fullscreen", True)
|
10
|
-
print(root.size())
|
11
10
|
|
12
11
|
frame = tk.Frame(root, width=root.winfo_screenwidth(),
|
13
12
|
height=root.winfo_screenheight(),
|