israel-dryer / ttkbootstrap

A supercharged theme extension for tkinter that enables on-demand modern flat style themes inspired by Bootstrap.
MIT License
1.88k stars 375 forks source link

Some considerations about the tableview #123

Closed antrrax closed 2 years ago

antrrax commented 2 years ago

When any number greater or less(0) than the maximum number of pages is entered into the Entry index. Currently loads an empty page, it would be better to load the first page. Because the input index is changed to 1


It would also be nice that whenever the information is loaded in the treeview or when moving to the next page, the first row is selected. And when returning to the previous page, the last line would be selected. This facilitates external automations


Striped lines would by default have better contrast in all themes (even, odd and selected lines). I made a few tries and I think these color options are good for all themes. I tried using the Api colors, I just needed to include an extra color #f3f3f3

        lst_dark_themes = ['solar', 'superhero', 'darkly', 'cyborg', 'vapor']
        if self.data['theme'] in lst_dark_themes:
            cst_striped = (self.style.colors.bg, self.style.colors.inputfg)
        else:
            if self.data['theme'] == 'morph':
                cst_striped = (self.style.colors.border, self.style.colors.fg)
            else:
                cst_striped = ('#f3f3f3', self.style.colors.inputfg)

See the example with the colors mentioned: https://www.mediafire.com/file/hrc8rjdmvekpn3x/striped_rows.mp4/file


israel-dryer commented 2 years ago

I'm adding an 'active' color which is either the default or 'active' color in the bootstyle table header section for each theme. https://bootswatch.com/darkly/

I'm going to modify the logic so that stripecolor=None will result in no stripes as usual, however, passing in a tuple (None, None) will result in default colored table stripes, where "None" is the default color for either the background or foreground.

image image
israel-dryer commented 2 years ago

@antrrax, I found the bug for that page number issue and and updating this in the next release.

antrrax commented 2 years ago

I don't know if I should open another issue, or post it here

I'm testing this new version of Widget.

When the typed page is smaller or larger than the limit, it is now correct. But when the typed page is in the limit, it adds 1 to the typed page number.


Striped lines are not being applied (bg and fg were not passed to the striped attribute). With this change below, it is possible to apply the striped lines:

    def apply_table_stripes(self, stripecolor):
        if len(stripecolor) == 2:
            self._stripecolor = stripecolor
            bg, fg = stripecolor
            kw = {}
            if bg is None:
                kw["background"] = colors.active
            else:
                kw["background"] = bg

            if fg is None:
                kw["foreground"] = colors.inputfg
            else:
                kw["foreground"] = fg

            self.view.tag_configure("striped", **kw)

Needed to add this:

            else:
               kw["background"] = bg

and that:

            else:
                kw["foreground"] = fg
antrrax commented 2 years ago

Something I noticed now, I think it would be better to put the function

if len(self.view.get_children()) > 0:
    try:
        self._select_first_visible_item()
    ....

at the end of

set load_table_data


This ensures that whenever the table data is loaded the first item will always be selected, currently when filtering or sorting the header this does not happen

israel-dryer commented 2 years ago

@antrrax, yeah, go ahead and open a new issue.