如何在创建菜单时删除 tkinter

编程入门 行业动态 更新时间:2024-10-25 08:21:33
本文介绍了如何在创建菜单时删除 tkinter - - - - 行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

这是什么行以及如何删除创建菜单时自动出现的行:

What is this line and How to remove the lines that appear automatically when creating a menu:

推荐答案

使用 tearoff=0.来自 NM 技术 Tkinter 参考:

撕掉

通常情况下,一个菜单可以被撕掉:选择列表中的第一个位置(位置 0)被撕掉元素占据,额外的选择从位置 1 开始添加.如果你设置了 撕下=0,菜单将没有撕下功能,并且从位置0开始添加选项.

Normally, a menu can be torn off: the first position (position 0) in the list of choices is occupied by the tear-off element, and the additional choices are added starting at position 1. If you set tearoff=0, the menu will not have a tear-off feature, and choices will be added starting at position 0.

您可以在此示例中看到不同之处:

You can see the difference in this example:

from tkinter import *

root = Tk()

menubar = Menu(root)

tearoff = Menu(menubar, tearoff=1)
tearoff.add_command(label="Tearoff")
menubar.add_cascade(label="Tearoff", menu=tearoff)

notearoff = Menu(menubar, tearoff=0)
notearoff.add_command(label="No Tearoff")
menubar.add_cascade(label="No Tearoff", menu=notearoff)

root.config(menu=menubar)
root.mainloop()

这篇关于如何在创建菜单时删除 tkinter - - - - 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 07:57:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1391413.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:菜单   如何在   tkinter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!