[Bug] controlling the scroller via `set_vscroll_position` does not work for Column elements
Type of Issue (Enhancement, Error, Bug, Question)
Bug
Operating System
windows 10
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions
Version information can be obtained by calling sg.main_get_debug_data()
Or you can print each version shown in ()
Python version (sg.sys.version)
3.8.1
PySimpleGUI Version (sg.__version__)
4.28.0
GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)
None
Your Experience In Months or Years (optional)
2 Years Python programming experience
5 Years Programming experience overall
None Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
Anything else you think would be helpful?
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
- [x] Searched main docs for your problem www.PySimpleGUI.org
- [x] Looked for Demo Programs that are similar to your goal Demos.PySimpleGUI.org
- [x] If not tkinter - looked for Demo Programs for specific port
- [x] For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
- [x] Run your program outside of your debugger (from a command line)
- [x] Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
- [x] Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description
I'm trying to use the set_vscroll_position() in order to ease the user navigation in a column containing lots of rows full with input boxes but it keeps firing the following warnings and does not work: Warning setting the vertical scroll (yview_moveto failed) 'TkScrollableFrame' object has no attribute 'yview_moveto'
My Code This program is creating a window which contains a column that has a pre determined layout containing all the mentioned input boxes and a pre determined sizes.
in addition there are the discussed buttons inside.
Code To Duplicate
form = sg.Window('analysis').Layout([
[sg.Column(layout, size=(width / 3, height / 2), scrollable=True, key = "Column")],
[sg.OK(), sg.Button('Up', key = "up"), sg.Button('Down', key = "down")]
])
while True:
event, values = form.read()
if(event == sg.WIN_CLOSED):
break
elif(event == "down"):
form.Element('Column').set_vscroll_position(1.0)
elif(event == "up"):
form.Element('Column').set_vscroll_position(0.0)
Screenshot, Sketch, or Drawing
Watcha Makin?
If you care to share something about your project, it would be awesome to hear what you're building.
Columns are special and will need some additional code done in order to manipulate their scrollbars. Didn't think to document / handle this element. The code operates on the "Widget" and the Column element on its own isn't a standalone Widget like some of the others with scrollbars.
The set_scroll_position is a really simple function:
self.Widget.yview_moveto(percent_from_top)
The vertical scrollbar is a member variable:
Widget.vscrollbar
I think you should be able to manipulate this scrollbar directly as a workaround. I haven't tried it yet but wanted to get you the info so you can see if you're able to make something work.
Thank you very much for the quick response, but i have some follow up question:
-
by "manipulate this scrollbar directly as a workaround" are you suggesting solutions that are not necessarily related to pysimplegui, such as bots or a connected program?
-
Will it be inserted to the column element later on?
-
What other element is a stand alone widget that I can use instead?
with respect, roey-coding
It was originally added, not long ago, for the Table element
https://github.com/PySimpleGUI/PySimpleGUI/issues/1878
- Manipulate using tkinter calls... you'll find a number of workarounds in the Issues that use the Widget variable for example
- It would be good to support the column
- I don't know.
I will use a table but in the future i would love to get back to column so i'm keeping this issue open until columns will be supported in controlling the scrollbar, for all of the columns users out there.
In the mid time, can you please direct me to the place in your code where the columns? in order to use tkinter calls I need to know exactly what is a column and how does it look in code.
please update here when the feature is added, for the sake of all the column users out there.
with respect, roey-coding
I'm sorry I don't have the ability to step you through adding this feature.
Here's the code to show how to control the scrollbar at this moment.
import PySimpleGUI as sg
font = ('Courier New', 16)
text = '\n'.join(chr(i)*50 for i in range(65, 91))
column = [[sg.Text(text, font=font)]]
layout = [
[sg.Column(column, size=(800, 300), scrollable=True, key = "Column")],
[sg.OK(), sg.Button('Up', key = "up"), sg.Button('Down', key = "down")],
]
window = sg.Window('Demo', layout, finalize=True)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
elif event == "down":
window['Column'].Widget.canvas.yview_moveto(1.0)
elif event == "up":
window['Column'].Widget.canvas.yview_moveto(0.0)
window.close()
Thank you very much jason990420 and PySimpleGUI for you helpful responses, hopefully it will be added in the future, keeping it open until the far future update that will make an official method but for know that will definitely do.
with respect, revolution