Skip to content

Adding more custom dialogs: Error dialog #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions artwork/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions artwork/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions examples/canvas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import os
import remi.gui as gui
from remi.game import Color, Rect
from remi.game.canvas import Canvas
from remi.game.draw import line, lines, circle, rect
from remi import start, App


class MyApp(App):
canvas = None
def __init__(self, *args):
super(MyApp, self).__init__(*args)

def main(self, name='world'):
#margin 0px auto allows to center the app to the screen
container = gui.Widget(width=600, height=600)
self.canvas = Canvas(self, resolution=(600, 400), margin='0px auto')
button = gui.Button('Go!')
button.set_on_click_listener(self.draw)
container.append(self.canvas)
container.append(button)
# returning the root widget
return container

def draw(self, widget):
line(self.canvas, Color(255, 0, 0), (0, 0), (200, 100))
lines(self.canvas, Color(0, 0, 255), [(200, 100),
(100, 0),
(150, 400)])
circle(self.canvas, Color(0, 255, 0), (200, 100), 10, width=1)
circle(self.canvas, Color(255, 0, 0), (300, 150), 10)
rect(self.canvas, Color(255, 255, 0), Rect((10, 10), (30, 30)), width=1)
rect(self.canvas, Color(128, 128, 255), Rect((5, 5), (15, 100)))

if __name__ == "__main__":
print 'Starting with pid: %s' % os.getpid()
# starts the webserver
# optional parameters
# start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
start(MyApp, debug=True)
51 changes: 51 additions & 0 deletions examples/canvas_raster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import os
import remi.gui as gui
from remi.game import Color, Rect
from remi.game.canvas import Canvas
from remi.game.raster import load_image, draw
from remi import start, App


class MyApp(App):
canvas = None
def __init__(self, *args):
super(MyApp, self).__init__(*args)

def main(self, name='world'):
#margin 0px auto allows to center the app to the screen
container = gui.Widget(width=600, height=600)
self.canvas = Canvas(self, resolution=(600, 400), margin='0px auto')
button = gui.Button('Go!')
button.set_on_click_listener(self.draw)
container.append(self.canvas)
container.append(button)
# returning the root widget
return container

def draw(self, widget):
image = load_image('example.png')
draw(image, self.canvas, position=(10, 10))

if __name__ == "__main__":
print 'Starting with pid: %s' % os.getpid()
# starts the webserver
# optional parameters
# start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
start(MyApp, debug=True)
57 changes: 57 additions & 0 deletions examples/dialogs_oeverview_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import remi.gui as gui
import remi.dialogs as dialogs
from remi import start, App


class MyApp(App):
def __init__(self, *args):
super(MyApp, self).__init__(*args)

def main(self):
# the margin 0px auto centers the main container
verticalContainer = gui.Widget(
width=540, margin='0px auto',
style={'display': 'block', 'overflow': 'hidden'})

info_bt = gui.Button('Show info dialog',
width=200, height=30, margin='10px')

error_bt = gui.Button('Show error dialog',
width=200, height=30, margin='10px')

# setting the listener for the onclick event of the button
info_bt.set_on_click_listener(self.show_info_dialog)
error_bt.set_on_click_listener(self.show_error_dialog)

verticalContainer.append(info_bt)
verticalContainer.append(error_bt)

# returning the root widget
return verticalContainer

def show_info_dialog(self, widget):
dialogs.Info('Some information message', width=300).show(self)

def show_error_dialog(self, widget):
dialogs.Error('Some error message', width=300).show(self)

if __name__ == "__main__":
# starts the webserver
# optional parameters
# start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)

start(MyApp, debug=True, address='0.0.0.0', start_browser=True)
Loading