📜  知道菜单的高度 tkinter - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:12.946000             🧑  作者: Mango

代码示例1
import tkinter as tk

#Init the window
window = tk.Tk()

#Creation and attachment of the Menu to the window
menuBar = tk.Menu(window)
window.config(menu = menuBar)

#Access to the menu's size in pixels wherever you are (in a function for example)
menuHeight = window.winfo_children()[3].winfo_reqheight() #Height of the menu
menuWidth = window.winfo_children()[3].winfo_reqwidth() #Width of the menu