Skip to content

How can I remove some labels on the right click popup menu? #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ychan79 opened this issue Mar 25, 2025 · 7 comments
Open

How can I remove some labels on the right click popup menu? #281

ychan79 opened this issue Mar 25, 2025 · 7 comments

Comments

@ychan79
Copy link

ychan79 commented Mar 25, 2025

I want to remove some label on the right click popup menu, like "Sort Values ->", "Sort Columns ->", etc. But can not remove by command popup_menu_del_command. Because I do not want to show this function on popup menu, and do not want to do this action through popup menu.

Thank you!

@ragardner
Copy link
Owner

disable_bindings is what I think you want:

https://github.com/ragardner/tksheet/wiki/Version-7#disable-table-functionality-and-bindings

uses the same arguments as enable_bindings

disable_bindings("sort_cells", "sort_row", "sort_col", "sort_rows", "sort_cols")

@ychan79
Copy link
Author

ychan79 commented Mar 25, 2025

Image

Thank you for your reply. But it seems not working. As shown in the image, I want to hide or remove the command in the rectangle in the inbuilt popup menu list. But from the document guide, it seems could not........

@ragardner
Copy link
Owner

Strange, this line seems to be working for me, replace sheet with your sheet name:

sheet.disable_bindings("sort_cells", "sort_col", "sort_cols", "sort_row", "sort_rows")

Is there any way you could provide some example code to demonstrate the issue?

@ychan79
Copy link
Author

ychan79 commented Mar 26, 2025

Image

Thank you! I tried one by one, now it is working.

Then what are the key words for other commands? such as "cut contents", "copy contents", "clear contents", "paste", etc. There are no description in the manual. Thank you!

@ragardner
Copy link
Owner

Then what are the key words for other commands? such as "cut contents", "copy contents", "clear contents", "paste", etc. There are no description in the manual. Thank you!

Do you want to keep the keyboard bindings for Cut, Copy, Paste and Delete but remove the menu items? Or disable the keyboard bindings as well?

@ychan79
Copy link
Author

ychan79 commented Mar 29, 2025

Just want to remove the label from the popup menu, same as above.

ragardner added a commit that referenced this issue Mar 31, 2025
Address #281 by adding an optional parameter to enable_bindings() named menu. When False it doesn't add edit bindings such as cut, copy, paste to the in-built right click popup menu.
@ragardner
Copy link
Owner

Hello,

In tksheet version 7.4.18 I have added a parameter to the function enable_bindings which you can use to prevent functionality being added to the in-built popup menu. e.g.

my_sheet.enable_bindings("all", menu=False)

You may have to use additional calls to enable_bindings with different arguments if you need some menu entries but not others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants