Skip to content
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

Can i have help changing listed behavior of tksheet ? #186

Open
Mrasipila opened this issue May 26, 2023 · 6 comments
Open

Can i have help changing listed behavior of tksheet ? #186

Mrasipila opened this issue May 26, 2023 · 6 comments

Comments

@Mrasipila
Copy link

Mrasipila commented May 26, 2023

Hello,
I have been going through your code for some time trying to edit it so that the sheet changes it's behavior, here are the behaviors i would like to change :

  • When i press < Tab > or < Enter > on an editable sheet, I can't edit the cell without an additional click to reselect the ongoing cell. I have tried to go through the tab_key(self, event=None) function of the MainTable class, replacing self.see by self.select_cell but it doesn't work.
  • The Second issue i came across was the double_clicking on a cell which has an overflowing number of characters. When i double click, the column gets resized. I have tried to disable the following bindings 'double_click_column_resize' and 'column_width_resize' but nothing changes. I still have the same issue.
  • I also would like to have an autofill feature for the drop down list. This way when I write 'OF' on an ['ON','OFF'] drop down list and then press < Tab > the 'OFF' gets selected.

If i can have any help on the functions i should focus on to add those features, please, it would be cool.

@ragardner
Copy link
Owner

ragardner commented May 26, 2023

Hi,

The Second issue i came across was the double_clicking on a cell which has an overflowing number of characters. When i double click, the column gets resized. I have tried to disable the following bindings 'double_click_column_resize' and 'column_width_resize' but nothing changes. I still have the same issue.

You can disable cell auto resizing when editing cells completely with the argument enable_edit_cell_auto_resize = False in the Sheet() initialization

my_sheet = Sheet(parent, enable_edit_cell_auto_resize = False)

or with set_options(enable_edit_cell_auto_resize = False)

The specific part of the code that deals with resizing the cell upon opening is:

text = "" if text is None else text
if self.cell_auto_resize_enabled:
    self.set_cell_size_to_text(r, c, only_set_if_too_small=True, redraw=True, run_binding=True)

It's in the open_text_editor() function


I also would like to have an autofill feature for the drop down list. This way when I write 'OF' on an ['ON','OFF'] drop down list and then press < Tab > the 'OFF' gets selected.

I won't be working on this functionality for some time, I am not sure of the best way to implement it sorry but there would have to be communication between the dropdown window and the text editor, these two are in the open_dropdown() function


When i press < Tab > or < Enter > on an editable sheet, I can't edit the cell without an additional click to reselect the ongoing cell. I have tried to go through the tab_key(self, event=None) function of the MainTable class, replacing self.see by self.select_cell but it doesn't work.

Sorry, I'm not sure what you mean, is focus not being applied to the text editor when you press Enter on a cell?

@Mrasipila
Copy link
Author

Thank you for your response. Focus is being applied but I can't write text on the cell without reclicking on the focused cell.

@ragardner
Copy link
Owner

I cannot think why this is happening sorry, is there any way you could provide a minimal example and which version of tksheet you're using?

@Mrasipila
Copy link
Author

Mrasipila commented May 28, 2023

I have the issue with this piece of code, my version is 6.1.2.

from tksheet import Sheet
import tkinter as tk


class demo(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.grid_columnconfigure(0, weight = 1)
        self.grid_rowconfigure(0, weight = 1)
        self.frame = tk.Frame(self)
        self.frame.grid_columnconfigure(0, weight = 1)
        self.frame.grid_rowconfigure(0, weight = 1)
        self.sheet = Sheet(self.frame,
                           data = [[f"Row {r}, Column {c}\nnewline1\nnewline2" for c in range(50)] for r in range(500)])
        self.sheet.enable_bindings()
        self.show_selections = tk.Label(self)
        self.frame.grid(row = 0, column = 0, sticky = "nswe")
        self.sheet.grid(row = 0, column = 0, sticky = "nswe")
        self.show_selections.grid(row = 1, column = 0, sticky = "nswe")
        self.sheet.dropdown_column(c=1, values=["ON", "OFF"])


app = demo()
app.mainloop()

I upgraded to the latest version which is "6.1.9" and the problem has been solved. I work with PyCharm hence the fact that i didn't have installed the latest version to start with.
Thank you !

@Mrasipila
Copy link
Author

Mrasipila commented May 28, 2023

from tksheet import Sheet
import tkinter as tk


class demo(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.grid_columnconfigure(0, weight = 1)
        self.grid_rowconfigure(0, weight = 1)
        self.frame = tk.Frame(self)
        self.frame.grid_columnconfigure(0, weight = 1)
        self.frame.grid_rowconfigure(0, weight = 1)
        self.sheet = Sheet(self.frame,
                           data = [[f"Row {r}, Column {c}\nnewline1\nnewline2" for c in range(50)] for r in range(500)])
        self.sheet.enable_bindings()
        self.show_selections = tk.Label(self)
        self.frame.grid(row = 0, column = 0, sticky = "nswe")
        self.sheet.grid(row = 0, column = 0, sticky = "nswe")
        self.show_selections.grid(row = 1, column = 0, sticky = "nswe")
        self.sheet.dropdown_column(c=1, values=["ON", "OFF"])
        self.sheet.dropdown_column(c=2, values=["ON", "OFF"])
        self.sheet.dropdown_column(c=3, values=["ON", "OFF"])


app = demo()
app.mainloop()

but with this example the problem seems to persist with the drop down columns. The dropdown list doesn't drop after pressing TAB and arriving on it.

@ragardner
Copy link
Owner

Ah, I think this is the behavior I programmed for,

Would you prefer the next dropdown box to open when pressing tab out of an existing one? I am not sure, it's not the behavior in excel and google sheets as far as I can tell, although it might be more convenient to have it this way...

You could open it by using Tab -> Return I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants