Исправлен вывод Qt элеменов

legacy27 3.6.0.2
Mike Hiretsky 6 years ago
parent 9a67f0410b
commit 4bfbcd718c

@ -21,17 +21,18 @@ from os import environ
from multiprocessing import Process, Queue from multiprocessing import Process, Queue
try: try:
from PySide import QtCore, QtGui, QtNetwork from PyQt5 import QtCore
from PySide.QtGui import QProgressBar from PyQt5 import QtGui
from PyQt5 import QtWidgets
class ControlledProgressDialog(QtGui.QProgressDialog): class ControlledProgressDialog(QtWidgets.QProgressDialog):
""" """
QProgressDialog controlled by pipe QProgressDialog controlled by pipe
""" """
def __init__(self, inQueue, outQueue, *args, **kwargs): def __init__(self, inQueue, outQueue, *args, **kwargs):
QtGui.QProgressDialog.__init__(self, *args, **kwargs) QtWidgets.QProgressDialog.__init__(self, *args, **kwargs)
self.progress = QProgressBar(self) self.progress = QtWidgets.QProgressBar(self)
self.progress.setFormat("%p%") self.progress.setFormat("%p%")
self.setBar(self.progress) self.setBar(self.progress)
self.inQueue = inQueue self.inQueue = inQueue
@ -47,12 +48,12 @@ try:
self.progress.setTextVisible(visible) self.progress.setTextVisible(visible)
def center(self): def center(self):
screen = QtGui.QDesktopWidget().screenGeometry() screen = QtWidgets.QDesktopWidget().screenGeometry()
size = self.geometry() size = self.geometry()
self.move((screen.width() - size.width()) / 2, self.move((screen.width() - size.width()) / 2,
(screen.height() - size.height()) / 2) (screen.height() - size.height()) / 2)
@QtCore.Slot() @QtCore.pyqtSlot()
def dispatcher(self): def dispatcher(self):
""" """
Dispatcher called by 50ms Dispatcher called by 50ms
@ -79,11 +80,12 @@ try:
def runProgress(self, message, typemes="warning"): def runProgress(self, message, typemes="warning"):
signal.signal(signal.SIGINT, sigint_handler) signal.signal(signal.SIGINT, sigint_handler)
QtGui.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
getattr(QtGui.QMessageBox, typemes)( getattr(QtWidgets.QMessageBox, typemes)(
None, "", message, None, "", message,
QtGui.QMessageBox.StandardButton.Close, QtWidgets.QMessageBox.Close,
QtGui.QMessageBox.StandardButton.Close) QtWidgets.QMessageBox.Close)
app.quit()
def critical(self, message): def critical(self, message):
self.proc = Process(target=self.runProgress, self.proc = Process(target=self.runProgress,
@ -106,9 +108,10 @@ try:
def runProgress(self, inQueue, outQueue): def runProgress(self, inQueue, outQueue):
signal.signal(signal.SIGINT, sigint_handler) signal.signal(signal.SIGINT, sigint_handler)
environ['HOME'] = self.homeDir environ['HOME'] = self.homeDir
QtGui.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
progressDialog = ControlledProgressDialog(inQueue, outQueue) progressDialog = ControlledProgressDialog(inQueue, outQueue)
progressDialog.exec_() progressDialog.exec_()
app.quit()
setMaximum = None setMaximum = None
setTextVisible = None setTextVisible = None

Loading…
Cancel
Save