问题描述
我正在尝试将菜单中的选定选项打印到框架(显示为log_Box),但是找不到在框架中显示动作的方法。我的菜单选项代码...
from tkinter import *
import tkinter as tk
# Creating window object
window = Tk()
window.title("Windows App")
window.configure(bg="#263D42")
window.geometry("700x400")
# Menubar
def DummyActions():
'''
:return: list of actions,where each action is a tuple whose first element is the new node and the second element is
the mode of transportation to be used to reach the node
'''
import random
coin_flip = random.random()
if coin_flip >= 0.5:
return [(38,'B'),(78,'T'),(108,'U')]
else:
return [(48,(58,(68,'U')]
if __name__ == '__main__' :
print('Running assignment dummy APIs')
options = []
for action in DummyActions():
options.append(action)
option = action
menubar = Menu(window)
menuOptions = options
menu = Menu(menubar,tearoff = 0)
menubar.add_cascade(label ='Menu',menu = menu)
for opt in menuOptions:
menu.add_command(label = opt,command = None)
menu.add_separator()
window.config(menu = menubar)
#Log Box - display all actions
log_Box = Frame(window,bg="#f0e4ea")
log_Box.place(relwidth=0.9,relheight=0.8,relx=0.05,rely=0.1)
label = Label(log_Box,text="Log Box",pady=2,bg="gray")
label.pack()
window.mainloop()
任何帮助将不胜感激!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)