Example #1
0
 def add_listbox(self, height, options, default_value=None, on_select=None, layout=[100], layout_index=0, add_divider=True, **kwargs):
     _layout = Layout(layout)
     self.add_layout(_layout)
     list_widget = ListBox(height, options, on_select=on_select, **kwargs)
     _layout.add_widget(list_widget, layout_index)
     if add_divider:
         _layout.add_widget(Divider(draw_line=False))
     if default_value is not None:
         list_widget._value = default_value
     return lambda: list_widget.value
Example #2
0
    def __init__(self, screen, interface):
        super(NetworkOptions, self).__init__(screen,
                                             8,
                                             26,
                                             y=2,
                                             has_shadow=True,
                                             is_modal=True,
                                             name="networkopts",
                                             title="Network Options",
                                             can_scroll=False)
        self.set_theme('shadowlands')
        self._interface = interface

        #debug(); pdb.set_trace()

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

        self._node = self._interface.node

        options = [
            ('Local node', 'connect_w3_local'),
            ('Custom infura', 'connect_w3_custom_infura'),
            ('Custom http', 'connect_w3_custom_http'),
            ('Custom websocket', 'connect_w3_custom_websocket'),
            ('Custom ipc', 'connect_w3_custom_ipc'),
            #('Custom Infura API Key', 'connect_w3_custom_infura'),
        ]
        listbox = ListBox(4, options, on_select=self._ok, name='netpicker')

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

        layout.add_widget(listbox)

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

        layout2.add_widget(Button("Cancel", self._cancel))
        #layout2.add_widget(Button("Connect", self._ok), 0)
        self.fix()