MCPcopy Create free account
hub / github.com/cztomczak/cefpython / ChromeWindow

Class ChromeWindow

src/cefpython3.wx/chromectrl.py:125–235  ·  view source on GitHub ↗

Standalone CEF component. The class provides facilites for interacting with wx message loop

Source from the content-addressed store, hash-verified

123
124
125class ChromeWindow(wx.Window):
126 """
127 Standalone CEF component. The class provides facilites for interacting
128 with wx message loop
129 """
130 def __init__(self, parent, url="", useTimer=True,
131 timerMillis=DEFAULT_TIMER_MILLIS, browserSettings=None,
132 size=(-1, -1), *args, **kwargs):
133 wx.Window.__init__(self, parent, id=wx.ID_ANY, size=size,
134 *args, **kwargs)
135
136 # This timer is not used anymore, but creating it for backwards
137 # compatibility. In one of external projects ChromeWindow.timer.Stop()
138 # is being called during browser destruction.
139 self.timer = wx.Timer()
140
141 # On Linux absolute file urls need to start with "file://"
142 # otherwise a path of "/home/some" is converted to "http://home/some".
143 if platform.system() in ["Linux", "Darwin"]:
144 if url.startswith("/"):
145 url = "file://" + url
146 self.url = url
147
148 windowInfo = cefpython.WindowInfo()
149 if platform.system() == "Windows":
150 windowInfo.SetAsChild(self.GetHandle())
151 elif platform.system() == "Linux":
152 windowInfo.SetAsChild(self.GetGtkWidget())
153 elif platform.system() == "Darwin":
154 (width, height) = self.GetClientSizeTuple()
155 windowInfo.SetAsChild(self.GetHandle(),
156 [0, 0, width, height])
157 else:
158 raise Exception("Unsupported OS")
159
160 if not browserSettings:
161 browserSettings = {}
162
163 # Disable plugins:
164 # | browserSettings["plugins_disabled"] = True
165
166 self.browser = cefpython.CreateBrowserSync(windowInfo,
167 browserSettings=browserSettings, navigateUrl=url)
168
169 if platform.system() == "Windows":
170 self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
171 self.Bind(wx.EVT_SIZE, self.OnSize)
172
173 self._useTimer = useTimer
174 if useTimer:
175 CreateMessageLoopTimer(timerMillis)
176 else:
177 # Currently multiple EVT_IDLE events might be registered
178 # when creating multiple ChromeWindow instances. This will
179 # result in calling CEF message loop work multiple times
180 # simultaneously causing performance penalties and possibly
181 # some unwanted behavior (CEF Python Issue 129).
182 Debug("WARNING: Using EVT_IDLE for CEF message loop processing"\

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected