Skip to content
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

Feature request: possibility of disabling some right-click options #60

Open
bartlomiejduda opened this issue Oct 6, 2019 · 5 comments

Comments

@bartlomiejduda
Copy link

Hello. Thank you for great tool. I have small feature request for future versions.

I have tried to disable adding rows and deleting rows for my table and I had to do it manually by changing line in Tables.py
from
general = ["Select All", "Add Row(s)" , "Delete Row(s)", "Auto Fit Columns", "Filter Records", "Preferences"]
to general = ["Select All", "Auto Fit Columns", "Filter Records", "Preferences"]

But it would be nice to make it possible while creating new table, for example:
table = TableCanvas(some_frame, model=model, disable_add_rows=True, disable_delete_rows=True)

It would be good solution to have such parameter for every right-click option. :)

@hannansatopay
Copy link
Contributor

Hello @bartlomiejduda Doing something like this would help serve your purpose: TableCanvas(self.tframe,read_only=True)

The above functionality helps make your table read-only!

@bartlomiejduda
Copy link
Author

Hey, @hannansatopay Thanks for answer. I know read-only option, I have tested it earlier, but in my particular case I needed to disable only adding and deleting rows to prevent breaking some functionality by user. :)

@MRES1
Copy link

MRES1 commented Jul 16, 2020

Hello, It's possible but you have to make a few changes

  1. On your ide navigate to class TableCanvas(Canvas):

  2. With crtl + f look for something like rename column it doesn't really matter the important thing is that you find the popup. You can also look for def popupMenu(self, event): and you will find what we are looking for just below. Note that we have two def popupMenu( , so changes are slightly different.

  3. You just have to comment on what you don't need.

  4. Example

On def popupMenu(self, event, rows=None, cols=None, outside=None): you have to change:

                    defaultactions = {
                    # "Set Fill Color" : lambda : self.setcellColor(rows,cols,key='bg'),
                    # "Set Text Color" : lambda : self.setcellColor(rows,cols,key='fg'),
                    "Copiar" : lambda : self.copyCell(rows, cols),
                    "Pegar" : lambda : self.pasteCell(rows, cols),
                    "Fill Down" : lambda : self.fillDown(rows, cols),
                    "Fill Right" : lambda : self.fillAcross(cols, rows),
                    # "Add Row(s)" : lambda : self.addRows(),   THIS LINE                   
                    # "Delete Row(s)" : lambda : self.deleteRow(), THIS LINE

But you also need to change this list below:
general = [...

  1. If you get any errors after doing this it's because some change is missing. In def popupMenu(self, event): changes are slightly different as I said before.

To sum up you just have comment and change values like the ones in general = [... for example.

@bartlomiejduda
Copy link
Author

Hello. Yeah, I was able to do it as I described in my first post by changing "general" list:

I have tried to disable adding rows and deleting rows for my table and I had to do it manually by changing line in Tables.py
from
general = ["Select All", "Add Row(s)" , "Delete Row(s)", "Auto Fit Columns", "Filter Records", "Preferences"]
to general = ["Select All", "Auto Fit Columns", "Filter Records", "Preferences"]

It is only a feature request for developers to make it by parameters:

It would be good solution to have such parameter for every right-click option. :)

For me It would be safer to make such changes in my code rather than tkintertable code. :)

@dmnfarrell
Copy link
Owner

Yes I think since you know how to do it it's better to allow developers to sub-class the table and add this themselves. I generally am not adding new features to this package now, only bug fixes.

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

4 participants