Skip to content

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

Open

Description

@bartlomiejduda

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. :)

Activity

  1. hannansatopay commented on Oct 7, 2019

    @hannansatopay
    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!

  2. bartlomiejduda commented on Oct 7, 2019

    @bartlomiejduda
    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. :)

  3. MRES1 commented on Jul 16, 2020

    @MRES1

    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.

  4. bartlomiejduda commented on Jul 16, 2020

    @bartlomiejduda
    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. :)

  5. dmnfarrell commented on Jul 16, 2020

    @dmnfarrell
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions