-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Enhancement] Add support for Tree().Update(select_rows=values)
#6671
Comments
#1170 was quite the ride, lots of different issues in there for sure, no wonder I didn't find it. The only thing I could find directly relating to this in there was this comment from Jason, suggesting that this may not be something the library wants to provide, but I could be wrong... #1170 (comment) Regarding #3441, I actually already have a sorting function that sorts the What I'm asking for is an option to set highlighted (or "selected") rows in the Here's some example images that will hopefully help clarify - User selects data on first tab: Calling update using the selection event allows me to synchronize the tables: But the final tab uses a |
Like all enhancements, I'll need to get past the PSG 5 launch over the next few days before I can get my bearings and do anything of substance. If you're in the mood to do a little expansion work on your own, I suggest looking at the Trees and Tables differ in their underlying data structures. Tables are tables and thus have rows. Trees are not the same. They have the secondary TreeData objects with Keys to identify each node in the tree (like a row, but not a row strictly speaking). I likely did a poor job with the terminology by mixing the terms of "row" in the ways I did. It's been a very long time since I looked at it in any detail. |
No problem, even having a starting point is helpful for me, thank you very much! I totally understand that the If I find something useful, would you like me to send the code here, so you have an idea of what would have to be done to implement this as a feature? |
Vaguely at best. There's a huge backlog that we're looking at here on top of the huge launch of the new line of products. Just wanting to be honest about not knowing the timing is all. |
Understandable. Solo maintaining a project this large is a monumental task. I'll try to implement it myself, and will keep you updated on how it goes. Appreciate all the work that goes into this library! |
Done. It was trickier than I thought, but still not too bad. Because calling the underlying def update_selected(self, values: list):
if self.tree_updated:
self.tree_updated = False
return
if self.selected_rows == values:
values = []
for table_key in TABLE_KEYS["table"]:
if table_key == "errors_table":
continue
table = window[table_key]
table.Update(select_rows=values)
for table_key in TABLE_KEYS["tree"]:
table = window[table_key]
table.TKTreeview.selection_set([table.KeyToID[x] for x in values])
self.tree_updated = True
self.selected_rows = values |
Very good! It looked like that function had the key member variables that would get you to where you were wanting to go. Glad you've got something working for the time being. |
Type of Issue - Enhancement
Operating System - Windows 10
PySimpleGUI Port - tkinter
Versions
Python version - 3.12.1
PySimpleGUI Version - 4.60.5
GUI Version - 8.6.13
Your Experience In Months or Years (optional)
Years Python programming experience - 2.5y
Years Programming experience overall - 2.5y
Have used another Python GUI Framework? - No
Anything else you think would be helpful?
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
Detailed Description
Right now,
Tree().Update
has no support for theselect_rows
parameter. It would be nice to have this for consistency with theTable
element, as I am using them semi-interchangeably (I have to useTree
because I am using the -1 column for small image based indicators).More context:
I am using a set of tabs, each tab having a table of some kind, which I would like to coordinate selections across, since there is so much data that it needs to be split across multiple tabs. All items are already added to each table, and they are updated and sorted as a group, however I now need to have them be able to be selected as a group. For the tables I am using the
Update
method, but since theTree
object has noselect_rows
parameter, this doesn't work for it. I have also considered trying to updateTree().SelectedRows
and replicate some of the code inside theTree()._table_clicked()
method, but that is pretty janky, and I would rather have first party support directly in the library.If there is a preference towards not adding this, then an idea of the best way to do this for the
Tree
element would be great as well.Code To Duplicate
sg.Tree().Update(select_rows=[])
Screenshot, Sketch, or Drawing
Watcha Makin?
https://github.com/UpstreamData/upstream_config_util
The text was updated successfully, but these errors were encountered: