From fec3728869237d9fe00e77abdbd0fda4f0d834fe Mon Sep 17 00:00:00 2001 From: Hanjin Liu Date: Fri, 21 Jun 2024 15:57:40 +0900 Subject: [PATCH 1/2] ensure selection visible when finding --- tabulous/_qt/_table_stack/_finder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tabulous/_qt/_table_stack/_finder.py b/tabulous/_qt/_table_stack/_finder.py index e8b129ba..3184a080 100644 --- a/tabulous/_qt/_table_stack/_finder.py +++ b/tabulous/_qt/_table_stack/_finder.py @@ -165,6 +165,8 @@ def findNext(self) -> None: qtable.moveToItem(r + 2, c + 2) qtable.moveToItem(r, c) qtable.setSelections([(r, c)]) + index = qtable._qtable_view.model().index(r, c) + qtable._qtable_view.scrollTo(index) self._current_index = (r, c) return @@ -185,6 +187,8 @@ def findPrevious(self) -> None: qtable.moveToItem(r + 2, c + 2) qtable.moveToItem(r, c) qtable.setSelections([(r, c)]) + index = qtable._qtable_view.model().index(r, c) + qtable._qtable_view.scrollTo(index) self._current_index = (r, c) return From 9c23ca6df296f2ec83a225dec33813bb2c4fd4b6 Mon Sep 17 00:00:00 2001 From: Hanjin Liu Date: Fri, 21 Jun 2024 16:10:21 +0900 Subject: [PATCH 2/2] fix numpy str --- tabulous/_qt/_table/_base/_table_wrappers.py | 4 +++- tabulous/_slice_op.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tabulous/_qt/_table/_base/_table_wrappers.py b/tabulous/_qt/_table/_base/_table_wrappers.py index 1b7de885..b84054f8 100644 --- a/tabulous/_qt/_table/_base/_table_wrappers.py +++ b/tabulous/_qt/_table/_base/_table_wrappers.py @@ -84,7 +84,9 @@ def __init__( _layout.addWidget(sizegrip, False, Qt.AlignmentFlag.AlignRight) self.setLayout(_layout) - _screen_rect = QtGui.QGuiApplication.primaryScreen().geometry() + _screen_rect = QtGui.QGuiApplication.screenAt( + parent.mapToGlobal(parent.geometry().topLeft()) + ).geometry() _screen_center = _screen_rect.center() self.resize(int(_screen_rect.width() * 0.8), int(_screen_rect.height() * 0.8)) self.move(_screen_center - self.rect().center()) diff --git a/tabulous/_slice_op.py b/tabulous/_slice_op.py index 1c6ea8e3..f185ed46 100644 --- a/tabulous/_slice_op.py +++ b/tabulous/_slice_op.py @@ -1,5 +1,7 @@ from __future__ import annotations +import numpy as np + # utility functions for working with slices @@ -51,11 +53,17 @@ def as_sized(sl: slice, size: int, allow_negative: bool = False): def fmt(sl: slice) -> str: """Format a slice as a string.""" if isinstance(sl, slice): - s0 = repr(sl.start) if sl.start is not None else "" - s1 = repr(sl.stop) if sl.stop is not None else "" + s0 = _repr(sl.start) if sl.start is not None else "" + s1 = _repr(sl.stop) if sl.stop is not None else "" return f"{s0}:{s1}" - return repr(sl) + return _repr(sl) def has_none(sl: slice): return sl.start is None or sl.stop is None + + +def _repr(x) -> str: + if isinstance(x, np.number): + return str(x) + return repr(x)