def __init__(self, parent, controller: ControllerTwo): self._controller = controller super().__init__(parent, controller) self._text = Text( "This is text that changes as a result of an event happening") # self._controller.add_task(self._controller.add_to_log.subscribe(self._add_to_log)) self.controller.add_to_log.publish += self._add_to_log self._callback_text = Text("Nothing selected yet")
def populate(self): """Populate this view.""" with self.add(Section("Min width")) as grp: with grp.add(Grid()) as grd: grd.add(Text("This is a text exceeding 80 min size", min_width=80)) grd.add(Text("Other text.")) with grp.add(Grid()) as grd: grd.add(Text("text < 80", min_width=80)) grd.add(Text("Other text."))
def __init__(self, parent: wx.Panel, controller: Controller): super().__init__(parent, controller) self.scanner_view = ScannerView(parent=self.ui_item, width=650, height=480) self.add(self.scanner_view, create=False) self.add(AioButton("start", self._on_start)) # type: ignore self.add(AioButton("stop", self._on_stop)) # type: ignore self.add(Text(binding=self.bind("scan_result")))
def init(self, parent): super().init(parent) if self.align_right: hor_alignment = HorAlign.right else: hor_alignment = None self.add( Text(self.label_text), weight=self._label_weight, hor_align=hor_alignment, ver_align=VerAlign.center, ) self.add(self._item, weight=self._item_weight, hor_align=self._item_alignment)
def populate(self): """Populate this view.""" self.splitter_window_one.add(Entry(binding=self.bind("value_1")), margin=20) # Use a context manager for container types like a group or grid. # A group is a container with a label and a sizer inside. Inside # this sizer widgets, or other containers can be placed. with self.splitter_window_one.add( Group("A labelled container.")) as group: # group.add(Text(text="A horizontal grid.")) with group.add(Grid()) as grd: # the binding binds to an attribute defined in the controller # the weight determines how much space a specific item should consume # with respect to the other members of the container. grd.add(Entry(binding=self.bind("value_1")), weight=3, margin=3) grd.add(Entry(binding=self.bind("value_1")), weight=1, margin=3) grd.add(Entry(binding=self.bind("value_1")), weight=1, margin=3) with self.add(Group("Any text entry.")) as group: group.add( Entry(binding=Binding(self._controller, "a_string_value"))) group.add( Entry(binding=Binding(self._controller, "a_string_value"))) with self.add(Grid()) as grd: grd.add(AioButton("button one", self._set_value), weight=6) grd.add(AioButton("button two,self", self._set_value), weight=6) self.add(Text(_LONG_TEXT, wrap=True)) with self.add(Grid()) as grd: grd.add(AioButton("toggle", self._toggle)) self._btn = grd.add( AioButton("toggle", self._toggle, enabled=self.bind("ready"))) grd.add(Entry(self.bind("bound_text"), enabled=self.bind("ready"))) self._set_split_button_text()
def populate(self): with self.add(Section("Labelled items.")) as sec: sec.add(Text("default labelled item:")) sec.add( LabelledItem( "Item", Select( self.controller.choices, on_select_callback=self._on_select_callback, ), )) l_item = LabelledItem( "Item", Select(self._controller.choices, binding=self.bind("selected_item")), align_right=False, ) sec.add(Text(str(l_item))) sec.add(l_item) l_item = LabelledItem( "Item", Select(self._controller.choices, binding=self.bind("selected_item")), item_weight=2, ) sec.add(Text(str(l_item))) sec.add(l_item) l_item = LabelledItem( "Item", Select(self._controller.choices, binding=self.bind("selected_item")), item_weight=2, item_alignment=HorAlign.left, ) sec.add(Text(str(l_item))) sec.add(l_item) with self.add(Section("Selectable, bound to None")) as sec: sec.add( Select(self._controller.choices, binding=self.bind("selected_item2"))) sec.add(Text(binding=self.bind("selected_item2"))) self.add( Entry(binding=Binding(self._controller, "value_1")), margin=(10, 10, 5, 20), ) self.add(Entry(binding=Binding(self._controller, "value_1"))) self.add( AioButton("test button with normal function as callback", self._press), margin=(10, 10, 5, 20), ) self.add(self._text) # It is possible to add bare wx-python widgets. self.add(wx.StaticLine(parent=self.ui_item), create=False) with self.add(Grid()) as grd: grd.add( Text("This is a selection dropdown"), weight=4, hor_align=HorAlign.right, ) with grd.add(Grid(orientation=VERTICAL), weight=6) as grd: grd.add( Select( self.controller.choices, on_select_callback=self._on_select_callback, binding=self.bind("selected_item"), ), hor_align=HorAlign.left, ) grd.add(Text("Selection based on callback:")) grd.add(self._callback_text) grd.add(Text("Selection based on binding value:")) grd.add(Text(binding=self.bind("selected_item")))
def populate(self): """Populate this view.""" # self.add(BulletText("this is stupid text.")) # with self.add(FixedGrid()) as grd: # grd.add(Text("This is text")) # grd.add(Text("this is other text")) # grd.add(Text("This is text")) # # with self.add(FixedGrid(), weight=1, margin=0) as fixed: # fixed.add(Text("Col1")) # fixed.add(Text("col2")) # fixed.add(Image(IMAGE_FOLDER / "phoenix_main.png")) # # with self.add(Group("label")) as group: # group.add(Text(binding=self.bind("int_val"), wrap=True), margin=20) # # with group.add(Group("other group")) as grp: # # grp.add(Text(text="more text")) # # with group.add(Section("section inside group")) as sec: # # sec.add(Text(text="section inside group")) # # with group.add(Grid(orientation=Grid.VER),weight=1) as grd: # # grd.add(Text("This is long text", min_width=50)) # # grd.add(Text("short", min_width=50)) # # self.add( # LabelledItem( # "Label text", # Entry(binding=self.bind("float_val"), validator=float_validator), # ) # ) # # with self.add(Section("Float validators")) as sc: # sc.add( # LabelledItem( # "Enter a float value", # Entry(binding=self.bind("float_val"), validator=float_validator,), # item_weight=2, # ) # ) # with sc.add(Grid()) as grd: # # the binding binds to an attribute defined in the controller # # the weight determines how much space a specific item should consume # # with respect to the other members of the container. # # grd.add( # Entry(binding=self.bind("float_val"), validator=float_validator,), # weight=4, # ) # grd.add( # Text(binding=self.bind("float_val")), # weight=4, # ver_align=VerAlign.center, # ) # with self.add(Section("Int validators")) as sc: # sc.add(Text("Only integer values are allowed.")) # with sc.add(Grid()) as grd: # grd.add( # Entry(binding=self.bind("int_val"), validator=int_validator,), # weight=3, # margin=0, # ) # grd.add( # Entry(binding=self.bind("int_val"), validator=int_validator,), # weight=1, # margin=0, # ) # grd.add(Text(binding=self.bind("int_val")), weight=1, margin=0) # # with self.add(Section("Bindings")) as sec: # with sec.add(Grid()) as grd: # grd.add( # Text( # "Use a converter with a binding to bind different types " # "of properties. Bind a color to a boolean using a converter.", # wrap=True, # ), # weight=1, # ) # with grd.add(Grid(), weight=1) as grd1: # grd1.add(CheckBox("RED", self.bind("color_red"))) # grd1.add( # Text( # text="This is text with a color binding", # color=self.bind("color_red", converter=_bool_to_color), # ) # ) # with sec.add(Grid()) as grd: # grd.add( # Text("Bind to the enabled property of a widget."), # weight=1, # ver_align=VerAlign.center, # ) # with grd.add(Grid(), weight=1) as items: # btn = items.add(AioButton("toggle", self._toggle)) # print(btn.ui_item.Parent) # items.add( # AioButton("toggle", self._toggle, enabled=self.bind("ready")) # ) # items.add( # Entry(self.bind("a_string_value"), enabled=self.bind("ready")) # ) # with self.add(Grid()) as grd: # grd.add(Entry(binding=Binding(self._controller, "a_string_value"))) # grd.add(Entry(binding=Binding(self._controller, "a_string_value"))) # # with self.add(Grid()) as grd: # grd.add(AioButton("button one", self._set_value), weight=6) # grd.add(AioButton("button two,self", self._set_value), weight=6) # # with self.add(Section("Layout")) as grp: # with grp.add(Grid()) as grd: # grd.add( # Text(text="Widget, right & center alignment"), # weight=3, # hor_align=HorAlign.right, # ver_align=VerAlign.center, # ) # with grd.add(Grid(VERTICAL), weight=6, margin=0) as vert_grid: # vert_grid.add( # AioButton("Left aligned button", self._set_value), # hor_align=HorAlign.left, # margin=4, # ) # vert_grid.add( # AioButton( # "No Aligned widget (button in this case)", self._set_value # ) # ) # vert_grid.add( # Text(text="Center aligned widget with a large margin."), # margin=(10, 10, 30, 5), # hor_align=HorAlign.center, # ) # vert_grid.add( # Text( # text="Text widget with centered text", # hor_align=Text.HOR_CENTER, # ) # ) # vert_grid.add( # AioButton( # "right aligned button.", # self._set_value, # enabled=self.bind("a_checkbox_value"), # ), # weight=2, # hor_align=HorAlign.right, # ) with self.add(Section("Min width")) as grp: with grp.add(Grid()) as grd: grd.add(Text("This is a text exceeding 80 min size")) grd.add(Text("Other text.")) with grp.add(Grid()) as grd: grd.add(Text("text < 80", min_width=80)) grd.add(Text("Other text.")) txt = wx.StaticText( parent=self.ui_item, label="A long label exceeding minwidth" ) with grp.add(Grid()) as grd: grd.add(txt, create=False) grd.add(Text("Other text.")) txt.SetMinSize(wx.Size(80, -1)) # self.add(CheckBox("A checkbox", binding=self.bind("a_checkbox_value"))) # self.add( # CheckBox("The same checkbox value", binding=self.bind("a_checkbox_value")) # ) self.add(AioButton("open other window", self._on_open_second_window)) self.add(AioButton("open third window", self._on_open_third_window)) self.add( AioButton("open text wrapping window", self._on_open_text_wrapping_window) ) self.add(AioButton("Open image view", self._on_open_image_view))