]> sigrok.org Git - sigrok-meter.git/blob - qtcompat.py
Allow changing the channel color.
[sigrok-meter.git] / qtcompat.py
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, write to the Free Software
18 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19 ##
20
21 def load_modules(force_pyside):
22     if force_pyside:
23         import PySide.QtCore as _QtCore
24         import PySide.QtGui as _QtGui
25     else:
26         try:
27             # Use version 2 API in all cases, because that's what PySide uses.
28             import sip
29             sip.setapi('QVariant', 2)
30             sip.setapi('QDate', 2)
31             sip.setapi('QDateTime', 2)
32             sip.setapi('QString', 2)
33             sip.setapi('QTextStream', 2)
34             sip.setapi('QTime', 2)
35             sip.setapi('QUrl', 2)
36             sip.setapi('QVariant', 2)
37
38             import PyQt4.QtCore as _QtCore
39             import PyQt4.QtGui as _QtGui
40
41             # Add PySide compatible names.
42             _QtCore.Signal = _QtCore.pyqtSignal
43             _QtCore.Slot = _QtCore.pyqtSlot
44         except:
45             sys.stderr.write('Import of PyQt4 failed, using PySide,\n')
46             import PySide.QtCore as _QtCore
47             import PySide.QtGui as _QtGui
48
49     global QtCore
50     global QtGui
51     QtCore = _QtCore
52     QtGui = _QtGui
53
54     import pyqtgraph as _pyqtgraph
55     import pyqtgraph.dockarea as _pyqtgraph_dockarea
56     global pyqtgraph
57     pyqtgraph = _pyqtgraph
58     pyqtgraph.dockarea = _pyqtgraph_dockarea