##// END OF EJS Templates
Keep track of Qt version since it can't change
Emilio Graff -
Show More
@@ -40,18 +40,19 b' class UnknownBackend(KeyError):'
40 ', '.join(backends + sorted(registered)))
40 ', '.join(backends + sorted(registered)))
41
41
42
42
43 last_qt_version = None # stores which version (i.e. `gui`) was requested the first time.
44
43 def set_qt_api(gui):
45 def set_qt_api(gui):
44 """Sets the `QT_API` environment variable if it isn't already set."""
46 """Sets the `QT_API` environment variable if it isn't already set."""
45 # TODO: how do we do this here?
46 # if hasattr(kernel, "app"):
47 # raise RuntimeError("Kernel already running a Qt event loop.")
48
47
49 # if gui != "qt" and hasattr(kernel, "last_qt_version"):
48 global last_qt_version
50 # if kernel.last_qt_version != gui:
49
51 # raise ValueError(
50 if gui != "qt" and last_qt_version is not None:
52 # "Cannot switch Qt versions for this session; "
51 if last_qt_version != gui:
53 # f"must use {kernel.last_qt_version}."
52 raise ValueError(
54 # )
53 "Cannot switch Qt versions for this session; "
54 f"must use {last_qt_version}."
55 )
55
56
56 qt_api = os.environ.get("QT_API", None)
57 qt_api = os.environ.get("QT_API", None)
57 if qt_api is not None and gui != "qt":
58 if qt_api is not None and gui != "qt":
@@ -115,6 +116,9 b' def set_qt_api(gui):'
115 f'Unrecognized Qt version: {gui}. Should be "qt4", "qt5", "qt6", or "qt".'
116 f'Unrecognized Qt version: {gui}. Should be "qt4", "qt5", "qt6", or "qt".'
116 )
117 )
117
118
119 # Due to the import mechanism, we can't change Qt versions once we've chosen one. So we tag the
120 # version so we can check for this and give an error.
121 last_qt_version = gui
118
122
119 def get_inputhook_name_and_func(gui):
123 def get_inputhook_name_and_func(gui):
120 print(f'`get_inputhook_name_and_func` called with {gui=}')
124 print(f'`get_inputhook_name_and_func` called with {gui=}')
General Comments 0
You need to be logged in to leave comments. Login now