导航:首页 > 编程语言 > 怎样添加菜单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相关的资料

热点内容
jar包启动命令 浏览:678
java数组一维转二维 浏览:498
office批量转pdf 浏览:183
boss直聘程序员多少薪 浏览:631
编程字母代表什么 浏览:952
rainmc服务器地址 浏览:456
电信校园网客户端认证服务器地址 浏览:448
掌阅怎么看文件夹 浏览:341
在伴伴app里面怎么拜师傅 浏览:942
编程珠玑笔记 浏览:281
结束命令行 浏览:270
力学原理pdf 浏览:737
宏定义编译后不变 浏览:404
如何搞免费服务器 浏览:212
神经系统pdf 浏览:672
如何查看服务器上的数据库服务器 浏览:195
压缩机型号v代表什么 浏览:58
旅游类源码 浏览:867
电脑服务器类型怎么设置 浏览:235
pdf炒股 浏览:791