# 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()
# 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()
# 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()
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()
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()
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()
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, "*") self.bind("expose", self.on_expose) self.bind("unexpose", self.on_unexpose) 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() return header def _find_header_index(self, header): for idx, child in enumerate(self.header_bar.children): if any([grandchild == header for grandchild in child.children]): break else: raise ValueError("Given object is not a header bar item.") return idx def remove(self, header): idx = self._find_header_index(header) 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 def _change_to_tab(self, lui_event): header = lui_event.sender if self.current_frame is not None: self.current_frame.trigger_event("unexpose") self.current_frame.hide() self.current_frame = self.header_to_frame[header] self.current_frame.show() self.current_frame.trigger_event("expose") def on_expose(self, event): self.current_frame.trigger_event("expose") def on_unexpose(self, event): self.current_frame.trigger_event("unexpose")
# 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()
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, "*") self.bind("expose", self.on_expose) self.bind("unexpose", self.on_unexpose) 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() return header def _find_header_index(self, header): for idx, child in enumerate(self.header_bar.children): if any([grandchild == header for grandchild in child.children]): break else: raise ValueError("Given object is not a header bar item.") return idx def remove(self, header): idx = self._find_header_index(header) 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 def _change_to_tab(self, lui_event): header = lui_event.sender if self.current_frame is not None: self.current_frame.trigger_event("unexpose") self.current_frame.hide() self.current_frame = self.header_to_frame[header] self.current_frame.show() self.current_frame.trigger_event("expose") def on_expose(self, event): self.current_frame.trigger_event("expose") def on_unexpose(self, event): self.current_frame.trigger_event("unexpose")