Message Box¶
Last Updated: August 10, 2015
-
class
tethys_sdk.gizmos.
MessageBox
(name, title, message='', dismiss_button='Cancel', affirmative_button='Ok', affirmative_attributes='', width=560, attributes={}, classes='')¶ Message box gizmos can be used to display messages to users. These are especially useful for alerts and warning messages. The message box gizmo is implemented using Twitter Bootstrap's modal.
-
name
¶ Unique name for the message box
- Type
str, required
-
title
¶ Title that appears at the top of the message box
- Type
str, required
-
message
¶ Message that will appear in the main body of the message box
- Type
str
Title for the dismiss button (a.k.a.: the "Cancel" button)
- Type
str
Title for the affirmative action button (a.k.a.: the "OK" button)
- Type
str
-
affirmative_attributes
¶ Use this to place any html attributes on the affirmative button. (e.g.: 'href="/action" onclick="doSomething();"')
- Type
str
-
width
¶ The width of the message box in pixels
- Type
int
-
attributes
¶ A dictionary representing additional HTML attributes to add to the primary element (e.g. {"onclick": "run_me();"}).
- Type
dict
-
classes
¶ Additional classes to add to the primary HTML element (e.g. "example-class another-class").
- Type
str
Controller Example
from tethys_sdk.gizmos import MessageBox message_box = MessageBox(name='sampleModal', title='Message Box Title', message='Congratulations! This is a message box.', dismiss_button='Nevermind', affirmative_button='Proceed', width=400, affirmative_attributes='href=javascript:void(0);') context = { 'message_box': message_box, }
Template Example
{% load tethys_gizmos %} <a href="#sampleModal" role="button" class="btn btn-success" data-toggle="modal">Show Message Box</a> {% block after_app_content %} {% gizmo message_box %} {% endblock %}
-