Skip to content

Commit

Permalink
allow edit object as string
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu committed Jun 14, 2024
1 parent 29d0e55 commit 1a47787
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tabulous/_qt/_table/_base/_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from qtpy.QtCore import Qt

from ._table_base import QBaseTable
from ._line_edit import QCellLiteralEdit
from ._line_edit import QCellLiteralEdit, QCellLineEdit

from tabulous._magicgui._timedelta import QTimeDeltaEdit

Expand Down Expand Up @@ -77,7 +77,9 @@ def createEditor(
td.setValue(value)
return td
elif dtype == "object":
raise NotImplementedError("Cannot edit cell of object dtype.")
line = QCellLineEdit(parent, qtable_view.parentTable(), (row, col))
line.setFont(font)
return line
else:
line = qtable_view._create_eval_editor(moveto=(row, col))
line.setFont(font)
Expand Down
3 changes: 3 additions & 0 deletions tabulous/_qt/_table/_base/_line_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ def eventFilter(self, o: QCellLiteralEdit, e: QtCore.QEvent):
return True
return False

class QCellLineEdit(_QTableLineEdit):
def _is_text_valid(self) -> bool:
return True

class QCellLiteralEdit(_QTableLineEdit):
"""Line edit used for evaluating cell text."""
Expand Down

0 comments on commit 1a47787

Please sign in to comment.