-
Notifications
You must be signed in to change notification settings - Fork 2
/
qt5pick.py
52 lines (40 loc) · 1.48 KB
/
qt5pick.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
#Choose which Qt binding to use
if 'WHICH_QT' in os.environ and \
os.environ['WHICH_QT'].lower() != "pyqt" or \
not 'WHICH_QT' in os.environ:
try:
from PySide2 import QtCore, QtGui, QtWidgets, QtUiTools, QtPositioning, QtNetwork, QtSerialPort
from PySide2.QtCore import Slot, Signal, QMetaObject, Property
from pyside_dynamic import UiLoader
def load_ui(ui_file, widget, widget_mapping = None):
if widget_mapping is None:
widget_mapping = {}
loader = UiLoader(widget, widget_mapping )
top_widget = loader.load(ui_file)
QMetaObject.connectSlotsByName(widget)
USE_PYSIDE = True
except ImportError:
USE_PYSIDE = False
if not USE_PYSIDE:
from PyQt5 import QtCore, QtGui, uic, QtWidgets, QtPositioning, QtNetwork, QtSerialPort
from PyQt5.QtCore import pyqtSlot as Slot
from PyQt5.QtCore import pyqtSignal as Signal
from PyQt5.QtCore import pyqtProperty as Property
def load_ui(ui_file, widget, widget_mapping = None):
uic.loadUi(ui_file, widget)
#from blocksignalqt import BlockSignal
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
w = QtWidgets.QWidget()
b = QtWidgets.QLabel(w)
b.setText("Hello World!")
w.setGeometry(100,100,200,50)
b.move(50,20)
if USE_PYSIDE:
w.setWindowTitle("PySide2")
else:
w.setWindowTitle("PyQt5")
w.show()
sys.exit(app.exec_())