[英]Python/Tkinter - new window command
我試圖通過單擊子菜單按鈕打開一個窗口,但我不能,我看到了一些視頻和帖子,但是我沒有成功添加任何命令。 我正在使用 Python 和 Tkinter。
下面是源代碼:
from tkinter import *
ftela = Tk()
ftela.state("zoomed")
ftela.title("OMNIA v0")
menu = Menu(ftela)
ftela.config(menu=menu)
##-----------------##
## LABELS ##
##-----------------##
mylabel = LabelFrame(ftela, text="teste")
mylabel.place(x=10, y=10, width=300, height=150)
l_teste = Label(ftela, text="teste")
l_teste.place(x=15, y=30)
e_teste = Entry(ftela)
e_teste.place(x=100, y=30)
##-----------------##
## SUBMENU ##
##-----------------##
subMenu1=Menu(menu, tearoff=0)
menu.add_cascade(label="Cadastro", menu=subMenu1)
subMenu1.add_command(label="Empresas")
subMenu1.add_command(label="Usuários")
subMenu1.add_separator()
subMenu1.add_command(label="Bancos/Caixas")
subMenu1.add_command(label="Contas")
##-----------------##
## MAINLOOP ##
##-----------------##
ftela.mainloop()
謝謝大家,我設法使用了這個功能:
def new_window():
newWindow = Toplevel()
newWindow.geometry("800x600+275+75")
newWindow.resizable(height=False, width=False)
newWindow = LabelFrame(newWindow, text="sex")
newWindow.place(x=10, y=10, width=675, height=400)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.