Giter Site home page Giter Site logo

Comments (4)

ragardner avatar ragardner commented on July 21, 2024 1

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 "<FocusOut>" is not triggered

What I've done in tksheet version 7.0.6 is added two functions:

This is so that in your compute() function you can add at the start of the function the line:

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

from tksheet.

ragardner avatar ragardner commented on July 21, 2024

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:

  • Any bindings you have made with the sheet, like extra_bindings() or other things that might involve the cell text editor
  • The tk button called function lines that involve the sheet

You can strip out anything sensitive and the code does not have to run/work

from tksheet.

joestraw265 avatar joestraw265 commented on July 21, 2024

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:

button = Button(frame, text="Compute", command=lambda: compute())
button.grid(row=6, column=0, columnspan=3)

The sheet is initialized like this:

sheet_in_AN = Sheet(frame, align="center", empty_horizontal=0, empty_vertical=0, show_top_left=False,   
                                   cell_auto_resize_enabled = False, show_row_index=False, show_header=False, width=661, height=208, 
                                   show_x_scrollbar=False)
sheet_in_AN.grid(row=2, column=3, columnspan=5,rowspan=7)
sheet_in_AN.set_sheet_data([["" for cj in range(4)] for ri in range(20)])
sheet_in_AN.set_column_widths(column_widths=[88,198,174,174])
sheet_in_AN.enable_bindings(("single_select", "drag_select","arrowkeys",
                                                 "right_click_popup_menu","copy","cut",
                                                  "paste","delete","undo","edit_cell"))

Inside the function compute(), the lines that go fetch the values input by the user:

col3 = sheet_in_AN["C"].data
col4 = sheet_in_AN["D"].data

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...

from tksheet.

joestraw265 avatar joestraw265 commented on July 21, 2024

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!

from tksheet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.