2
Hello, below you follow the source code of my program, the question is this: How do I add functions and pair/connect with the submenus after the user’s click, being the same executed in the main window, without needing an external window?
For example: I want to add a function that after the User click the day or night option of the Tools > Environment tab perform a function to change the Background to a Hexadecimal number.
#! /usr/bin/python
# -*- coding: UTF-8 -*-
from Tkinter import *
import tkFileDialog
import random
#Classe do Programa:
class Random:
    def __init__(self):
        janela = Tk()
        janela.geometry("1024x720")
        janela.title("Sorteio de Times")#Aqui é o nome do programa
        lb1 = Label (janela, font=("Tahoma", 10), text="Todos os Direitos Reservados à Del+, entretanto o código está aberto exclusivamente para Programadores Brasileiros. (Atenção: Este programa não pode ser comercializado.)")
        lb1.pack(side=BOTTOM)
        caixa=Frame(janela, borderwidth=3, relief=GROOVE)
        caixa.pack(pady=40)
        lb2 = Label (caixa, font=("Tahoma", 10), text="*Instruções:\n- Clique no Botão Arquivo > Começar. O programa irá criar uma lista vazia para que o usuário possa escrever o nome dos Times a serem sorteados aleatóriamente \n- Em Seguida, depois de ter escrevido os times, Clique em Sortear. (Obs.: Não precisa escrever a lista toda) \n\n*Como Funciona:\n- Só ir clicando em Sortear até sortear todos os Times. \n(Obs.: Além  dos Times serem sorteados aleatóriamente, o programa não deixa os times se repetirem, \nporém quando acabar você pode clicar em Continuar com a mesma Lista ou Criar nova Lista).",  anchor=W, justify=LEFT)
        lb2.pack()
        def Open(): tkFileDialog.askopenfilename()
        def Quit(): janela.destroy()
        menubar = Menu(tearoff=False)
        MENUarquivo = Menu(tearoff=False)
        MENUferramentas = Menu(tearoff=False)
        MENUlang = Menu(tearoff=False)
        MENUajuda = Menu(tearoff=False)
        MENUenv = Menu(tearoff=False)
        menubar.add_cascade(label="Arquivo", menu=MENUarquivo)
        MENUarquivo.add_command(label="Começar",)
        MENUarquivo.add_command(label="Abrir", command=Open)
        MENUarquivo.add_separator()
        MENUarquivo.add_command(label="Sair", command=Quit)
        menubar.add_cascade(label="Ferramentas", menu=MENUferramentas)
        MENUferramentas.add_cascade(label="Linguagens", menu=MENUlang)
        MENUlang.add_command(label="Português",)
        MENUlang.add_command(label="English",)
        MENUlang.add_command(label="Espanõl",)
        def Dia(): Text(fg = '250330').pack()
        def Noite(): Text(background="").pack()
        MENUferramentas.add_cascade(label="Ambiente", menu=MENUenv)
        MENUenv.add_command(label="Dia", command=Dia)
        MENUenv.add_command(label="Noite",)
        MENUenv.add_command(label="ENV 3",)
        menubar.add_cascade(label="Ajuda", menu=MENUajuda)
        MENUajuda.add_command(label="Sobre", command=self.sobre)
        MENUajuda.add_command(label="Como Usar?",)
        bt = Button(janela, width=15, height=2, text="Resetar")
        bt.place(x=10, y=200)
        bt = Button(janela, width=15, height=2, text="Sortear")
        bt.place(x=10, y=310)
        # Por Fim, a janela:
        janela.config(menu=menubar)
        janela.mainloop()
    def sobre(self):# uma pequena função "sobre"
        root = Tk()
        root.geometry("240x110+70+70")
        root.title("Sobre")
        texto=("Random.v0.1_Estável")
        textONlabel = Label(root, text=texto)
        textONlabel.pack()
        lb2 = Label(root, text="Licença Livre")
        lb2.pack()
Random()
						
You’ve already solved Victor?
– Miguel
Unfortunately no, what I managed to do is the functions (def) that are opened in separate windows.
– Victor Souza
you’re gonna help me?
– Victor Souza
Seriously, no one has an idea?
– Victor Souza
Help is still needed?
– Caio de Paula Silva