Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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("single_select",
- "drag_select",
- "edit_cell",
- "select_all",
- "column_select",
- "row_select",
- "column_width_resize",
- "double_click_column_resize",
- "arrowkeys",
- "row_height_resize",
- "double_click_row_resize",
- "right_click_popup_menu",
- "rc_select")
- self.sheet.extra_bindings([("begin_edit_cell", self.begin_edit_cell),
- ("end_edit_cell", self.end_edit_cell)])
- self.sheet.popup_menu_add_command("Say Hello", self.new_right_click_button)
- self.frame.grid(row = 0, column = 0, sticky = "nswe")
- self.sheet.grid(row = 0, column = 0, sticky = "nswe")
- def new_right_click_button(self, event = None):
- print ("Hello World!")
- def begin_edit_cell(self, event = None):
- return event.text
- def end_edit_cell(self, event = None):
- # remove spaces from user input
- if event.text is not None:
- return event.text.replace(" ", "")
- self.recalculate()
- def recalculate(self):
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement