I'm trying to create two custom scales in one GUI. The simplest way to create a custom scale is by using a style; but the problem is that when this function is called for the second time to create the second scale, the style.element_create() generates an error as it sees the 'custom.Horizontal.Scale.trough' as a duplicate.
def create_style():
global startup
if startup=="no":
img_trough = PhotoImage(file="bar.gif")
img_slider = PhotoImage(file="slider.gif")
if startup=="yes":
img_trough = PhotoImage(file="bar_small.gif")
img_slider = PhotoImage(file="slider_small.gif")
# create scale elements
style.element_create('custom.Horizontal.Scale.trough', 'image', img_trough)
style.element_create('custom.Horizontal.Scale.slider', 'image', img_slider)
# create custom layout
style.layout('custom.Horizontal.TScale',[('custom.Horizontal.Scale.trough', {'sticky': 'ns'}),
('custom.Horizontal.Scale.slider', {'side': 'left', 'sticky': '','children': [('custom.Horizontal.Scale.label', {'sticky': ''})]})])
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…