Python PyQt5.QtGui() Examples
The following are 30
code examples of PyQt5.QtGui().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: qt_compat.py From twitter-stock-recommendation with MIT License | 32 votes |
def _setup_pyqt5(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName if QT_API == QT_API_PYQT5: from PyQt5 import QtCore, QtGui, QtWidgets __version__ = QtCore.PYQT_VERSION_STR QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty elif QT_API == QT_API_PYSIDE2: from PySide2 import QtCore, QtGui, QtWidgets, __version__ else: raise ValueError("Unexpected value for the 'backend.qt5' rcparam") _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName def is_pyqt5(): return True
Example #2
Source File: pyeditor.py From Python_editor with The Unlicense | 6 votes |
def setupUi1(self, messageformForm): messageformForm.setObjectName("messageformForm") messageformForm.resize(404, 169) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(messageformForm.sizePolicy().hasHeightForWidth()) messageformForm.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setFamily("Consolas") messageformForm.setFont(font) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(":/icons/twa.gif"), QtGui.QIcon.Normal, QtGui.QIcon.Off) messageformForm.setWindowIcon(icon2) self.label = QtWidgets.QLabel(messageformForm) self.label.setGeometry(QtCore.QRect(40, 20, 341, 111)) font = QtGui.QFont() font.setPointSize(19) self.label.setFont(font) self.label.setObjectName("label") self.retranslateUi(messageformForm) QtCore.QMetaObject.connectSlotsByName(messageformForm)
Example #3
Source File: pyeditor.py From Python_editor with The Unlicense | 6 votes |
def setupUi1(self, messageformForm): messageformForm.setObjectName("messageformForm") messageformForm.resize(404, 169) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(messageformForm.sizePolicy().hasHeightForWidth()) messageformForm.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setFamily("Consolas") messageformForm.setFont(font) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(":/icons/twa.gif"), QtGui.QIcon.Normal, QtGui.QIcon.Off) messageformForm.setWindowIcon(icon2) self.label = QtWidgets.QLabel(messageformForm) self.label.setGeometry(QtCore.QRect(40, 20, 341, 111)) font = QtGui.QFont() font.setPointSize(19) self.label.setFont(font) self.label.setObjectName("label") self.retranslateUi(messageformForm) QtCore.QMetaObject.connectSlotsByName(messageformForm)
Example #4
Source File: _compat.py From mGui with MIT License | 6 votes |
def _pyside_as_qt_object(widget): from PySide.QtCore import QObject from PySide.QtGui import QWidget from PySide import QtGui from shiboken import wrapInstance if hasattr(widget, '__qt_object__'): return widget.__qt_object__ ptr = _find_widget_ptr(widget) qobject = wrapInstance(long(ptr), QObject) meta = qobject.metaObject() _class = meta.className() _super = meta.superClass().className() qclass = getattr(QtGui, _class, getattr(QtGui, _super, QWidget)) return wrapInstance(long(ptr), qclass)
Example #5
Source File: qt_loaders.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def import_pyqt4(version=2): """ Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors raised within this function are non-recoverable """ # The new-style string API (version=2) automatically # converts QStrings to Unicode Python strings. Also, automatically unpacks # QVariants to their underlying objects. import sip if version is not None: sip.setapi('QString', version) sip.setapi('QVariant', version) from PyQt4 import QtGui, QtCore, QtSvg if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): raise ImportError("IPython requires PyQt4 >= 4.7, found %s" % QtCore.PYQT_VERSION_STR) # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # query for the API version (in case version == None) version = sip.getapi('QString') api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT return QtCore, QtGui, QtSvg, api
Example #6
Source File: syncModOrder.py From mo2-plugins with MIT License | 5 votes |
def icon(self): return QtGui.QIcon(':/deorder/syncModOrder')
Example #7
Source File: syncModOrder.py From mo2-plugins with MIT License | 5 votes |
def openProfileMenu(self, position): selectedItems = self.profileList.selectedItems() if selectedItems: menu = QtWidgets.QMenu() selectedItemsData = [item.data(0, Qt.UserRole) for item in selectedItems] selectedProfiles = [selectedItemData['profileName'] for selectedItemData in selectedItemsData] syncAction = QtWidgets.QAction(QtGui.QIcon(':/MO/gui/next'), self.__tr('&Sync mod order'), self) syncAction.setEnabled(True) menu.addAction(syncAction) action = menu.exec_(self.profileList.mapToGlobal(position)) try: if action == syncAction: for profileName in selectedProfiles: profileInfo = self.__profileInfo[profileName] modListPath = os.path.join(profileInfo['path'], 'modlist.txt') modListBackupPath = modListPath + '.' + datetime.datetime.now().strftime('%Y%m%d%H%M%S%f') qDebug(self.__tr("Backing up to {}".format(modListBackupPath)).encode('utf-8')) shutil.copy(modListPath, modListBackupPath) selectedModListInfo = self.getModListInfoByPath(modListPath) mergedModListInfo = dict(self.__modListInfo, **selectedModListInfo) for modName in list(self.__modListInfo.keys()): mergedModListInfo[modName]['index'] = self.__modListInfo[modName]['index'] qDebug(self.__tr("Updating {} mod order".format(modListPath)).encode('utf-8')) with open(modListPath, 'w', encoding='utf-8') as modListFile: for modName, modListEntry in sorted(list(mergedModListInfo.items()), key=lambda x: x[1]['index']): modListFile.write(modListEntry['symbol'] + modListEntry['name'] + '\n') self.refreshProfileList() except Exception as e: qCritical(str(e).encode('utf-8'))
Example #8
Source File: mergePluginsHide.py From mo2-plugins with MIT License | 5 votes |
def icon(self): return QtGui.QIcon(':/deorder/mergePluginsHide')
Example #9
Source File: main.py From BeautyCamera with MIT License | 5 votes |
def show_camera(self): flag, self.camera_image = self.cap.read() show = cv2.resize(self.image, (640, 480)) show = cv2.cvtColor(show, cv2.COLOR_BGR2RGB) showImage = QtGui.QImage(show.data, show.shape[1], show.shape[0], QtGui.QImage.Format_RGB888) self.label_show_camera.setPixmap(QtGui.QPixmap.fromImage(showImage)) # 初始化
Example #10
Source File: loader.py From Python_editor with The Unlicense | 5 votes |
def __init__(self, package): UIParser.__init__(self, QtCore, QtGui, QtWidgets, LoaderCreatorPolicy(package))
Example #11
Source File: qt_compat.py From ImageFusion with MIT License | 5 votes |
def _getSaveFileName(*args, **kwargs): return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None
Example #12
Source File: qt_compat.py From ImageFusion with MIT License | 5 votes |
def _getSaveFileName(*args, **kwargs): return (QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None)
Example #13
Source File: _compat.py From mGui with MIT License | 5 votes |
def _pyqt4_as_qt_object(widget): from sip import wrapinstance # Seting to api level 2 to better align with PySide behavior. sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) sip.setapi('QString', 2) sip.setapi('QtextStream', 2) sip.setapi('Qtime', 2) sip.setapi('QUrl', 2) sip.setapi('QVariant', 2) from PyQt4.QtGui import QWidget if hasattr(widget, '__qt_object__'): return widget.__qt_object__ ptr = _find_widget_ptr(widget) return wrapinstance(long(ptr), QWidget)
Example #14
Source File: qt_loaders.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def has_binding(api): """Safely check for PyQt4 or PySide, without importing submodules Parameters ---------- api : str [ 'pyqtv1' | 'pyqt' | 'pyside' | 'pyqtdefault'] Which module to check for Returns ------- True if the relevant module appears to be importable """ # we can't import an incomplete pyside and pyqt4 # this will cause a crash in sip (#1431) # check for complete presence before importing module_name = {QT_API_PYSIDE: 'PySide', QT_API_PYQT: 'PyQt4', QT_API_PYQTv1: 'PyQt4', QT_API_PYQT_DEFAULT: 'PyQt4', QT_API_PYQT5: 'PyQt5', } module_name = module_name[api] import imp try: #importing top level PyQt4/PySide module is ok... mod = __import__(module_name) #...importing submodules is not imp.find_module('QtCore', mod.__path__) imp.find_module('QtGui', mod.__path__) imp.find_module('QtSvg', mod.__path__) #we can also safely check PySide version if api == QT_API_PYSIDE: return check_version(mod.__version__, '1.0.3') else: return True except ImportError: return False
Example #15
Source File: qt_loaders.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def import_pyqt5(): """ Import PyQt5 ImportErrors raised within this function are non-recoverable """ from PyQt5 import QtGui, QtCore, QtSvg # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot return QtCore, QtGui, QtSvg, QT_API_PYQT5
Example #16
Source File: qt_loaders.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def import_pyside(): """ Import PySide ImportErrors raised within this function are non-recoverable """ from PySide import QtGui, QtCore, QtSvg # @UnresolvedImport return QtCore, QtGui, QtSvg, QT_API_PYSIDE
Example #17
Source File: qt_compat.py From neural-network-animation with MIT License | 5 votes |
def _getSaveFileName(*args, **kwargs): return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None
Example #18
Source File: qt_compat.py From neural-network-animation with MIT License | 5 votes |
def _getSaveFileName(*args, **kwargs): return (QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None)
Example #19
Source File: find.py From Writer-Tutorial with MIT License | 5 votes |
def moveCursor(self,start,end): # We retrieve the QTextCursor object from the parent's QTextEdit cursor = self.parent.text.textCursor() # Then we set the position to the beginning of the last match cursor.setPosition(start) # Next we move the Cursor by over the match and pass the KeepAnchor parameter # which will make the cursor select the the match's text cursor.movePosition(QtGui.QTextCursor.Right,QtGui.QTextCursor.KeepAnchor,end - start) # And finally we set this new cursor as the parent's self.parent.text.setTextCursor(cursor)
Example #20
Source File: find.py From Writer-Tutorial with MIT License | 5 votes |
def moveCursor(self,start,end): # We retrieve the QTextCursor object from the parent's QTextEdit cursor = self.parent.text.textCursor() # Then we set the position to the beginning of the last match cursor.setPosition(start) # Next we move the Cursor by over the match and pass the KeepAnchor parameter # which will make the cursor select the the match's text cursor.movePosition(QtGui.QTextCursor.Right,QtGui.QTextCursor.KeepAnchor,end - start) # And finally we set this new cursor as the parent's self.parent.text.setTextCursor(cursor)
Example #21
Source File: qt_compat.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def _setup_pyqt5(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName if QT_API == QT_API_PYQT5: from PyQt5 import QtCore, QtGui, QtWidgets __version__ = QtCore.PYQT_VERSION_STR QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty elif QT_API == QT_API_PYSIDE2: from PySide2 import QtCore, QtGui, QtWidgets, __version__ else: raise ValueError("Unexpected value for the 'backend.qt5' rcparam") _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName def is_pyqt5(): return True
Example #22
Source File: syncModOrder.py From mo2-plugins with MIT License | 4 votes |
def __init__(self, organizer, parent = None): self.__modListInfo = {} self.__profilesInfo = {} self.__organizer = organizer super(PluginWindow, self).__init__(parent) self.resize(500, 500) self.setWindowIcon(QtGui.QIcon(':/deorder/syncModOrder')) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # Vertical Layout verticalLayout = QtWidgets.QVBoxLayout() # Vertical Layout -> Merged Mod List (TODO: Better to use QTreeView and model?) self.profileList = QtWidgets.QTreeWidget() self.profileList.setColumnCount(1) self.profileList.setRootIsDecorated(False) self.profileList.header().setVisible(True) self.profileList.headerItem().setText(0, self.__tr("Profile name")) self.profileList.setContextMenuPolicy(Qt.CustomContextMenu) self.profileList.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.profileList.customContextMenuRequested.connect(self.openProfileMenu) verticalLayout.addWidget(self.profileList) # Vertical Layout -> Button Layout buttonLayout = QtWidgets.QHBoxLayout() # Vertical Layout -> Button Layout -> Refresh Button refreshButton = QtWidgets.QPushButton(self.__tr("&Refresh"), self) refreshButton.setIcon(QtGui.QIcon(':/MO/gui/refresh')) refreshButton.clicked.connect(self.refreshProfileList) buttonLayout.addWidget(refreshButton) # Vertical Layout -> Button Layout -> Close Button closeButton = QtWidgets.QPushButton(self.__tr("&Close"), self) closeButton.clicked.connect(self.close) buttonLayout.addWidget(closeButton) verticalLayout.addLayout(buttonLayout) # Vertical Layout self.setLayout(verticalLayout) # Build lookup dictionary of all profiles self.__profileInfo = self.getProfileInfo() # Build lookup dictionary of mods in current profile self.__modListInfo = self.getModListInfoByPath(os.path.join(self.__organizer.profilePath(), 'modlist.txt')) self.refreshProfileList()
Example #23
Source File: find.py From Writer-Tutorial with MIT License | 4 votes |
def find(self): # Grab the parent's text text = self.parent.text.toPlainText() # And the text to find query = self.findField.toPlainText() if self.normalRadio.isChecked(): # Use normal string search to find the query from the # last starting position self.lastStart = text.find(query,self.lastStart + 1) # If the find() method didn't return -1 (not found) if self.lastStart >= 0: end = self.lastStart + len(query) self.moveCursor(self.lastStart,end) else: # Make the next search start from the begining again self.lastStart = 0 self.parent.text.moveCursor(QtGui.QTextCursor.End) else: # Compile the pattern pattern = re.compile(query) # The actual search match = pattern.search(text,self.lastStart + 1) if match: self.lastStart = match.start() self.moveCursor(self.lastStart,match.end()) else: self.lastStart = 0 # We set the cursor to the end if the search was unsuccessful self.parent.text.moveCursor(QtGui.QTextCursor.End)
Example #24
Source File: mergePluginsHide.py From mo2-plugins with MIT License | 4 votes |
def openMergedModMenu(self, position): selectedItems = self.mergedModList.selectedItems() if selectedItems: menu = QtWidgets.QMenu() selectedItemsData = [item.data(0, Qt.UserRole) for item in selectedItems] selectedMods = [selectedItemData['modName'] for selectedItemData in selectedItemsData] selectedModsWithEnabled = [selectedItemData['modName'] for selectedItemData in selectedItemsData if (selectedItemData['modPluginsState'] in Dc.SomeModPluginsInactive)] selectedModsWithDisabled = [selectedItemData['modName'] for selectedItemData in selectedItemsData if (selectedItemData['modPluginsState'] in Dc.SomeModPluginsActive)] enableAction = QtWidgets.QAction(QtGui.QIcon(':/MO/gui/active'), self.__tr('&Enable plugins'), self) enableAction.setEnabled(False) menu.addAction(enableAction) if selectedModsWithEnabled: enableAction.setEnabled(True) disableAction = QtWidgets.QAction(QtGui.QIcon(':/MO/gui/inactive'), self.__tr('&Disable plugins'), self) disableAction.setEnabled(False) menu.addAction(disableAction) if selectedModsWithDisabled: disableAction.setEnabled(True) action = menu.exec_(self.mergedModList.mapToGlobal(position)) # Catch and log exceptional side-effects try: if action == enableAction: for selectedMod in selectedModsWithEnabled: for plugin in self.__mergedModInfo[selectedMod]['plugins']: if plugin in self.__pluginInfo: pluginInfo = self.__pluginInfo[plugin.lower()] for mod in pluginInfo['mods']: if self.__hide_type == "mohidden": Dc.tryMoveFile(os.path.join(mod['dirname'], pluginInfo['filename'] + '.mohidden'), os.path.join(mod['dirname'], pluginInfo['filename'])) if self.__hide_type == "optional": Dc.tryMoveFile(os.path.join(mod['dirname'], 'optional', pluginInfo['filename']), os.path.join(mod['dirname'], pluginInfo['filename'])) if self.__hide_type == "disable": Dc.setPluginStateByName(self.__organizer, pluginInfo['filename'], Dc.PluginState.ACTIVE) if action == disableAction: for selectedMod in selectedModsWithDisabled: for plugin in self.__mergedModInfo[selectedMod]['plugins']: if plugin in self.__pluginInfo: pluginInfo = self.__pluginInfo[plugin.lower()] for mod in pluginInfo['mods']: if self.__hide_type == "mohidden": Dc.tryMoveFile(os.path.join(mod['dirname'], pluginInfo['filename']), os.path.join(mod['dirname'], pluginInfo['filename'] + '.mohidden')) if self.__hide_type == "optional": Dc.tryCreateDir(os.path.join(mod['dirname'], 'optional')) Dc.tryMoveFile(os.path.join(mod['dirname'], pluginInfo['filename']), os.path.join(mod['dirname'], 'optional', pluginInfo['filename'])) if self.__hide_type == "disable": Dc.setPluginStateByName(self.__organizer, pluginInfo['filename'], Dc.PluginState.INACTIVE) self.refreshMergedModList() except Exception as e: qCritical(traceback.format_exc().encode('utf-8')) qCritical(str(e).encode('utf-8'))
Example #25
Source File: find.py From Writer-Tutorial with MIT License | 4 votes |
def find(self): # Grab the parent's text text = self.parent.text.toPlainText() # And the text to find query = self.findField.toPlainText() if self.normalRadio.isChecked(): # Use normal string search to find the query from the # last starting position self.lastStart = text.find(query,self.lastStart + 1) # If the find() method didn't return -1 (not found) if self.lastStart >= 0: end = self.lastStart + len(query) self.moveCursor(self.lastStart,end) else: # Make the next search start from the begining again self.lastStart = 0 self.parent.text.moveCursor(QtGui.QTextCursor.End) else: # Compile the pattern pattern = re.compile(query) # The actual search match = pattern.search(text,self.lastStart + 1) if match: self.lastStart = match.start() self.moveCursor(self.lastStart,match.end()) else: self.lastStart = 0 # We set the cursor to the end if the search was unsuccessful self.parent.text.moveCursor(QtGui.QTextCursor.End)
Example #26
Source File: qt_compat.py From Mastering-Elasticsearch-7.0 with MIT License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #27
Source File: qt_compat.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #28
Source File: qt_compat.py From coffeegrindsize with MIT License | 2 votes |
def _setup_pyqt5(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName if QT_API == QT_API_PYQT5: from PyQt5 import QtCore, QtGui, QtWidgets __version__ = QtCore.PYQT_VERSION_STR QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty elif QT_API == QT_API_PYSIDE2: from PySide2 import QtCore, QtGui, QtWidgets, __version__ else: raise ValueError("Unexpected value for the 'backend.qt5' rcparam") _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName def is_pyqt5(): return True
Example #29
Source File: qt_compat.py From coffeegrindsize with MIT License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #30
Source File: qt_compat.py From CogAlg with MIT License | 2 votes |
def _setup_pyqt5(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName if QT_API == QT_API_PYQT5: from PyQt5 import QtCore, QtGui, QtWidgets __version__ = QtCore.PYQT_VERSION_STR QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty elif QT_API == QT_API_PYSIDE2: from PySide2 import QtCore, QtGui, QtWidgets, __version__ else: raise ValueError("Unexpected value for the 'backend.qt5' rcparam") _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName def is_pyqt5(): return True