Forum Archive

TableView content_size Problem

DavinE

Hey guys,

i have a weird problem with an TableView....

when my view on an iPhone or iPad is "full" i need scrolling to see more of my stuff but the last row of my TableView is always out of my View..

when I want to see the last row and scroll down and as soon as I let go it pops out of view again but i don't know why...
did i already a mistake... :(

        self.table_view = ui.TableView()
        self.table_view.data_source = self
        self.table_view.delegate = self
        self.table_view.flex = 'WH'
        self.table_view.allows_selection_during_editing = True
        self.table_view.tint_color = 'grey'

        dock(self.table_view).top_left(self.view)
        at(self.table_view).top = at(self.adaptSpecificCustomer).bottom

EDIT:

On this pic:
https://imgur.com/a/sejyonX
Is in the left side free Space How can i Remove this ?

This is a Video to explain my issue at the Main Topic
https://imgur.com/a/g9tnWOe

cvp

@DavinE do you use tableview_cell_for_row and content_inset?
Do you set a cell type like in ui.TableViewCell(type)?

DavinE

@cvp said:

@DavinE do you use tableview_cell_for_row and content_inset?

I'm using tableview_cell_for_row but not content_inset

@cvp said:

Do you set a cell type like in ui.TableViewCell(type)?

No, i only use ui.TableViewCell() not a special Type

@DavinE said:

On this pic:
https://imgur.com/a/sejyonX
Is in the left side free Space How can i Remove this ?

I know where this Problem comes from but not how to solve it....
when i remove editing = True it is gone

This is because i don't set tableview_can_delete to true... when i do this:
https://imgur.com/a/HB45cr3
but i don't need this

cvp

@DavinE said:

I know where this Problem comes from but not how to solve it....
when i remove editing = True it is gone

Why do you need it?

DavinE

@cvp, for moving rows

cvp

@DavinE try, for the other problem

        self.table_view.content_inset = (0,0,50,0) # bottom
cvp

@DavinE said:

I'm using tableview_cell_for_row

Normally, the left area is reserved for cell.image, like cell.label_text for the text

DavinE

@cvp said:

@DavinE try, for the other problem
self.table_view.content_inset = (0,0,50,0) # bottom

This works ;)

DavinE

@cvp said:

@DavinE said:

I'm using tableview_cell_for_row

Normally, the left area is reserved for cell.image, like cell.label_text for the text

I Think so too..
But i don't set one it's weird

cvp

@DavinE said:

This works ;)

One done

cvp

@DavinE said:

But i don't set one it's weird

Try

self.table_view.content_inset = (0,-50,50,0) # left + bottom
DavinE

@cvp said:

@DavinE said:

But i don't set one it's weird

Try
self.table_view.content_inset = (0,-50,50,0) # left + bottom

I've had the same Idea :D
i set it to -25 because the underline for the rows moves too

cvp

@DavinE agree this is only a workaround. Must be a setting to avoid this

cvp

@DavinE could you post you tableview_cell_for_row

DavinE

@cvp
This is the tableview_cell_for_row from file-picker.py
with this i'm working

def tableview_cell_for_row(self, tv, section, row):
        cell = ui.TableViewCell()
        entry = self.flat_entries[row]
        level = entry.level - 1
        image_view = ui.ImageView(frame=(44 + 20*level, 5, 34, 34))
        label_x = 44+34+8+20*level
        label_w = cell.content_view.bounds.w - label_x - 8
        if entry.subtitle:
            label_frame = (label_x, 0, label_w, 26)
            sub_label = ui.Label(frame=(label_x, 26, label_w, 14))
            sub_label.text = entry.subtitle
            sub_label.text_color = '#999'
            cell.content_view.add_subview(sub_label)
        else:
            label_frame = (label_x, 0, label_w, 44)
        label = ui.Label(frame=label_frame)
        label.text = entry.title
        label.flex = 'W'
        cell.content_view.add_subview(label)
        if entry.leaf and not entry.enabled:
            label.text_color = '#999'
        cell.content_view.add_subview(image_view)
        if not entry.leaf:
            has_children = entry.expanded
            if not appex.is_running_extension():
                btn = ui.Button(image=ui.Image.named('CollapseFolder' if has_children else 'ExpandFolder'))
            else:
                btn = ui.Button(image=ui.Image.named('iob:arrow_down_b_24' if has_children else 'iob:arrow_right_b_24'))
            btn.frame = (20*level, 0, 44, 44)
            btn.action = self.expand_dir_action
            cell.content_view.add_subview(btn)
        if entry.icon_name:
            image_view.image = ui.Image.named(entry.icon_name)
        else:
            image_view.image = None
        return cell
cvp

@DavinE said:

On this pic:
https://imgur.com/a/sejyonX
Is in the left side free Space How can i Remove this ?

You have to show the first row of your TableView to be sure

Same File_Picker without this left space

DavinE

@cvp I don't know exactly what you want from me :( sorry

cvp

@DavinE never mind, I did forget that if you remove the editing=True the problem disappeared

DavinE

@cvp said:

@DavinE said:

On this pic:
https://imgur.com/a/sejyonX
Is in the left side free Space How can i Remove this ?

You have to show the first row of your TableView to be sure

Same File_Picker without this left space

yes, but without moving rows...
when you add editing = True i think it's the same issue or ?

DavinE

@cvp said:

@DavinE never mind, I did forget that if you remove the edited=True the problem disappeared

yeah right :D

cvp

@DavinE ok, if content_inset solves it, let us forget and sorry

DavinE

@cvp said:

@DavinE ok, if content_inset solves it, let us forget and sorry

hehe no Problem i thank you again @cvp

moezop

the left area is reserved for cell.image, like cell.label_text for the text. .

cvp

@moezop

Yes but if you don't use cell.image, you can hide this left blank area by

tableview.content_inset = (0,-80,50,0) # left + bottom