Files
lintunes/tests/test_round127.py
T

27 lines
934 B
Python

"""Round 127: a list highlights the whole row and draws no focus box round
the clicked cell on top of it."""
from PyQt6.QtWidgets import QTableWidget, QTableWidgetItem
from lintunes.gui.track_table import ClickToJumpScrollStyle
def test_no_focus_box_round_the_clicked_cell(qapp):
style = ClickToJumpScrollStyle()
table = QTableWidget(3, 3)
table.setStyle(style)
table.resize(300, 150)
for r in range(3):
for c in range(3):
table.setItem(r, c, QTableWidgetItem(f"x{r}{c}"))
table.setSelectionBehavior(table.SelectionBehavior.SelectRows)
table.show()
table.setFocus()
table.setCurrentCell(1, 1)
qapp.processEvents()
img = table.viewport().grab().toImage()
rect = table.visualRect(table.model().index(1, 1))
edge = {img.pixelColor(x, rect.top() + 1).name()
for x in range(rect.left(), rect.right())}
table.close()
assert len(edge) == 1, edge