Skip to content

Instantly share code, notes, and snippets.

@imakin
Created January 5, 2015 22:57
Show Gist options
  • Save imakin/3738bc36b9ad07fdc836 to your computer and use it in GitHub Desktop.
Save imakin/3738bc36b9ad07fdc836 to your computer and use it in GitHub Desktop.
Hackish Popup Window
def DataMaster_Popup(self,mother,text,function_callback,FW=500,FH=200):
WinW = mother.geometry().width()
WinH = mother.geometry().height()
FrameWindowS = self.findChildren(QtGui.QFrame,_fromUtf8("DataMaster_Popup_FrameWindowS"))
if (len(FrameWindowS)<1):
FrameWindowS = QtGui.QFrame(mother)
else:
FrameWindowS = FrameWindowS[0]
FrameWindowS.setGeometry(QtCore.QRect((WinW/2)-FW/2+10, WinH/2- FH/2+10, FW, FH))
FrameWindowS.setObjectName(_fromUtf8("DataMaster_Popup_FrameWindowS"))
FrameWindowS.setStyleSheet(_fromUtf8("QFrame{background:#828282;border-radius:0px;border-style: solid;border-width: 2px;border-color:#828282;}"))
FrameWindowS.show()
FrameWindow = self.findChildren(QtGui.QFrame,_fromUtf8("DataMaster_Popup_FrameWindow"))
if (len(FrameWindow)<1):
FrameWindow = QtGui.QFrame(mother)
else:
FrameWindow = FrameWindow[0]
FrameWindow.setGeometry(QtCore.QRect((WinW/2)-FW/2, WinH/2- FH/2, FW, FH))
FrameWindow.setObjectName(_fromUtf8("DataMaster_Popup_FrameWindow"))
FrameWindow.setStyleSheet(_fromUtf8("QFrame{background:#ffffff;border-radius:0px;border-style: solid;border-width: 2px;border-color:#868686;}"))
FrameWindow.show()
Label = self.findChildren(QtGui.QFrame,_fromUtf8("DataMaster_Popup_Label"))
if (len(Label)<1):
Label = QtGui.QLabel(FrameWindow)
else:
Label = Label[0]
Label.setGeometry(QtCore.QRect(10, 10, FW-20, FH-20))
Label.setObjectName(_fromUtf8("DataMaster_Popup_Label"))
Label.setText(_fromUtf8(text))
Label.setStyleSheet(_fromUtf8("QFrame{background:#ffffff;border-radius:0px;border-style: solid;border-width: 0px;border-color:#ffffff;}"))
Label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignCenter)
Label.show()
ConfirmOk = self.findChildren(QtGui.QFrame,_fromUtf8("DataMaster_Popup_ConfirmOk"))
if (len(ConfirmOk)<1):
ConfirmOk = QtGui.QPushButton(FrameWindow)
ConfirmOk.setGeometry(QtCore.QRect(FW/2-42-85, FH-45, 85, 30))
ConfirmOk.setObjectName(_fromUtf8("DataMaster_Popup_ConfirmOk"))
ConfirmOk.setText(_fromUtf8("Ok"))
ConfirmOk.setStyleSheet(_fromUtf8("QPushButton{background:#555555;}"))
else:
ConfirmOk = ConfirmOk[0]
try:
ConfirmOk.clicked.disconnect()
except:
pass
def tutup(f):
f.close()
ConfirmOk.clicked.connect(functools.partial(tutup,FrameWindow))
ConfirmOk.clicked.connect(functools.partial(tutup,FrameWindowS))
ConfirmOk.clicked.connect(function_callback)
ConfirmOk.show()
ConfirmClose = self.findChildren(QtGui.QFrame,_fromUtf8("DataMaster_Popup_ConfirmClose"))
if (len(ConfirmClose)<1):
ConfirmClose = QtGui.QPushButton(FrameWindow)
ConfirmClose.setGeometry(QtCore.QRect(FW/2-42+85, FH-45, 85, 30))
ConfirmClose.setObjectName(_fromUtf8("DataMaster_Popup_ConfirmClose"))
ConfirmClose.setText(_fromUtf8("Cancel"))
ConfirmClose.setStyleSheet(_fromUtf8("QPushButton{background:#555555;}"))
else:
ConfirmClose = ConfirmClose[0]
ConfirmClose.show()
ConfirmClose.clicked.connect(functools.partial(tutup,FrameWindow))
ConfirmClose.clicked.connect(functools.partial(tutup,FrameWindowS))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment