Browse Source

PR #500, point 3: Rename ui.table.py() to ui.qtable() and reintroduce ui.table deprecation notice.

Dominique CLAUSE 2 years ago
parent
commit
b9bd74abd8
4 changed files with 17 additions and 15 deletions
  1. 1 1
      examples/table_and_slots/main.py
  2. 10 10
      nicegui/elements/table.py
  3. 3 1
      nicegui/ui.py
  4. 3 3
      website/reference.py

+ 1 - 1
examples/table_and_slots/main.py

@@ -16,7 +16,7 @@ class Demo:
     ]
     ]
 
 
 
 
-with ui.table(title='Table', columns=Demo.fields, rows=Demo.data, selection='single') \
+with ui.qtable(title='QTable', columns=Demo.fields, rows=Demo.data, selection='single') \
         .bind_value(Demo, 'filter') as table:
         .bind_value(Demo, 'filter') as table:
     with table.add_slot('top-right'):
     with table.add_slot('top-right'):
         with ui.input(placeholder='Search').props('type="search"').bind_value(Demo, 'filter') as search:
         with ui.input(placeholder='Search').props('type="search"').bind_value(Demo, 'filter') as search:

+ 10 - 10
nicegui/elements/table.py

@@ -6,30 +6,30 @@ from .mixins.value_element import ValueElement
 from ..element import Element
 from ..element import Element
 
 
 
 
-class Tr(Element):
+class QTr(Element):
     def __init__(self) -> None:
     def __init__(self) -> None:
         super().__init__('q-tr')
         super().__init__('q-tr')
 
 
 
 
-class Th(Element):
+class QTh(Element):
     def __init__(self) -> None:
     def __init__(self) -> None:
         super().__init__('q-th')
         super().__init__('q-th')
 
 
 
 
-class Td(Element):
+class QTd(Element):
     def __init__(self, key: str = '') -> None:
     def __init__(self, key: str = '') -> None:
         super().__init__('q-td')
         super().__init__('q-td')
         if key:
         if key:
             self._props['key'] = key
             self._props['key'] = key
 
 
 
 
-class Table(ValueElement):
+class QTable(ValueElement):
     VALUE_PROP = 'filter'
     VALUE_PROP = 'filter'
 
 
     # Scope table element as Table class attributes.
     # Scope table element as Table class attributes.
-    row = Tr
-    header = Th
-    cell = Td
+    row = QTr
+    header = QTh
+    cell = QTd
 
 
     def __init__(
     def __init__(
             self,
             self,
@@ -39,11 +39,11 @@ class Table(ValueElement):
             selection: Optional[Literal['single', 'multiple', 'none']] = 'none',
             selection: Optional[Literal['single', 'multiple', 'none']] = 'none',
             on_filter_change: Optional[Callable] = None,
             on_filter_change: Optional[Callable] = None,
     ) -> None:
     ) -> None:
-        """Table
+        """QTable
 
 
-        A component that allows you to display using `QTable <https://quasar.dev/vue-components/table>` component.
+        A component that allows you to display using `QTable <https://quasar.dev/vue-components/table>`_ component.
 
 
-        :param columns: A list of column objects (see `column API <https://quasar.dev/vue-components/table#qtable-api>`)
+        :param columns: A list of column objects (see `column API <https://quasar.dev/vue-components/table#qtable-api>`_)
         :param rows: A list of row objects.
         :param rows: A list of row objects.
         :param title: The title of the table.
         :param title: The title of the table.
         :param selection: defines the selection behavior.
         :param selection: defines the selection behavior.

+ 3 - 1
nicegui/ui.py

@@ -47,7 +47,7 @@ from .elements.separator import Separator as separator
 from .elements.slider import Slider as slider
 from .elements.slider import Slider as slider
 from .elements.spinner import Spinner as spinner
 from .elements.spinner import Spinner as spinner
 from .elements.switch import Switch as switch
 from .elements.switch import Switch as switch
-from .elements.table import Table as table
+from .elements.table import QTable as qtable
 from .elements.tabs import Tab as tab
 from .elements.tabs import Tab as tab
 from .elements.tabs import TabPanel as tab_panel
 from .elements.tabs import TabPanel as tab_panel
 from .elements.tabs import TabPanels as tab_panels
 from .elements.tabs import TabPanels as tab_panels
@@ -75,6 +75,8 @@ from .page_layout import RightDrawer as right_drawer
 from .run import run
 from .run import run
 from .run_with import run_with
 from .run_with import run_with
 
 
+table = deprecated(aggrid, 'ui.table', 'ui.aggrid', 370)
+
 if os.environ.get('MATPLOTLIB', 'true').lower() == 'true':
 if os.environ.get('MATPLOTLIB', 'true').lower() == 'true':
     from .elements.line_plot import LinePlot as line_plot
     from .elements.line_plot import LinePlot as line_plot
     from .elements.pyplot import Pyplot as pyplot
     from .elements.pyplot import Pyplot as pyplot

+ 3 - 3
website/reference.py

@@ -292,8 +292,8 @@ To overlay an SVG, make the `viewBox` exactly the size of the image and provide
         ui.button('Update', on_click=update)
         ui.button('Update', on_click=update)
         ui.button('Select all', on_click=lambda: grid.call_api_method('selectAll'))
         ui.button('Select all', on_click=lambda: grid.call_api_method('selectAll'))
 
 
-    @example(ui.table, menu)
-    def table_example():
+    @example(ui.qtable, menu)
+    def qtable_example():
 
 
         fields = [
         fields = [
             {'name': 'name', 'label': 'Name', 'field': 'name', 'required': True, 'align': 'left'},
             {'name': 'name', 'label': 'Name', 'field': 'name', 'required': True, 'align': 'left'},
@@ -306,7 +306,7 @@ To overlay an SVG, make the `viewBox` exactly the size of the image and provide
             {'name': 'Carol'},
             {'name': 'Carol'},
         ]
         ]
 
 
-        ui.table(columns=fields, rows=data, selection='none').props('hide-pagination').classes('w-full')
+        ui.qtable(columns=fields, rows=data, selection='none').props('hide-pagination').classes('w-full')
 
 
     @example(ui.chart, menu)
     @example(ui.chart, menu)
     def chart_example():
     def chart_example():