LoginSignup
0
1

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

0
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
0
1