Мне нужно обновить / преобразовать приложение Pyqt4 в Pyqt5. Он отлично работает при запуске с использованием Pyqt4 и дает желаемый результат, как показано на прилагаемом скриншоте, но он не работает на PyQt5 даже после внесения необходимых изменений. В обновленном коде меню не соединяются и при их нажатии ничего не происходит. Пожалуйста, помогите мне, если я что-то упустил.
Это UI.py
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(1192, 794)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Main_UI/icons/icons/icon-main.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setAutoFillBackground(False)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.horizontalLayoutWidget = QtGui.QWidget(self.centralwidget)
self.horizontalLayoutWidget.setGeometry(QtCore.QRect(0, 0, 1201, 771))
self.horizontalLayoutWidget.setObjectName(_fromUtf8("horizontalLayoutWidget"))
self.horizontalLayout = QtGui.QHBoxLayout(self.horizontalLayoutWidget)
self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.gridLayout_6 = QtGui.QGridLayout()
self.gridLayout_6.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
self.gridLayout_6.setSpacing(0)
self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6"))
self.horizontalLayout.addLayout(self.gridLayout_6)
self.mdiArea = QtGui.QMdiArea(self.horizontalLayoutWidget)
self.mdiArea.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
self.mdiArea.setObjectName(_fromUtf8("mdiArea"))
self.horizontalLayout.addWidget(self.mdiArea)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1192, 21))
self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuSpatial_Analyst = QtGui.QMenu(self.menubar)
self.menuSpatial_Analyst.setObjectName(_fromUtf8("menuSpatial_Analyst"))
self.menuTool2 = QtGui.QMenu(self.menubar)
self.menuTool2.setObjectName(_fromUtf8("menuTool2"))
self.menuTool3 = QtGui.QMenu(self.menubar)
self.menuTool3.setObjectName(_fromUtf8("menuTool3"))
self.menuHelp = QtGui.QMenu(self.menubar)
self.menuHelp.setObjectName(_fromUtf8("menuHelp"))
MainWindow.setMenuBar(self.menubar)
self.menubar.addMenu(self.menuSpatial_Analyst)
self.menubar.addMenu(self.menuTool2)
self.menubar.addMenu(self.menuTool3)
self.menubar.addMenu(self.menuHelp)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Toolbox", None))
self.menuSpatial_Analyst.setTitle(_translate("MainWindow", "Tool1", None))
self.menuTool2.setTitle(_translate("MainWindow", "Tool2", None))
self.menuTool3.setTitle(_translate("MainWindow", "Tool3", None))
self.menuHelp.setTitle(_translate("MainWindow", "Help", None))
import resources_rc
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Это Integration.py
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import *
import sys
import os
import thread
import frmParent_Form
import Scripts.Zonal_Stat.Qt_ZoneStat as Qt_ZoneStat
import Scripts.Tabulate_Threading.UI_Func_Integrate as UI_Func_Integrate
import Scripts.Nearby.Join_NearbyFGDB as Join_NearbyFGDB
import Scripts.MakeThematic.UI_Func_Integrate as makeThem
class MyDialog(QtGui.QMainWindow,frmParent_Form.Ui_MainWindow):
btn_added_Tool1=False
btn_added_Tool2=False
btn_added_Tool3=False
btn_added_Help=False
def __init__(self):
super(self.__class__, self).__init__()
self.subwindow=None
QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowMinimizeButtonHint)
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('cleanlooks'))
self.setupUi(self)
self.setFixedSize(self.size())
self.activeMenu=""
self.menubar.triggered.connect(self.setUIForMenu)
self.setStyleSheet("""
QMenuBar {
background-color: rgb(117, 161, 216);
color: rgb(255,255,255);
border: 1px solid #000;
}
QMenuBar::item {
background-color: rgb(117, 161, 216);
color: rgb(255,255,255);
}
QMenuBar::item::selected {
background-color: rgb(21, 112, 216);
}
QMenu {
background-color: rgb(49,49,49);
color: rgb(255,255,255);
border: 1px solid #000;
}
QMenu::item::selected {
background-color: rgb(21, 112, 216);
}
""")
def setUIForMenu(self):
mdi_dimension=self.mdiArea.frameGeometry()
self.widthDesktop = mdi_dimension.width()
self.heightDesktop = mdi_dimension.height()
test=self.menubar.activeAction()
strMenu= test.text()
if strMenu=="Tool1" and self.activeMenu!="Tool1":
self.activeMenu="Tool1"
self.Tool1()
elif strMenu=="Tool2" and self.activeMenu!="Tool2":
self.activeMenu="Tool2"
self.Tool2()
elif strMenu=="Tool3" and self.activeMenu!="Tool3":
self.activeMenu="Tool3"
self.Tool3()
elif strMenu=="Help":
self.activeMenu="Help"
self.help()
def Tool3(self):
MyDialog.btn_added_Tool1=False
MyDialog.btn_added_Tool2=False
MyDialog.btn_added_Miscellaneous=False
MyDialog.btn_added_Help=False
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if not MyDialog.btn_added_Tool3:
for i in reversed(range(self.gridLayout_6.count())):
self.gridLayout_6.itemAt(i).widget().deleteLater()
if not MyDialog.btn_added_Tool3:
MyDialog.btn_added_Tool3=True
def Tool2(self):
MyDialog.btn_added_Tool1=False
MyDialog.btn_added_Tool3=False
MyDialog.btn_added_Miscellaneous=False
MyDialog.btn_added_Help=False
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if not MyDialog.btn_added_Tool2:
for i in reversed(range(self.gridLayout_6.count())):
self.gridLayout_6.itemAt(i).widget().deleteLater()
MyDialog.btn_added_Tool2=True
def Tool1(self):
MyDialog.btn_added_Tool3=False
MyDialog.btn_added_Miscellaneous=False
MyDialog.btn_added_Help=False
MyDialog.btn_added_Tool2=False
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if not MyDialog.btn_added_Tool1:
for i in reversed(range(self.gridLayout_6.count())):
self.gridLayout_6.itemAt(i).widget().deleteLater()
if not MyDialog.btn_added_Tool1:
widget=QWidget()
#
self.btn_ZonalStat = QtGui.QPushButton(self.horizontalLayoutWidget)
self.btn_ZonalStat.setText("Zonal Stat")
self.gridLayout_6.addWidget(self.btn_ZonalStat,0,0,1,5)
self.btn_ZonalStat.setStyleSheet("background-color: white")
self.btn_ZonalStat.clicked.connect(self.Add_Subwindow)
#
self.btn_TabulateArea =QtGui.QPushButton(self.horizontalLayoutWidget)
self.btn_TabulateArea.setText("Tabulate Area")
self.gridLayout_6.addWidget(self.btn_TabulateArea,1,0,1,5)
self.btn_TabulateArea.setStyleSheet("background-color: white")
self.btn_TabulateArea.clicked.connect(self.Add_TabulateWindow)
#
self.btn_NearBy = QtGui.QPushButton(self.horizontalLayoutWidget)
self.btn_NearBy.setText("Nearby (Distance Computation)")
self.gridLayout_6.addWidget(self.btn_NearBy,2,0,1,5)
self.btn_NearBy.setStyleSheet("background-color: white")
self.btn_NearBy.clicked.connect(self.Add_NearbyWindow)
#
self.MakeThem = QtGui.QPushButton(self.horizontalLayoutWidget)
self.MakeThem.setText("Make Thematic")
self.gridLayout_6.addWidget(self.MakeThem,3,0,1,5)
self.gridLayout_6.addWidget(widget,4,0,10,10)
self.MakeThem.setStyleSheet("background-color: white")
self.MakeThem.clicked.connect(self.Add_MakeThemWindow)
MyDialog.btn_added_Tool1=True
def help(self):
foldPath=os.getcwd()+"\\help\\"
path=str(os.path.join(foldPath, "Toolbox-Chm.chm"))
thread.start_new_thread(os.system, (r"KeyHH.exe -MyHelp -#klink 'Toolbox' "+path,))
def check_position(self, y, width, height, sub_window):
from random import randint
sub_window.move(int(self.widthDesktop/2)-int(width/2), int(self.heightDesktop/2)-int(height/2))
print("Sub Window Moved")
def Add_Subwindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.btn_ZonalStat.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
widget = Qt_ZoneStat.MyDialog()
self.subwindow = QtGui.QMdiSubWindow(self.mdiArea)
self.subwindow.setWidget(widget)
self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.connect(widget,QtCore.SIGNAL('Progres_Counter_1'),self.test)
widget.show()
self.subwindow.show()
self.subwindow.widget().show()
def Add_TabulateWindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.btn_TabulateArea.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
widget = UI_Func_Integrate.MyDialog()
self.subwindow = QtGui.QMdiSubWindow(self.mdiArea)self.subwindow.setWidget(widget)self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.connect(widget,QtCore.SIGNAL('Progres_Counter_1'),self.test)
widget.show()
self.subwindow.show()
self.subwindow.widget().show()
def Add_NearbyWindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.btn_NearBy.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
widget = Join_NearbyFGDB.MyDialog()
self.subwindow = QtGui.QMdiSubWindow(self.mdiArea)
self.subwindow.setWidget(widget)
self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.connect(widget,QtCore.SIGNAL('Progres_Counter_1'),self.test)
widget.show()
self.subwindow.show()
self.subwindow.widget().show()
def Add_MakeThemWindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.MakeThem.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
self.subwindow = QtGui.QMdiSubWindow(self.mdiArea)
widget = makeThem.MyDialog()
self.subwindow.setWidget(widget)
self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.subwindow.show()
self.subwindow.widget().show()
self.connect(widget,QtCore.SIGNAL('Progres_Counter_1'),self.test)
def test(self):
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if __name__ == '__main__':# if we're running file directly and not importing it
try:
app = QtGui.QApplication(sys.argv)
myapp = MyDialog()
myapp.show()
app.exec_()
except:
print (str(sys.exc_info()[0]))
На этом рисунке показано, как работает приложение. Каждый пункт меню имеет подменю в виде кнопок, открывающих новое окно инструментов.
Я обновил Ui.py с необходимыми изменениями, то есть изменил модуль там, где требуется. Это обновленный PyQt5 Integration.py
class MyDialog(QtWidgets.QMainWindow,frmParent_Form.Ui_MainWindow):
Progres_Counter_1= pyqtSignal()
btn_added_Tool1=False
btn_added_Tool2=False
btn_added_Tool3=False
btn_added_Help=False
def __init__(self):
super(self.__class__, self).__init__()
self.subwindow=None
QtWidgets.QDialog.__init__(self, None, QtCore.Qt.WindowMinimizeButtonHint)
QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create('cleanlooks'))
self.setupUi(self)
self.setFixedSize(self.size())
self.activeMenu=""
self.menubar.triggered.connect(self.setUIForMenu)
self.setStyleSheet("""
QMenuBar {
background-color: rgb(117, 161, 216);
color: rgb(255,255,255);
border: 1px solid #000;
}
QMenuBar::item {
background-color: rgb(117, 161, 216);
color: rgb(255,255,255);
}
QMenuBar::item::selected {
background-color: rgb(21, 112, 216);
}
QMenu {
background-color: rgb(49,49,49);
color: rgb(255,255,255);
border: 1px solid #000;
}
QMenu::item::selected {
background-color: rgb(21, 112, 216);
}
""")
def setUIForMenu(self):
mdi_dimension=self.mdiArea.frameGeometry()
self.widthDesktop = mdi_dimension.width()
self.heightDesktop = mdi_dimension.height()
test=self.menubar.activeAction()
strMenu= test.text()
if strMenu=="Tool1" and self.activeMenu!="Tool1":
self.activeMenu="Tool1"
self.Tool1()
elif strMenu=="Tool2" and self.activeMenu!="Tool2":
self.activeMenu="Tool2"
self.Tool2()
elif strMenu=="Tool3" and self.activeMenu!="Tool3":
self.activeMenu="Tool3"
self.Tool3()
elif strMenu=="Help":
self.activeMenu="Help"
self.help()
def Tool3(self):
MyDialog.btn_added_Tool1=False
MyDialog.btn_added_Tool2=False
MyDialog.btn_added_Miscellaneous=False
MyDialog.btn_added_Help=False
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if not MyDialog.btn_added_Tool3:
for i in reversed(range(self.gridLayout_6.count())):
self.gridLayout_6.itemAt(i).widget().deleteLater()
if not MyDialog.btn_added_Tool3:
MyDialog.btn_added_Tool3=True
def Tool2(self):
MyDialog.btn_added_Tool1=False
MyDialog.btn_added_Tool3=False
MyDialog.btn_added_Miscellaneous=False
MyDialog.btn_added_Help=False
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if not MyDialog.btn_added_Tool2:
for i in reversed(range(self.gridLayout_6.count())):
self.gridLayout_6.itemAt(i).widget().deleteLater()
MyDialog.btn_added_Tool2=True
def Tool1(self):
MyDialog.btn_added_Tool3=False
MyDialog.btn_added_Miscellaneous=False
MyDialog.btn_added_Help=False
MyDialog.btn_added_Tool2=False
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if not MyDialog.btn_added_Tool1:
for i in reversed(range(self.gridLayout_6.count())):
self.gridLayout_6.itemAt(i).widget().deleteLater()
if not MyDialog.btn_added_Tool1:
#
widget=QWidget()
self.btn_ZonalStat = QtWidgets.QPushButton(self.horizontalLayoutWidget)
self.btn_ZonalStat.setText("Zonal Stat")
self.gridLayout_6.addWidget(self.btn_ZonalStat,0,0,1,5)
self.btn_ZonalStat.setStyleSheet("background-color: white")
self.btn_ZonalStat.clicked.connect(self.Add_Subwindow)
#
self.btn_TabulateArea = QtWidgets.QPushButton(self.horizontalLayoutWidget)
self.btn_TabulateArea.setText("Tabulate Area")
self.gridLayout_6.addWidget(self.btn_TabulateArea,1,0,1,5)
self.btn_TabulateArea.setStyleSheet("background-color: white")
self.btn_TabulateArea.clicked.connect(self.Add_TabulateWindow)
#
self.btn_NearBy = QtWidgets.QPushButton(self.horizontalLayoutWidget)
self.btn_NearBy.setText("Nearby (Distance Computation)")
self.gridLayout_6.addWidget(self.btn_NearBy,2,0,1,5)
self.btn_NearBy.setStyleSheet("background-color: white")
self.btn_NearBy.clicked.connect(self.Add_NearbyWindow)
#
self.MakeThem = QtWidgets.QPushButton(self.horizontalLayoutWidget)
self.MakeThem.setText("Make Thematic")
self.gridLayout_6.addWidget(self.MakeThem,3,0,1,5)
self.gridLayout_6.addWidget(widget,4,0,10,10)
self.MakeThem.setStyleSheet("background-color: white")
self.MakeThem.clicked.connect(self.Add_MakeThemWindow)
MyDialog.btn_added_Tool1=True
def help(self):
#os.system(r"KeyHH.exe -MyHelp -#klink 'Zonal Stats' C:\Users\nkandpal\Desktop\package\ITool.chm::Zonal Stats")
foldPath=os.getcwd()+"\\help\\"
path=str(os.path.join(foldPath, "Toolbox-Chm.chm"))
_thread.start_new_thread(os.system, (r"KeyHH.exe -MyHelp -#klink 'Toolbox' "+path,))
def check_position(self, y, width, height, sub_window):
from random import randint
sub_window.move(int(self.widthDesktop/2)-int(width/2), int(self.heightDesktop/2)-int(height/2))
print("Sub Window Moved")
def Add_Subwindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.btn_ZonalStat.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
widget = Qt_ZoneStat.MyDialog()
self.subwindow = QtWidgets.QMdiSubWindow(self.mdiArea)
self.subwindow.setWidget(widget)
self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
#self.subwindow.setWindowTitle("GeoHazzard Aggregation")
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.widget.Progres_Counter_1.connect(self.test)
widget.show()
self.subwindow.show()
self.subwindow.widget().show()
def Add_TabulateWindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.btn_TabulateArea.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
widget = UI_Func_Integrate.MyDialog()
self.subwindow = QtWidgets.QMdiSubWindow(self.mdiArea)
self.subwindow.setWidget(widget)
self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
#self.subwindow.setWindowTitle("GeoHazzard Aggregation")
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.widget.Progres_Counter_1.connect(self.test)
widget.show()
self.subwindow.show()
self.subwindow.widget().show()
def Add_NearbyWindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.btn_NearBy.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
widget = Join_NearbyFGDB.MyDialog()
self.subwindow = QtWidgets.QMdiSubWindow(self.mdiArea)
self.subwindow.setWidget(widget)
self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
#val= widget.size().height()
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.widget.Progres_Counter_1.connect(self.test)
widget.show()
self.subwindow.show()
self.subwindow.widget().show()
def Add_MakeThemWindow(self):
for i in reversed(range(self.gridLayout_6.count()-1)):
self.gridLayout_6.itemAt(i).widget().setStyleSheet("background-color: white")
self.MakeThem.setStyleSheet("background-color: rgb(21, 112, 216);color: rgb(255,255,255);")
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
self.subwindow = QtWidgets.QMdiSubWindow(self.mdiArea)
widget = makeThem.MyDialog()
self.subwindow.setWidget(widget)
self.subwindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.WindowMinimizeButtonHint)
self.subwindow.setFixedSize(widget.size().width()+10,widget.size().height()+30)
#self.subwindow.setWindowTitle("GeoHazzard Aggregation")
self.mdiArea.addSubWindow(self.subwindow)
widget_position = self.subwindow.pos()
widget_dimensions = self.subwindow.frameGeometry()
self.check_position(y=widget_position.y(), width=widget_dimensions.width(), height=widget_dimensions.height(), sub_window=self.subwindow)
self.subwindow.show()
self.subwindow.widget().show()
self.widget.Progres_Counter_1.connect(self.test)
def test(self):
if self.subwindow!=None:
self.mdiArea.removeSubWindow(self.subwindow)
if __name__ == '__main__':# if we're running file directly and not importing it
try:
app = QtWidgets.QApplication(sys.argv)
myapp = MyDialog()
myapp.show()
app.exec_()
except:
print (str(sys.exc_info()[0]))