1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

tkinter キャンバス内にフレームを配置するときの注意点

Last updated at Posted at 2022-06-04

注意点

ウィジェットの設定をするときはpropagate=Falseと明示的に書かないと設定が反映されない。(tk.Tkの設定で上書きされてしまう)

import tkinter as tk

if __name__ == '__main__':
    root = tk.Tk()
    root.configure(background='black')
    root.geometry('1000x1000')

    canvas = tk.Canvas(root, width=800, height=800, background='white')
    canvas.propagate(False)
    canvas.pack()

    frame = tk.Frame(canvas, width=500, height=500, background='blue')
    frame.propagate(False)
    frame.pack()

    root.mainloop()

image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?