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

Looking to customize scrollbar and scrollbar frame bg #213

Closed
infiniteTesch opened this issue Mar 6, 2024 · 2 comments
Closed

Looking to customize scrollbar and scrollbar frame bg #213

infiniteTesch opened this issue Mar 6, 2024 · 2 comments

Comments

@infiniteTesch
Copy link

infiniteTesch commented Mar 6, 2024

As the topic suggest im looking for a way to accomplish this. Can't seem to find customizable variables inside the tksheet class.
Anyone knows?

Best regards
InfiniteTesch

@ragardner
Copy link
Owner

ragardner commented Mar 18, 2024

Thanks for your question and sorry for the late reply,

I think I have found a way to do this, the test code I have been using sits inside sheet.py __init__ function:

style = ttk.Style()
for orientation in ("Vertical", "Horizontal"):
    style.element_create(f"Tksheet.{orientation}.TScrollbar.trough", "from", "default")
    style.element_create(f"Tksheet.{orientation}.TScrollbar.thumb", "from", "default")
    style.element_create(f"Tksheet.{orientation}.TScrollbar.grip", "from", "default")
    
    # in case you want to remove the arrow buttons uncomment below:
    
    # style.layout(
    #     f"Tksheet.{orientation}.TScrollbar",
    #     [
    #         (
    #             f"Tksheet.{orientation}.TScrollbar.trough",
    #             {
    #                 "children": [
    #                     (
    #                         f"Tksheet.{orientation}.TScrollbar.thumb",
    #                         {
    #                             "unit": "1",
    #                             "children": [(f"Tksheet.{orientation}.TScrollbar.grip", {"sticky": ""})],
    #                             "sticky": "nswe",
    #                         },
    #                     )
    #                 ],
    #                 "sticky": "ns" if orientation == "Vertical" else "ew",
    #             },
    #         )
    #     ],
    # )
    style.configure(
        f"Tksheet.{orientation}.TScrollbar",
        gripcount=0,
        borderwidth=2,
        background="#b0b0b0",
        troughcolor="red",
        bordercolor="#252526",
        lightcolor="#252526",
        darkcolor="#252526",
    )

Those colours are just to test it out

I will hopefully be adding the Sheet initialization and set_options() parameters for scrollbar colours in the next update

Edit: I forgot to mention you also have to set the style parameter for the scrollbars if using the above code

self.yscroll = ttk.Scrollbar(
    self,
    command=self.MT.set_yviews,
    orient="vertical",
    style="Tksheet.Vertical.TScrollbar",
)
self.xscroll = ttk.Scrollbar(
    self,
    command=self.MT.set_xviews,
    orient="horizontal",
    style="Tksheet.Horizontal.TScrollbar",
)

Edit 2: You also have to use the style.map() function it seems, something like shown in this stackoverflow answer

Edit 3: This seems to clash with the dropdown boxes scrollbars and cause an error

@ragardner
Copy link
Owner

@infiniteTesch I have now added the ability to change scroll bar appearance in version 7.1.0

documentation here:
https://github.com/ragardner/tksheet/wiki/Version-7#scrollbar-appearance

Thanks again for your suggestion!

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