Python/Tkinter新窗口命令

2024-05-20 19:36:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图通过单击子菜单按钮打开一个窗口,但我不能,我看到了一些视频和帖子,但我没有成功地添加任何命令。我用的是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()


Tags: textadd视频菜单place按钮labelcommand
1条回答
网友
1楼 · 发布于 2024-05-20 19:36:02

谢谢大家,我使用了这个函数:

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)

相关问题 更多 >