Created
March 8, 2018 13:14
-
-
Save domagojhack/70aecfeecbf40e52aabc84c7d46640c2 to your computer and use it in GitHub Desktop.
Revisions
-
domagojhack created this gist
Mar 8, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,99 @@ import remi import webview import threading from cefpython3 import cefpython as cef import platform import sys class test(remi.App): def __init__(self, *args): super(spatio, self).__init__(*args) def main(self): # defining the looks of the program self.html_head = """ <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css"> <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --> <!--<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> --> <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script> """ cont = remi.gui.HBox(width= "100%", height= "100%", margin="0px auto") l_cont = remi.gui.VBox(width="18%", height="100%", margin="0px") c_cont = remi.gui.VBox(width="64%", height="100%", margin="0px") r_cont = remi.gui.VBox(width="18%", height="100%", margin="0px") self.map = remi.gui.Widget(height="50%", width="100%") # Widgets not active yet! ignore this # self.datalst = remi.gui.TreeView(width="15%", height="100%") # self.layerlst = remi.gui.ListView(width="15%", height="100%") # self.grid = remi.gui.Table(height="50%", width="70%") tag = remi.gui.Tag(_type='script') tag.add_child("javascript", """ var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ], target: '%s', controls: [], view: new ol.View({ center: [0, 0], zoom: 2 }) }); """ % (str(self.map.identifier))) c_cont.append(self.map) self.map.add_child("openlayerscript", tag) # l_cont.append(self.datalst) cont.append(l_cont) cont.append(c_cont) cont.append(r_cont) return cont def check_versions(): ver = cef.GetVersion() print("[hello_world.py] CEF Python {ver}".format(ver=ver["version"])) print("[hello_world.py] Chromium {ver}".format(ver=ver["chrome_version"])) print("[hello_world.py] CEF {ver}".format(ver=ver["cef_version"])) print("[hello_world.py] Python {ver} {arch}".format( ver=platform.python_version(), arch=platform.architecture()[0])) assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this" def CreateW(): check_versions() sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error cef.Initialize() cef.CreateBrowserSync(url="http://127.0.0.1:8081/", window_title="Spatio") cef.MessageLoop() cef.Shutdown() def startApp(): if __name__ == "__main__": print "starting app" remi.start(test, address='127.0.0.1', port=8081, multiple_instance=False, enable_file_cache=False, start_browser=False) thread1 = threading.Thread(target=CreateW) thread2 = threading.Thread(target=startApp) thread1.setDaemon(True) thread2.start() thread1.start() thread1.join()