Exemplo n.º 1
0
    def __init__(self):
        ShowBase.__init__(self)

        # Construct a new LUIRegion
        region = LUIRegion.make("LUI", base.win)

        # Construct a new InputHandler to catch and process events
        handler = LUIInputHandler()
        base.mouseWatcher.attach_new_node(handler)
        region.set_input_handler(handler)

        # Load the default LUI skin
        skin = LUIDefaultSkin()
        skin.load()

        # LUI is initialized now, so we can start adding elements, for example:
        button = LUIButton(parent=region.root,
                           text="Hello world!",
                           top=30,
                           left=30)
Exemplo n.º 2
0
    def prepare_demo(self, demo_title=u"Some Demo"):

        # Background
        self._background = LUISprite(self._root, "res/DemoBackground.png")
        # Make the background solid and recieve events
        self._background.solid = True

        # Logo
        self._logo = LUISprite(self._root, "res/LUILogo.png")
        self._logo.top_left = 15, 20

        # Title
        self._title_label = LUILabel(parent=self._root,
                                     text=demo_title,
                                     font_size=40,
                                     font="header",
                                     pos=(120, 27))
        self._subtitle_label = LUILabel(parent=self._root,
                                        text="Widget Demo",
                                        font_size=14,
                                        font="default",
                                        pos=(121, 70),
                                        alpha=0.3)

        # Right bar

        self._right_bar = LUIVerticalLayout(parent=self._root)
        self._left_bar = LUIVerticalLayout(parent=self._root)
        self._right_bar.width = 350
        self._right_bar.pos = (410, 120)
        self._right_bar.spacing = 10
        self._left_bar.width = 350
        self._left_bar.pos = (20, 120)
        self._left_bar.spacing = 10

        # Public functions
        self._public_functions = LUIFrame(width=340, style=LUIFrame.FS_sunken)
        self._functions_label = LUILabel(text=U"Additional Public functions")
        self._functions_layout = LUIVerticalLayout(
            parent=self._public_functions)
        self._functions_layout.add(self._functions_label, 30)

        # Events
        self._events = LUIFrame(width=340, style=LUIFrame.FS_sunken)
        self._events_label = LUILabel(text=U"Additional Events")
        self._events_layout = LUIVerticalLayout(parent=self._events)
        self._events_layout.add(self._events_label, 30)

        # Actions
        self._actions = LUIFrame(width=340, style=LUIFrame.FS_sunken)
        self._actions_label = LUILabel(parent=self._actions,
                                       text=U"Demo-Actions")
        self._actions_select = LUISelectbox(parent=self._actions,
                                            width=225,
                                            top=30)
        self._actions_btn = LUIButton(parent=self._actions,
                                      right=0,
                                      top=30,
                                      text=u"Execute",
                                      template="ButtonGreen")
        self._actions_btn.bind("click", self._exec_action)

        # Properties
        self._properties = LUIFrame(width=340, style=LUIFrame.FS_sunken)
        self._properties_label = LUILabel(text=u"Additional Properties")
        self._properties_layout = LUIVerticalLayout(parent=self._properties)
        self._properties_layout.add(self._properties_label, 30)

        self._right_bar.add(self._actions)
        self._right_bar.add(self._public_functions)
        self._right_bar.add(self._properties)
        self._right_bar.add(self._events)

        # Widget
        self._widget_container = LUIFrame(width=360,
                                          height=250,
                                          style=LUIFrame.FS_sunken)
        self._widget_label = LUILabel(parent=self._widget_container,
                                      text=u"Widget Demo")
        self._left_bar.add(self._widget_container)

        # Source Code
        self._source_container = LUIFrame(width=360,
                                          height=190,
                                          style=LUIFrame.FS_sunken)
        self._source_label = LUILabel(parent=self._source_container,
                                      text=u"Default Constructor")
        self._copy_code_button = LUIButton(parent=self._source_container,
                                           text=u"Copy to Clipboard",
                                           template="ButtonGreen",
                                           bottom_right=(0, 0))
        self._source_content = LUIObject(self._source_container)
        self._source_content.top = 40
        self._left_bar.add(self._source_container)

        self._widget_node = LUIObject(self._widget_container, x=0, y=40)
Exemplo n.º 3
0
# label_tl = LUILabel(parent=container, text="Top Left", top_left=(0,0))
# label_tr = LUILabel(parent=container, text="Top Right", top_right=(0,0))
# label_bl = LUILabel(parent=container, text="Bottom Left", bottom_left=(0,0))
# label_br = LUILabel(parent=container, text="Bottom Right", bottom_right=(0,0))

# button = LUIButton(parent=container, top_left=(0, 0), text="Well this one .. is a long button! (A really long one!) ............ really long!")
# button.bind("click", lambda event: button.set_text("Hello!"))
container.size = 300, 300
# group = LUIRadioboxGroup()
# box = LUIRadiobox(parent=container, group=group, top=50)
# box2 = LUICheckbox(parent=container, top=100)

layout = LUIVerticalLayout(parent=container)
# layout.height = 280
# layout.width = 300

LUILabel(parent=layout.cell(), text="Hello")
LUILabel(parent=layout.cell(), text="World")
LUILabel(parent=layout.cell(100), text="100px row")
LUILabel(parent=layout.cell(), text="Next")
LUIButton(parent=layout.cell(), text="SomeButton")
LUILabel(parent=layout.cell('*'), text="Fill column")
LUILabel(parent=layout.cell(), text="Last column")

for i in range(5):
    base.graphicsEngine.render_frame()

region.root.ls()

s.run()
Exemplo n.º 4
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.º 5
0
    def __init__(self, parent=None):
        LUIPopup.__init__(self, parent=parent, width=240, height=146)
        LUICallback.__init__(self)

        self.field = LUIObject(self.content, x=0, y=0, w=128, h=128)

        self.fieldBG = LUISprite(self.field, "blank", "skin")
        self.fieldBG.size = (128, 128)
        self.fieldBG.color = (0.2, 0.6, 1.0)
        self.fieldFG = LUISprite(self.field, "ColorpickerFieldOverlay", "skin")
        self.fieldFG.pos = (-2, 0)

        self.fieldBG.bind("mousedown", self._start_field_dragging)
        self.fieldBG.bind("mouseup", self._stop_field_dragging)

        self.fieldHandle = LUISprite(self.field, "ColorpickerFieldHandle",
                                     "skin")
        self.fieldHandle.bind("mousedown", self._start_field_dragging)
        self.fieldHandle.bind("mouseup", self._stop_field_dragging)

        self.fieldDragging = False

        self.hueSlider = LUIObject(self.content, x=140, y=0, w=40, h=128)
        self.hueSliderFG = LUISprite(self.hueSlider, "ColorpickerHueSlider",
                                     "skin")

        self.hueHandle = LUISprite(self.hueSlider, "ColorpickerHueHandle",
                                   "skin")
        self.hueHandle.left = (self.hueSliderFG.width -
                               self.hueHandle.width) / 2.0
        self.hueHandle.top = 50

        self.hueDragging = False
        self.hueSlider.bind("mousedown", self._start_hue_dragging)
        self.hueSlider.bind("mouseup", self._stop_hue_dragging)

        self.labels = LUIVerticalLayout(self.content, width=40)
        self.labels.pos = (177, 42)

        colors = [u"R", u"G", u"B"]
        self.colorLabels = []

        for color in colors:
            label = LUILabel(text=color, shadow=True)
            label.color = (1, 1, 1, 0.3)

            valueLabel = LUILabel(text=u"255", shadow=True)
            valueLabel.right = 0
            self.labels.add(label, valueLabel)
            self.colorLabels.append(valueLabel)

        self.activeColor = LUIObject(self.content, x=177, y=0)
        self.activeColorBG = LUISprite(self.activeColor, "blank", "skin")
        self.activeColorFG = LUISprite(self.activeColor,
                                       "ColorpickerActiveColorOverlay", "skin")

        self.activeColorBG.size = (40, 40)
        self.activeColorBG.pos = (2, 0)
        self.activeColorBG.color = (0.2, 0.6, 1.0, 1.0)

        self.closeButton = LUIButton(parent=self.content,
                                     text=u"Done",
                                     width=45,
                                     template="ButtonGreen")
        self.closeButton.left = 177
        self.closeButton.top = 98
        self.closeButton.bind("click", self._close_popup)

        self._set_hue(0.5)
        self._set_sat_val(0.5, 0.5)

        self.widget = parent
Exemplo n.º 6
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()