-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #11
- Loading branch information
Showing
10 changed files
with
96 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
IS_QT_5 = False | ||
|
||
if IS_QT_5: | ||
from PySide2 import QtGui, QtCore, QtWidgets | ||
IS_QT_5 = True | ||
else: | ||
from PySide import QtGui, QtCore | ||
import PySide.QtGui as QtWidgets | ||
|
||
import time | ||
|
||
# Common classes | ||
QByteArray = QtCore.QByteArray | ||
QBuffer = QtCore.QBuffer | ||
QIODevice = QtCore.QIODevice | ||
Qt = QtCore.Qt | ||
QImage = QtGui.QImage | ||
QColor = QtGui.QColor | ||
QDialog = QtWidgets.QDialog | ||
QLabel = QtWidgets.QLabel | ||
QVBoxLayout = QtWidgets.QVBoxLayout | ||
QScrollArea = QtWidgets.QScrollArea | ||
QPalette = QtWidgets.QPalette | ||
QSizePolicy = QtWidgets.QSizePolicy | ||
QPixmap = QtWidgets.QPixmap | ||
|
||
# File patterns | ||
IMAGE_FILES = "Image Files (*.png *.jpg *.bmp)" | ||
|
||
|
||
def activeWindow(): | ||
return QtWidgets.QApplication.activeWindow() | ||
|
||
def userSelectedFile(title, filePattern): | ||
fileName = QtWidgets.QFileDialog.getOpenFileName(activeWindow(), title, '', filePattern)[0] | ||
|
||
if fileName == '': | ||
return None | ||
|
||
return fileName | ||
|
||
def showInfo(title, message): | ||
QtWidgets.QMessageBox.information(activeWindow(), title, message) | ||
|
||
def readImage(imagePath): | ||
imageReader = QtGui.QImageReader(imagePath) | ||
|
||
if imageReader.canRead(): | ||
image = imageReader.read() | ||
|
||
if image.isNull(): | ||
showInfo("Image Read Error", "Can't read image: %s" % imageReader.errorString()) | ||
|
||
return image | ||
else: | ||
showInfo("Image Read Error", "Can't read image: %s" % imageReader.errorString()) | ||
|
||
def processEvents(): | ||
time.sleep(0.001) | ||
QtGui.QApplication.processEvents() | ||
|
||
# https://github.com/PySide/pyside2/wiki/My_Practice_:_Porting_python_scripts_to_PySide2#qhboxlayout-qvboxlayout | ||
# important info about layout in qt4 and qt5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters