You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote some code on the backend to change color of a tab item.
I copy paste the original table & table item and added the code to it via mouseover & mouseout function.
i think this also should be possible on the front end.
any idea how?
here is the code:
fromremiimportApp, gui, startclassHighLightTableItem(gui.TableItem):
''' Hightlight the item when hovered over '''def__init__(self, *arg, **kwargs):
""" init, like before """super(HighLightTableItem, self).__init__(*arg, **kwargs)
self.onmouseout.connect(self.mouseout)
self.onmouseover.connect(self.mouseover)
self.hover_over=Falsedefmouseover(self, _emitter):
""" mouse over """self.hover_over=True#print("item over")# css background: rgba(4, 90, 188, 0.26);#outline: 1px solid red;self.style['background'] ="rgba(4, 90, 188, 0.26)"#self.style['outline'] = "1px solid red"defmouseout(self, _emitter):
""" mouse out """self.hover_over=False#print("item out")self.style['background'] ="white"#self.style['outline'] = "white"#outline: 1px solid red;classHighLightTableWidget(gui.Table):
''' A subclass of gui.Table that has the feature that the last selected row is highlighted and that allows for multi_row selection. '''@property@gui.editor_attribute_decorator("WidgetSpecific", '''Table colum count.''', int, {'possible_values': '', 'min': 0, 'max': 100, 'default': 1, 'step': 1})defcolumn_count(self): returnself.__column_count@column_count.setterdefcolumn_count(self, value): self.set_column_count(value)
@property@gui.editor_attribute_decorator("WidgetSpecific", '''Table row count.''', int, {'possible_values': '', 'min': 0, 'max': 100, 'default': 1, 'step': 1})defrow_count(self): returnlen(self.children)
@row_count.setterdefrow_count(self, value): self.set_row_count(value)
@property@gui.editor_attribute_decorator("WidgetSpecific", '''Table use title.''', bool, {})defuse_title(self): returnself.__use_title@use_title.setterdefuse_title(self, value): self.set_use_title(value)
def__init__(self, n_rows=2, n_columns=2, use_title=True, editable=False, use_selection=False, *arg, **kwargs):
self.__column_count=0self.__use_title=use_titlesuper(HighLightTableWidget, self).__init__(*arg, **kwargs)
self._editable=editableself.set_use_title(use_title)
self.set_column_count(n_columns)
self.set_row_count(n_rows)
self.css_display='table'# the additions belowself.attributes['tabindex'] ='1'self.onkeydown.connect(self.keydown)
self.onkeyup.connect(self.keyup)
#self.onmouseout.connect(self.mouseout)#self.onmouseover.connect(self.mouseover)self.multi_selection_enabled=Falseself.hover_over=Falseself.selected_row_list= []
self.use_selection=use_selectiondefset_use_title(self, use_title):
"""Returns the TableItem instance at row, column cordinates Args: use_title (bool): enable title bar. """self.__use_title=use_titleself._update_first_row()
def_update_first_row(self):
cl=HighLightTableItemifself.__use_title:
cl=gui.TableTitleiflen(self.children) >0:
forc_keyinself.children['0'].children.keys():
instance=cl(self.children['0'].children[c_key].get_text())
self.children['0'].append(instance, c_key)
# here the cells of the first row are overwritten# and aren't appended by the standard Table.append# method. We have to restore de standard on_click#internal listener in order to make it working# the Table.on_table_row_click functionalityinstance.onclick.connect(self.children['0'].on_row_item_click)
defitem_at(self, row, column):
"""Returns the TableItem instance at row, column cordinates Args: row (int): zero based index column (int): zero based index """returnself.children[str(row)].children[str(column)]
defitem_coords(self, table_item):
"""Returns table_item's (row, column) cordinates. Returns None in case of item not found. Args: table_item (TableItem): an item instance """forrow_keyinself.children.keys():
foritem_keyinself.children[row_key].children.keys():
ifself.children[row_key].children[item_key] ==table_item:
return (int(row_key), int(item_key))
returnNonedefset_row_count(self, count):
"""Sets the table row count. Args: count (int): number of rows
I wrote some code on the backend to change color of a tab item.
I copy paste the original table & table item and added the code to it via mouseover & mouseout function.
i think this also should be possible on the front end.
any idea how?
here is the code: