コード例 #1
0
 def add_radiobuttons(self, options, default_value=None, layout=[100], layout_index=0, add_divider=True, **kwargs):
     _layout = Layout(layout)
     self.add_layout(_layout)
     radiobuttons_widget = RadioButtons(options, **kwargs)
     _layout.add_widget(radiobuttons_widget, layout_index)
     if add_divider:
         _layout.add_widget(Divider(draw_line=False))
     if default_value is not None:
         radiobuttons_widget._value = default_value
     return lambda: radiobuttons_widget.value
コード例 #2
0
 def __init__(
     self,
     options: List[Tuple[str, int]],
     label: Optional[str] = None,
     name: Optional[str] = None,
     on_change: Optional[Callable] = None,
     **kwargs: Any,
 ):
     RadioButtons.__init__(self, options, label=label, name=name, on_change=on_change, **kwargs)
     self._value = self._options[self._selection][1]
コード例 #3
0
    def __init__(self, screen, frame_type, frame_data):
        super(CommonSettingsFrame, self).__init__(screen, frame_type,
                                                  frame_data)

        self._layout.add_widget(Label("VM count:", height=2), 1)
        self._layout.add_widget(
            RadioButtons([("Single VM", 1), ("2 VMs", 2), ("3 VMs", 3)],
                         name="vm_count"), 1)

        self._layout.add_widget(Divider(height=1, draw_line=False), 1)
        self._layout.add_widget(Label("Additional options:", height=2), 1)

        self._layout.add_widget(
            CheckBox("Add local YAML config", name="add_config"), 1)
        self._layout.add_widget(Divider(height=1, draw_line=False), 1)

        self._layout.add_widget(
            CheckBox("Require 'vagrant-vbguest' plugin",
                     name="require_vagrant_vbguest"), 1)
        self._layout.add_widget(Divider(height=1, draw_line=False), 1)

        self._add_intnet_checkbox = CheckBox(
            "Add VirtualBox internal network",
            name="add_vb_intnet",
            on_change=self._on_add_intnet_change)
        self._layout.add_widget(self._add_intnet_checkbox, 1)
        self._intnet_name_edit = Text(
            # label="Network name:",
            name="intnet_name")
        # self._intnet_name_edit.offset = 5
        self._layout.add_widget(self._intnet_name_edit, 1)
        # self._layout.add_widget(Divider(height=1, draw_line=False), 1)

        self.data = frame_data.controls_data
        self.fix()
コード例 #4
0
ファイル: forms.py プロジェクト: ulthiel/PicoScope
 def __init__(self, screen):
     super(DemoFrame, self).__init__(screen,
                                     int(screen.height * 2 // 3),
                                     int(screen.width * 2 // 3),
                                     data=form_data,
                                     has_shadow=True,
                                     name="My Form")
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     self._reset_button = Button("Reset", self._reset)
     layout.add_widget(Label("Group 1:"), 1)
     layout.add_widget(TextBox(5,
                               label="My First Box:",
                               name="TA",
                               on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Alpha:",
              name="TB",
              on_change=self._on_change,
              validator="^[a-zA-Z]*$"), 1)
     layout.add_widget(
         Text(label="Number:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$"), 1)
     layout.add_widget(
         Text(label="Email:",
              name="TD",
              on_change=self._on_change,
              validator=self._check_email), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(RadioButtons([("Option 1", 1),
                                     ("Option 2", 2),
                                     ("Option 3", 3)],
                                    label="A Longer Selection:",
                                    name="Things",
                                    on_change=self._on_change), 1)
     layout.add_widget(CheckBox("Field 1",
                                label="A very silly long name for fields:",
                                name="CA",
                                on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(DatePicker("Date",
                                  name="DATE",
                                  year_range=range(1999, 2100),
                                  on_change=self._on_change), 1)
     layout.add_widget(
         TimePicker("Time", name="TIME", on_change=self._on_change, seconds=True), 1)
     layout.add_widget(Text("Password", name="PWD", on_change=self._on_change, hide_char="*"), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
コード例 #5
0
ファイル: main.py プロジェクト: makoki13/botsclash
    def __init__(self, screen):
        super(DemoFrame2, self).__init__(screen,
                                         int(screen.height * 0.95),
                                         int(screen.width * 0.9),
                                         data=form_data,
                                         has_shadow=True,
                                         name="My Form")
        #layout = Layout([1, 18, 1])
        #self.add_layout(layout)
        layout = Layout([1, 3])
        self.add_layout(layout)

        layout.add_widget(Button("Añadir personaje", self._quit), 0)
        layout.add_widget(Button("Borrar personaje ", self._quit), 0)
        layout.add_widget(Button("Editar personaje", self._quit), 0)
        layout.add_widget(Button("Testear personajes", self._quit), 0)
        layout.add_widget(Button("Salir", self._quit), 0)

        self._reset_button = Button("Añadir personaje", self._reset)
        #layout.add_widget(self._reset_button, 0)
        #layout.add_widget(Button("Salir", self._quit), 0)

        layout.add_widget(
            Text(label="Alpha:",
                 name="TB",
                 on_change=self._on_change,
                 validator="^[a-zA-Z]*$"), 1)
        layout.add_widget(
            Text(label="Number:",
                 name="TC",
                 on_change=self._on_change,
                 validator="^[0-9]*$"), 1)
        layout.add_widget(
            Text(label="Email:",
                 name="TD",
                 on_change=self._on_change,
                 validator=self._check_email), 1)
        layout.add_widget(Divider(height=2), 1)
        layout.add_widget(Label("Group 2:"), 1)
        layout.add_widget(
            RadioButtons([("Option 1", 1), ("Option 2", 2), ("Option 3", 3)],
                         label="A Longer Selection:",
                         name="Things",
                         on_change=self._on_change), 1)
        layout.add_widget(
            CheckBox("Field 1",
                     label="A very silly long name for fields:",
                     name="CA",
                     on_change=self._on_change), 1)
        layout.add_widget(
            CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
        layout.add_widget(
            CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
        layout.add_widget(Divider(height=3), 1)
        layout2 = Layout([1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(self._reset_button, 0)
        layout2.add_widget(Button("View Data", self._view), 1)
        layout2.add_widget(Button("Quit", self._quit), 2)
        self.fix()
コード例 #6
0
ファイル: ascii.py プロジェクト: rybnik/misp-takedown
 def __init__(self, screen):
     self.screen = screen
     super(DemoFrame, self).__init__(
         screen,
         int(screen.height),
         int(screen.width),
         data=form_data,
         has_shadow=True,
         has_border=True,
         name="My Form",
         x=0,
         y=0,
     )
     layout = Layout([1], fill_frame=False)
     self.add_layout(layout)
     self._reset_button = Button("Reset", self._reset)
     title = "MISP Event #{} ({}):".format(args.event, event_tag)
     layout.add_widget(
         Text(label=title, name="ENA", on_change=self._on_change), 0)
     layout.add_widget(Divider(height=1), 0)
     layout1 = Layout([1, 1], fill_frame=False)
     self.add_layout(layout1)
     layout1.add_widget(
         RadioButtons([("Malicious files hosted", 1),
                       ("Compromised server", 2)],
                      label="Templates",
                      name="template",
                      on_change=self._on_change), 0)
     dryruntext = "Dry-run (all mails to %s)" % override_email
     layout1.add_widget(
         CheckBox(dryruntext, name="dryrun", on_change=self._on_change), 1)
     onlinechecktext = "Verify resource (online and size > %s bytes)" % min_size
     layout1.add_widget(
         CheckBox(onlinechecktext,
                  name="onlinecheck",
                  on_change=self._on_change), 1)
     layout2 = Layout([50, 50], fill_frame=True)
     self.add_layout(layout2)
     layout2.add_widget(Divider(height=1), 0)
     layout2.add_widget(Divider(height=1), 1)
     layout2.fix(0, 0, 0, 5)
     i = False
     for entry in urllist:
         if i is False:
             layout2.add_widget(
                 CheckBox(entry, name=entry, on_change=self._on_change), 0)
             i = True
         else:
             layout2.add_widget(
                 CheckBox(entry, name=entry, on_change=self._on_change), 1)
             i = False
     self.l = layout2
     layout4 = Layout([1, 1, 1])
     self.add_layout(layout4)
     layout4.add_widget(self._reset_button, 0)
     layout4.add_widget(Button("Quit", self._quit), 1)
     layout4.add_widget(Button("Process data", self._process), 2)
     self.fix()
コード例 #7
0
ファイル: dog.py プロジェクト: chafgames/writer
 def __init__(self, screen):
     super(DemoFrame, self).__init__(screen,
                                     screen.height,
                                     screen.width // 5,
                                     data=form_data,
                                     x=0,
                                     y=0,
                                     name="Side bar")
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     self._reset_button = Button("Reset", self._reset)
     layout.add_widget(Label("Group 1:"), 1)
     layout.add_widget(
         TextBox(5,
                 label="My First Box:",
                 name="TA",
                 on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Alpha:",
              name="TB",
              on_change=self._on_change,
              validator="^[a-zA-Z]*$"), 1)
     layout.add_widget(
         Text(label="Number:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$"), 1)
     layout.add_widget(
         Text(label="Email:",
              name="TD",
              on_change=self._on_change,
              validator=self._check_email), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(
         RadioButtons([("Option 1", 1), ("Option 2", 2), ("Option 3", 3)],
                      label="A Longer Selection:",
                      name="Things",
                      on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 1",
                  label="A very silly long name for fields:",
                  name="CA",
                  on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
コード例 #8
0
    def __init__(self, screen, model):
        super(FilterView, self).__init__(screen,
                                         screen.height * 2 // 3,
                                         screen.width * 2 // 3,
                                         hover_focus=True,
                                         title="Filters",
                                         reduce_cpu=True)
        self._model = model

        self.data["filter_finished"] = 0
        self.data["filter_due"] = 0
        self.data["filter_category"] = -2

        self._finished_rbutton = RadioButtons([("All", 0), ("Finished", 1),
                                               ("Unfinished", 2)],
                                              label="Finished:",
                                              name="filter_finished")
        self._due_rbutton = RadioButtons([("None", 0), ("Closest", 1),
                                          ("Farthest", 2)],
                                         label="Due Sort:",
                                         name="filter_due")
        self._category_ddlist = DropdownList([("ALL", -2), ("", -1)],
                                             label="Category:",
                                             name="filter_category")
        self._apply_button = Button("Apply", self._apply)
        self._back_button = Button("Back", self._back)

        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._finished_rbutton)
        layout.add_widget(Divider())
        layout.add_widget(self._due_rbutton)
        layout.add_widget(Divider())
        layout.add_widget(self._category_ddlist)
        layout.add_widget(Divider())

        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(self._apply_button, 0)
        layout2.add_widget(self._back_button, 3)

        self.fix()
コード例 #9
0
    def __init__(self, screen, interface):
        super(ValueOptions, self).__init__(screen,
                                           15,
                                           24,
                                           y=2,
                                           has_shadow=True,
                                           is_modal=True,
                                           name="valueopts",
                                           title="Value display",
                                           can_scroll=False)
        self.set_theme('shadowlands')
        self._interface = interface

        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(Divider(draw_line=False))

        self._node = self._interface.node

        options = []
        currencies = self._interface.price_poller.eth_prices
        for k in currencies.keys():
            options.append((k, k))

        #debug(); pdb.set_trace()

        radiobuttons = RadioButtons(options, name='valuepicker')

        # Set radiobox to match stored options
        for i, option in enumerate(options):
            if option[1] == self._interface._config.displayed_currency:
                radiobuttons._value = option[1]
                radiobuttons._selection = i

        layout.add_widget(radiobuttons)

        layout2 = Layout([1, 1])
        self.add_layout(layout2)

        layout2.add_widget(Button("Cancel", self._cancel), 1)
        layout2.add_widget(Button("Select", self._ok), 0)
        self.fix()
コード例 #10
0
 def __init__(self, screen, has_border=True, reduce_cpu=False):
     super(TestFrame, self).__init__(screen,
                                     screen.height,
                                     screen.width,
                                     name="Test Form",
                                     has_border=has_border,
                                     hover_focus=True,
                                     reduce_cpu=reduce_cpu)
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     self._reset_button = Button("Reset", self._reset)
     layout.add_widget(Label("Group 1:"), 1)
     layout.add_widget(
         TextBox(5,
                 label="My First Box:",
                 name="TA",
                 on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Text1:", name="TB", on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Text2:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$"), 1)
     layout.add_widget(
         Text(label="Text3:",
              name="TD",
              on_change=self._on_change,
              validator=lambda x: x in ("", "a")), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(
         RadioButtons([("Option 1", 1), ("Option 2", 2), ("Option 3", 3)],
                      label="A Longer Selection:",
                      name="Things",
                      on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 1",
                  label="A very silly long name for fields:",
                  name="CA",
                  on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
コード例 #11
0
    def __init__(self, screen, dirstat: DirectoryStat):
        super(TDirStatView, self).__init__(
            screen, screen.height, screen.width,
            has_border=True,
            name="My Form")
        # Model
        self.dirstat: DirectoryStat = dirstat
        self.disk_usage = shutil.disk_usage(str(self.dirstat.path)).used

        # Settings
        self.percent_mode = PercentMode.rel_to_dir

        # Create layouts
        layout_1 = Layout([1], fill_frame=True)
        layout_2 = Layout([1, 1])
        self.add_layout(layout_1)
        self.add_layout(layout_2)

        titles = [("Name", 0), ("%", "20>"), ("Size", "15>"), ("Items", "15>")]
        self._list = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            columns=[c[1] for c in titles],
            titles=[c[0] for c in titles],
            options=[],
            name="qdirstat_list",
            on_select=self.enter_directory,
            on_change=self.details)

        self._details = Text()
        self._details.disabled = True
        self._details.custom_colour = "field"

        percent_mode_radio_btn = RadioButtons(
            [("% Relative to Directory", PercentMode.rel_to_dir),
             ("% Relative to Drive", PercentMode.rel_to_drive_usage)],
            on_change=lambda: self.set_percent_mode(
                percent_mode_radio_btn.value))

        layout_1.add_widget(Label("TDirStat"))
        layout_1.add_widget(Divider())
        layout_1.add_widget(self._list)
        layout_1.add_widget(Divider())

        layout_2.add_widget(self._details, column=0)
        layout_2.add_widget(
            column=1,
            widget=percent_mode_radio_btn)

        layout_2.add_widget(Label("Press Enter to select or `q` to quit."))
        # Prepare the Frame for use
        self.fix()
コード例 #12
0
 def process_event(self, event: Event) -> Optional[Event]:
     if isinstance(event, KeyboardEvent):
         if event.key_code == Screen.KEY_UP and self._selection > 0:
             self._selection -= 1
             return None
         elif event.key_code == Screen.KEY_DOWN and self._selection < len(self._options) - 1:
             self._selection += 1
             return None
         elif event.key_code in [Screen.ctrl("M"), Screen.ctrl("J"), ord(" ")]:
             self._value = self._options[self._selection][1]
             return None
         return event
     else:
         return RadioButtons.process_event(self, event)
コード例 #13
0
    def __init__(self, screen, model, ui: UIController):
        super().__init__(screen,
                         height=screen.height // 2,
                         width=screen.width // 2,
                         can_scroll=False,
                         title="Add Command",
                         hover_focus=True)

        self._model: ModelInterface = model
        self._ui: UIController = ui
        self._theme = None
        self.set_theme(ui.theme)

        # Initialize Widgets
        self._confirm_button = Button("Confirm", self._confirm)
        self._cancel_button = Button("Cancel", self._cancel)
        self._ip_input = Text("IPs and/or subnet(s): ",
                              name="ips",
                              disabled=True)
        self._ip_input.value = self._model.current_machine
        self._command_type = RadioButtons([("Powershell", "ps"),
                                           ("DOS", "cmd"), ("Bash", "bash")],
                                          name="cmdtype",
                                          label="Command Type: ")
        # self._or = Text("OR", disabled=True)
        # self._hostname_input = Text("Hostname(s):", name="hostnames")
        self._command_input = TextBox(Widget.FILL_FRAME,
                                      label="Command(s): \n(one per line)",
                                      name="commands",
                                      line_wrap=True)

        # Create and Generate Layouts
        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._ip_input)
        layout.add_widget(self._command_type)
        # layout.add_widget(self._or)
        # layout.add_widget(self._hostname_input)
        layout.add_widget(Divider())
        layout.add_widget(self._command_input)
        layout.add_widget(Divider())

        button_layout = Layout([1, 1])
        self.add_layout(button_layout)
        button_layout.add_widget(self._confirm_button, 0)
        button_layout.add_widget(self._cancel_button, 1)

        # Save Layouts
        self.fix()
コード例 #14
0
    def __init__(self, screen):
        super(org_list_frame, self).__init__(
            screen,
            int(screen.height),
            int(screen.width),
            data=form_data,
            has_shadow=False,
            name="Org List",
            has_border=False,
            hover_focus=False,
        )

        layout = Layout([1, 18, 1])
        self.add_layout(layout)

        layout.add_widget(
            RadioButtons(
                options=org_options,
                label="Orgs List",
                name="radio",
                on_change=self._on_change,
            ),
            1,
        )

        layout.add_widget(Divider(height=3), 1)

        layout.add_widget(Text(label="Org Id", name="org_id", readonly=True), 1)
        layout.add_widget(Text(label="Username", name="username", readonly=True), 1)
        layout.add_widget(Text(label="Url", name="url", readonly=True), 1)
        layout.add_widget(
            Text(label="Access Token", name="access_token", readonly=True), 1
        )

        layout.add_widget(Divider(height=3), 1)

        layout2 = Layout([1, 1, 1])
        self.add_layout(layout2)

        layout2.add_widget(Button("Login", self.sf_login, name="login"), 0)
        layout2.add_widget(Button("(Q)uit", self._quit, name="quit"), 2)

        # self.set_theme("default")
        self.set_theme("bright")

        self.fix()
コード例 #15
0
 def __init__(self, screen):
     super(DemoFrame, self).__init__(screen,
                                     int(screen.height * 2 // 3),
                                     int(screen.width * 2 // 3),
                                     data=form_data,
                                     has_shadow=True,
                                     name="My Form")
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     self._reset_button = Button("Reset", self._reset)
     layout.add_widget(Label("Group 1:"), 1)
     layout.add_widget(
         TextBox(5,
                 label="My First Box:",
                 name="TA",
                 on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Text1:", name="TB", on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Text2:", name="TC", on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Text3:", name="TD", on_change=self._on_change), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(
         RadioButtons([("Option 1", 1), ("Option 2", 2), ("Option 3", 3)],
                      label="A Longer Selection:",
                      name="Things",
                      on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 1",
                  label="A very silly long name for fields:",
                  name="CA",
                  on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
コード例 #16
0
 def __init__(self, screen):
     super(InputIngredients, self).__init__(screen,
                                     int(screen.height * 2 // 3),
                                     int(screen.width * 2 // 3),
                                     has_shadow=True,
                                     data={
                                         'ingredients': ['onions, green pepers, turmeric'],
                                         'recipies': "5",
                                         'pantry': 0
                                     },
                                     name="Input Ingredients")
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     layout.add_widget(Label("Ingrediaent List"), 1)
     ingredient_list_widget = TextBox(5,
                               label="Enter the ingredients you wish to find dishes for.  Separate them with a comma (onions, green pepers, turmeric, etc.):",
                               name="ingredients",
                               line_wrap=False,
                               on_change=self._on_change)
     pantry_widget = RadioButtons([("Yes", 1),
                                 ("No", 0)],
                                 label="include the pantry basics such as water, salt, flour, etc.?",
                                 name="pantry",
                                 on_change=self._on_change)
     text_widget = Text(label="How many recipies would you like to see?",
              name="recipies",
              on_change=self._on_change,
              validator="^[0-9]*$")
     layout.add_widget(ingredient_list_widget, 1)
     layout.add_widget(pantry_widget, 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(text_widget, 1)
     layout.add_widget(Divider(height=2), 1)
     layout2 = Layout([1, 1, 1], fill_frame=True)
     self.add_layout(layout2)
     layout2.add_widget(Button("Quit", self._quit), 2)
     layout2.add_widget(Button("Continue", self._continue), 1)
     layout2.add_widget(Button("Back", self._continue), 0)
     self.fix()
コード例 #17
0
 def __init__(self, screen):
     super(RegisterView, self).__init__(screen,
                                        10, 50,
                                        on_load=self._onload,
                                        hover_focus=True,
                                        can_scroll=False,
                                        title="Register Page")
     layout = Layout([1])
     self.add_layout(layout)
     self._text_name = Text("账号:", "name")
     self._text_nickname = Text("昵称:", "nickname")
     self._text_pwd = Text("密码:", "pwd", hide_char="*")
     self._radio_gender = RadioButtons([("Girl", Gender_Female),
                                        ("Boy", Gender_Male)],
                                       label="性别",
                                       name="gender")
     self._radio_gender.value = Gender_Female
     layout.add_widget(self._text_name)
     layout.add_widget(self._text_nickname)
     layout.add_widget(self._text_pwd)
     layout.add_widget(self._radio_gender)
     layout.add_widget(Button("注册", self._register))
     layout.add_widget(Button("取消", self._cancel))
     self.fix()
コード例 #18
0
ファイル: wizard.py プロジェクト: 76782875/ehForwarderBot
    def __init__(self, screen, data):
        """
        Args:
            screen (Screen): Screen
            data (DataModel): Data model
        """
        super(ModulesView, self).__init__(screen,
                                          min(screen.height, 43),
                                          min(screen.width, 132),
                                          hover_focus=True,
                                          title=_("Choose modules"),
                                          reduce_cpu=True)

        self._model = data
        self.set_theme("bright")
        master_layout = Layout([6, 4])
        self.add_layout(master_layout)

        self.master_channel = RadioButtons(self._model.get_master_id_tuples(),
                                           label=_("Master channel"),
                                           name="master_channel")
        if "master_channel" in self._model.config and \
                self._model.config['master_channel'] in self._model.modules and \
                self._model.modules[self._model.config['master_channel']].type == "master":
            self.master_channel.value = self._model.config['master_channel']
        master_layout.add_widget(self.master_channel, 0)
        self.master_instance = Text(_("Instance ID"),
                                    "master_channel_instance")
        master_layout.add_widget(self.master_instance, 1)
        master_layout.add_widget(
            Label(_("Leave this blank to use the default instance."), 3), 1)

        layout = Layout([1])
        self.add_layout(layout)
        layout.add_widget(Label("", 3))

        slave_layout = Layout([8, 2])
        self.add_layout(slave_layout)
        slave_layout.add_widget(Label(_("Slave channels")), 0)
        self.slave_channels = ListBox(
            Widget.FILL_COLUMN,
            self._model.get_selected_slave_id_tuples(),
            name="slave_channels",
            add_scroll_bar=True)
        slave_layout.add_widget(self.slave_channels, 0)
        slave_layout.add_widget(
            Button(_("Add"), self.edit_popup("slave", "add")), 1)
        slave_layout.add_widget(
            Button(_("Edit"), self.edit_popup("slave", "edit")), 1)
        slave_layout.add_widget(
            Button(_("Up"), self.shift("slave", is_up=True)), 1)
        slave_layout.add_widget(
            Button(_("Down"), self.shift("slave", is_up=False)), 1)
        slave_layout.add_widget(Button(_("Remove"), self.delete("slave")), 1)

        layout = Layout([1])
        self.add_layout(layout)
        layout.add_widget(Label("", 3))

        middleware_layout = Layout([8, 2])
        self.add_layout(middleware_layout)
        middleware_layout.add_widget(Label(_("Middlewares")), 0)
        self.middlewares = ListBox(
            Widget.FILL_COLUMN,
            self._model.get_selected_middleware_id_tuples(),
            name="middlewares",
            add_scroll_bar=True)
        middleware_layout.add_widget(self.middlewares, 0)
        middleware_layout.add_widget(
            Button(_("Add"), self.edit_popup("middleware", "add")), 1)
        middleware_layout.add_widget(
            Button(_("Edit"), self.edit_popup("middleware", "edit")), 1)
        middleware_layout.add_widget(
            Button(_("Up"), self.shift("middleware", is_up=True)), 1)
        middleware_layout.add_widget(
            Button(_("Down"), self.shift("middleware", is_up=False)), 1)
        middleware_layout.add_widget(
            Button(_("Remove"), self.delete("middleware")), 1)

        confirm_layout = Layout([1])
        self.add_layout(confirm_layout)
        confirm_layout.add_widget(Divider(height=4))
        confirm_layout.add_widget(Button(_("Next"), self._ok))
        self.fix()
コード例 #19
0
ファイル: wizard.py プロジェクト: 76782875/ehForwarderBot
    def __init__(self, screen, data, mtype, index, mode, on_close=None):
        # self.palette['background'] = (Screen.COLOUR_WHITE, Screen.A_NORMAL, Screen.COLOUR_BLUE)

        if mtype == "slave" and mode == "add":
            title = _("Add a new slave channel")
        elif mtype == "slave" and mode == "edit":
            title = _("Edit a slave channel entry")
        elif mtype == "middleware" and mode == "add":
            title = _("Add a new middleware")
        elif mtype == "middleware" and mode == "edit":
            title = _("Edit a middleware entry")
        else:
            raise ValueError("Unknown mtype and mode pair: %s, %s", mtype,
                             mode)

        super(ModuleEntryView, self) \
            .__init__(screen,
                      min(screen.height, 15), min(screen.width, 75),
                      hover_focus=True,
                      is_modal=True,
                      title=title,
                      reduce_cpu=True
                      )

        self.set_theme("bright")
        self._model = data  # type: DataModel
        self._mtype = mtype  # type: str
        self._index = index
        self._mode = mode
        self._on_close = on_close
        layout = Layout([1])
        self.add_layout(layout)

        module_kv = []
        label = ""
        if mtype == "slave":
            module_kv = self._model.get_slave_id_tuples()
            label = _("Slave channel")
        elif mtype == 'middleware':
            module_kv = self._model.get_middleware_id_tuples()
            label = _("Middleware")

        self.modules = RadioButtons(module_kv, label=label, name="modules")
        layout.add_widget(self.modules)

        self.instance = Text(
            _("Instance ID"),
            "instance_id",
        )
        layout.add_widget(self.instance)

        layout.add_widget(
            Label(_("Leave this blank to use the default instance."), 3))

        layout.add_widget(Divider(height=2))
        layout.add_widget(Button(_("Save"), self._save))

        if mode == "edit":
            if mtype == "slave":
                c = self._model.config['slave_channels'][index].split("#")
            else:  # mtype == "middleware"
                c = self._model.config['middlewares'][index].split("#")
            self.modules.value = c[0]
            if len(c) > 1:
                self.instance.value = c[1]
        self.fix()
コード例 #20
0
ファイル: ng_creator.py プロジェクト: morin4ga/gochan
    def __init__(self, screen: Screen, on_close, default_value: str, mode):
        """
        Parameters
        ----------
        on_close : (value: str, use_reg: bool, hide: bool, auto_ng_id: bool, scope_idx: int) -> None
                   | (value: str, use_reg: bool, hide: bool, scope_idx: int) -> None
                   | (value: str, use_reg: bool, scope_idx: int) -> None
                   scope_idx : 0 - 全ての板
                               1 - この板のみ
                               2 - このスレのみ
        mode : "name" | "id" | "word" | "title"
        """

        super().__init__(screen,
                         screen.height,
                         screen.width,
                         hover_focus=True,
                         can_scroll=False,
                         has_border=True,
                         is_modal=True)

        self.set_theme("user_theme")

        self._on_close = on_close
        self._mode = mode

        if mode == "title":
            self._scope_radio = RadioButtons([("全ての板", 0), ("この板のみ", 1)])
        else:
            self._scope_radio = RadioButtons([("全ての板", 0), ("この板のみ", 1),
                                              ("このスレのみ", 2)])

        self._use_reg_chk = CheckBox("")

        if mode != "title":
            self._hide_chk = CheckBox("")

        if mode == "name" or mode == "word":
            self._auto_ng_id_chk = CheckBox("")

        self._value_box = TextBox(Widget.FILL_COLUMN, as_string=True)
        self._value_box.value = default_value

        self._save_btn = Button("Save", self._save_clicked)
        self._cancel_btn = Button("Cancel", lambda: self.disappaer())

        layout = Layout([10, 3, 87])
        self.add_layout(layout)
        layout.add_widget(Label("scope"), 0)
        layout.add_widget(VerticalDivider(), 1)
        layout.add_widget(self._scope_radio, 2)

        layout = Layout([100])
        self.add_layout(layout)
        layout.add_widget(Divider())

        layout = Layout([10, 3, 87])
        self.add_layout(layout)
        layout.add_widget(Label("use_reg"), 0)
        layout.add_widget(VerticalDivider(), 1)
        layout.add_widget(self._use_reg_chk, 2)

        layout = Layout([100])
        self.add_layout(layout)
        layout.add_widget(Divider())

        if mode != "title":
            layout = Layout([10, 3, 87])
            self.add_layout(layout)
            layout.add_widget(Label("hide"), 0)
            layout.add_widget(VerticalDivider(), 1)
            layout.add_widget(self._hide_chk, 2)

            layout = Layout([100])
            self.add_layout(layout)
            layout.add_widget(Divider())

        if mode == "name" or mode == "word":
            layout = Layout([10, 3, 87])
            self.add_layout(layout)
            layout.add_widget(Label("auto_ng_id"), 0)
            layout.add_widget(VerticalDivider(), 1)
            layout.add_widget(self._auto_ng_id_chk, 2)

            layout = Layout([100])
            self.add_layout(layout)
            layout.add_widget(Divider())

        layout = Layout([10, 3, 87], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(Label("value"), 0)
        layout.add_widget(VerticalDivider(), 1)
        layout.add_widget(self._value_box, 2)

        layout = Layout([100])
        self.add_layout(layout)
        layout.add_widget(Divider())

        layout = Layout([5, 5])
        self.add_layout(layout)
        layout.add_widget(self._save_btn)
        layout.add_widget(self._cancel_btn, 1)

        self.fix()
コード例 #21
0
    def __init__(self, screen, settings, tbapi, serial):

        self.has_connection_to_birdhouse = False
        self.initializing = True
        self.orig_data = {}
        self.tbapi = tbapi
        self.token_ok = False
        self.bhserial = serial
        self.settings = settings

        # For keeping track of threads
        self.busy = False  # Is a thread off doing something?
        self.timeout = 0  # When will that the active thread be considered tardy and marked absent?
        self.active_thread = None

        # if not port:
        #     raise Exception("I don't know what port to use!")

        super(MainMenu, self).__init__(screen,
                                       screen.height * 2 // 3,
                                       screen.width * 2 // 3,
                                       hover_focus=True,
                                       title="Birdhouse Configurator")

        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        self.layout = layout  # For use when detecting changes

        # Add some colors to our palette
        self.palette["changed"] = (Screen.COLOUR_RED, Screen.A_NORMAL,
                                   Screen.COLOUR_BLUE)

        self._status_msg = Label("Welcome!")

        # User supplied data:
        layout.add_widget(
            Text("Birdhouse Number:",
                 "birdhouse_number",
                 validator=r'^\d+$',
                 on_change=self.on_birdhouse_number_changed,
                 on_blur=partial(self.on_blurred, "birdhouse_number", True)))
        layout.add_widget(
            Text("Device Token:",
                 "device_token",
                 validator=token_validation_pattern,
                 on_blur=partial(self.on_blurred, "device_token", True)))

        layout.add_widget(
            Text("Local Password:"******"local_pass",
                 on_blur=partial(self.on_blurred, "local_pass", False)))
        layout.add_widget(
            Text("WiFi SSID:",
                 "wifi_ssid",
                 on_blur=partial(self.on_blurred, "wifi_ssid", False)))
        layout.add_widget(
            Text("WiFi Password:"******"wifi_pass",
                 on_blur=partial(self.on_blurred, "wifi_pass", False)))

        layout.add_widget(
            RadioButtons(led_styles,
                         "LED Style:",
                         "led_style",
                         on_change=self.on_led_style_changed))

        # provision.py [<number> --token TOKEN --ledstyle LEDSTYLE --wifissid SSID --wifipass PASSWORD --devicepass PASSWORD]

        # layout.add_widget(RadioButtons([("Red", "Red"), ("Yellow", "Yellow"), ("Green", "Green"), ("Cycle", "all"), ("Off", "off")], "Test LEDs", "led_test", on_change=self.on_test_leds_changed))
        # self.layout.find_widget("led_test").value = "off"

        # Parameters
        layout.add_widget(Text("Using device on Port:", "port"))
        layout.find_widget("port").disabled = True
        # layout.find_widget("port").value = settings.portname or "Device not found! Please plug it in!"

        layout.add_widget(
            Text("Local SSID:", "local_ssid", on_change=self.input_changed))
        layout.find_widget("local_ssid").disabled = True

        layout.add_widget(Divider())

        # Buttons
        layout2 = Layout([1, 1])
        self.add_layout(layout2)
        layout2.add_widget(
            Button("[Install firmware]", self.install_firmware, add_box=False),
            0)
        layout2.add_widget(Button("[Exit]", self._quit, add_box=False), 1)

        layout3 = Layout([16, 15, 8])
        self.add_layout(layout3)
        layout3.add_widget(
            Button("[Write settings]",
                   self.save_values_to_device,
                   add_box=False), 0)
        layout3.add_widget(
            Button("[Load settings]",
                   self.load_values_from_device,
                   add_box=False), 1)
        layout3.add_widget(Button("[Reboot]", self.reboot, add_box=False), 2)

        # Status message
        layout_status = Layout([100])
        self.add_layout(layout_status)
        layout_status.add_widget(self._status_msg)

        self.fix()  # Calculate positions of widgets

        self.initializing = False

        self.has_connection_to_birdhouse = False

        self.input_changed()
        self.overwrite_params_with_cmd_line_values = False

        self.set_widgets_from_settings()
コード例 #22
0
ファイル: interface.py プロジェクト: silky/PyPadberg
    def __init__(self, screen):
        super().__init__(screen,
                         int(screen.height * 2 // 3),
                         int(screen.width * 2 // 3),
                         data=form_data,
                         has_shadow=True,
                         title="PyPadberg")
        layout_discr = Layout([1, 10, 1])
        self.add_layout(layout_discr)
        layout_discr.add_widget(
            Label(
                "\nSelect instrument and number of voices for you piece below.\
",
                height=3,
                align="^"), 1)

        layout_div_1 = Layout([100])
        self.add_layout(layout_div_1)
        layout_div_1.add_widget(Divider())

        layout = Layout([1, 18, 1])
        self.add_layout(layout)
        layout.add_widget(
            RadioButtons([("one", "one"), ("two", "two"), ("three", "three")],
                         label="Choose a Sound:",
                         name="sound_choice",
                         on_change=self._on_change), 1)

        layout_spacer = Layout([1, 18, 1])
        self.add_layout(layout_spacer)
        layout_spacer.add_widget(Label(" " * 100, height=2, align="^"), 1)

        layout2 = Layout([1, 18, 1])
        self.add_layout(layout2)
        layout2.add_widget(
            RadioButtons([("1", 1), ("2", 2), ("3", 3), ("4", 4)],
                         label="How Many Voices?:",
                         name="num_voices",
                         on_change=self._on_change), 1)

        layout_spacer2 = Layout([1, 18, 1])
        self.add_layout(layout_spacer2)
        layout_spacer2.add_widget(Label(" " * 100, height=2, align="^"), 1)

        layout_label = Layout([1, 10, 1])
        self.add_layout(layout_label)
        layout_spacer2.add_widget(
            Label(
                "You may optionally enter a name to save your melody under in the box below.",
                height=3,
                align="^"), 1)

        layout3 = Layout([1, 18, 1], fill_frame=True)
        self.add_layout(layout3)
        layout3.add_widget(
            Text(label="Filename: ", name="fname", on_change=self._on_change),
            1)

        layout_div_2 = Layout([100])
        self.add_layout(layout_div_2)
        layout_div_2.add_widget(Divider())

        layout_buttons = Layout([1, 6, 6, 6, 1])
        self.add_layout(layout_buttons)
        layout_buttons.add_widget(Button("Play", self._play), 1)
        layout_buttons.add_widget(Button("Save Audio", self._save_audio), 2)
        layout_buttons.add_widget(Button("Save CSV", self._save_csv), 3)

        layout_buttons2 = Layout([1, 3, 3, 1])
        self.add_layout(layout_buttons2)
        layout_buttons2.add_widget(Button("Make Another", self._make_another),
                                   1)
        layout_buttons2.add_widget(Button("Quit", self._quit), 2)
        self.fix()
コード例 #23
0
    def __init__(self, screen):
        global port

        self.has_connection_to_birdhouse = False
        self.initializing = True
        self.orig_data = { }

        self.bhserial = None
        self.port = port

        if not port:
            raise Exception("I don't know what port to use!")

        super(Main, self).__init__(screen, 
                                   screen.height * 2 // 3, 
                                   screen.width * 2 // 3, 
                                   hover_focus=True, 
                                   title="Birdhouse Configurator")

        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        self.layout = layout    # For use when detecting changes


        # Add some colors to our palette
        self.palette["changed"] = (Screen.COLOUR_RED, Screen.A_NORMAL, Screen.COLOUR_BLUE)

        self._status_msg = Label("Welcome!")

        self.reset_form()


        # Connection info
        layout.add_widget(Text("Birdhouse Number:", "birdhouse_number", validator=r"^\d\d\d$", on_change=self.input_changed))
        self.layout.find_widget("birdhouse_number").value = args.number

        layout.add_widget(RadioButtons([("Red", "Red"), ("Yellow", "Yellow"), ("Green", "Green"), ("Cycle", "all"), ("Off", "off")], "Test LEDs", "led_test", on_change=self.on_test_leds_changed))
        self.layout.find_widget("led_test").value = "off"


        # Parameters
        layout.add_widget(Text("Uptime:", "uptime"))
        layout.find_widget("uptime").disabled=True
        layout.add_widget(Text("Temp Sensor:", "temperatureSensor"))
        layout.find_widget("temperatureSensor").disabled=True
        layout.add_widget(Text("Found Plantower Sensor:", "plantowerSensorDetected"))
        layout.find_widget("plantowerSensorDetected").disabled=True
        layout.add_widget(Text("WiFi Status:", "wifi_status"))
        layout.find_widget("wifi_status").disabled=True
        layout.add_widget(Text("MQTT Status:", "mqtt_status"))
        layout.find_widget("mqtt_status").disabled=True

        layout.add_widget(RadioButtons([("Traditional (R/Y/G)", 'RYG'), ("Traditional, wired backward", 'RYG_REVERSED'), ("Single square LED", 'DOTSTAR'), ("Single round LED", '4PIN')], "LED Style:", "led_style", on_change=self.on_led_style_changed))

        layout.add_widget(Text("Device Token:", "device_token", on_change=self.input_changed))

        layout.add_widget(Text("Local SSID:", "local_ssid", on_change=self.input_changed))
        layout.find_widget("local_ssid").disabled=True

        layout.add_widget(Text("Local Password:"******"local_pass", on_change=self.input_changed))
        layout.add_widget(Text("WiFi SSID:", "wifi_ssid", on_change=self.input_changed))
        layout.add_widget(Text("WiFi Password:"******"wifi_pass", on_change=self.input_changed))
        layout.add_widget(Text("MQTT Url:", "mqtt_url", on_change=self.input_changed))
        layout.add_widget(Text("MQTT Port:", "mqtt_port", on_change=self.input_changed))
        layout.add_widget(Divider())

        # Buttons
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Server", self.server_config), 0)
        layout2.add_widget(Button("Commit", self.write_values), 0)
        layout2.add_widget(Button("Refresh", self.reload_values), 1)
        # layout2.add_widget(Button("Rescan Ports", self.scan_ports), 1)
        layout2.add_widget(Button("Reboot Birdhouse", self.reboot), 2)
        layout2.add_widget(Button("Exit", self._quit), 3)


        layout3 = Layout([100])
        self.add_layout(layout3)
        layout3.add_widget(Divider())
        layout3.add_widget(Button("Finalize", self.finalize), 0)
        layout3.add_widget(Button("Get Token from SSID", self.retrieve_token), 0)


        # Status message
        layout4 = Layout([100])
        self.add_layout(layout4)
        layout4.add_widget(Divider())
        layout4.add_widget(self._status_msg)

        self.fix()  # Calculate positions of widgets


        self.initializing = False

        self.bhserial = serial.Serial(port, 115200, timeout=5)
        self.query_birdhouse(port)

        self.port = port
        self.has_connection_to_birdhouse = True


        self.input_changed()
        self.overwrite_params_with_cmd_line_values = False