Advertisement
ALEXANDAR_GEORGIEV

Primer

Jun 17th, 2023
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. class demo(tk.Tk):
  2.     def __init__(self):
  3.         tk.Tk.__init__(self)
  4.         self.grid_columnconfigure(0, weight = 1)
  5.         self.grid_rowconfigure(0, weight = 1)
  6.         self.frame = tk.Frame(self)
  7.         self.frame.grid_columnconfigure(0, weight = 1)
  8.         self.frame.grid_rowconfigure(0, weight = 1)
  9.         self.sheet = Sheet(self.frame,
  10.                            data = [[f"Row {r}, Column {c}\nnewline1\nnewline2" for c in range(50)] for r in range(500)])
  11.         self.sheet.enable_bindings("single_select",
  12.                                    "drag_select",
  13.                                    "edit_cell",
  14.                                    "select_all",
  15.                                    "column_select",
  16.                                    "row_select",
  17.                                    "column_width_resize",
  18.                                    "double_click_column_resize",
  19.                                    "arrowkeys",
  20.                                    "row_height_resize",
  21.                                    "double_click_row_resize",
  22.                                    "right_click_popup_menu",
  23.                                    "rc_select")
  24.         self.sheet.extra_bindings([("begin_edit_cell", self.begin_edit_cell),
  25.                                    ("end_edit_cell", self.end_edit_cell)])
  26.         self.sheet.popup_menu_add_command("Say Hello", self.new_right_click_button)
  27.         self.frame.grid(row = 0, column = 0, sticky = "nswe")
  28.         self.sheet.grid(row = 0, column = 0, sticky = "nswe")
  29.  
  30.     def new_right_click_button(self, event = None):
  31.         print ("Hello World!")
  32.  
  33.     def begin_edit_cell(self, event = None):
  34.         return event.text
  35.  
  36.     def end_edit_cell(self, event = None):
  37.         # remove spaces from user input
  38.         if event.text is not None:
  39.             return event.text.replace(" ", "")
  40.         self.recalculate()
  41.            
  42.            
  43.     def recalculate(self):
  44.    
  45.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement