Giter Site home page Giter Site logo

Comments (6)

ragardner avatar ragardner commented on July 21, 2024

Hello,

Thanks for your excellent questions and sorry for the delay in my reply

I would like to prevent user to write down more than 12 characters in single tksheet cell. So if it is more than 12 characters the end ones shall be trimmed.

Unfortunately with tksheet versions 6.x.x this is rather difficult and verbose so I've made an effort to finish version 7 and changed it's behaviour a little

Here is the changelog for version 7 in case you're interested:

And here is the code I've made to demonstrate how easy this is with versions 7+

All edits including paste should be trimmed to 12 characters

The documentation for the function is available here:

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)

        # create an instance of Sheet()
        self.sheet = Sheet(
            # set the Sheets parent widget
            self,
            # optional: set the Sheets data at initialization
            data=[[f"Row {r}, Column {c}\nnewline1\nnewline2" for c in range(20)] for r in range(100)],
            theme="light green",
            height=520,
            width=1000,
        )
        # enable various bindings
        self.sheet.enable_bindings()

        # set a user edit validation function
        # AND bind all sheet modification events to a function
        # chained as two functions
        # more information at:
        # https://github.com/ragardner/tksheet/wiki/Version-7#validate-user-cell-edits
        self.sheet.edit_validation(self.validate_edits)
        self.sheet.grid(row=0, column=0, sticky="nswe")

    def validate_edits(self, event):
        # trim the edits to the table
        return event.value[:12]


app = demo()
app.mainloop()

For your 2nd question

P.S.: I have another question is there maybe a simple way to translate following actions into other languages: cut, copy, paste,...?

I am not sure, perhaps in your code you could create links to the functions using variables/attributes

# i think this is copy in spanish
sheet_copiar = sheet.copy

# or...

# i think this is copy in swedish
sheet_kopiera = sheet.copy

and then using the function later on:

sheet_kopiera()

Let me know if you run into any issues

Kind regards

from tksheet.

janez111 avatar janez111 commented on July 21, 2024

from tksheet.

janez111 avatar janez111 commented on July 21, 2024

from tksheet.

ragardner avatar ragardner commented on July 21, 2024

Hello,

Probably my last question about translation was to general, so the idea was to translate the menu which opens when You right-click one of the tksheet ceels.

Oh sorry I misunderstood, yea that's a good idea. Currently you'd have to edit the tksheet code by going to the tksheet folder then if you're using version 6.x.x inside the file _tksheet_main_table.py and starting on line 2262 - label="Edit header", edit each of the label= lines to your desired labels

You'll also have to go into the file _tksheet_other_classes.py and starting on line 116 - label="Select all", and edit those label= lines also

I am working on a way of setting these things but the change won't be out for version 6, only for version 7 and I can't give a date on it

The last row #tk_sheet.set_dropdown_values(set_existing_dropdown=True, values=['Kopiraj', 'Izreži', 'Prilepi', 'Uredi celico']) is commented as it generates me the error. I am wondering whether my idea is plausible or I should do something completely different?

I am not sure if this is your issue but only use set_existing_dropdown=True if there is a dropdown open at the time otherwise use the r and c parameters to set a specific dropdowns values

Hope this helps

from tksheet.

janez111 avatar janez111 commented on July 21, 2024

from tksheet.

ragardner avatar ragardner commented on July 21, 2024

Thank you for the reply and for giving me new ideas for the project! If you're interested and also using the latest version I have added the label change functionality:

https://github.com/ragardner/tksheet/wiki/Version-7#sheet-languages-and-bindings

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.