I'm using this them in py tkinter program. My problem is that I make like 20 buttonst, it becomes very slow. I know that this is beacuse all the buttons have images. I alredy get a suggestion, that use OpenCV instead of tkinter to load images. But the images are loaded in the Tcl not in the Python file.
Any suggestions to overcome this issue?
UPDATE:
def draw(self):
self['width'] = self.width
self['height'] = self.height
self['background'] = COLORS['GRAY3']
s_btn_add_scene = ttk.Style()
s_btn_add_scene.configure('scene.TButton', font=(FONT_NAME, self.font_size), padding=(0, 0))
btn_add_scene = ttk.Button(self.viewport, text='Add Scene', style='scene.TButton')
cf_scenes = CollapsingFrame(self.viewport, padding=10)
btn_remove = ttk.Button(None, text='Remove', style='scene.TButton')
btn_add = ttk.Button(None, text='+', style='scene.TButton', width=3)
btn_add_scene.pack(anchor='nw', pady=10, padx=8)
cf_scenes.pack(expand=True, fill='x', anchor='n')
for i in range(20):
#TODO: remove
go = randint(0, 100)
frame1 = ttk.Frame(cf_scenes, padding=10)
for j in range(go):
ttk.Label(frame1, text=f"GameEntity{j}").pack(anchor='w')
cf_scenes.add(frame1, title=f"NewScene{i}", collapsed=True, widgets=[btn_remove, btn_add])
I'm no expert in this area, but I believe the trend is to start using SVG graphics for themes rather than bitmapped images, for greater efficiency. I see that the same guy has an svg theme at https://github.com/rdbende/Sun-Valley-ttk-theme-svg . It might be worth trying that just to see if the slowness goes away.