Created
November 16, 2012 22:53
-
-
Save rdeaton/4091688 to your computer and use it in GitHub Desktop.
This file contains 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 characters
from spyral import Sprite, AggregateSprite | |
class FormWidget(object): | |
def get_value(self): | |
pass | |
def set_value(self, value): | |
pass | |
class TextInputWidget(Sprite, FormWidget): | |
def __init__(self, value = '', default_value = True, max_width = None, max_length = None, style = None, validator = None): | |
pass | |
class ButtonWidget(Sprite, FormWidget): | |
def __init__(self, text, style = None): | |
pass | |
class ToggleButtonWidget(Sprite, FormWidget): | |
def __init__(self, text, style = None): | |
pass | |
class CheckboxWidget(Sprite, FormWidget): | |
def __init__(self, text, style = None): | |
pass | |
class RadioButton(Sprite): | |
def __init__(self, value, style = None): | |
pass | |
class RadioGroup(object, FormWidget): | |
def __init__(self, *buttons): | |
pass | |
class FormStyle(object): | |
text_input_font = None | |
text_input_images = None | |
text_input_padding = None | |
text_input_font_color = None | |
text_input_highlight_color = None | |
text_input_highlight_background_color = None | |
button_font = None | |
button_padding = None | |
button_font_color = None | |
button_images = None | |
button_images_selected = None | |
button_images_hover = None | |
radio_image = None | |
radio_image_selected = None | |
radio_image_hover = None | |
checkbox_image = None | |
checkbox_image_selected = None | |
checkbox_image_hover = None | |
class Form(AggregateSprite, EventManager): | |
def __init__(self, style = None): | |
pass | |
def add_widget(self, tab_order = None): | |
""" | |
If tab-order is None, it is set to one higher than the highest tab order. | |
""" | |
def add_label(self, sprite): | |
""" | |
Adds a non-widget sprite as part of the form. | |
""" | |
def get_values(self): | |
""" | |
Returns a dictionary of the values for all the fields. | |
""" | |
def focus(self, widget_name): | |
""" | |
Sets the focus to be on a specific widget. Focus by default goes | |
to the first widget added to the form. | |
""" | |
def blur(self): | |
""" | |
Defocuses the entire form. | |
""" | |
def next(self, wrap = True): | |
""" | |
Focuses the next widget | |
""" | |
def previous(self, wrap = True): | |
""" | |
Focuses the previous widget | |
""" | |
form = Form() | |
name = TextInputWidget(max_length=30) | |
# Change the name's positioning and all that stuff | |
easy = RadioButton('easy') | |
med = RadioButton('medium') | |
hard = RadioButton('hard') | |
difficulty = RadioGroup(easy, med, hard) | |
difficulty.set_value('medium') | |
start = ButtonWidget("Start Game", on_submit) | |
random_checkbox = CheckboxWidget("random", value = True) | |
form.add_widget('name', name) | |
form.add_widget('difficulty', difficulty) | |
form.add_widget('random', random_checkbox) | |
form.add_widget('start', on_submit) | |
# When submit is hit, it should look like | |
{'difficulty' : 'medium', | |
'name' : 'rdeaton', | |
'random' : True, | |
'start' : True} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment