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

热点内容
地推统计图app怎么做 浏览:162
android文件夹不能用了 浏览:857
加密软件的日志 浏览:892
肾病pdf 浏览:230
网站怎么用本地服务器 浏览:120
javadoc导入android 浏览:517
文件扫描成pdf 浏览:696
凉山火灾救援命令 浏览:54
压缩机三相检测 浏览:861
linux怎么安装光盘 浏览:799
宽带服务器无响应是为什么 浏览:226
压缩包内看图 浏览:914
安卓手机如何发现app后台调用情况 浏览:561
程序员简历工作描述 浏览:159
服务器中强制疾跑的指令是什么 浏览:54
日语命令性 浏览:261
免费的程序编译游戏 浏览:892
如何安装屏蔽的APP 浏览:198
猪脸识别app如何下载 浏览:156
卓岚串口服务器如何使用 浏览:440