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