Пример #1
0
    def __init__(self, label="Date", **kwargs):

        date_picker = v.DatePicker(no_title=True,
                                   v_model=None,
                                   scrollable=True)

        date_text = v.TextField(v_model=None,
                                label=label,
                                hint="YYYY-MM-DD format",
                                persistent_hint=True,
                                prepend_icon="event",
                                readonly=True,
                                v_on='menuData.on')

        menu = v.Menu(transition="scale-transition",
                      offset_y=True,
                      v_slots=[{
                          'name': 'activator',
                          'variable': 'menuData',
                          'children': date_text,
                      }],
                      children=[date_picker])

        super().__init__(v_model=None,
                         row=True,
                         class_='pa-5',
                         align_center=True,
                         children=[v.Flex(xs10=True, children=[menu])],
                         **kwargs)

        jslink((date_picker, 'v_model'), (date_text, 'v_model'))
        jslink((date_picker, 'v_model'), (self, 'v_model'))
Пример #2
0
    def __init__(self,
                 extentions=['.txt'],
                 folder=os.path.expanduser('~'),
                 label='select file',
                 **kwargs):

        self.extentions = extentions
        self.folder = folder

        self.selected_file = v.TextField(label='file', v_model=self.file)

        self.file_list = v.List(
            dense=True,
            color='grey lighten-4',
            flat=True,
            children=[v.ListItemGroup(children=self.get_items(), v_model='')])

        self.file_menu = v.Menu(min_width=300,
                                children=[self.file_list],
                                close_on_content_click=False,
                                max_height='300px',
                                v_slots=[{
                                    'name':
                                    'activator',
                                    'variable':
                                    'x',
                                    'children':
                                    v.Btn(v_model=False,
                                          v_on='x.on',
                                          children=[label])
                                }])

        super().__init__(row=True,
                         class_='pa-5',
                         align_center=True,
                         children=[
                             v.Flex(xs12=True, children=[self.selected_file]),
                             v.Flex(xs12=True, children=[self.file_menu])
                         ],
                         **kwargs)

        link((self.selected_file, 'v_model'), (self, 'file'))

        def on_file_select(change):

            new_value = change['new']
            if new_value:
                if os.path.isdir(new_value):
                    self.folder = new_value
                    self.change_folder()

                elif os.path.isfile(new_value):
                    self.file = new_value

        self.file_list.children[0].observe(on_file_select, 'v_model')
Пример #3
0
 def __init__(self):
     
     # create the extra widget
     self.state = sw.StateBar(done=True)
     self.color = v.ListItemGroup(v_model = None, children=[v.ListItem(children= [c], value=c) for c in cp.planet_colors[:4]])
     self.palette = v.Menu(
         value=False,
         v_slots=[{
             'name': 'activator',
             'variable': 'menu',
             'children': v.Btn(v_model = False, v_on='menu.on', color='primary', icon = True, children=[v.Icon(children=['mdi-palette'])])
         }],
         children = [v.List(dense=True, outlined=True, rounded=True, children=[self.color])]
     )
     
     # create the map 
     super().__init__(gee=False)
     
     # add the widget to the map (as to left and right items)
     self.add_control(WidgetControl(widget=self.state, position='topleft'))
     self.add_control(WidgetControl(widget=self.palette, position='topleft'))
     
     # create jslinks
     jslink((self, 'combo'), (self.color, 'v_model'))
Пример #4
0
    def __init__(self,
                 extentions=[],
                 folder=os.path.expanduser('~'),
                 label='search file',
                 **kwargs):

        self.extentions = extentions
        self.folder = folder

        self.selected_file = v.TextField(label='Selected file',
                                         class_='ml-5 mt-5',
                                         v_model=self.file)

        self.loading = v.ProgressLinear(
            indeterminate=False, color=COMPONENTS['PROGRESS_BAR']['color'])

        self.file_list = v.List(dense=True,
                                color='grey lighten-4',
                                flat=True,
                                children=[
                                    self.loading,
                                    v.ListItemGroup(children=self.get_items(),
                                                    v_model='')
                                ])

        self.file_menu = v.Menu(min_width=300,
                                children=[self.file_list],
                                close_on_content_click=False,
                                max_height='300px',
                                v_slots=[{
                                    'name':
                                    'activator',
                                    'variable':
                                    'x',
                                    'children':
                                    Btn(icon='mdi-file-search',
                                        v_model=False,
                                        v_on='x.on',
                                        text=label)
                                }])

        super().__init__(row=True,
                         class_='d-flex align-center mb-2',
                         align_center=True,
                         children=[
                             self.file_menu,
                             self.selected_file,
                         ],
                         **kwargs)

        link((self.selected_file, 'v_model'), (self, 'file'))

        def on_file_select(change):
            new_value = change['new']
            if new_value:
                if os.path.isdir(new_value):
                    self.folder = new_value
                    self.change_folder()

                elif os.path.isfile(new_value):
                    self.file = new_value

        self.file_list.children[1].observe(on_file_select, 'v_model')
Пример #5
0
    def __init__(self, filename, vizapp):

        self._vizapp = vizapp

        self._vizapp.glue_app.load_data(filename)

        #
        #  Create File Menu
        #
        self.tile_load = v.ListTile(
            children=[v.ListTileTitle(children=["Load"])])
        self.tile_save = v.ListTile(
            children=[v.ListTileTitle(children=["Save"])])
        self.tile_load.on_event('click', self._on_change_menu_bar_file)
        self.tile_save.on_event('click', self._on_change_menu_bar_file)
        self.f_items = [self.tile_load, self.tile_save]

        self._menu_bar_file = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'File',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.f_items)
                   ])
        ])

        #
        #  Create Add Viewer Menu
        #
        self.tile_3d_viewer = v.ListTile(
            children=[v.ListTileTitle(children=["3D Viewer"])])
        self.tile_3d_viewer.on_event('click', self._on_change_menu_bar_viewer)
        self.v_items = [self.tile_3d_viewer]

        self._menu_bar_viewer = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'Add Viewer',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.v_items)
                   ])
        ])

        # Add to menu bar
        self._menu_bar = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_file]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_viewer]),
                                  ])

        self._menu_bar.box_style = 'success'

        self._v3d = ViewerND(self._vizapp)

        # Going to set the upper percentile rather than use the max value.
        self._v3d._v3d.state.layers[0].percentile = 99.5

        self._main_box = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs12=True,
                                             class_='px-2',
                                             children=[self._menu_bar]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._v3d.show()]),
                                  ])
Пример #6
0
    def __init__(self, filename, vizapp, process_data=None):

        self._vizapp = vizapp

        self._vizapp.glue_app.load_data(filename)
        if process_data is not None:
            process_data(self)

        #
        #  Create File Menu
        #
        self.tile_load = v.ListTile(
            children=[v.ListTileTitle(children=["Load"])])
        self.tile_save = v.ListTile(
            children=[v.ListTileTitle(children=["Save"])])
        self.tile_load.on_event('click', self._on_change_menu_bar_file)
        self.tile_save.on_event('click', self._on_change_menu_bar_file)
        self.f_items = [self.tile_load, self.tile_save]

        self._menu_bar_file = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'File',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.f_items)
                   ])
        ])

        #
        #  Create Add Viewer Menu
        #
        self.tile_3d_viewer = v.ListTile(
            children=[v.ListTileTitle(children=["3D Viewer"])])
        self.tile_1d_viewer = v.ListTile(
            children=[v.ListTileTitle(children=["1D Viewer"])])
        self.tile_3d_viewer.on_event('click', self._on_change_menu_bar_viewer)
        self.tile_1d_viewer.on_event('click', self._on_change_menu_bar_viewer)
        self.v_items = [self.tile_3d_viewer, self.tile_1d_viewer]

        self._menu_bar_viewer = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'Add Viewer',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.v_items)
                   ])
        ])

        # Add to menu bar
        self._menu_bar = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_file]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_viewer]),
                                  ])

        self._menu_bar.box_style = 'success'

        self._v1d = Viewer1D(self._vizapp)
        self._v3d = ViewerND(self._vizapp)

        self._main_box = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs12=True,
                                             class_='px-2',
                                             children=[self._menu_bar]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._v3d.show()]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._v1d.show()]),
                                  ])
Пример #7
0
    def __init__(self,
                 extentions=[],
                 folder=os.path.expanduser('~'),
                 label='search file',
                 v_model=None,
                 **kwargs):

        self.extentions = extentions
        self.folder = folder

        self.selected_file = v.TextField(readonly=True,
                                         label='Selected file',
                                         class_='ml-5 mt-5',
                                         v_model=self.file)

        self.loading = v.ProgressLinear(
            indeterminate=False,
            background_color='grey darken-3',
            color=COMPONENTS['PROGRESS_BAR']['color'])

        self.file_list = v.List(
            dense=True,
            color='grey darken-3',
            flat=True,
            max_height='300px',
            style_='overflow: auto; border-radius: 0 0 0 0;',
            children=[v.ListItemGroup(children=self._get_items(), v_model='')])

        self.file_menu = v.Menu(min_width=300,
                                children=[self.loading, self.file_list],
                                close_on_content_click=False,
                                v_slots=[{
                                    'name':
                                    'activator',
                                    'variable':
                                    'x',
                                    'children':
                                    Btn(icon='mdi-file-search',
                                        v_model=False,
                                        v_on='x.on',
                                        text=label)
                                }])

        self.reload = v.Btn(icon=True,
                            color='primary',
                            children=[v.Icon(children=['mdi-cached'])])

        super().__init__(row=True,
                         class_='d-flex align-center mb-2',
                         align_center=True,
                         children=[
                             self.reload,
                             self.file_menu,
                             self.selected_file,
                         ],
                         **kwargs)

        link((self.selected_file, 'v_model'), (self, 'file'))
        link((self.selected_file, 'v_model'), (self, 'v_model'))

        self.file_list.children[0].observe(self._on_file_select, 'v_model')
        self.reload.on_event('click', self._on_reload)
Пример #8
0
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. 
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'''

items = [
    v.ListItem(children=[v.ListItemTitle(children=[f'Click me {i}'])])
    for i in range(1, 5)
]

menu = v.Menu(offset_y=True,
              v_slots=[{
                  'name':
                  'activator',
                  'variable':
                  'menuData',
                  'children':
                  v.Btn(v_on='menuData.on',
                        color='primary',
                        children=[
                            'menu',
                            v.Icon(right=True, children=['mdi-menu-down'])
                        ]),
              }],
              children=[v.List(children=items)])

dialog = v.Dialog(
    width='500',
    v_slots=[{
        'name':
        'activator',
        'variable':
        'x',