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

Add ability to remove tab color #1166

Closed
MikesAtMIT opened this issue Jan 31, 2023 · 4 comments · Fixed by #1199
Closed

Add ability to remove tab color #1166

MikesAtMIT opened this issue Jan 31, 2023 · 4 comments · Fixed by #1199

Comments

@MikesAtMIT
Copy link

MikesAtMIT commented Jan 31, 2023

It would be nice to update Worksheet.update_tab_color() to accept None as a value, which would then unset the color in Google.

In #1095, a method to retrieve and set the color of a tab was added. However, the update_tab_color() method does not support removing the color. It's not well documented in Google's docs, but after some poking around, it appears that if you set the value to None, it unsets the color. Setting to an empty dict {} sets the color to black (i.e., seems to imply { 'red': 0, 'green': 0, 'blue': 0 }).

The following code works for me, which I am doing in the meantime:

body = {
    'requests': [
        {
            'updateSheetProperties': {
                'properties': {
                    'sheetId': <sheet_id>,
                    'tabColorStyle': {
                        'rgbColor': None,
                    },
                },
                'fields': 'tabColorStyle',
            },
        },
    ],
}
spreadsheet.batch_update(body)

Incidentally, it looks like the issue with the Google API described in the original ticket #996 has been fixed by Google. So the method could also be updated to remove the deprecated tabColor. https://issuetracker.google.com/issues/236109669

@lavigne958
Copy link
Collaborator

Hi this is a good feature, would you like to open a PR to add that feature to the method update_tab_color ?

The approach I would take, to match similar behavior with other methods would be to create a new method dedicated to clearing the tab color, that accepts no arguments and set the tab color to None.

let me know if you wish to participate to the project or if I should do it.

@MikesAtMIT
Copy link
Author

Happy to update the method, but am unfamiliar with how the testing works. Do I use my real credentials and make a real google spreadsheet? Where should that spreadsheet live permanently, i.e., what happens if I delete it? Sorry, I haven't contributed to an open source project before.

@lavigne958
Copy link
Collaborator

The testing can work offline for any already existent test.

When adding a new test you can follow the procedure here: https://github.com/burnash/gspread/blob/master/.github/CONTRIBUTING.md

You will be required to use your service account credentials file, and you should use the option new_episodes for the recording mode.

In any case you can see any new files created by the test framework under the folder tests/cassettes. You should only have a new file for your new test. If you have more than that it means that's not the right recording mode and you can reset the recorded files and start again 😆.

Feel free to come back here if you have any more questions

@MikesAtMIT
Copy link
Author

Ok I'll give it a shot

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

Successfully merging a pull request may close this issue.

2 participants