导航:首页 > 编程语言 > 怎样添加菜单python

怎样添加菜单python

发布时间:2023-08-19 13:05:26

python tkinter如何添加像word一样的菜单栏

搜索 tkinter ribbon
比如
from tkinter import Widget
from os import path

class Ribbon(Widget):
def __init__(self, master, kw=None):
self.version = master.tk.call('package','require','tkribbon')
self.library = master.tk.eval('set ::tkribbon::library')
Widget.__init__(self, master, 'tkribbon::ribbon', kw=kw)

def load_resource(self, resource_file, resource_name='APPLICATION_RIBBON'):
"""Load the ribbon definition from resources.

Ribbon markup is compiled using the uicc compiler and the resource included
in a dll. Load from the provided file."""
self.tk.call(self._w, 'load_resources', resource_file)
self.tk.call(self._w, 'load_ui', resource_file, resource_name)

if __name__ == '__main__':
import sys
from tkinter import *
def main():
root = Tk()
r = Ribbon(root)
name = 'APPLICATION_RIBBON'
if len(sys.argv) > 1:
resource = sys.argv[1]
if len(sys.argv) > 2:
name = sys.argv[2]
else:
resource = path.join(r.library, 'libtkribbon1.0.dll')
r.load_resource(resource, name)
t = Text(root)
r.grid(sticky=(N,E,S,W))
t.grid(sticky=(N,E,S,W))
root.grid_columnconfigure(0, weight=1)
root.grid_rowconfigure(1, weight=1)
root.mainloop()
main()

② 如何用python设计一个能实现添加、修改、删除、显示、退出等功能的小程序

可以使用 Python 中的字典(dictionary)来实现一个简单的增删改查程序。具体实现步骤如下:

data = {}裂祥 # 创建空字典用于存储数据

while True:

print('请选择操作:')

print('1. 添加数据')

print('2. 修改数据')

print('3. 删除数据')

print('4. 显示数据')

print('5. 退出程序')

choice = input('请输入选项:')

if choice == '1':

key = input('请输入键:')

value = input('请输入值:')

data[key] = value

print('添加成功!')

elif choice == '2':

key = input('请输入要修改的键:')

if key in data:

value = input('请输入新值:')

data[key] = value

print('修改成功!')

else:

print('该键不存在!')

elif choice == '3':

key = input('请输入要删除的键:')

if key in data:

del data[key]

print('删除成功!')

else:

print('该键不存在!')

elif choice == '4':

print(data)

elif choice == '5':

print('谢谢使用,再见!')

break

else:

print('输入错误,请重新选择。')

这个程序简单易罩枣懂,可以根据自己的需要进行修改和扩展。

③ 如何构建命令行下的Python菜单选项

我还没发现有现成的第三方库解决这么简单的问题,自己可以用循环和条件语句结构写一个程序然后作为库使用

阅读全文

与怎样添加菜单python相关的资料

热点内容
macpdfword转换器 浏览:904
压缩面膜是什么材质 浏览:353
抖音发布作品怎么建文件夹 浏览:13
安卓如何更改谷歌地区 浏览:273
airpods为什么安卓连上声音很大 浏览:510
联想服务器按钮怎么开不了机 浏览:93
苹果xrapp程序库没有了怎么办 浏览:843
在上海程序员一个月多少工资 浏览:326
k歌解压图片 浏览:579
cad中清理多余图层的命令 浏览:989
华为nova8xe是安卓什么 浏览:58
汤姆猫服务器为什么免费 浏览:274
safenet加密狗怎么用 浏览:41
phpsql查询变量 浏览:104
地磅仪表盘加密方法 浏览:480
brew安装php环境 浏览:829
电脑版钉钉如何加密 浏览:709
android动画结合 浏览:925
androidfb0 浏览:579
我的世界怎么给服务器称号 浏览:462