導航:首頁 > 編程語言 > 怎樣添加菜單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相關的資料

熱點內容
8051單片機包含多大的ram 瀏覽:811
man文件linux 瀏覽:282
javaweb實現頁面跳轉 瀏覽:125
命令如什麼 瀏覽:315
centos如何使用ftp伺服器 瀏覽:981
直立車陀螺儀演算法 瀏覽:69
coreldrawpdf下載 瀏覽:895
虛擬主機雲伺服器軟體服務 瀏覽:370
蘋果的怎麼拉安卓的打游戲 瀏覽:412
游戲程序員負責角色 瀏覽:313
於丹pdf 瀏覽:716
反編譯ref 瀏覽:550
鴻蒙智能文件夾怎麼弄 瀏覽:547
grunt壓縮html 瀏覽:791
macpdfword轉換器 瀏覽:907
壓縮面膜是什麼材質 瀏覽:355
抖音發布作品怎麼建文件夾 瀏覽:17
安卓如何更改谷歌地區 瀏覽:276
airpods為什麼安卓連上聲音很大 瀏覽:514
聯想伺服器按鈕怎麼開不了機 瀏覽:99