Comments (6)
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.
from tksheet.
from tksheet.
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.
from tksheet.
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)
- Partial Horizontal Scrolling HOT 2
- Rows sorting? HOT 2
- Cell Selection Persistence HOT 2
- Keypad enter button ignored HOT 2
- Quotes multiplies when i copy text from cell with ctrl+c or popup menu. HOT 2
- Editing out of bounds when changing sheets HOT 2
- Is there a way to set copy and paste bindings on cyrillic layout? HOT 7
- Issues with auto_resize_row_index HOT 1
- Column header data not made when creating new columns HOT 2
- KeyError when binding a function (which selects a row) to "cell_select" HOT 8
- Resizing columns automatically to fit the frame if they would be smaller in total than the available space HOT 6
- Can we add a feature where Checkbox fill the entire cell ?
- Deleting popup_menu. HOT 3
- Moving columns/rows to the end is currently broken on 7.2.6
- How to make the Checkbox remain checked after searching in Entry HOT 1
- Copy&Paste HOT 2
- Sheet object takes focus when setting sheet data? How to inhibit? HOT 6
- Dropdown multi-select checkbox filter HOT 1
- function "checkbox" in "other_classes.py" currently creates a dropdown instead of a checkbox HOT 1
- REQUEST : Add a sort function
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 tksheet.