def __init__(self, screen): super(DemoFrame, self).__init__(screen, screen.height, screen.width, has_border=False, name="My Form") # Internal state required for doing periodic updates self._last_frame = 0 self._sort = 5 self._reverse = True # Create the basic form layout... layout = Layout([1], fill_frame=True) self._header = TextBox(1, as_string=True) self._header.disabled = True self._header.custom_colour = "label" self._list = MultiColumnListBox( Widget.FILL_FRAME, [">6", 10, ">4", ">7", ">7", ">5", ">5", "100%"], [], titles=["PID", "USER", "NI", "VIRT", "RSS", "CPU%", "MEM%", "CMD"], name="mc_list") self.add_layout(layout) layout.add_widget(self._header) layout.add_widget(self._list) layout.add_widget( Label("Press `<`/`>` to change sort, `r` to toggle order, or `q` to quit.")) self.fix() # Add my own colour palette self.palette = defaultdict( lambda: (Screen.COLOUR_WHITE, Screen.A_NORMAL, Screen.COLOUR_BLACK)) for key in ["selected_focus_field", "label"]: self.palette[key] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_BLACK) self.palette["title"] = (Screen.COLOUR_BLACK, Screen.A_NORMAL, Screen.COLOUR_WHITE)
def __init__(self, screen, plugin_data): super(CreateConfFileView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, hover_focus=True, title='Create configuration file', reduce_cpu=True ) self._plugin_data = plugin_data layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Label('')) layout.add_widget(Label('')) layout.add_widget(Label('Confirm proceed to create configuration file for InMan Freeradius Cluster Plugin.')) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button('Proceed', self._proceed), 1) layout2.add_widget(Button('Previous', self._previous), 2) layout2.add_widget(Button('Quit', self._quit), 3) self.fix()
def __init__(self, screen): super(Show_paste, self).__init__(screen, screen.height, screen.width, hover_focus=True, on_load=self._setValue, title="Show current paste", reduce_cpu=True) layout = Layout([100], fill_frame=True) self.layout = layout self.add_layout(layout) self.label_list = [] self.num_label = 42 # Number of line available for displaying the paste for i in range(self.num_label): self.label_list += [Label("THE PASTE CONTENT " + str(i))] layout.add_widget(self.label_list[i]) layout2 = Layout([100]) self.add_layout(layout2) layout2.add_widget(Button("Ok", self._ok), 0) self.fix()
def __init__(self, screen): super(Confirm, self).__init__(screen, screen.height * 1 // 8, screen.width * 1 // 3, hover_focus=True, on_load=self._setValue, title="Confirm action", reduce_cpu=True) # Create the form for displaying the list of contacts. layout = Layout([100], fill_frame=True) self.add_layout(layout) self.label = CLabel("{} module {} {}?") layout.add_widget(Label(" ")) layout.add_widget(self.label) layout2 = Layout([1,1]) self.add_layout(layout2) layout2.add_widget(Button("Ok", self._ok), 0) layout2.add_widget(Button("Cancel", self._cancel), 1) self.fix()
def __init__(self, screen, worker_info_manager: WorkerInfoManager): super(WorkerInfoScene, self).__init__(screen, screen.height, screen.width, title='Worker Info', reduce_cpu=False) self._last_frame = 0 self._model = worker_info_manager self._model._refresh() self.data = {'updated_at': str(dt.now())} self.palette = PALETTE rollup_layout = Layout([100]) self.add_layout(rollup_layout) self.rollup_widget = MultiColumnListBox(round(screen.height * .05), ['12%'] * 8, [], titles=[ 'Worker Count', 'Average CPU', 'Average Memory', 'Total Fds', 'Total Executing', 'Total In Mem', 'Total Ready', 'Total In Flight', ], parser=AsciimaticsParser()) rollup_layout.add_widget(self.rollup_widget) div_layout = Layout([100]) self.add_layout(div_layout) div_layout.add_widget(Divider()) column_layout = Layout([100]) self.add_layout(column_layout) self.worker_widget = MultiColumnListBox( round(screen.height * .95), [ '20%', '10%', '20%', '10%', '10%', '10%', '10%', '10%', ], [], titles=[ 'Worker Address', 'CPU', 'Memory', 'File Descriptors', 'Executing', 'In Memory', 'Ready', 'In Flight', ], parser=AsciimaticsParser(), ) column_layout.add_widget(self.worker_widget) self.fix()
def __init__(self, screen): super(LoginView, self).__init__(screen, screen.height * 33 // 100, screen.width * 33 // 100, hover_focus=True, title="Login", reduce_cpu=True, y=1) layout = Layout([100], fill_frame=True) self.add_layout(layout) self._pw1 = Text("", "mpw1") self._pw2 = Text("", "mpw2") layout.add_widget(Label('enter password')) layout.add_widget(self._pw1) layout.add_widget(Divider()) layout.add_widget(Label('confirm password')) layout.add_widget(self._pw2) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("OK", self._ok), 0) layout2.add_widget(Button("Cancel", self._cancel), 3) self.fix()
def __init__(self, screen): super(DemoFrame, self).__init__( screen, screen.height, screen.width, has_border=False, name="My Form") # Create the (very simple) form layout... layout = Layout([1], fill_frame=True) self.add_layout(layout) # Now populate it with the widgets we want to use. self._details = Text() self._details.disabled = True self._details.custom_colour = "field" self._list = FileBrowser(Widget.FILL_FRAME, os.path.abspath("."), name="mc_list", on_select=self.popup, on_change=self.details) layout.add_widget(Label("Local disk browser sample")) layout.add_widget(Divider()) layout.add_widget(self._list) layout.add_widget(Divider()) layout.add_widget(self._details) layout.add_widget(Label("Press Enter to select or `q` to quit.")) # Prepare the Frame for use. self.fix()
def __init__(self, screen): super(Action_choice, self).__init__(screen, screen.height * 1 // 8, screen.width * 1 // 2, hover_focus=True, on_load=self._setValue, title="Confirm action", reduce_cpu=True) # Create the form for displaying the list of contacts. layout = Layout([100], fill_frame=True) self.add_layout(layout) self.label = CLabel("Choose action on module {} {}") layout.add_widget(self.label) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("Cancel", self._cancel), 0) self._ShowPasteBtn = Button("Show current paste", self._showpaste) layout2.add_widget(self._ShowPasteBtn, 1) self._killBtn = Button("KILL", self._kill) layout2.add_widget(self._killBtn, 2) layout2.add_widget(Button("START", self._start), 3) layout3 = Layout([1, 1, 1, 1]) self.add_layout(layout3) self.textEdit = Text("Amount", "amount") layout3.add_widget(self.textEdit, 3) self.fix()
def __init__(self, screen, model): super(MainView, self).__init__(screen, screen.height, screen.width, on_load=self._load, hover_focus=True, can_scroll=False, title="Gestion Des stocks") self.set_theme("cs") self._model = model lay = Layout([1, 1, 8], fill_frame=True) self.add_layout(lay) lay.add_widget(Label("Rack"), 0) lay.add_widget(Label(""), 0) lay.add_widget(Button(f"Rack A", lambda: self._to_rack("A")), 0) lay.add_widget(Label(""), 0) lay.add_widget(Button(f"Rack B", lambda: self._to_rack("B")), 0) lay.add_widget(Label(""), 0) lay.add_widget(Button(f"Rack C", lambda: self._to_rack("C")), 0) lay.add_widget(Label(""), 0) lay.add_widget(Button(f"Rack D", lambda: self._to_rack("D")), 0) lay.add_widget(Label(""), 0) lay.add_widget(Button(f"Rack E", lambda: self._to_rack("E")), 0) self._l_qt_A = Label(label="") self._l_qt_B = Label(label="") self._l_qt_C = Label(label="") self._l_qt_D = Label(label="") self._l_qt_E = Label(label="") lay.add_widget(Label("#Vide"), 1) lay.add_widget(Label(""), 1) lay.add_widget(self._l_qt_A, 1) lay.add_widget(Label(""), 1) lay.add_widget(self._l_qt_B, 1) lay.add_widget(Label(""), 1) lay.add_widget(self._l_qt_C, 1) lay.add_widget(Label(""), 1) lay.add_widget(self._l_qt_D, 1) lay.add_widget(Label(""), 1) lay.add_widget(self._l_qt_E, 1) self._l_list_A = Label(label="") self._l_list_B = Label(label="") self._l_list_C = Label(label="") self._l_list_D = Label(label="") self._l_list_E = Label(label="") lay.add_widget(Label("Composants Epuises"), 2) lay.add_widget(Label(""), 2) lay.add_widget(self._l_list_A, 2) lay.add_widget(Label(""), 2) lay.add_widget(self._l_list_B, 2) lay.add_widget(Label(""), 2) lay.add_widget(self._l_list_C, 2) lay.add_widget(Label(""), 2) lay.add_widget(self._l_list_D, 2) lay.add_widget(Label(""), 2) lay.add_widget(self._l_list_E, 2) ly2 = Layout([100]) self.add_layout(ly2) ly2.add_widget(Button("Quit", self._quit)) self.fix()
def __init__(self, screen, model): super(PartView, self).__init__(screen, screen.height * 4 // 5, screen.width * 4 // 5, hover_focus=True, can_scroll=False, title="Part Details", reduce_cpu=True) self.set_theme("cs") # Save off the model that accesses the parts database. self._model = model # Create the form for displaying the list of parts. layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Text("Nom :", "name")) layout.add_widget(Text("Categorie :", "mcat")) layout.add_widget(Text("Sous-catégorie 1 :", "scat1")) layout.add_widget(Text("Sous-catégorie 2 :", "scat2")) layout.add_widget(Text("Emplacement :", "pos")) layout.add_widget(Text("Quantité :", "amnt")) layout.add_widget( TextBox(Widget.FILL_FRAME, "Description:", "notes", as_string=True, line_wrap=True)) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("OK", self._ok), 0) layout2.add_widget(Button("Cancel", self._cancel), 3) self.fix()
def __init__(self, screen, model): super(BoxListView, self).__init__(screen, screen.height * 4 // 5, screen.width * 4 // 5, on_load=self._reload_list, hover_focus=True, can_scroll=False, title=f"Boite {model.current_pos}") # Save off the model that accesses the parts database. self._model = model # Create the form for displaying the list of parts. self._list_view = MultiColumnListBox( Widget.FILL_FRAME, columns=['30%', '20%', '20%', '20%', '10%'], options=self._model.get_items_in_box(self._model.current_pos), titles=['Name', 'Cat', 'S-Cat', 'S-S-Cat', 'Qte'], add_scroll_bar=True, on_change=self._on_pick, on_select=self._edit, name="parts") self.set_theme("cs") self._edit_button = Button("Edit", self._edit) self._delete_button = Button("Delete", self._delete) layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(self._list_view) layout.add_widget(Divider()) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("Add", self._add), 0) layout2.add_widget(self._edit_button, 1) layout2.add_widget(self._delete_button, 2) layout2.add_widget(Button("Back", self._back), 3) self.fix() self._on_pick()
class View(Frame): def __init__(self, model, screen, height, width, data=None, on_load=None, has_border=True, hover_focus=False, name=None, title=None, x=None, y=None, has_shadow=False, reduce_cpu=False, is_modal=False, can_scroll=True): super(View, self).__init__(screen=screen, height=height, width=width, data=data, on_load=on_load, has_border=has_border, hover_focus=hover_focus, name=name, title=title, x=x, y=y, has_shadow=has_shadow, reduce_cpu=reduce_cpu, is_modal=is_modal, can_scroll=can_scroll) self._model = model self.nav_header = None self.set_theme("tlj256") def add_navigation_header(self): self.nav_header = Layout([1, 1, 1, 1]) self.add_layout(self.nav_header) self.nav_header.add_widget(Button("Branches", self._open_branch_view), 0) self.nav_header.add_widget(Button("History", self._open_commits_view), 1) self.nav_header.add_widget( Button("Commit", self._open_working_copy_view), 2) self.nav_header.add_widget(Button("Quit", self._quit), 3) def add_divider(self): divider_layout = Layout([100]) self.add_layout(divider_layout) divider_layout.add_widget(Divider()) def add_shortcut_panel(self): layout0 = Layout([100]) _header = TextBox(1, as_string=True) _header.disabled = True _header.custom_colour = "label" _header.value = "Press ctrl-a to see a list of shortcuts. Press ctrl-x to quit." self.add_layout(layout0) layout0.add_widget(_header, 0) @staticmethod def _open_branch_view(): raise NextScene("Main") @staticmethod def _open_commits_view(): raise NextScene("Commits") @staticmethod def _open_working_copy_view(): raise NextScene("Working Copy") @staticmethod def _quit(): raise StopApplication("User pressed quit")
def __init__(self, screen, plugin_data): super(PluginConfView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, hover_focus=True, title='Define Plugin configuration', reduce_cpu=True ) self._plugin_data = plugin_data layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Text('Hostname:', 'plugin_hostname')) layout.add_widget(Text('IP:', 'plugin_ip')) layout.add_widget(Text('Plugin log path:', 'plugin_log_path')) layout.add_widget(Text('InMan Server:', 'inman_server')) layout.add_widget(Text('Cluster Master Name:', 'cluster_master_name')) layout.add_widget(Text('Cluster Master IP:', 'cluster_master_ip')) layout.add_widget(Text('Cluster RADIUS name:', 'cluster_radius_name')) debug_choice = ListBox(4, [('Debug', 'logging.DEBUG'), ('Info', 'logging.INFO'), ('Warning', 'logging.WARNING'), ('Error', 'logging.ERROR'), ('Critical', 'logging.CRITICAL')], label='Agent debug level:', name='cluster_debug_level') layout.add_widget(debug_choice) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button('Next', self._next), 2) layout2.add_widget(Button('Quit', self._quit), 3) self.fix()
def __init__(self, screen, model): super(ListView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, on_load=self._reload_list, hover_focus=True, title="Contact List") # Save off the model that accesses the contacts database. self._model = model # Create the form for displaying the list of contacts. self._list_view = ListBox(Widget.FILL_FRAME, model.get_summary(), name="contacts", on_change=self._on_pick) self._edit_button = Button("Edit", self._edit) self._delete_button = Button("Delete", self._delete) layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(self._list_view) layout.add_widget(Divider()) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("Add", self._add), 0) layout2.add_widget(self._edit_button, 1) layout2.add_widget(self._delete_button, 2) layout2.add_widget(Button("Quit", self._quit), 3) self.fix() self._on_pick()
def __init__(self, screen, longitude, latitude, on_ok): super(EnterLocation, self).__init__(screen, 7, 40, data={ "long": str(longitude), "lat": str(latitude) }, name="loc", title="Enter New Location", is_modal=True) # Remember the callback to use when OK is clicked self._on_ok = on_ok # Create the form layout = Layout([1, 18, 1]) self.add_layout(layout) layout.add_widget(Divider(draw_line=False), 1) layout.add_widget( Text(label="Longitude:", name="long", validator="^[-]?\d+?\.\d+?$"), 1) layout.add_widget( Text(label="Latitude:", name="lat", validator="^[-]?\d+?\.\d+?$"), 1) layout.add_widget(Divider(draw_line=False), 1) layout2 = Layout([1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("OK", self._ok), 1) layout2.add_widget(Button("Cancel", self._cancel), 2) self.fix()
def __init__(self, screen, model, ui: UIController): super().__init__(screen, height=screen.height // 2, width=screen.width // 2, can_scroll=False, title="Add Host", 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("IP Address: ", name="ip") self._hostname_input = Text("Hostname (optional):", name="hostname") self._beacon_type = DropdownList([("DNS", "DNS"), ("HTTP", "HTTP"), ("ICMP", "ICMP")], label="Beacon Type: ", name="beacon") # Create and Generate Layouts layout = Layout([1], fill_frame=True) self.add_layout(layout) layout.add_widget(self._ip_input) layout.add_widget(self._hostname_input) layout.add_widget(self._beacon_type) layout.add_widget(TextBox(Widget.FILL_FRAME, disabled=True)) 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()
def add_path_selector(self, button_fn, text): layout = Layout([80, 20]) self.add_layout(layout) layout.add_widget(Label(lambda: self.dapp.config.sl_dapp_path), 0) layout.add_widget(Button(text, button_fn), 1) layout.add_widget(Divider(draw_line=False))
def __init__(self, screen): super(ListView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, on_load=self._reload_list, hover_focus=True, title="Inbox") self._list_view = ListBox(Widget.FILL_FRAME, recv.build_option(IMAP_EP, USER, PASS), name="emails", on_change=self._on_pick) self._view_button = Button("View", self._view) self._delete_button = Button("Delete", self._delete) layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Label(recv.get_header())) layout.add_widget(self._list_view) layout.add_widget(Divider()) layout2 = Layout([1, 1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("Refresh", self._update_cb), 0) layout2.add_widget(self._view_button, 2) layout2.add_widget(self._delete_button, 3) layout2.add_widget(Button("Compose", self._compose), 1) layout2.add_widget(Button("Quit", self._quit), 4) self.fix() self._on_pick()
def __init__(self, screen, table, edit_scene, header_text='TableFrame', spacing=2, has_border=True, footer=dict(), reverse_sort=False, sort_index=0, scene_keybinds=None): self.table = table self.__screen = screen self.__edit_scene = edit_scene self.__spacing = spacing self.__reverse_sort = reverse_sort self.__sort_index = sort_index self.__scene_keybinds = scene_keybinds super().__init__(screen, screen.height, screen.width, has_border=has_border, name=header_text, on_load=self._reload_list) layout = Layout([17, 3]) # Search def searching(): self.__searching = True self.data["row_index"] = None def not_searching(): self.__searching = False self.__search_box = Text(label='Search:', name='search', on_focus=searching, on_blur=not_searching) self.__search_box._on_change = self._reload_list # Header self.__header = TextBox(1, as_string=True) self.__header.disabled = True self.__header.custom_colour = "label" self.__header.value = header_text # List of rows self.__list = MultiColumnListBox(Widget.FILL_FRAME, self.table.get_column_widths( self.__spacing), [], titles=self.table.get_column_names(), name='row_index') footers = ['[{}] {}'.format(key, text) for key, text in footer.items()] default_footer_text = '[a] Add Row [e] Edit/View Row [r] Reverse Sort [<;>] Change Sort Column [tab] Search [d] Delete [q] Quit' self.__footer = Label(' '.join(footers) + ' ' + default_footer_text) self.add_layout(layout) layout.add_widget(self.__header) layout.add_widget(self.__search_box, column=1) layout.add_widget(self.__list) layout.add_widget(self.__footer) self.fix() # Change colours self.set_theme('monochrome')
def __init__(self, screen, model): super(ListView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, on_load=self._reload_list, hover_focus=True, can_scroll=False, title="Contact List") # Save off the model that accesses the contacts database. self._model = model # Create the form for displaying the list of contacts. self._list_view = ListBox( Widget.FILL_FRAME, model.get_summary(), name="contacts", add_scroll_bar=True, on_change=self._on_pick, on_select=self._edit) self._edit_button = Button("Edit", self._edit) self._delete_button = Button("Delete", self._delete) layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(self._list_view) layout.add_widget(Divider()) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("Add", self._add), 0) layout2.add_widget(self._edit_button, 1) layout2.add_widget(self._delete_button, 2) layout2.add_widget(Button("Quit", self._quit), 3) self.fix() self._on_pick()
class CommandTuiAdaptor: def __init__(self, message_model, frame: Frame, layout=None, layout_column=None): self._message_model = message_model self._frame = frame self._lay = layout self._lay_column = layout_column self._has_frame_filler = None def draw_ui(self): self._init_layout() descr = self._message_model.descriptor if len(descr): command_name = re.sub( r"([A-Z])", r" \1", self._message_model.descriptor[0]["message_path"]).strip() self._lay.add_widget( Label("Current Command: {}".format(command_name)), self._lay_column) self._lay.add_widget(Divider(), self._lay_column) has_optional_primitive = False for field_descriptor in descr: if field_descriptor["optional_primitive"]: has_optional_primitive = True self._draw_component(field_descriptor) if has_optional_primitive: self._lay.add_widget(Divider(), self._lay_column) self._lay.add_widget( Label( '* Fields, which names are enclosed into "[" and "]" are optional' ), self._lay_column, ) """ @ @ @ Private part @ @ """ def _init_layout(self): if not self._lay: self._lay = Layout([1, 18, 1], fill_frame=True) self._lay_column = 1 self._frame.add_layout(self._lay) def _draw_component(self, field_descriptor): switcher = { "CPPTYPE_STRING": "_draw_textline", "CPPTYPE_UINT32": "_draw_uint32", "CPPTYPE_ENUM": "_draw_enum", } painter_name = switcher.get(field_descriptor["cpp_type"], "_draw_unknown_field") painter_func = getattr(self, painter_name) painter_func(field_descriptor) def _draw_unknown_field(self, field_descriptor): self._lay.add_widget( Label("Unable to display field: {}{} (unsupported type)".format( field_descriptor["message_path"], field_descriptor["field_path"])), self._lay_column, ) def _draw_textline(self, field_descriptor): self._lay.add_widget( Text(label=field_label(field_descriptor), name=field_descriptor["field_path"]), self._lay_column, ) def _draw_uint32(self, field_descriptor): self._lay.add_widget( Text( label=field_label(field_descriptor), name=field_descriptor["field_path"], validator=uint32_validator, ), self._lay_column, ) def _draw_enum(self, field_descriptor): if not self._has_frame_filler: height = Widget.FILL_FRAME self._has_frame_filler = True else: height = 8 if field_descriptor["repeated"]: # then we use checkboxes self._lay.add_widget( CheckListBox( height=height, options=field_descriptor["enum_options"], label=field_label(field_descriptor), add_scroll_bar=True, name=field_descriptor["field_path"], ), self._lay_column, ) else: # field is not repeated and we use radio buttons self._lay.add_widget( RadioListBox( label=field_label(field_descriptor), height=height, options=field_descriptor["enum_options"], add_scroll_bar=True, name=field_descriptor["field_path"], ), self._lay_column, )
def __init__(self, screen, agent_data): super(ServerInfoView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, hover_focus=True, title='Define Server info', reduce_cpu=True ) self._agent_data = agent_data layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Text('InMan server URL:', 'inman_server')) layout.add_widget(Text('Websocket server URL:', 'websocket_server')) layout.add_widget(Text('Websocket server port:', 'websocket_port')) layout.add_widget(Text('Websocket local log:', 'websocket_log_path')) debug_choice = ListBox(4, [('Debug', 'logging.DEBUG'), ('Info', 'logging.INFO'), ('Warning', 'logging.WARNING'), ('Error', 'logging.ERROR'), ('Critical', 'logging.CRITICAL')], label='Websocket debug level:', name='websocket_debug_level') layout.add_widget(debug_choice) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button('Finish', self._finish), 1) layout2.add_widget(Button('Previous', self._previous), 2) layout2.add_widget(Button('Quit', self._quit), 3) self.fix()
def _compose_actions_layout(self): layout = Layout([1]) self.add_layout(layout) layout.add_widget(Button("Cancel", self._model.go_back))
def __init__(self, screen, model): super(ContactView, self).__init__(screen, screen.height * 75 // 100, screen.width * 75 // 100, hover_focus=True, title="Login Details", reduce_cpu=True, y=1) # Save off the model that accesses the contacts database. self._model = model # Create the form for displaying the list of contacts. layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Text("Login:"******"login")) layout.add_widget(Text("Group:", "lgroup")) layout.add_widget(Text("Username:"******"username")) layout.add_widget(Text("Loginlink:", "link")) layout.add_widget(Text("Email address:", "email")) layout.add_widget(Text("Length:", "length")) layout.add_widget(Divider()) layout.add_widget( TextBox(Widget.FILL_FRAME, "Notes:", "notes", as_string=True)) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("OK", self._ok), 0) layout2.add_widget(Button("Cancel", self._cancel), 3) self.fix()
def __init__(self, screen, interface): super(SendBox, self).__init__(screen, 21, 59, interface, tx_func=self._ok, cancel_func=self._cancel, name="sendbox", title="Send Crypto") layout = Layout([100]) #, fill_frame=True) self.prepend_layout(layout) layout.add_widget(Text("To Address:", "address")) layout.add_widget(Divider(draw_line=False)) self.everything_checkbox = CheckBox("Send Everything", on_change=self.checkbox_change) self.amount_text = Text(" Amount:", "amount", on_change=self.amount_change) layout.add_widget(self.amount_text) layout.add_widget(self.everything_checkbox) layout.add_widget(Divider(draw_line=False)) balances = [{'name': 'ETH', 'balance': interface.node.eth_balance}] balances += [ x for x in interface.node.erc20_balances if x['balance'] > 0 ] currency_options = [(x['name'], x) for x in balances] logging.info(currency_options) logging.info(currency_options) self.estimated_gas = Decimal(21000) self.currency_listbox = ListBox(1, currency_options, label=" Currency:", name="currency") layout.add_widget(self.currency_listbox) self.currency_balance_label = Label(self.currency_balance) layout.add_widget(self.currency_balance_label) layout.add_widget(Divider(draw_line=False)) self.fix()
def __init__(self, screen): super(Dashboard, self).__init__(screen, screen.height, screen.width, hover_focus=True, reduce_cpu=True) self._list_view_run_queue = CListBox( "running", screen.height // 2, [], name="LIST") self._list_view_idle_queue = CListBox( "idle", screen.height // 2, [], name="LIST") self._list_view_noRunning = CListBox( "notRunning", screen.height // 5, [], name="LIST") self._list_view_Log = CListBox( "logs", screen.height // 4, [], name="LIST") #self._list_view_Log.disabled = True #Running Queues layout = Layout([100]) self.add_layout(layout) text_rq = CLabel("Running Queues") layout.add_widget(text_rq) layout.add_widget(CLabel(TABLES_TITLES["running"], listTitle=True)) layout.add_widget(self._list_view_run_queue) layout.add_widget(Divider()) #Idling Queues layout2 = Layout([1,1]) self.add_layout(layout2) text_iq = CLabel("Idling Queues") layout2.add_widget(text_iq, 0) layout2.add_widget(CLabel(TABLES_TITLES["idle"], listTitle=True), 0) layout2.add_widget(self._list_view_idle_queue, 0) #Non Running Queues text_nq = CLabel("Queues not running") layout2.add_widget(text_nq, 1) layout2.add_widget(CLabel(TABLES_TITLES["notRunning"], listTitle=True), 1) layout2.add_widget(self._list_view_noRunning, 1) layout2.add_widget(Divider(), 1) #Log text_l = CLabel("Logs") layout2.add_widget(text_l, 1) layout2.add_widget(CLabel(TABLES_TITLES["logs"], listTitle=True), 1) layout2.add_widget(self._list_view_Log, 1) self.fix()
def _create_window(self): self.screen = Screen.open() self.frame = Frame(self.screen, self.screen.height, self.screen.width, has_border=False, title="Test") self.frame.set_theme("mpf_theme") title_layout = Layout([1, 5, 1]) self.frame.add_layout(title_layout) title_left = Label("") title_left.custom_colour = "title" title_layout.add_widget(title_left, 0) title = 'Mission Pinball Framework v{}'.format(mpf._version.__version__) # noqa title_text = Label(title, align="^") title_text.custom_colour = "title" title_layout.add_widget(title_text, 1) exit_label = Label("< CTRL + C > TO EXIT", align=">") exit_label.custom_colour = "title_exit" title_layout.add_widget(exit_label, 2) self.layout = MpfLayout([1, 1, 1, 1], fill_frame=True) self.frame.add_layout(self.layout) footer_layout = Layout([1, 1, 1]) self.frame.add_layout(footer_layout) self.footer_memory = Label("", align=">") self.footer_memory.custom_colour = "footer_memory" self.footer_uptime = Label("", align=">") self.footer_uptime.custom_colour = "footer_memory" self.footer_mc_cpu = Label("") self.footer_mc_cpu.custom_colour = "footer_mc_cpu" self.footer_cpu = Label("") self.footer_cpu.custom_colour = "footer_cpu" footer_path = Label(self.machine.machine_path) footer_path.custom_colour = "footer_path" footer_empty = Label("") footer_empty.custom_colour = "footer_memory" footer_layout.add_widget(footer_path, 0) footer_layout.add_widget(self.footer_cpu, 0) footer_layout.add_widget(footer_empty, 1) footer_layout.add_widget(self.footer_mc_cpu, 1) footer_layout.add_widget(self.footer_uptime, 2) footer_layout.add_widget(self.footer_memory, 2) self.scene = Scene([self.frame], -1) self.screen.set_scenes([self.scene], start_scene=self.scene) # prevent main from scrolling out the footer self.layout.set_max_height(self.screen.height - 2)
def __init__(self, screen): super(Action_choice, self).__init__(screen, screen.height * 1 // 8, screen.width * 1 // 2, hover_focus=True, on_load=self._setValue, title="Confirm action", reduce_cpu=True) # Create the form for displaying the list of contacts. layout = Layout([100], fill_frame=True) self.add_layout(layout) self.label = CLabel("Choose action on module {} {}") layout.add_widget(self.label) layout2 = Layout([1,1,1,1]) self.add_layout(layout2) layout2.add_widget(Button("Cancel", self._cancel), 0) self._ShowPasteBtn = Button("Show current paste", self._showpaste) layout2.add_widget(self._ShowPasteBtn, 1) self._killBtn = Button("KILL", self._kill) layout2.add_widget(self._killBtn, 2) layout2.add_widget(Button("START", self._start), 3) layout3 = Layout([1,1,1,1]) self.add_layout(layout3) self.textEdit = Text("Amount", "amount") layout3.add_widget(self.textEdit, 3) self.fix()
def __init__(self, screen, model: ModelController, logger: LoggingController, ui: UIController): super().__init__(screen, height=screen.height // 2, width=screen.width // 2, can_scroll=False, title="Settings", hover_focus=True) # Controllers that access different aspects of provenance self._logger: LoggingController = logger self._model: ModelController = 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._discovery = CheckBox( "All hosts that connect are regarded as clients", label="Discovery: ", name="discovery") self._display_logs = CheckBox("Display logs on the main menu", label="Display Logs: ", name="logs") self._log_level_widget = DropdownList([("Debug", logging.DEBUG), ("Info", logging.INFO), ("Warning", logging.WARNING), ("Error", logging.ERROR), ("Critical", logging.CRITICAL)], label="Logging Level: ", name="loglevel") self._theme_widget = DropdownList([(t, t) for t in asciimatics_themes.keys()], label="Theme: ", name="theme") self._refreshrate = Text(label="Refresh Rate (s):", name="refresh") # Set default values self._refreshrate.value = str(2) self._log_level_widget.value = self._logger.log_level self._discovery.value = True self._display_logs.value = True self._theme_widget.value = ui.theme # Create and Generate Layouts layout = Layout([1], fill_frame=True) self.add_layout(layout) layout.add_widget(self._discovery) layout.add_widget(self._display_logs) layout.add_widget(self._refreshrate) layout.add_widget(self._log_level_widget) layout.add_widget(self._theme_widget) 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()
def __init__(self, screen, model): super(ContactView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, hover_focus=True, title="Contact Details", reduce_cpu=True) # Save off the model that accesses the contacts database. self._model = model # Create the form for displaying the list of contacts. layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Text("Name:", "name")) layout.add_widget(Text("Address:", "address")) layout.add_widget(Text("Phone number:", "phone")) layout.add_widget(Text("Email address:", "email")) layout.add_widget( TextBox(Widget.FILL_FRAME, "Notes:", "notes", as_string=True)) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("OK", self._ok), 0) layout2.add_widget(Button("Cancel", self._cancel), 3) self.fix()
def __init__(self, screen, game): self.game = game self.form_data = { "playerName": "", "cb_one": False, "cb_two": False, "cb_three": False, "cb_four": False, "cb_five": False, "cb_six": False, "cb_seven": False, "cb_eight": False, "cb_nine": False, "cb_ten": False } self._readConfig(game.config) super(SplashScreenFrame, self).__init__(screen, int(self.game.config.windowHeight), int(self.game.config.windowWidth), data=self.form_data, has_shadow=True, name="SplashScreen") layout = Layout([1, 18, 1]) self.add_layout(layout) self._reset_button = Button("Reset", self._reset) layout.add_widget(Divider(height=3), 1) layout.add_widget(Label("MURPHY MAN 1 - Einmaleins"), 1) layout.add_widget(Divider(height=3), 1) layout.add_widget( CheckBox("1", "1x?", "cb_one", self._on_change), 1) layout.add_widget( CheckBox("2", None, "cb_two", self._on_change), 1) layout.add_widget( CheckBox("3", None, "cb_three", self._on_change), 1) layout.add_widget( CheckBox("4", None, "cb_four", self._on_change), 1) layout.add_widget( CheckBox("5", None, "cb_five", self._on_change), 1) layout.add_widget( CheckBox("6", None, "cb_six", self._on_change), 1) layout.add_widget( CheckBox("7", None, "cb_seven", self._on_change), 1) layout.add_widget( CheckBox("8", None, "cb_eight", self._on_change), 1) layout.add_widget( CheckBox("9", None, "cb_nine", self._on_change), 1) layout.add_widget( CheckBox("10", None, "cb_ten", self._on_change), 1) layout.add_widget(Divider(height=3), 1) nameWidget = Text(label="Name:", name="playerName", on_change=self._on_change, validator="^[a-zA-Z]*$") layout.add_widget(nameWidget, 1) layout.add_widget(Divider(height=3), 1) layout2 = Layout([10, 10]) self.add_layout(layout2) layout2.add_widget(Button("Start", self._start), 0) layout2.add_widget(Button("Beenden", self._quit), 1) self.fix()
def __init__(self, screen): try: super(FlowTraceView, self).__init__(screen, screen.height, screen.width, x=0, y=0, hover_focus=True, title=" FLOW TRACE ", reduce_cpu=True) self._screen = screen layout_cpt = Layout([1]) self.add_layout(layout_cpt) layout_cpt.add_widget(Text(" [NODE] ", "COMPUTE")) layout_cpt.add_widget(Divider()) i = 0 for key, value in TRACE.trace_l2_cond_list + TRACE.trace_l3_cond_list: if i % 2 == 0: layout_line = Layout([1, 35, 3, 35, 1]) self.add_layout(layout_line) layout_line.add_widget(Text(self.key_name(key), value), 1) else: layout_line.add_widget(Text(self.key_name(key), value), 3) i = i + 1 layout_btn = Layout([1, 3, 3, 3, 3]) self.add_layout(layout_btn) layout_btn.add_widget(Divider(), 0) layout_btn.add_widget(Divider(), 1) layout_btn.add_widget(Divider(), 2) layout_btn.add_widget(Divider(), 3) layout_btn.add_widget(Divider(), 4) layout_btn.add_widget(Button("Start Trace", self._ok), 1) layout_btn.add_widget(Button("Clear All", self.reset), 2) layout_btn.add_widget(Button("Menu", self._menu), 3) layout_btn.add_widget(Button("Quit", self._quit), 4) layout_btn.add_widget(Divider(height=2), 0) layout_btn.add_widget(Divider(), 1) layout_btn.add_widget(Divider(), 2) layout_btn.add_widget(Divider(), 3) layout_btn.add_widget(Divider(), 4) layout_result = Layout([1], fill_frame=True) self.add_layout(layout_result) self._trace_result = TextBox(Widget.FILL_FRAME, name='Flow', label='[Flow]', as_string=True) layout_result.add_widget(self._trace_result) layout_result.add_widget(Divider()) self._list_view = ListBox(5, self.trace_history, name="LIST_HISTORY", label="[HISTORY]") layout_history = Layout([1]) self.add_layout(layout_history) layout_history.add_widget(self._list_view) self.fix() self.palette = defaultdict(lambda: (Screen.COLOUR_WHITE, Screen. A_BOLD, Screen.COLOUR_CYAN)) self.palette["selected_focus_field"] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_YELLOW) self.palette["title"] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_CYAN) self.palette["edit_text"] = (Screen.COLOUR_BLUE, Screen.A_BOLD, Screen.COLOUR_CYAN) self.palette["focus_edit_text"] = (Screen.COLOUR_BLUE, Screen.A_BOLD, Screen.COLOUR_YELLOW) self.palette["focus_button"] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_YELLOW) self.palette["label"] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_CYAN) except: LOG.exception_err_write()
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()
def __init__(self, screen): super(Dashboard, self).__init__(screen, screen.height, screen.width, hover_focus=True, reduce_cpu=True) self._list_view_run_queue = CListBox("running", screen.height // 2, [], name="LIST") self._list_view_idle_queue = CListBox("idle", screen.height // 2, [], name="LIST") self._list_view_noRunning = CListBox("notRunning", screen.height // 5, [], name="LIST") self._list_view_Log = CListBox("logs", screen.height // 4, [], name="LIST") #self._list_view_Log.disabled = True #Running Queues layout = Layout([100]) self.add_layout(layout) text_rq = CLabel("Running Queues") layout.add_widget(text_rq) layout.add_widget(CLabel(TABLES_TITLES["running"], listTitle=True)) layout.add_widget(self._list_view_run_queue) layout.add_widget(Divider()) #Idling Queues layout2 = Layout([1, 1]) self.add_layout(layout2) text_iq = CLabel("Idling Queues") layout2.add_widget(text_iq, 0) layout2.add_widget(CLabel(TABLES_TITLES["idle"], listTitle=True), 0) layout2.add_widget(self._list_view_idle_queue, 0) #Non Running Queues text_nq = CLabel("Queues not running") layout2.add_widget(text_nq, 1) layout2.add_widget(CLabel(TABLES_TITLES["notRunning"], listTitle=True), 1) layout2.add_widget(self._list_view_noRunning, 1) layout2.add_widget(Divider(), 1) #Log text_l = CLabel("Logs") layout2.add_widget(text_l, 1) layout2.add_widget(CLabel(TABLES_TITLES["logs"], listTitle=True), 1) layout2.add_widget(self._list_view_Log, 1) self.fix()
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()
def __init__(self, screen, recipe): name = recipe['title'] image_url = recipe['image'] self.missed_ingredients = recipe['missedIngredients'] self.recipie_id = recipe['id'] used_ingredients = recipe['usedIngredients'] super(Recipie, self).__init__(screen, int(screen.height) - 10, int(screen.width // 2), x=(int(screen.width // 2) - 5), has_shadow=True) layout = Layout([1]) self.add_layout(layout) layout.add_widget(Label(name, align='^', height=2), 0) layout.add_widget(Divider(height=1), 0) layout2 = Layout([1, 1]) self.add_layout(layout2) layout2.add_widget(Label("Used Ingrediants", height=2), 0) for used_ingredient in used_ingredients: layout2.add_widget(Label(f" - {used_ingredient['name']}"), 0) layout2.add_widget(Label("", height=1), 0) layout2.add_widget( Label("Ingrediants Required From the Groccery Store", height=2), 0) for missed_ingredient in self.missed_ingredients: layout2.add_widget(Label(f" - {missed_ingredient['name']}"), 0) layout2.add_widget(Label("", height=1), 0) self.image_name = self._download_image(image_url) image = Print(screen, ColourImageFile(screen, self.image_name), x=5, y=5) self.add_effect(image) layout3 = Layout([1, 1, 1]) self.add_layout(layout3) layout3.add_widget(Button("Don't Add And Continue", self._dont_add), 0) layout3.add_widget(Button("Add and Continue", self._add), 1) layout3.add_widget(Button("Quit", self._quit), 2) self.fix()
def __init__(self, screen, model): super(ListView, self).__init__(screen, height=screen.height, width=screen.width, can_scroll=False, on_load=self._reload_list, title='Windows PATH variable transfer ') self._model = model self.current_id = 0 layout = Layout([1], fill_frame=True) self.add_layout(layout) self._list_view = MultiColumnListBox( Widget.FILL_FRAME, columns=['<3', '<5', '<10', '<20%', '<100%'], options=self._model.get_summary(), titles=['S', 'Wind', 'branch', 'value', 'data'], name="key values", add_scroll_bar=True, on_change=self._on_pick, on_select=self._select) layout.add_widget(self._list_view) layout2 = Layout([1, 1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button('Load config', self._load_configfile), 0) layout2.add_widget(Button('Select all', self._select_all), 1) layout2.add_widget(Button('Update registry', self._update_registry), 2) layout2.add_widget(Button('Unselect all', self._unselect_all), 3) layout2.add_widget(Button("Quit", self._quit), 4) self.fix()
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]*$", max_length=4), 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(DropdownList( [("Item 1", 1), ("Item 2", 2), ("Item 3", 3), ("Item 3", 4), ("Item 3", 5), ("Item 3", 6), ("Item 3", 7), ("Item 3", 8), ("Item 3", 9), ("Item 3", 10), ("Item 3", 11), ("Item 3", 12), ("Item 3", 13), ("Item 3", 14), ("Item 3", 15), ("Item 3", 16), ("Item 4", 17), ("Item 5", 18), ], label="Dropdown", name="DD", 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()
def __init__(self, screen, init_values): super(TestFrame2, self).__init__(screen, screen.height, screen.width, title="Test Frame 2") # Create the form for displaying the list of contacts. self._list_view = ListBox(Widget.FILL_FRAME, init_values, name="contacts", on_change=self._on_pick) self._edit_button = Button("Edit", self._edit) self._delete_button = Button("Delete", self._delete) layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(self._list_view) layout.add_widget(Divider()) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("Add", self._add), 0) layout2.add_widget(self._edit_button, 1) layout2.add_widget(self._delete_button, 2) layout2.add_widget(Button("Quit", self._quit), 3) self.fix() self._on_pick()
def __init__(self, screen, model): super(ContactView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, hover_focus=True, can_scroll=False, title="Contact Details", reduce_cpu=True) # Save off the model that accesses the contacts database. self._model = model # Create the form for displaying the list of contacts. layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Text("Name:", "name")) layout.add_widget(Text("Address:", "address")) layout.add_widget(Text("Phone number:", "phone")) layout.add_widget(Text("Email address:", "email")) layout.add_widget(TextBox( Widget.FILL_FRAME, "Notes:", "notes", as_string=True, line_wrap=True)) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("OK", self._ok), 0) layout2.add_widget(Button("Cancel", self._cancel), 3) self.fix()
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()
def __init__(self, screen, init_values): super(TestFrame2, self).__init__(screen, screen.height, screen.width, title="Test Frame 2") # Create the form for displaying the list of contacts. self._list_view = ListBox( Widget.FILL_FRAME, init_values, name="contacts", on_change=self._on_pick) self._edit_button = Button("Edit", self._edit) self._delete_button = Button("Delete", self._delete) layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(self._list_view) layout.add_widget(Divider()) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button("Add", self._add), 0) layout2.add_widget(self._edit_button, 1) layout2.add_widget(self._delete_button, 2) layout2.add_widget(Button("Quit", self._quit), 3) self.fix() self._on_pick()
def test_multi_column_list_box(self): """ Check MultiColumnListBox works as expected. """ # Create a dummy screen. screen = MagicMock(spec=Screen, colours=8, unicode_aware=False) scene = MagicMock(spec=Scene) canvas = Canvas(screen, 10, 40, 0, 0) # Create the form we want to test. form = Frame(canvas, canvas.height, canvas.width, has_border=False) layout = Layout([100], fill_frame=True) mc_list = MultiColumnListBox( Widget.FILL_FRAME, [3, "4", ">4", "<4", ">10%", "100%"], [ (["1", "2", "3", "4", "5", "6"], 1), (["11", "222", "333", "444", "555", "6"], 2), (["111", "2", "3", "4", "5", "6"], 3), (["1", "2", "33333", "4", "5", "6"], 4), (["1", "2", "3", "4", "5", "6666666666666666666666"], 5), ], titles=["A", "B", "C", "D", "E", "F"], name="mc_list") form.add_layout(layout) layout.add_widget(mc_list) form.fix() form.register_scene(scene) form.reset() # Check we have a default value for our list. form.save() self.assertEqual(form.data, {"mc_list": 1}) # Check that UP/DOWN change selection. self.process_keys(form, [Screen.KEY_DOWN]) form.save() self.assertEqual(form.data, {"mc_list": 2}) self.process_keys(form, [Screen.KEY_UP]) form.save() self.assertEqual(form.data, {"mc_list": 1}) # Check that PGUP/PGDN change selection. self.process_keys(form, [Screen.KEY_PAGE_DOWN]) form.save() self.assertEqual(form.data, {"mc_list": 5}) self.process_keys(form, [Screen.KEY_PAGE_UP]) form.save() self.assertEqual(form.data, {"mc_list": 1}) # Check that the widget is rendered correctly. form.update(0) self.assert_canvas_equals( canvas, "A B C D E F \n" + "1 2 3 4 5 6 \n" + "11 222 333 444 555 6 \n" + "...2 3 4 5 6 \n" + "1 2 3... 4 5 6 \n" + "1 2 3 4 5 6666666666666666666\n" + " \n" + " \n" + " \n" + " \n") # Check that mouse input changes selection. self.process_mouse(form, [(2, 2, MouseEvent.LEFT_CLICK)]) form.save() self.assertEqual(form.data, {"mc_list": 2}) self.process_mouse(form, [(2, 1, MouseEvent.LEFT_CLICK)]) form.save() self.assertEqual(form.data, {"mc_list": 1}) # Check that the start_line can be read and set - and enforces good behaviour mc_list.start_line = 0 self.assertEqual(mc_list.start_line, 0) mc_list.start_line = len(mc_list.options) - 1 self.assertEqual(mc_list.start_line, len(mc_list.options) - 1) mc_list.start_line = 10000000 self.assertEqual(mc_list.start_line, len(mc_list.options) - 1) # Check that options can be read and set. mc_list.options = [(["a", "b", "c", "d", "e", "f"], 0)] self.assertEqual(mc_list.options, [(["a", "b", "c", "d", "e", "f"], 0)]) mc_list.options = [] self.assertEqual(mc_list.options, []) # Check that the form re-renders correctly afterwards. self.maxDiff = None form.update(1) self.assert_canvas_equals( canvas, "A B C D E F \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n") # Check that the current focus ignores unknown events. event = object() self.assertEqual(event, form.process_event(event))
def __init__(self, screen): super(DemoFrame, self).__init__(screen, int(screen.height * 2 // 3), int(screen.width * 2 // 3), data=form_data, 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()
def __init__(self, screen, agent_data): super(AgentConfView, self).__init__(screen, screen.height * 2 // 3, screen.width * 2 // 3, hover_focus=True, title='Define Agent configuration', reduce_cpu=True ) self._agent_data = agent_data layout = Layout([100], fill_frame=True) self.add_layout(layout) layout.add_widget(Text('Hostname:', 'agent_hostname')) layout.add_widget(Text('IP:', 'agent_ip')) layout.add_widget(Text('Agent name:', 'agent_name')) debug_choice = ListBox(4, [('Debug', 'logging.DEBUG'), ('Info', 'logging.INFO'), ('Warning', 'logging.WARNING'), ('Error', 'logging.ERROR'), ('Critical', 'logging.CRITICAL')], label='Agent debug level:', name='agent_debug_level') layout.add_widget(debug_choice) layout.add_widget(Text('Agent log path:', 'agent_log_path')) layout.add_widget(Text('RADIUS env path:', 'radius_env_path')) layout.add_widget(Text('RADIUS log path:', 'radius_log_path')) layout2 = Layout([1, 1, 1, 1]) self.add_layout(layout2) layout2.add_widget(Button('Next', self._next), 2) layout2.add_widget(Button('Quit', self._quit), 3) self.fix()