Tengo el siguiente problea.
Tengo una venta con un boton cuya función es mostrar una segunda ventana, pero cuando vuelvo a la primera ventana la segunda ventana que se abrio se va al fondo de la primera y si vuelvo a dar click en el boton no se muestra al frente de nuevo.
Que puedo hacer para que al dar click de nuevo en el boton esa ventana pase al frente de nuevo.
primero.py
from PyQt5.QtWidgets import QMainWindow,QApplication
from PyQt5 import uic
from segundo import Secundaria
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("1.ui",self)
self.segunda = Secundaria()
self.boton.clicked.connect(lambda:self.segunda.show())
app = QApplication([])
p = Principal()
p.show()
app.exec_()
segundo.py
from PyQt5.QtWidgets import QMainWindow,QApplication
from PyQt5 import uic
class Secundaria(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("2.ui",self)
1.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>609</width>
<height>435</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="boton">
<property name="geometry">
<rect>
<x>220</x>
<y>190</y>
<width>151</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Mostrar SEGUNDA Ventana</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>609</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
2.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>439</width>
<height>279</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>439</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>