Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

[Enhancement] Table rows navigation with keyboard PageUp and PageDown

Offen
#6,078 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
42/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
desktop

Rechercherichtung

Beginne in PySimpleGUI.py bei der Behandlung von select_rows in der update-Methode von Table und vergleiche sie anschließend mit DemoPrograms/Demo_Table_Element_Header_or_Cell_Clicks.py und der angehängten geänderten Demo. Überprüfe, wie sich der Fokus auf die anschließende Navigation mit Pfeiltasten auswirkt, und berücksichtige das angeforderte automatische Verhalten für PageUp/PageDown; die Demo sollte von der neu ausgewählten Zeile aus navigieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement Port - TK
Type of Issue (Enhancement, Error, Bug, Question)

Enhancement

Operating System

Windows 10 Home 22H2

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

Python version (sg.sys.version)

sg.sys.version
'3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]'

PySimpleGUI Version (sg.__version__)

4.60.4.123

GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)

sg.tclversion_detailed
8.6.12


Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
  • If not tkinter - looked for Demo Programs for specific port
  • For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
  • Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description

I would like to suggest automatic support for Table rows navigation by using the keyboard's PageUp and PageDown, just like the arrow up and arrow down keys works automatically.

I tried to add that kind of navigation in the demo table "Demo_Table_Element_Header_or_Cell_Clicks.py" and I am attaching my modified version in a file named "Demo_Table_Element_Header_or_Cell_Clicks_2.py".
(but I had to put it within a zip file since github did not accept attaching a .py file for this issue)

It does work visually i.e. when using the keyboard keys "page up" and "page down" the selected row seem to be changed as expected, when using the Table method "update" with the argument "select_rows" currently documented like this:

Type	Name	Meaning
List[int]	select_rows	List of rows to select as if user did

However, the new row does not really become selected, since when then trying to use the arrow up/down keys, the navigation does not start from there, but instead starts from the previously selected row (i.e. a row previously selected with a mouse click).

When trying to modify the Table method update (in the file "PySimpleGUI.py") it seems to work if also adding a call to the "focus" method as shown below:
(I added the two last lines)

  if select_rows is not None:
      rows_to_select = [i + 1 for i in select_rows]
      self.TKTreeview.selection_set(rows_to_select)
      if len(rows_to_select) == 1:
          self.TKTreeview.focus(rows_to_select[0])

So if you would add that kind of call to the method "focus" then it would be possible to make the PageDown/PageUp work as in my attached demo file.
However, I think it should not be necessary to write that kind of code for every table, but instead I think it should work automatically just like the arrow up and arrow down works out of the box.
Maybe with a configuration option, but IMHO the default should be to automatically support navigation with PageUp/PageDown

Code To Duplicate

See the attached demo file which is a modified version of "Demo_Table_Element_Header_or_Cell_Clicks.py" and here are the most relevant modifications:

...
window["-TABLE-"].bind('<Next>' , "+-PageDown-")
window["-TABLE-"].bind('<Prior>' , "+-PageUp-")
...
    elif event == '-TABLE-+-PageUp-':
        currently_selected_row = values['-TABLE-'][0]
        new_selected_row = max(0, currently_selected_row - number_of_rows_pageup_pagedown)
        window['-TABLE-'].update(select_rows=[new_selected_row])
    elif event == '-TABLE-+-PageDown-':
        currently_selected_row = values['-TABLE-'][0]
        new_selected_row = min(len(data)-1, currently_selected_row + number_of_rows_pageup_pagedown)
        window['-TABLE-'].update(select_rows=[new_selected_row])
...

Demo_Table_Element_Header_or_Cell_Clicks_2.zip

Vorherrschende Sprache
Python
Sterne
13.8k
Forks
1.8k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus PySimpleGUI/PySimpleGUI

Alle Issues in PySimpleGUI/PySimpleGUI

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.