Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure selection visible during "find" #135

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tabulous/_qt/_table/_base/_table_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 4 additions & 0 deletions tabulous/_qt/_table_stack/_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
14 changes: 11 additions & 3 deletions tabulous/_slice_op.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import numpy as np

# utility functions for working with slices


Expand Down Expand Up @@ -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)
Loading