|
| 1 | +""" |
| 2 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | + you may not use this file except in compliance with the License. |
| 4 | + You may obtain a copy of the License at |
| 5 | +
|
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | + Unless required by applicable law or agreed to in writing, software |
| 9 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | + See the License for the specific language governing permissions and |
| 12 | + limitations under the License. |
| 13 | +""" |
| 14 | + |
| 15 | +import remi.gui as gui |
| 16 | +from remi import start, App |
| 17 | +import os |
| 18 | + |
| 19 | +class MyApp(App): |
| 20 | + def __init__(self, *args): |
| 21 | + res_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res') |
| 22 | + #static_file_path can be an array of strings allowing to define |
| 23 | + # multiple resource path in where the resources will be placed |
| 24 | + super(MyApp, self).__init__(*args, static_file_path=res_path) |
| 25 | + |
| 26 | + def main(self): |
| 27 | + #creating a container VBox type, vertical (you can use also HBox or Widget) |
| 28 | + main_container = gui.VBox(width=300, height=200, style={'margin':'0px auto'}) |
| 29 | + self.page.children['head'].add_child('test', '<meta patate>') |
| 30 | + self.page.children['body'].style['background-color'] = 'lightyellow' |
| 31 | + # returning the root widget |
| 32 | + return main_container |
| 33 | + |
| 34 | + def onload(self, emitter): |
| 35 | + print(">>>>>>>>> ON PAGE LOADED") |
| 36 | + |
| 37 | + def onerror(self, emitter, message, source, line, col): |
| 38 | + print(">>>>>>>>> ON ERROR: %s\n%s\n%s\n%s"%(message, source, line, col)) |
| 39 | + self.execute_javascript('document.onkeydo') |
| 40 | + |
| 41 | + |
| 42 | +if __name__ == "__main__": |
| 43 | + # starts the webserver |
| 44 | + start(MyApp, debug=True, address='0.0.0.0', port=8081) |
0 commit comments