Skip to content

Commit

Permalink
Merge pull request #2017 from freakboy3742/audit-tree
Browse files Browse the repository at this point in the history
[widget Audit] toga.Tree
  • Loading branch information
freakboy3742 committed Aug 29, 2023
2 parents da6e7b3 + 3911cad commit 237ccee
Show file tree
Hide file tree
Showing 54 changed files with 3,855 additions and 1,982 deletions.
11 changes: 8 additions & 3 deletions android/src/toga_android/widgets/table.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from warnings import warn

from travertino.size import at_least

import toga

from ..libs.activity import MainActivity
from ..libs.android import R__attr
from ..libs.android.graphics import Rect, Typeface
Expand Down Expand Up @@ -162,13 +166,14 @@ def create_table_row(self, row_index):
return table_row

def get_data_value(self, row_index, col_index):
row_object = self.interface.data[row_index]
value = getattr(
row_object,
self.interface.data[row_index],
self.interface._accessors[col_index],
None,
)

if isinstance(value, toga.Widget):
warn("This backend does not support the use of widgets in cells")
value = None
if isinstance(value, tuple): # TODO: support icons
value = value[1]
if value is None:
Expand Down
7 changes: 7 additions & 0 deletions android/tests_backend/widgets/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from android.widget import ScrollView, TableLayout, TextView

from .base import SimpleProbe
from .properties import toga_font

HEADER = "HEADER"

Expand All @@ -11,6 +12,7 @@ class TableProbe(SimpleProbe):
native_class = ScrollView
supports_icons = False
supports_keyboard_shortcuts = False
supports_widgets = False

def __init__(self, widget):
super().__init__(widget)
Expand Down Expand Up @@ -86,3 +88,8 @@ async def select_row(self, row, add=False):

async def activate_row(self, row):
self._row_view(row).performLongClick()

@property
def font(self):
tv = self._row_view(0).getChildAt(0)
return toga_font(tv.getTypeface(), tv.getTextSize(), tv.getResources())
2 changes: 2 additions & 0 deletions changes/1767.feature.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Headings are no longer mandatory for Tree widgets.
If headings are not provided, the widget will not display its header bar.
2 changes: 1 addition & 1 deletion changes/2011.removal.2.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Tables now use an empty string for the default missing value on a Table.
Tables now use an empty string for the default missing value, rather than warning about missing values.
1 change: 1 addition & 0 deletions changes/2017.feature.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Tree widget now has 100% test coverage and complete API documentation.
1 change: 1 addition & 0 deletions changes/2017.feature.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Columns can now be added and removed from a Tree.
1 change: 1 addition & 0 deletions changes/2017.removal.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``parent`` argument has been removed from the ``insert`` and ``append`` calls on ``TreeSource``. This improves consistency between the API for ``TreeSource`` and the API for ``list``. To insert or append a row in to a descendent of a TreeSource root, use ``insert`` and ``append`` on the parent node itself - i.e., ``source.insert(parent, index, ...)`` becomes ``parent.insert(index, ...)``, and ``source.insert(None, index, ...)`` becomes ``source.insert(index, ...)``.
1 change: 1 addition & 0 deletions changes/2017.removal.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Trees now use an empty string for the default missing value, rather than warning about missing values.
1 change: 1 addition & 0 deletions changes/2017.removal.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``Table.on_double_click`` has been renamed ``Table.on_activate``.

0 comments on commit 237ccee

Please sign in to comment.