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

熱點內容
ubuntu圖形編程 瀏覽:439
jar包啟動命令 瀏覽:678
java數組一維轉二維 瀏覽:498
office批量轉pdf 瀏覽:183
boss直聘程序員多少薪 瀏覽:631
編程字母代表什麼 瀏覽:952
rainmc伺服器地址 瀏覽:456
電信校園網客戶端認證伺服器地址 瀏覽:448
掌閱怎麼看文件夾 瀏覽:341
在伴伴app裡面怎麼拜師傅 瀏覽:943
編程珠璣筆記 瀏覽:281
結束命令行 瀏覽:270
力學原理pdf 瀏覽:737
宏定義編譯後不變 瀏覽:404
如何搞免費伺服器 瀏覽:213
神經系統pdf 瀏覽:672
如何查看伺服器上的資料庫伺服器 瀏覽:195
壓縮機型號v代表什麼 瀏覽:58
旅遊類源碼 瀏覽:867
電腦伺服器類型怎麼設置 瀏覽:235