Comments (3)
It's a bit crude but
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(30)] for r in range(2000)], #to set sheet data at startup
headers = [f"Column {c}\nnewline1\nnewline2" for c in range(30)],
)
self.sheet.enable_bindings(("single_select", #"single_select" or "toggle_select"
"drag_select", #enables shift click selection as well
"rc_select",
"row_select",
"column_select",
"arrowkeys",
"row_height_resize",
"double_click_row_resize",
"copy",
"cut",
"paste",
"delete",
"undo",
"edit_cell"))
self.frame.grid(row = 0, column = 0, sticky = "nswe")
self.sheet.grid(row = 0, column = 0, sticky = "nswe")
self.del_rows_button = tk.Button(self,
text = "Delete Rows",
command = self.del_rows)
self.del_rows_button.grid(row = 1, column = 0)
self.new_rc_popup_menu = tk.Menu(self, tearoff = 0, background = "white")
self.new_rc_popup_menu.add_command(label = "Delete Rows",
font = ("Arial", 13, "normal"),
foreground = "gray10",
background = "white",
activebackground = "gray90",
activeforeground = "gray5",
command = self.del_rows)
#self.sheet.bind("<3>", self.rc) #use "<2>" if on Mac OS this is in case you need your own right click binding
def rc(self, event):
self.new_rc_popup_menu.tk_popup(event.x_root, event.y_root)
def del_rows(self, event = None):
selected_rows = self.sheet.get_selected_rows()
if selected_rows:
start = min(selected_rows)
end = max(selected_rows) + 1
self.sheet.MT.data_ref[start:end] = []
index = self.sheet.row_index()
if index:
try:
index[start:end] = []
self.sheet.row_index(index)
except:
pass
self.sheet.deselect("all")
self.sheet.refresh()
app = demo()
app.mainloop()
You can control the bindings using enable_bindings()
function for the Sheet()
widget, all the bindings are listed in the readme file demonstration
from tksheet.
@CorpseKiller I reopened to update my response, I am not sure if you mean your own right click function or literally a button, but I put both in the example
from tksheet.
Thanks a lot for taking the time good sir!
from tksheet.
Related Issues (20)
- How to change appereance of the Thsheet when bindings are disabled HOT 2
- In drop down, how do i display default text? HOT 1
- Is it possible to center the text in vertical alignment? HOT 1
- Include freezing option HOT 1
- Calculos con tksheet
- trouble with shifting the data over the tksheet HOT 1
- Higher resolution support HOT 9
- Add prompt for wrong keyward args in get_sheet_data/get_cell_data/get_row_data/get_column_data HOT 1
- Issue with set_sheet_data HOT 6
- Manually set displayed row index HOT 3
- Dropdown menu fails to open if some rows are hidden HOT 2
- Update cells data using specific conditions on user input. HOT 27
- SyntaxWarning HOT 3
- Currently selected cell rows in sheet vs in data HOT 2
- on Rpi5, OS debian bookworm, tksheet's sheet defined col-w & row-h of 10x16 cells size has slow/lagging mouse's cursor movement HOT 12
- How to fix the maximum size of characters in tksheet ceels HOT 6
- The tabel font does not change. HOT 1
- How to Check if a Check Box is checked in tksheet 7 HOT 1
- How to accept user input even if "enter" is not pressed HOT 4
- Looking to customize scrollbar and scrollbar frame bg HOT 2
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.