]> sigrok.org Git - sigrok-meter.git/blame_incremental - qtcompat.py
doc: update IRC reference to Libera.Chat
[sigrok-meter.git] / qtcompat.py
... / ...
CommitLineData
1##
2## This file is part of the sigrok-meter project.
3##
4## Copyright (C) 2014 Jens Steinhauser <jens.steinhauser@gmail.com>
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 2 of the License, or
9## (at your option) any later version.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
17## along with this program; if not, see <http://www.gnu.org/licenses/>.
18##
19
20import sys
21
22def load_modules(force_pyside):
23 if force_pyside:
24 import PySide.QtCore as _QtCore
25 import PySide.QtGui as _QtGui
26 else:
27 try:
28 # Use version 2 API in all cases, because that's what PySide uses.
29 import sip
30 sip.setapi('QVariant', 2)
31 sip.setapi('QDate', 2)
32 sip.setapi('QDateTime', 2)
33 sip.setapi('QString', 2)
34 sip.setapi('QTextStream', 2)
35 sip.setapi('QTime', 2)
36 sip.setapi('QUrl', 2)
37 sip.setapi('QVariant', 2)
38
39 import PyQt4.QtCore as _QtCore
40 import PyQt4.QtGui as _QtGui
41
42 # Add PySide compatible names.
43 _QtCore.Signal = _QtCore.pyqtSignal
44 _QtCore.Slot = _QtCore.pyqtSlot
45 except:
46 sys.stderr.write('Import of PyQt4 failed, using PySide,\n')
47 import PySide.QtCore as _QtCore
48 import PySide.QtGui as _QtGui
49
50 global QtCore
51 global QtGui
52 QtCore = _QtCore
53 QtGui = _QtGui
54
55 import pyqtgraph as _pyqtgraph
56 import pyqtgraph.dockarea as _pyqtgraph_dockarea
57 global pyqtgraph
58 pyqtgraph = _pyqtgraph
59 pyqtgraph.dockarea = _pyqtgraph_dockarea