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

熱點內容
程序員這個工作好嗎 瀏覽:898
agps定位伺服器地址 瀏覽:659
用水做的解壓玩具怎麼做 瀏覽:418
安卓411能下載什麼 瀏覽:304
小海龜logo命令 瀏覽:493
java製作界面 瀏覽:895
台達plc編程電纜製作 瀏覽:249
30多歲當程序員 瀏覽:442
怎樣把表格轉換成pdf 瀏覽:514
行列式分解演算法 瀏覽:290
mscoreedll是什麼文件夾修復 瀏覽:697
什麼app測臉型 瀏覽:43
cf手游刀戰演算法 瀏覽:318
北京壓縮米飯 瀏覽:554
施工員與程序員哪個好 瀏覽:207
vc與word編程 瀏覽:951
androidmenu文字顏色 瀏覽:983
安卓手機玩游戲怎麼會閃退 瀏覽:554
聲控解壓球要晾幾天才能晾乾呢 瀏覽:562
安卓手機拍照如何自動調整 瀏覽:627