Changeset 685:6391018c120b for src/mlx
- Timestamp:
- 10/18/15 14:51:39 (9 years ago)
- Branch:
- cef
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/cef.py
r682 r685 1 1 from common import * 2 3 from mava_simbrief import MavaSimbriefIntegrator 2 4 3 5 from mlx.util import secondaryInstallation … … 87 89 self._commands = [] 88 90 91 self._driver = None 92 89 93 self._toQuit = False 94 95 @property 96 def programDirectory(self): 97 """Get the program directory.""" 98 return self._programDirectory 90 99 91 100 def run(self): … … 102 111 options = Options() 103 112 options.binary_location = scriptPath 104 driver = webdriver.Chrome(chrome_options = options)113 driver = self._driver = webdriver.Chrome(chrome_options = options) 105 114 # try: 106 115 # except: … … 120 129 driver.quit() 121 130 131 def callSimBrief(self, plan, getCredentials, updateProgress, 132 htmlFilePath): 133 """Call SimBrief with the given plan.""" 134 self._enqueue(lambda: 135 self._callSimBrief(plan, self._driver, 136 getCredentials, updateProgress, 137 htmlFilePath)) 138 122 139 def quit(self): 123 140 """Instruct the thread to quit and then join it.""" … … 132 149 self._commands.append(command) 133 150 self._commandsCondition.notify() 151 152 def _callSimBrief(self, plan, driver, 153 getCredentials, updateProgress, htmlFilePath): 154 """Perform the SimBrief call.""" 155 integrator = MavaSimbriefIntegrator(plan = plan, driver = driver) 156 link = integrator.get_xml_link(getCredentials, updateProgress, 157 local_xml_debug = False, 158 local_html_debug = False) 159 160 updateProgress("Retrieving briefing...", False) 161 162 flight_info = integrator.get_results(link, 163 html_file_path = htmlFilePath) 164 165 updateProgress("Done", True) 134 166 135 167 def _quit(self): … … 231 263 #------------------------------------------------------------------------------ 232 264 265 class OffscreenRenderHandler(object): 266 def GetRootScreenRect(self, browser, rect): 267 #print "GetRootScreenRect" 268 rect += [0, 0, 800, 600] 269 return True 270 271 def GetViewRect(self, browser, rect): 272 #print "GetViewRect" 273 rect += [0, 0, 800, 600] 274 return True 275 276 def GetScreenPoint(self, browser, viewX, viewY, screenCoordinates): 277 #print "GetScreenPoint", viewX, viewY 278 rect += [viewX, viewY] 279 return True 280 281 def GetScreenInfo(self, browser, screenInfo): 282 #print "GetScreenInfo" 283 pass 284 285 def OnPopupShow(self, browser, show): 286 #print "OnPopupShow", show 287 pass 288 289 def OnPopupSize(self, browser, rect): 290 #print "OnPopupSize", rect 291 pass 292 293 def OnPaint(self, browser, paintElementType, dirtyRects, buffer, width, height): 294 #print "OnPaint", paintElementType, dirtyRects, buffer, width, height 295 pass 296 297 def OnCursorChange(self, browser, cursor): 298 #print "OnCursorChange", cursor 299 pass 300 301 def OnScrollOffsetChanged(self, browser): 302 #print "OnScrollOffsetChange" 303 pass 304 305 def OnBeforePopup(self, browser, frame, targetURL, targetFrameName, 306 popupFeatures, windowInfo, client, browserSettings, 307 noJavascriptAccess): 308 wInfo = cefpython.WindowInfo() 309 wInfo.SetAsOffscreen(int(0)) 310 311 windowInfo.append(wInfo) 312 313 return False 314 315 #------------------------------------------------------------------------------ 316 317 def initializeSimBrief(): 318 """Initialize the (hidden) browser window for SimBrief.""" 319 windowInfo = cefpython.WindowInfo() 320 windowInfo.SetAsOffscreen(int(0)) 321 322 url = "file://" + os.path.join(_seleniumHandler.programDirectory, 323 "simbrief.html") 324 simBriefBrowser = cefpython.CreateBrowserSync(windowInfo, 325 browserSettings = {}, 326 navigateUrl = url) 327 simBriefBrowser.SetClientHandler(OffscreenRenderHandler()) 328 329 simBriefBrowser.SetFocus(True) 330 331 #------------------------------------------------------------------------------ 332 333 def callSimBrief(plan, getCredentials, updateProgress, htmlFilePath): 334 """Call SimBrief with the given plan.""" 335 _seleniumHandler.callSimBrief(plan, getCredentials, 336 updateProgress, htmlFilePath) 337 338 #------------------------------------------------------------------------------ 339 233 340 def finalize(): 234 341 """Finalize the Chrome Embedded Framework."""
Note:
See TracChangeset
for help on using the changeset viewer.