简体   繁体   中英

Python/Tkinter - new window command

I'm trying to open a window by clicking on a submenu button, but I can't, I saw some videos and posts, but I was unsuccessful in adding any of the commands. I'm using Python and Tkinter.

Below is the source code:

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()

Thank you all, i managed using this function:

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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