示例#1
0
    def __init__(self, interpreter):
        self.interpreter = interpreter
        self.history_objects = []

        skin = LUIDefaultSkin()
        skin.load()

        region = LUIRegion.make("LUI", base.win)
        handler = LUIInputHandler()
        base.mouseWatcher.attach_new_node(handler)
        region.set_input_handler(handler)

        self.console_frame = LUIFrame(
            parent=region.root,
            pos=(0, 0),
            width=base.win.get_x_size() - 10,
            height=base.win.get_y_size() * 0.75,
            style=LUIFrame.FS_raised,
            #style = LUIFrame.FS_sunken,
            margin=(5, 5, 5, 5),
        )
        console = LUIVerticalLayout(parent=self.console_frame, spacing=3)
        #console.use_dividers = True
        console.margin = (0, 0, 0, 0)
        console.width = self.console_frame.width

        self.history_region = LUIScrollableRegion(margin=0,
                                                  width=console.width - 10)
        console.add(self.history_region)
        self.history = LUIVerticalLayout(
            parent=self.history_region.content_node, spacing=2)
        self.history.margin = (0, 0, 0, 0)
        self.history.width = self.history_region.width

        self.command_line = LUIInputField(width=console.width - 10)
        console.add(self.command_line)
        self.command_line.bind("tab", self.tab)
        self.command_line.bind("enter", self.enter)
        self.command_line.bind("control-c", self.copy)
        self.command_line.bind("control-v", self.paste)
        self.command_line.bind("control-x", self.cut)
        self.command_line.bind("control-u", self.kill_to_start)
        self.command_line.bind("control-k", self.kill_to_end)
        self.command_line.bind("control-l", self.kill_line)
示例#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)
示例#3
0
    base.win.set_clear_color(Vec4(0.1, 0.0, 0.0, 1))

skin.load()

# Initialize LUI
region = LUIRegion.make("LUI", base.win)
handler = LUIInputHandler()
base.mouseWatcher.attach_new_node(handler)
region.set_input_handler(handler)

# Title
title_label = LUILabel(parent=region.root, text="LUI Console Example", font_size=40,
                       font="header", pos=(25, 17))

# Container
container = LUIFrame(parent = region.root, width=700, height=500,
    style=LUIFrame.FS_sunken, margin=30, top=50)

text_container = LUIScrollableRegion(parent=container, width=675, height=440,
    padding=0)

base.win.set_clear_color(Vec4(0.1, 0.1, 0.1, 1.0))
layout = LUIVerticalLayout(parent=text_container.content_node)

def send_command(event):
    """ Called when the user presses enter in the input field, submits the
    command and prints something on the console """
    label = LUIFormattedLabel()
    color = (0.9, 0.9, 0.9, 1.0)
    if event.message.startswith(u"/"):
        color = (0.35, 0.65, 0.24, 1.0)
    label.add(text=">>>  ", color=(0.35, 0.65, 0.24, 1.0))
示例#4
0
base.win.set_clear_color(Vec4(0.05, 0.05, 0.05, 1.0))

skin = LUIDefaultSkin()
skin.load()

region = LUIRegion.make("LUI", base.win)
handler = LUIInputHandler()
base.mouseWatcher.attach_new_node(handler)
region.set_input_handler(handler)

# bg = LUISprite(region.root, "blank", "skin")
# bg.pos = 200, 200
# bg.size = 200, 300

container = LUIFrame(parent=region.root,
                     pos=(200, 200),
                     height=300,
                     style=LUIFrame.FS_sunken)

# 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)
示例#5
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()