Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
TableView Editing / Move Enabled
-
Hey Guys,
I don't find my issue i want to Move my Cells but nothing i tried works for me....
In the Doku stand nothing about that...i tried it with:
TableView.editing = True
but here comes only a delete button....
i hope anyone can help me out..
p.s. in the pyui file i found this:
"data_source_move_enabled" : true,
but i don't know to use this :D
-
-
hay @cvp i think i missed something to say...
i do not use the UI Designer!i tried it but i don't get it..
here is my Code can you have a look on it maybe does you find something:
self.QRCODES = [['0001', '+10'], ['0002', '-20'], ['0003', '+30'], ['0004', '-40'], ['0005', '+50']] mainView_selectProject_3 = ui.View(name='Auswahl des Projektes', bg_color='#3664a8') tbv6_1 = ui.TableView(name='Table_View', separator_color='black') #tbv6_1.editing = True tbv6_1.width = (self.WIDTH - self.tbv6_1_width) tbv6_1.height = (self.HEIGHT - self.tbv6_1_height) tbv6_1.x = ((self.WIDTH - tbv6_1.width) / 2) tbv6_1.y = ((self.HEIGHT * self.tbv6_1_y) / 100) tbv6_1.data_source = ui.ListDataSource(items=self.QRCODES) tbv6_1.data_source.tableview_cell_for_row = self.tableview_cell_for_row tbv6_1.data_source.tableview_delete = self.tableview_delete tbv6_1.data_source.tableview_number_of_rows = self.tableview_number_of_rows tbv6_1.data_source.tableview_number_of_sections= self.tableview_number_of_sections tbv6_1.delegate = tbv6_1.data_source tbv6_1.delegate.tableview_accessory_button_tapped = self.test1 self.nav_view = ui.NavigationView(mainView_selectProject_3) self.nav_view.add_subview(tbv6_1) self.nav_view.present('fullscreen') #FUNKTION test1 def test1(self, tableview, section, row): consoleOption = console.alert('Bearbeiten / Löschen', 'Möchtest du diesen Eintrag löschen oder Bearbeiten ?', 'Move', 'Bearbeiten', 'Daten eintragen', hide_cancel_button=False) if consoleOption == 1: tableview.editing = True elif consoleOption == 2: QRCODEtmp = tableview.data_source.items[row][0] del tableview.data_source.items[row] tableview.delete_rows([row]) newCount = console.input_alert('Materialangabe', 'Bitte achte darauf als erstes - oder + anzugeben!!\nz.B. +3 oder -3', '', 'Eintragung in Liste', hide_cancel_button=True) if newCount == '': newCount = 0 tableview.data_source.items.append([QRCODEtmp, newCount]) row = len(tableview.data_source.items) - 1 tableview.insert_rows([row]) elif consoleOption == 3: self.mysqlQRCodeQuerry(tableview.data_source.items) self.nav_view.close() def tableview_delete(self, tableview, section, row): del tableview.data_source.items[row] tableview.delete_rows([row]) def tableview_number_of_sections(self, tableview): return 1 def tableview_number_of_rows(self, tableview, section): return len(tableview.data_source.items) #FUNKTION tableview_cell_for_row def tableview_cell_for_row(self, tableview, section, row): cell =ui.TableViewCell("subtitle") data_textLabel = tableview.data_source.items[row][0] data_detailTextLable = tableview.data_source.items[row][1] cell.bg_color = '#98FB98' if data_detailTextLable[0] == '+' else '#F08080' cell.accessory_type = 'detail_button' cell.selectable = False self.MarinaDB_DATA() try: self.cur.execute("SELECT `manufacturer_designation__short` FROM `datanorm` WHERE `Barcode` = '{}'".format(str(data_textLabel))) for tmp in self.cur: text_label_text = ' '.join(str(x) for x in tmp) except mysql.connector.Error as e: print(f'SELECT `manufacturer_designation__short` FROM `datanorm` WHERE `Barcode` = {str(data_textLabel)}:\n{e}') notification.schedule(message=f'SELECT Abfrage konnte nicht erstellt werden:\Barcode: {str(data_textLabel)}\nFehlerausgabe im Terminal', delay=5.0, sound_name='default', title='mysql.connector', subtitle='SELECT Fehlerhaft') sound.play_effect('arcade:Powerup_3') console.alert('mysql.connector', f'SELECT Abfrage konnte nicht erstellt werden:\Barcode: {str(data_textLabel)}\nFehlerausgabe im Terminal') sys.exit(1) self.cur.close() self.conn.close() cell.text_label.text = text_label_text cell.detail_text_label.text = str(data_detailTextLable) try: cell.image_view.image = ui.Image.named(f'iob:clipboard_{self.IMAGE_SIZE}') except AttributeError: pass return cell
on my sample the Red Delete Buttons pops up but not the Move "buttons"
-
i got my solution :D
i need to ad this lines:
tbv6_1.data_source.tableview_can_move= self.tableview_can_move def tableview_can_move(self, tableview, section, row): return True
now it works like i will :D
thanks @cvp for the help ;)
-
@DavinE 👍