繁体   English   中英

Python/Tkinter - 新窗口命令

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM