israel-dryer / ttkbootstrap

A supercharged theme extension for tkinter that enables on-demand modern flat style themes inspired by Bootstrap.
MIT License
1.86k stars 371 forks source link

Combobox scrollbar is missing ttkbootstrap style #319

Open antrrax opened 2 years ago

antrrax commented 2 years ago

Desktop (please complete the following information):

ttkbootstrap Version [1.9.0] OS: Linux Mint x64 Cinnamon X11

Describe the bug

Combobox scrollbar is tk styled instead of ttkbootstrap styled Is this a bug or am I doing something wrong?

To Reproduce

Combobox scrollbar is missing ttkbootstrap style

Combobox scrollbar is tk styled instead of ttk styled Is this a bug or am I doing something wrong?

I have these three files https://www.mediafire.com/file/wx9j4a7vyp2pzf0/test.zip/file

when opening the combobox list the scrollbar is in tk style instead of ttk see the image

main.py

import tkinter as tk
import ttkbootstrap as ttk
import custom_styles

class Defaultframe(ttk.Window):
    def __init__(self):
        ttk.Window.__init__(self)
        self.theme_default = 'cosmo'
        ttk.Style(self.theme_default)

        style = ttk.Style()

        initdata = {}

        from form_main import Wmain
        self.frm = Wmain(self, data=initdata)
        custom_styles.load_cst_style(style, self.theme_default)   #<-- before pack and after frame
        self.frm.pack(fill=tk.BOTH, expand=True)
        return

if __name__== '__main__':
    app = Defaultframe()
    app.mainloop()

form_main.py

import tkinter as tk
import ttkbootstrap as ttk
import custom_styles

class Func(ttk.Frame):
    def change_theme(self, user_theme, event=None):
        self.style.theme_use(user_theme)
        custom_styles.load_cst_style(self.style, user_theme)
        return

class Wmain(Func):
    def __init__(self, master=None, **kwargs):

        self.data = kwargs.pop('data', None)

        ttk.Frame.__init__(self, master, **kwargs)

        self.theme_default = self.master.theme_default

        self.style = ttk.Style()

        self.master.geometry('500x200')

        self.panel_header()
        return

    def panel_header(self):
        frame_top = ttk.Frame(self, bootstyle='primary')
        frame_top.pack(fill=tk.BOTH)

        dots = 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAAAS0lEQVRIx+2SMQoAIAzExNcp/v8D6j/iIugkXaQKl720KQlBfANQgA40IN9Y0FhU61z0/sxukKdFBZL3PQ+iiiwGquiMKrIYqKJPGcKohPddpdT6AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTEyLTAyVDIxOjE3OjA1KzAwOjAwwFXs0AAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0xMi0wMlQyMToxNzowNSswMDowMLEIVGwAAAAASUVORK5CYII='
        self.img_opt = tk.PhotoImage(data=dots)
        btn_opt = ttk.Menubutton(frame_top, image=self.img_opt)
        btn_opt.configure(style='opt.TMenubutton')
        btn_opt.pack(side='right', padx=5)

        theme_names = ['cosmo', 'flatly', 'journal', 'litera', 'lumen', 'minty', 'pulse', 'sandstone', 'united', 'yeti', 'morph', 'simplex', 
                    'cerculean', 'solar', 'superhero', 'darkly', 'cyborg', 'vapor', 'mint-y-royal', 'breeze']

        self.cbb_themes = ttk.Combobox(frame_top, values=theme_names)
        self.cbb_themes.pack()
        self.cbb_themes.set(self.theme_default)
        self.cbb_themes.configure(state="readonly")
        self.cbb_themes.bind('<<ComboboxSelected>>', lambda x: self.change_theme(self.cbb_themes.get()))

        return

custom_styles.py

def load_cst_style(style, user_theme):
    colors = style.colors

    if user_theme == 'mint-y-royal':
        style.configure('img.TButton', padding=[5, 3])
        style.configure('TButton', padding=[20, 6])
        style.configure('TButton', background='#fafafa', foreground=style.colors.fg, bordercolor=style.colors.border, darkcolor=style.colors.bg, lightcolor=style.colors.bg)
        style.map("TButton", background=[('active', style.colors.inputbg)])

    if user_theme == 'breeze':
        style.configure('TButton', padding=[10, 2])
        style.configure('TButton', background='#f7f7f7', foreground=style.colors.fg, bordercolor=style.colors.border, darkcolor=style.colors.bg, lightcolor=style.colors.bg)
        style.map("TButton", background=[('active', style.colors.inputbg)])

    style.configure('opt.TMenubutton', arrowsize=0, arrowpadding=[0,0,0,0], arrowcolor='primary', padding=[0, 10])

    return

Expected behavior

No response

Screenshots

error

expected: expected

Additional context

No response

TsaiTung-Chen commented 2 months ago

Found a workaround. Try this:

import ttkbootstrap as ttk

root = ttk.Window()
builder = root.style._get_builder()  # add these two lines to your code
builder.create_scrollbar_style()  # add these two lines to your code
ttk.Combobox(root, values=list(range100)).pack()
root.mainloop()