Exemplo n.º 1
0
from DemoFramework import DemoFramework
from LUILabel import LUILabel

import random

f = DemoFramework()
f.prepare_demo("LUILabel")

# Constructor

f.add_constructor_parameter("text", "u'Label'")
f.add_constructor_parameter("shadow", "True")
f.add_constructor_parameter("font_size", "14")
f.add_constructor_parameter("font", "'label'")

# Functions
f.add_public_function("get_text", [], "string")
f.add_public_function("set_text", [("text", "string")])

# Events
f.construct_sourcecode("LUILabel")

# Create a new label
label = LUILabel(parent=f.get_widget_node(), text="This is a fancy label")

f.set_actions({
        "Set Random Text": lambda: label.set_text(unicode(random.randint(100, 10000))),
    })

run()
Exemplo n.º 2
0
f.add_constructor_parameter("show_label", "False")

# Functions
f.add_public_function("get_value", [], "float")
f.add_public_function("set_value", [("value", "float")])

f.add_property("value", "float")

# Events
f.construct_sourcecode("LUIProgressbar")

# Create the checkbox
layout = LUIVerticalLayout(parent=f.get_widget_node(), spacing=10)

LUILabel(parent=layout.cell(),
         text="This is a progressbar:",
         color=(1, 1, 1, 0.4))
bar = LUIProgressbar(parent=layout.cell(), width=200.0)

LUILabel(parent=layout.cell(),
         text="You can control it with this slider:",
         color=(1, 1, 1, 0.4))
slider = LUISlider(parent=layout.cell(), width=200.0, filled=True)
slider.bind("changed", lambda event: bar.set_value(slider.value * 100.0))

f.set_actions({
    "Set to 30%": lambda: bar.set_value(30),
})

run()
Exemplo n.º 3
0
# Functions
f.add_public_function("get_checked", [], "bool")
f.add_public_function("toggle_checked", [], "bool")
f.add_public_function("set_checked", [("checked", "bool")])
f.add_public_function("get_label", [], "UILabel")

f.add_property("checked", "bool")
f.add_property("label", "LUILabel")

# Events
f.add_event("changed")
f.construct_sourcecode("LUICheckbox")

# Create the checkbox
checkbox = LUICheckbox(parent=f.get_widget_node())

f.set_actions({
    "Set Checked":
    lambda: checkbox.set_checked(True),
    "Set Unchecked":
    lambda: checkbox.set_checked(False),
    "Toggle Checked":
    lambda: checkbox.toggle_checked(),
    "Set Random Text":
    lambda: checkbox.get_label().set_text(u"Text: " + unicode(
        random.randint(100, 10000))),
})

run()
Exemplo n.º 4
0
f.add_public_function("get_label", [], "LUILabel")
f.add_public_function("set_active", [], "void")

f.add_property("value", "object")
f.add_property("label", "LUILabel")

# Events
f.add_event("changed")
f.construct_sourcecode("LUIRadiobox")

# Create a group to connect the boxes
group = LUIRadioboxGroup()

# Create a layout for the boxes
grid = LUIVerticalLayout(parent=f.get_widget_node(), spacing=5)

# Create the boxes
boxes = []
for i in range(1, 4):
    boxes.append(LUIRadiobox(group=group, value=i, label="Radiobox {0}".format(i), active=i==2))
    grid.add(boxes[-1])

f.set_actions({
        "Select Box 1": lambda: boxes[0].set_active(),
        "Select Box 2": lambda: boxes[1].set_active(),
        "Select Box 3": lambda: boxes[2].set_active(),
        "Set Random Text": lambda: boxes[0].label.set_text(u"Text: " + unicode(random.randint(100, 10000))),
    })

run()
Exemplo n.º 5
0
label.add(text="Label", font_size=25, margin =(-11, 0, 0, 0), color=(0.2,1.0,0.6))

# Go to next line
label.newline()
label.newline()

# Add some more parts
label.add(text="This is the same label ..", color=(0.3,0.7,0.32))

# Go to next line
label.newline()
label.newline()

# Add some more parts
label.add(text="... but another line forced with ", color=(0.6,0.3,0.8))
label.add(text="newline() ", color=(1.0,0.6,0.2))

def make_random_color():
    return (random.random(), random.random(), random.random())

def newline():
    label.newline()
    label.add(text="New Line!", color=make_random_color())

f.set_actions({
        "Add random text": lambda: label.add(text="Text ", color=make_random_color()),
        "Go to next line": newline
    })

run()
Exemplo n.º 6
0
# Constructor
f.add_constructor_parameter("width", "200")
f.add_constructor_parameter("height", "200")
f.add_constructor_parameter("innerPadding", "5")
f.add_constructor_parameter("scrollable", "False")
f.add_constructor_parameter("style", "UIFrame.Raised")

# Functions

# Events
f.construct_sourcecode("LUIFrame")

# Construct a new frame
frame = LUIFrame(parent=f.get_widget_node())

layout = LUIVerticalLayout(parent=frame, spacing=5)
layout.add(LUILabel(text="This is some frame ..", color=(0.2, 0.6, 1.0, 1.0), font_size=20))
layout.add(LUILabel(text="It can contain arbitrary elements."))
layout.add(LUILabel(text="For example this button:"))
layout.add(LUIButton(text="Fancy button"))

# frame.fit_to_children()

f.set_actions({
        "Resize to 300x160": lambda: frame.set_size(300, 160),
        "Fit to children": lambda: frame.clear_size(),
    })

run()
Exemplo n.º 7
0
# Add some more parts
label.add(text="This is the same label ..", color=(0.3, 0.7, 0.32))

# Go to next line
label.newline()
label.newline()

# Add some more parts
label.add(text="... but another line forced with ", color=(0.6, 0.3, 0.8))
label.add(text="newline() ", color=(1.0, 0.6, 0.2))


def make_random_color():
    return (random.random(), random.random(), random.random())


def newline():
    label.newline()
    label.add(text="New Line!", color=make_random_color())


f.set_actions({
    "Add random text":
    lambda: label.add(text="Text ", color=make_random_color()),
    "Go to next line":
    newline
})

run()
Exemplo n.º 8
0
f = DemoFramework()
f.prepare_demo("LUIButton")

# Constructor
f.add_constructor_parameter("text", "u'Button'")
f.add_constructor_parameter("template", "'ButtonDefault'")

# Functions
f.add_public_function("set_text", [("text", "string")])
f.add_public_function("get_text", [], "string")
f.add_property("text", "string")

# Construct source code
f.construct_sourcecode("LUIButton")

# Create 2 new buttons, and store them in a vertical layout
layout = LUIHorizontalLayout(parent=f.get_widget_node(), spacing=10)

button1 = LUIButton(text="Do not click me")
button2 = LUIButton(text="Instead click me", template="ButtonGreen")

layout.add(button1)
layout.add(button2)

f.set_actions({
        "Set Random Text": lambda: button1.set_text("Text: " + str(random.randint(100, 10000000))),
    })

run()
Exemplo n.º 9
0
f = DemoFramework()
f.prepare_demo("LUIProgressbar")

# Constructor
f.add_constructor_parameter("show_label", "False")

# Functions
f.add_public_function("get_value", [], "float")
f.add_public_function("set_value", [("value", "float")])

f.add_property("value", "float")

# Events
f.construct_sourcecode("LUIProgressbar")

# Create the checkbox
layout = LUIVerticalLayout(parent=f.get_widget_node(), spacing=10)

LUILabel(parent=layout.cell(), text="This is a progressbar:", color=(1, 1, 1, 0.4))
bar = LUIProgressbar(parent=layout.cell(), width=200.0)

LUILabel(parent=layout.cell(), text="You can control it with this slider:", color=(1, 1, 1, 0.4))
slider = LUISlider(parent=layout.cell(), width=200.0, filled=True)
slider.bind("changed", lambda event: bar.set_value(slider.value * 100.0))

f.set_actions({
        "Set to 30%": lambda: bar.set_value(30),
    })

run()
Exemplo n.º 10
0
from DemoFramework import DemoFramework
from LUIFrame import LUIFrame

import random

f = DemoFramework()
f.prepare_demo("LUIFrame")

# Constructor
f.add_constructor_parameter("width", "200")
f.add_constructor_parameter("height", "200")
f.add_constructor_parameter("innerPadding", "5")
f.add_constructor_parameter("scrollable", "False")
f.add_constructor_parameter("style", "UIFrame.Raised")

# Functions

# Events
# f.add_event("changed")
f.construct_sourcecode("LUIFrame")

frame = LUIFrame(width=300, height=100, parent=f.get_widget_node())

f.set_actions({
        "Resize to 100x100": lambda: frame.set_size(100, 100),
        "Resize to 150x150": lambda: frame.set_size(150, 150),
        "Fit to children": lambda: frame.fit_to_children(),
        "Resize to Random Size": lambda: frame.set_size(random.randint(10, 150), random.randint(10, 150)),
    })

run()
Exemplo n.º 11
0
f = DemoFramework()
f.prepare_demo("LUIButton")

# Constructor
f.add_constructor_parameter("text", "u'Button'")
f.add_constructor_parameter("template", "'ButtonDefault'")

# Functions
f.add_public_function("set_text", [("text", "string")])
f.add_public_function("get_text", [], "string")
f.add_property("text", "string")

# Construct source code
f.construct_sourcecode("LUIButton")

# Create 2 new buttons, and store them in a vertical layout
layout = LUIHorizontalLayout(parent=f.get_widget_node(), spacing=10)

button1 = LUIButton(text="Do not click me")
button2 = LUIButton(text="Instead click me", template="ButtonGreen")

layout.add(button1)
layout.add(button2)

f.set_actions({
        "Set Random Text": lambda: button1.set_text(u"Text: " + unicode(random.randint(100, 10000000))),
    })

run()
Exemplo n.º 12
0
f.add_public_function("get_value", [], "object")
f.add_public_function("get_label", [], "LUILabel")
f.add_public_function("set_active", [], "void")

# Events
f.add_event("changed")
f.construct_sourcecode("LUIRadiobox")

# Create a group to connect the boxes
group = LUIRadioboxGroup()

# Create a layout for the boxes
grid = LUIVerticalLayout(parent=f.get_widget_node(), width=250, spacing=5)   

# Create 3 boxes
box1 = LUIRadiobox(group=group, value=1, label="Radiobox 1")
box2 = LUIRadiobox(group=group, value=2, label="Radiobox 2", active=True)
box3 = LUIRadiobox(group=group, value=3, label="Radiobox 3")

# Add 3 boxes
grid.add_row(box1)
grid.add_row(box2)
grid.add_row(box3)

f.set_actions({
        "Select Box 1": lambda: box1.set_active(),
        "Select Box 2": lambda: box2.set_active(),
        "Set Random Text": lambda: box1.get_label().set_text(unicode(random.randint(100, 10000))),
    })

run()
Exemplo n.º 13
0
f = DemoFramework()
f.prepare_demo("LUILabel")

# Constructor

f.add_constructor_parameter("text", "u'Label'")
f.add_constructor_parameter("shadow", "True")
f.add_constructor_parameter("font_size", "14")
f.add_constructor_parameter("font", "'label'")

# Functions
f.add_public_function("get_text", [], "string")
f.add_public_function("set_text", [("text", "string")])

f.add_property("text", "string")
f.add_property("text_handle", "LUIText")

# Events
f.construct_sourcecode("LUILabel")

# Create a new label
label = LUILabel(parent=f.get_widget_node(), text="This is a fancy label")

f.set_actions({
        "Set Random Text": lambda: label.set_text(unicode(random.randint(100, 10000))),
        "Set Random Color": lambda: label.set_color(random.random(), random.random(), random.random(), 1)
    })

run()
Exemplo n.º 14
0
label.add_text(text="! ")
label.add_text(text="This ", font_size=20, margin_top=-6, color=(0.4,0.2,1.0))
label.add_text(text="is ", color=(1.0,0.2,1.0))
label.add_text(text="a formatted ", font_size=10, color=(0.6,0.3,0.6))
label.add_text(text="Label", font_size=25, margin_top=-11, color=(0.2,1.0,0.6))

# Go to next line
label.br()
label.br()

# Add some more parts
label.add_text(text="This is the same label ..", color=(0.3,0.7,0.32))

# Go to next line
label.br()
label.br()

# Add some more parts
label.add_text(text="... but another line forced with ", color=(0.6,0.3,0.8))
label.add_text(text="br() ", color=(1.0,0.6,0.2))

label.br()


f.set_actions({
        # "Set Random Text": lambda: label.set_text(unicode(random.randint(100, 10000))),
        "Add random text": lambda: label.add_text(text="Text ", color=(random.random(), random.random(), random.random())),
        "Go to next line": lambda: label.br()
    })

run()
Exemplo n.º 15
0
from DemoFramework import DemoFramework
from LUIInputField import LUIInputField

import random

f = DemoFramework()
f.prepare_demo("LUIInputField")

# Constructor
f.add_constructor_parameter("value", "u''")
f.add_constructor_parameter("placeholder", "u'Enter some text ..'")
f.add_property("value", "string")
f.add_event("changed")

# Construct source code
f.construct_sourcecode("LUIInputField")

# Create 2 new buttons, and store them in a vertical layout
field = LUIInputField(parent=f.get_widget_node())

f.set_actions({
        "Set Random Text": lambda: field.set_value(u"Text: " + unicode(random.randint(100, 10000000))),
        "Clear": lambda: field.clear(),
    })

run()
Exemplo n.º 16
0
def setWidth(width):
    label.set_width(width)
    text_container.on_element_added()


def setWrap(wrap):
    label.set_wrap(wrap)
    text_container.on_element_added()


f.set_actions({
    "Set Random Text":
    lambda: label.set_text(str(random.randint(100, 10000))),
    "Set Random Color":
    lambda: label.set_color(
        (random.random(), random.random(), random.random(), 1)),
    "Clear":
    lambda: label.clear(),
    "Smaller":
    lambda: setWidth(200),
    "Larger":
    lambda: setWidth(310),
    "Wrapping on":
    lambda: setWrap(True),
    "Wrapping off":
    lambda: setWrap(False),
})

base.run()
Exemplo n.º 17
0
import random

f = DemoFramework()
f.prepare_demo("LUICheckbox")

# Constructor
f.add_constructor_parameter("checked", "False")
f.add_constructor_parameter("label", "'Checkbox'")

# Functions
f.add_public_function("get_checked", [], "bool")
f.add_public_function("toggle_checked", [], "bool")
f.add_public_function("set_checked", [("checked", "bool")])
f.add_public_function("get_label", [], "UILabel")

# Events
f.add_event("changed")
f.construct_sourcecode("LUICheckbox")

# Create the checkbox
checkbox = LUICheckbox(parent=f.get_widget_node())

f.set_actions({
        "Set Checked": lambda: checkbox.set_checked(True),
        "Set Unchecked": lambda: checkbox.set_checked(False),
        "Toggle Checked": lambda: checkbox.toggle_checked(),
        "Set Random Text": lambda: checkbox.get_label().set_text(unicode(random.randint(100, 10000))),
    })

run()
Exemplo n.º 18
0
# Constructor
f.add_constructor_parameter("filled", "False")
f.add_constructor_parameter("min_value", "0.0")
f.add_constructor_parameter("max_value", "0.0")
f.add_constructor_parameter("value", "None")

# Functions
f.add_public_function("get_value", [], "float")
f.add_public_function("set_value", [("value", "float")])

f.add_property("value", "float")

# Events
f.add_event("changed")
f.construct_sourcecode("LUISlider")

# Create the checkbox
layout = LUIVerticalLayout(parent=f.get_widget_node(), spacing=10)

LUILabel(parent=layout.cell(), text="This is a filled slider:", color=(1, 1, 1, 0.4))
slider = LUISlider(parent=layout.cell(), width=200.0)

LUILabel(parent=layout.cell(), text="This is a regular slider:", color=(1, 1, 1, 0.4))
slider_nofill = LUISlider(parent=layout.cell(), width=200.0, filled=False)

f.set_actions({
        "Set to 30%": lambda: slider.set_value(0.3),
    })

run()
Exemplo n.º 19
0
# Constructor

f.add_constructor_parameter("text", "Label")
f.add_constructor_parameter("shadow", "True")
f.add_constructor_parameter("font_size", "14")
f.add_constructor_parameter("font", "'label'")

# Functions
f.add_public_function("get_text", [], "string")
f.add_public_function("set_text", [("text", "string")])

f.add_property("text", "string")
f.add_property("text_handle", "LUIText")

# Events
f.construct_sourcecode("LUILabel")

# Create a new label
label = LUILabel(parent=f.get_widget_node(), text="This is a fancy label")

f.set_actions({
    "Set Random Text":
    lambda: label.set_text(str(random.randint(100, 10000))),
    "Set Random Color":
    lambda: label.set_color(random.random(), random.random(), random.random(),
                            1)
})

run()
Exemplo n.º 20
0
)

# Paragraph with no spaces or linebreaks
label.add(
	text='''Loremipsumolorsitamet,consecteturadipiscingelit.Sedmalesuadasitameteratnongravida.PellentesquesitametcursusrisusSedegestas,nullaintemporcursus,antefeliscursusmagna,necvehiculanisinullaeunulla.''',
	color=(0.9,0.9,.9),
	wordwrap=True,
	padding=5,
)

def setWidth(width):
	label.set_width(width)
	text_container.on_element_added()

def setWrap(wrap):
	label.set_wrap(wrap)
	text_container.on_element_added()


f.set_actions({
        "Set Random Text": lambda: label.set_text(unicode(random.randint(100, 10000))),
        "Set Random Color": lambda: label.set_color((random.random(), random.random(), random.random(), 1)),
        "Clear": lambda: label.clear(),
        "Smaller": lambda: setWidth(200),
        "Larger": lambda: setWidth(310),
        "Wrapping on": lambda: setWrap(True),
        "Wrapping off": lambda: setWrap(False),
    })

base.run()