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

熱點內容
網站怎麼用本地伺服器 瀏覽:120
javadoc導入android 瀏覽:517
文件掃描成pdf 瀏覽:696
涼山火災救援命令 瀏覽:52
壓縮機三相檢測 瀏覽:861
linux怎麼安裝光碟 瀏覽:799
寬頻伺服器無響應是為什麼 瀏覽:226
壓縮包內看圖 瀏覽:912
安卓手機如何發現app後台調用情況 瀏覽:561
程序員簡歷工作描述 瀏覽:159
伺服器中強制疾跑的指令是什麼 瀏覽:54
日語命令性 瀏覽:261
免費的程序編譯游戲 瀏覽:892
如何安裝屏蔽的APP 瀏覽:198
豬臉識別app如何下載 瀏覽:156
卓嵐串口伺服器如何使用 瀏覽:440
pdf周振甫 瀏覽:759
程序員35歲生日圖片 瀏覽:628
矩形密封圈的壓縮量 瀏覽:455
信息安全中圖像加密技術畢業論文 瀏覽:536