Esempio n. 1
0
class LUITabbedFrame(LUIFrame):
    def __init__(self, **kwargs):
        super(LUITabbedFrame, self).__init__(**kwargs)

        # The main window layout
        bar_spacing = kwargs.get('bar_spacing', 3)
        self.root_layout = LUIVerticalLayout(parent=self, spacing=bar_spacing)
        self.root_layout.height = "100%"
        self.root_layout.width = "100%"
        self.root_layout.margin = 0

        # The header bar
        header_spacing = kwargs.get('header_spacing', 3)
        self.header_bar = LUIHorizontalLayout(
            parent=self.root_layout.cell("?"), spacing=header_spacing)
        self.root_layout.add(self.header_bar, "?")
        self.header_to_frame = {}
        self.current_frame = None

        # The main window contents
        self.main_frame = LUIObject()
        self.main_frame.height = "100%"
        self.main_frame.width = "100%"
        self.main_frame.margin = 0
        # self.main_frame.padding = 0
        self.root_layout.add(self.main_frame, "*")

    def add(self, header, frame):
        # header
        if isinstance(header, str):
            header = LUILabel(text=header)
        self.header_bar.add(header, "?")
        self.header_to_frame[header] = frame
        header.solid = True
        header.bind("click", self._change_to_tab)
        # Frame
        frame.parent = self.main_frame
        frame.width = "100%"
        frame.height = "100%"
        # Put frame in front
        if self.current_frame is None:
            self.current_frame = frame
            self.current_frame.show()
        else:
            frame.hide()

    #def remove(self, header):
    #    if header in self.header_to_frame.keys():
    #        idx_dict = {idx: elem
    #                    for idx, elem in zip(range(self.header_bar.child_count),
    #                                         self.header_bar.children)}
    #        idx = idx_dict[header]
    #        print(idx)
    #        self.header_bar.remove_cell(idx)
    #        frame = self.header_to_frame[header]
    #        frame.parent = None
    #        del self.header_to_frame[header]
    #        if self.current_frame == frame:
    #            self.current_frame = None
    #        return True
    #    else:
    #        return False

    def _change_to_tab(self, lui_event):
        header = lui_event.sender
        if self.current_frame is not None:
            self.current_frame.hide()
        self.current_frame = self.header_to_frame[header]
        self.current_frame.show()
Esempio n. 2
0
# 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()
Esempio 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()