-
Notifications
You must be signed in to change notification settings - Fork 48
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
How to accept user input even if "enter" is not pressed #212
Comments
Hello, thanks for your report and sorry to hear that the behaviour has changed. It's difficult for me know what's going on at the moment, would it be possible to get just the lines that involve the sheet, specifically:
You can strip out anything sensitive and the code does not have to run/work |
Hello, Thanks for the quick response. Here are the chunks of the code. I know it is pretty rudimentary, but bear with me :P The code for the button:
The sheet is initialized like this:
Inside the function compute(), the lines that go fetch the values input by the user:
The values in columns A and B are automatically filled by other function. The user only inputs data in columns C and D. What usually happens is that the users fill all the blank cells in columns C and D, but after writing the last value in column D, they don't press "enter" or click anywhere else on the sheet. Instead, they normally click directly on the button and the last cell filled in D column never ceases to edit, therefore the value they input is never stored. So, col3 list's length is 1 value higher than the col4 and the rest of the compute() function, that needs that last value, fails to run on that try and the computations aren't done. What is funny is that the first click on the button takes the focus out of the sheet widget, but it doesn't store the value, so the function doesn't run. But if I click a second time, the value is stored (probably after the first run of the function) and it works... |
Hello, Thanks for the extra detail, I reckon the issue is partly related to this Where a tk button doesn't receive focus upon clicking on it and so What I've done in tksheet version
This is so that in your sheet_in_AN.close_text_editor() This should set the cells value as if the user has hit Return I am not sure why it was previously working okay with the older version though, perhaps I had bound more events to trigger the closing of the editor Let me know if this is any help, if not I will try a different strategy |
Hello again, I must say it worked like a charm! Thank you so much for the impeccable assistance you have provided me and for the amazing work with developing this tool. Keep up the awesome job, it is really uncanny how useful tksheet in our community! |
Hello!
First and foremost, congratulations for the amazing job!
My question is simple (I guess) but I have been trying to circumvent this issue for 2 days without any success.
I have a sheet in a tkinter GUI where the user is supposed to input values manually.
I have a tk button that calls a function that makes several computations with the values given by the user.
The problem lies with the last value given by the user. If the user presses "enter", or clicks anywhere on the table, no worries. The cell's edit ends and the value is stored.
However, if after writing the last value in the last cell, the user immediately presses the button without "finalizing" the editing (so to speak. i.e. not clicking anywhere inside the table or pressing "enter"), the value will not be stored and the computations won't be done.
PS1: If the user presses the button a 2nd time, everything works again
PS2: This didn't happen when I first wrote my code (almost 2 years ago... I was updating it now and making the necessary changes to be aligned with your newest version)
I am using Python 3.11.5 and tksheet 7.0.5
Many thanks in advance!
The text was updated successfully, but these errors were encountered: