INNER CODE UNIT · Python
_set_table_row
wzyn20051216/solidworks-automation-skill · apps/desktop/cad_workbench/app.py:470
def _set_table_row(self, table: QTableWidget, values: list[Any]) -> None:
row = table.rowCount()
table.insertRow(row)
for column, value in enumerate(values):
table.setItem(row, column, QTableWidgetItem(str(value)))
def add_default_row(self, table: QTableWidget, kind: str) -> None:
if kind == "hole":
self._set_table_row(table, ["H1", "安装孔", "round", "bottom", "3.4", "4", "left", "bottom", "10", "10", "100", "60", "true"])
elif kind == "cutout":
self._set_table_row(table, ["I1", "USB-C", "front", "10", "4", "0", "1", "60", "15", "1", "0.3"])
else:
self._set_table_row(table, ["B1", "M3", "7", "2.8", "8", "bottom", "10", "10", "4", "true"])
def remove_selected_rows(self, table: QTableWidget) -> None:
rows = sorted({index.row() for index in table.selectedIndexes()}, reverse=True)
for row in rows:
table.removeRow(row)