[Question] change colors of scrollbar in combo?
arminposchmann opened this issue · comments
Type of Issue (Enhancement, Error, Bug, Question)
Question
Environment
Operating System
Linux version ('glibc', '2.35')
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions
Python version (sg.sys.version
)
3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
PySimpleGUI Version (sg.__version__
)
5.0.2
GUI Version (tkinter (sg.tclversion_detailed
), PySide2, WxPython, Remi)
8.6.12
Your Experience In Months or Years (optional)
2 Years Python programming experience
30 Years Programming experience overall
Yes Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
- Searched main docs for your problem www.PySimpleGUI.org
- Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
- If not tkinter - looked for Demo Programs for specific port
- For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
- Run your program outside of your debugger (from a command line)
- Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
- Upgraded to the latest official release of PySimpleGUI on PyPI
- Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description
Just a Question:
Is it possible to change the colors of scrollbar in combo to look like listbox?
scrollbar and sbar_through, sbar_tips of Combobox and Menubutton don't look like those of other scrollbars and keep their colors no matter which theme is selected.
Code To Duplicate
import sys
import PySimpleGUI as sg
from random import choice as rc
def main(theme):
sg.theme(theme)
win_layout = [
[sg.Listbox(values = sg.theme_list(),
size =(20, 12),
key ='-THEME LISTBOX-',
enable_events = True),
sg.vtop(
sg.Combo(values= sg.theme_list(),
default_value=theme,
size=(20, 11),
key='-THEME COMBO-',
enable_events=True, pad=(25,0))),
],
]
window = sg.Window('Color Test', win_layout, resizable=True,
margins=(0,0), use_custom_titlebar=True,
finalize=True, keep_on_top=True)
while True:
e, v = window.read(timeout=200)
if e in (None, 'Exit'):
break
window.Close()
if __name__ == '__main__':
themes = sg.theme_list()
theme = rc(themes) if len(sys.argv) < 2 else sys.argv[1]
main(theme)
Screenshot, Sketch, or Drawing
Workaround here
import PySimpleGUI as sg
def new_window(theme):
sg.theme(theme)
layout = [
[
sg.Listbox(values=themes, default_values=[themes[0]], size=(width, 12), key='-LISTBOX-'),
sg.vtop(sg.Combo(values=themes, size=(width, 11), key='-COMBO-')),
],
]
window = sg.Window('Color Test', layout, finalize=True)
root = window.TKroot
combo = window['-COMBO-']
window.force_focus()
combo.set_focus()
window.refresh()
combo.widget.event_generate('<Down>')
# Workaround after window finalized
fg, bg = sg.theme_button_color()
style_name = combo.ttk_style_name + ".Vertical.TScrollbar"
style = combo.ttk_style
style.configure(style_name, arrowcolor=fg, background=bg, troughcolor=sg.theme_slider_color())
root.tk.eval(f'set popdown [ttk::combobox::PopdownWindow {combo.widget}]')
root.tk.eval(f'$popdown.f.sb configure -style "{style_name}"')
window.read(timeout=1000, close=True)
themes = sg.theme_list()
width = max(map(len, themes))
for theme in themes[::10]:
new_window(theme)
That works, just a comment:
to have the same look with all themes it should be
style.configure(style_name, arrowcolor=newbfg, background=newbbg, troughcolor=newslc = sg.theme_slider_color())
where :
newbbg = sg.LOOK_AND_FEEL_TABLE[theme]['BUTTON'][1]
newbfg = sg.LOOK_AND_FEEL_TABLE[theme]['BUTTON'][0]
Is there a way to set this new ttk style for all combos at once, or must each combo configured this way?
I didn't find any way to configure same style at once for all Combo elements at once.