0

i want to fire a pyqt signal to reopen the menu every time the other windows are closed, i think the class QMainWindow doesn't have a .closed signal, can you help me?

import sys
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication
import Caixa
import Estoque
import Relatorio

app = QApplication(sys.argv)
menu = uic.loadUi(r'window/menu.ui')


caixa = Caixa.Window()
estoque = Estoque.Window()
relatorio = Relatorio.Window()

# gatilhos
menu.caixa.clicked.connect(lambda: caixa.open())
menu.caixa.clicked.connect(lambda: menu.close())

menu.produtos.clicked.connect(lambda: estoque.open())
menu.produtos.clicked.connect(lambda: menu.hide())

menu.relatorio.clicked.connect(lambda: relatorio.open())
menu.relatorio.clicked.connect(lambda: menu.hide())

estoque.window.exit.triggered.connect(lambda: menu.show())
caixa.window.exit.triggered.connect(lambda: menu.show())
relatorio.window.exit.triggered.connect(lambda: menu.show())

menu.show()
sys.exit(app.exec_())
igor
  • 1

1 Answers1

1

You could use the "atexit" handler. atexit Documents

In my example

import atexit

atexit.register(/*call your function here*/)

So when the window closes it registers a signal and calls the function in need.