Comments (10)
Huh. For a single moment when making this bug report yesterday I haven't noticed this is select_rows and not row_colors which I have been dealing with a lot lately, that could have helped figuring out the issue :)
Adding select_mode=sg.TABLE_SELECT_MODE_NONE,
fixes the issue, thanks!
from pysimplegui.
I'm very grateful for the immense work you do in supporting users both here and on Stack Overflow, I definitely picked a lot of tips over the years from yours and Jasons responses :)
from pysimplegui.
For 4.55.1.19
if element.enable_click_events is True:
treeview.bind('<Button-1>', element._table_clicked)
For 5.0.4.13
if element.enable_click_events is True:
treeview.bind('<ButtonRelease-1>', element._table_clicked)
So it will select last clicked row, then selected all previous clicked rows for 5.0.4.13
Not sure why it changed ?
from pysimplegui.
Not sure why it changed ?
Thank you for identifying what changed!
Here is what I wrote in the release notes about this change:
Changed Table click events to be generated on Button Release instead of Button (down). Was not getting the correct selected rows in the values dictionary when the click event was generated using down. Now the selected rows is correct
from pysimplegui.
If you click a row and hold the click down, then you'll see that tkinter removes all of the selected row highlights. When you release the button, then the rows are highlighted again. I believe it's this tkinter behavior that is causing the "flash".
from pysimplegui.
The selection for one row is done defaultly by clicking the mouse, and all old selection removed before it.
Now the option enable_click_events=True
generate an event to add one new row to existing selection, and update the total selection to the Table elemenet by method update
in the event loop by user code.
What I can do is to recover it to old one, like
window = sg.Window('test gui', layout, resizable=True, finalize=True)
window['-TABLE-'].update(values=table, select_rows=list(selected))
tbl = window['-TABLE-']
tbl.widget.unbind('<ButtonRelease-1>')
tbl.widget.bind('<Button-1>', tbl._table_clicked)
from pysimplegui.
This will fix it.... add the select_mode
parameter to your Table element.
select_mode=sg.TABLE_SELECT_MODE_NONE,
Because you are doing your own highlighting, using a mode of 'none'
will keep tkinter from removing the previous selection. It will be smooth again.
# Code taken from my code, modified from Demo_Table_Checkmark.py
import PySimpleGUI as sg
table = [["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"], ["☐", "a", "a"]]
BLANK_BOX = '☐'
CHECKED_BOX = '☑'
table_headings = ["☐", "a", "a"]
selected = {i for i, row in enumerate(table) if row[0] == CHECKED_BOX}
layout = [ [sg.Table(values=table, headings=table_headings,
max_col_width=25,
auto_size_columns=False,
col_widths=[3, 5, 20],
display_row_numbers=False,
justification='center',
num_rows=20,
key='-TABLE-',
selected_row_colors='red on yellow',
expand_x=True,
expand_y=True,
vertical_scroll_only=True,
select_mode=sg.TABLE_SELECT_MODE_NONE,
enable_click_events=True)]
]
window = sg.Window('test gui', layout, resizable=True, finalize=True)
window['-TABLE-'].update(values=table, select_rows=list(selected))
while True:
event, values = window.read()
if event[0] == '-TABLE-' and event[2][0] not in (None, -1): # if clicked a data row rather than header or outside table
row = event[2][0]
if table[row][0] == CHECKED_BOX: # Going from Checked to Unchecked
selected.remove(row)
table[row][0] = BLANK_BOX
else: # Going from Unchecked to Checked
selected.add(row)
table[row ][0] = CHECKED_BOX
window['-TABLE-'].update(values=table, select_rows=list(selected)) # Update the table and the selected rows
from pysimplegui.
In 5.0.4.14 I changed the docstring for the Table
element. It is not required in order for the code that added:
select_mode=sg.TABLE_SELECT_MODE_NONE,
In PyCharm I was seeing a warning because the parameter was defined as an enum instead of a string.
from pysimplegui.
I haven't noticed this is select_rows and not row_colors
That's an interesting observation that I missed..... row colors could have been used perhaps instead of selected rows. Maybe?
I've updated the Table Checkmark Demo Program with this change too. Thank you for indicating you picked up code from the Demo so that it's fixed and the next person won't have this problem.
And, thank you for the "thanks!"
It's always nice to see that Jason and I are doing a good job of helping PySimpleGUI users be successful.
from pysimplegui.
I'm very grateful
I can't express how much it means to see these words. Thank you so very much. I'm extremely grateful to have grateful users. Maybe it's not unusual or rare, but it sure feels that way. Jason provides the best support I've ever seen, is quicker and more thorough than I am. We're very fortunate.
from pysimplegui.
Related Issues (20)
- [Question] How to trap an event HOT 2
- [Enhancement] CI friendly handling for the first time installation dialog HOT 3
- [Question] How to update class parameter within inherited class HOT 4
- [Question] How To Re-Enter Data For A Specific Field - AND 'CR to act like TAB HOT 1
- [ Bug] sg.ColorChooserButton Unless Additional Tkinter Import HOT 1
- [Bug] Hitting the image-count limit [Fail to create pixmap with Tk_GetPixmap in TkImgPhotoInstanceSetSize] HOT 6
- [Question] Import error HOT 3
- [Question] Change focus highlight when tabbing to button HOT 8
- [ Enhancement/Bug/Question] NOTE - you can also call sg.main() or sg.main_open_github_issue() to post an issue HOT 1
- [ Question] Compiling Errors since License validation HOT 2
- [ Bug] Broken Doc Link HOT 2
- [Question] NOTE - Table get doesn't work HOT 6
- [ Enhancement] allow arrowheads for lines in tkinter graphs HOT 8
- [Question] Question of shortcut HOT 17
- [Question] How to Use PySimpleGui Programs on Other PCs HOT 1
- [ Question] How to detect when we manually enter a value in combo box in Pysimple GUI HOT 1
- [Question] No right_click_menu in Combo HOT 3
- [Enhancement] Reusing Context Menu HOT 6
- [ Bug] Garbled output on WSL HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysimplegui.