Example #1
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()
Example #2
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()
Example #3
0
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.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()
Example #4
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()
Example #5
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()
Example #6
0
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),
})
Example #7
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()
Example #8
0
f.add_public_function("get_value", [], "object")
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()
import random

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

# Functions
f.add_public_function("clear", [], "void")
f.add_public_function("newline", [], "void")
f.add_public_function("add", [("*args", "List"), ("**kwargs", "Dict")])

# Events
f.construct_sourcecode("LUIFormattedLabel")

# Create a new label
label = LUIFormattedLabel(parent=f.get_widget_node())

# Add parts to the label
label.add(text="Hello ", color=(0.2,0.6,1.0))
label.add(text="World", color=(1.0,0.6,0.2))
label.add(text="! ")
label.add(text="This ", font_size=20, margin=(-6, 0, 0, 0), color=(0.4,0.2,1.0))
label.add(text="is ", color=(1.0,0.2,1.0))
label.add(text="a formatted ", font_size=10, color=(0.6,0.3,0.6))
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
Example #10
0
from DemoFramework import DemoFramework
from LUIButton import LUIButton

import random

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")])

# Events
f.construct_sourcecode("LUIButton")

# Create 2 new buttons
button1 = LUIButton(parent=f.get_widget_node(), text="Do not click me")
button2 = LUIButton(parent=f.get_widget_node(), text="Instead click me", template="ButtonMagic", left=button1.width + 10)



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

run()
Example #11
0
f.add_constructor_parameter("font_size", "14")
f.add_constructor_parameter("font", "'label'")

# Functions
f.add_public_function("clear", [])
f.add_public_function("set_text", [("text", "string")])
f.add_public_function("set_wrap", [("wrap", "boolean")])
f.add_public_function("set_width", [("width", "integer")])

f.add_property("labels", "list")

# Events
f.construct_sourcecode("LUIBlockText")

text_container = LUIScrollableRegion(
    parent=f.get_widget_node(),
    width=340,
    height=190,
    padding=0,
)

#TODO: Support newline through charcode 10
#TODO: If space causes next line, dont print it

# Create a new label
label = LUIBlockText(parent=text_container, width=310)

# Paragraph with no line breaks
label.add(
    text=
    '''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada sit amet erat non gravida.  Pellentesque sit amet cursus risus Sed egestas, nulla in tempor cursus, ante felis cursus magna, nec vehicula nisi nulla eu nulla.''',
Example #12
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()
Example #13
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()
Example #14
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()
Example #15
0
import random

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

# Functions
f.add_public_function("clear", [], "void")
f.add_public_function("newline", [], "void")
f.add_public_function("add", [("*args", "List"), ("**kwargs", "Dict")])

# Events
f.construct_sourcecode("LUIFormattedLabel")

# Create a new label
label = LUIFormattedLabel(parent=f.get_widget_node())

# Add parts to the label
label.add(text="Hello ", color=(0.2, 0.6, 1.0))
label.add(text="World", color=(1.0, 0.6, 0.2))
label.add(text="! ")
label.add(text="This ",
          font_size=20,
          margin=(-6, 0, 0, 0),
          color=(0.4, 0.2, 1.0))
label.add(text="is ", color=(1.0, 0.2, 1.0))
label.add(text="a formatted ", font_size=10, color=(0.6, 0.3, 0.6))
label.add(text="Label",
          font_size=25,
          margin=(-11, 0, 0, 0),
          color=(0.2, 1.0, 0.6))
Example #16
0
f.add_constructor_parameter("font_size", "14")
f.add_constructor_parameter("font", "'label'")

# Functions
f.add_public_function("clear", [])
f.add_public_function("set_text", [("text", "string")])
f.add_public_function("set_wrap", [("wrap", "boolean")])
f.add_public_function("set_width", [("width", "integer")])

f.add_property("labels", "list")

# Events
f.construct_sourcecode("LUIBlockText")

text_container = LUIScrollableRegion(
	parent=f.get_widget_node(),
	width=340,
	height=190,
    padding=0,
)

#TODO: Support newline through charcode 10
#TODO: If space causes next line, dont print it

# Create a new label
label = LUIBlockText(parent=text_container, width=310)

# Paragraph with no line breaks
label.add(
	text='''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada sit amet erat non gravida.  Pellentesque sit amet cursus risus Sed egestas, nulla in tempor cursus, ante felis cursus magna, nec vehicula nisi nulla eu nulla.''',
	color=(0.9,0.9,.9),