@@ -59,81 +59,83 @@ const EVENT_LOOPS = Dict{Symbol,Base.Timer}()
59
59
const new_event_loop_callback = pynew ()
60
60
61
61
function init_gui ()
62
- # define callbacks
63
- @py g = {}
64
- @py @exec """
65
- def new_event_loop_callback(g, interval=0.04):
66
- if g in ("pyqt4","pyqt5","pyside","pyside2"):
67
- if g == "pyqt4":
68
- import PyQt4.QtCore as QtCore
69
- elif g == "pyqt5":
70
- import PyQt5.QtCore as QtCore
71
- elif g == "pyside":
72
- import PySide.QtCore as QtCore
73
- elif g == "pyside2":
74
- import PySide2.QtCore as QtCore
75
- instance = QtCore.QCoreApplication.instance
76
- AllEvents = QtCore.QEventLoop.AllEvents
77
- processEvents = QtCore.QCoreApplication.processEvents
78
- maxtime = interval * 1000
79
- def callback():
80
- app = instance()
81
- if app is not None:
82
- app._in_event_loop = True
83
- processEvents(AllEvents, maxtime)
84
- elif g in ("gtk","gtk3"):
85
- if g == "gtk3":
86
- import gi
87
- if gi.get_required_version("Gtk") is None:
88
- gi.require_version("Gtk", "3.0")
89
- import gi.repository.Gtk as gtk
90
- elif g == "gtk":
91
- import gtk
92
- events_pending = gtk.events_pending
93
- main_iteration = gtk.main_iteration
94
- def callback():
95
- while events_pending():
96
- main_iteration()
97
- elif g == "wx":
98
- import wx
99
- GetApp = wx.GetApp
100
- EventLoop = wx.EventLoop
101
- EventLoopActivator = wx.EventLoopActivator
102
- def callback():
103
- app = GetApp()
104
- if app is not None:
105
- app._in_event_loop = True
106
- evtloop = EventLoop()
107
- ea = EventLoopActivator(evtloop)
108
- Pending = evtloop.Pending
109
- Dispatch = evtloop.Dispatch
110
- while Pending():
111
- Dispatch()
112
- app.ProcessIdle()
113
- elif g == "tkinter":
114
- import tkinter, _tkinter
115
- flag = _tkinter.ALL_EVENTS | _tkinter.DONT_WAIT
116
- root = None
117
- def callback():
118
- global root
119
- new_root = tkinter._default_root
120
- if new_root is not None:
121
- root = new_root
122
- if root is not None:
123
- while root.dooneevent(flag):
124
- pass
125
- else:
126
- raise ValueError("invalid event loop name: {}".format(g))
127
- return callback
128
- """ g
129
- pycopy! (new_event_loop_callback, g[" new_event_loop_callback" ])
130
-
131
- # add a hook to automatically call fix_qt_plugin_path()
132
- fixqthook = Py (() -> (CONFIG. auto_fix_qt_plugin_path && fix_qt_plugin_path (); nothing ))
133
- pymodulehooks. add_hook (" PyQt4" , fixqthook)
134
- pymodulehooks. add_hook (" PyQt5" , fixqthook)
135
- pymodulehooks. add_hook (" PySide" , fixqthook)
136
- pymodulehooks. add_hook (" PySide2" , fixqthook)
62
+ if ! C. CTX. is_embedded
63
+ # define callbacks
64
+ @py g = {}
65
+ @py @exec """
66
+ def new_event_loop_callback(g, interval=0.04):
67
+ if g in ("pyqt4","pyqt5","pyside","pyside2"):
68
+ if g == "pyqt4":
69
+ import PyQt4.QtCore as QtCore
70
+ elif g == "pyqt5":
71
+ import PyQt5.QtCore as QtCore
72
+ elif g == "pyside":
73
+ import PySide.QtCore as QtCore
74
+ elif g == "pyside2":
75
+ import PySide2.QtCore as QtCore
76
+ instance = QtCore.QCoreApplication.instance
77
+ AllEvents = QtCore.QEventLoop.AllEvents
78
+ processEvents = QtCore.QCoreApplication.processEvents
79
+ maxtime = interval * 1000
80
+ def callback():
81
+ app = instance()
82
+ if app is not None:
83
+ app._in_event_loop = True
84
+ processEvents(AllEvents, maxtime)
85
+ elif g in ("gtk","gtk3"):
86
+ if g == "gtk3":
87
+ import gi
88
+ if gi.get_required_version("Gtk") is None:
89
+ gi.require_version("Gtk", "3.0")
90
+ import gi.repository.Gtk as gtk
91
+ elif g == "gtk":
92
+ import gtk
93
+ events_pending = gtk.events_pending
94
+ main_iteration = gtk.main_iteration
95
+ def callback():
96
+ while events_pending():
97
+ main_iteration()
98
+ elif g == "wx":
99
+ import wx
100
+ GetApp = wx.GetApp
101
+ EventLoop = wx.EventLoop
102
+ EventLoopActivator = wx.EventLoopActivator
103
+ def callback():
104
+ app = GetApp()
105
+ if app is not None:
106
+ app._in_event_loop = True
107
+ evtloop = EventLoop()
108
+ ea = EventLoopActivator(evtloop)
109
+ Pending = evtloop.Pending
110
+ Dispatch = evtloop.Dispatch
111
+ while Pending():
112
+ Dispatch()
113
+ app.ProcessIdle()
114
+ elif g == "tkinter":
115
+ import tkinter, _tkinter
116
+ flag = _tkinter.ALL_EVENTS | _tkinter.DONT_WAIT
117
+ root = None
118
+ def callback():
119
+ global root
120
+ new_root = tkinter._default_root
121
+ if new_root is not None:
122
+ root = new_root
123
+ if root is not None:
124
+ while root.dooneevent(flag):
125
+ pass
126
+ else:
127
+ raise ValueError("invalid event loop name: {}".format(g))
128
+ return callback
129
+ """ g
130
+ pycopy! (new_event_loop_callback, g[" new_event_loop_callback" ])
131
+
132
+ # add a hook to automatically call fix_qt_plugin_path()
133
+ fixqthook = Py (() -> (CONFIG. auto_fix_qt_plugin_path && fix_qt_plugin_path (); nothing ))
134
+ pymodulehooks. add_hook (" PyQt4" , fixqthook)
135
+ pymodulehooks. add_hook (" PyQt5" , fixqthook)
136
+ pymodulehooks. add_hook (" PySide" , fixqthook)
137
+ pymodulehooks. add_hook (" PySide2" , fixqthook)
138
+ end
137
139
end
138
140
139
141
"""
0 commit comments