Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#@+leo-ver=5-thin 

2#@+node:ekr.20140810053602.18074: * @file leoQt.py 

3#@@nopyflakes 

4""" 

5General import wrapper for PyQt5 and PyQt6. 

6 

7Provides the *PyQt6* spellings of Qt modules, classes, enums and constants: 

8 

9- QtWidgets, not QtGui, for all widget classes. 

10- QtGui, not QtWidgets, for all other classes in the *PyQt4* QtGui module. 

11- QtWebKitWidgets, not QtWebKit. 

12- Enums: KeyboardModifier, not KeyboardModifiers, etc. 

13""" 

14import leo.core.leoGlobals as g 

15# 

16# Set defaults. 

17isQt6 = isQt5 = False 

18# 

19# Make *sure* this module always imports the following symbols. 

20Qt = QtConst = QtCore = QtGui = QtWidgets = QUrl = QCloseEvent = None 

21QtDeclarative = Qsci = QtSvg = QtMultimedia = QtWebKit = QtWebKitWidgets = None 

22phonon = uic = None 

23QtMultimedia = None # Replacement for phonon. 

24qt_version = '<no qt version>' 

25printsupport = Signal = None 

26# 

27# Skip all other imports in the bridge. 

28if not g.in_bridge: 

29 # 

30 # Pyflakes will complaint about * imports. 

31 # 

32 # pylint: disable=unused-wildcard-import,wildcard-import 

33 # 

34 # Set the isQt* constants only if all required imports succeed. 

35 try: 

36 if 0: # Testing: Force Qt5. 

37 raise AttributeError 

38 from leo.core.leoQt6 import * # type:ignore 

39 # 

40 # Restore the exec_method! 

41 def exec_(self, *args, **kwargs): 

42 return self.exec(*args, **kwargs) 

43 

44 # pylint: disable=c-extension-no-member 

45 g.funcToMethod(exec_, QtWidgets.QWidget) 

46 isQt6 = True 

47 # print('\n===== Qt6 =====') 

48 except Exception: 

49 # g.es_exception() 

50 try: 

51 from leo.core.leoQt5 import * # type:ignore 

52 isQt5 = True 

53 # print('\n===== Qt5 =====') 

54 except Exception: 

55 # print('===== No Qt =====') 

56 if g.app.gui.guiName() == 'qt': 

57 print('Can not load pyQt5 or pyQt6') 

58#@-leo