Radio and Check Buttons#

Radiobutton radio Checkbutton checkb

Both radio- and check buttons are created in a similar fashion, in that multiple images were created for the various states. All images need to be the same size and if they are about the same distance between the lines of widgets that would not be such a bad idea.

Whenever a radio or check button is disabled or enabled its selection must be maintained.

Radio Buttons#

Show/Hide Code 07pirate_radio.py

# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
#style.theme_settings('default', {
# start of theme extract
     'Radiobutton.indicator': {"element create":
          ('image', "radio",
            ('active', "radio-a"),
           ('selected', "radio-s"),
            ('disabled', "radio-d"),
           {'width':20, 'sticky': "w"})
        }
# end of theme extract - don't forget to add comma at end when inserting
     })

style.theme_use('yummy') # 'default'
widg = Radiobutton(fr,text='Piratz!')
widg.grid(column=0,row=13,sticky='nsew', padx=5, pady=5)
widg1 = Radiobutton(fr,text='Piratz!\nextra line')
widg1.grid(column=0,row=14,sticky='nsew', padx=5, pady=5)
run_state(fr,widg,widg1)

root.mainloop()

Check Buttons#

Show/Hide Code 07pirate_check.py

# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
# style.theme_settings('default', {
# start of theme extract
     'Checkbutton.indicator': {"element create":
          ('image', "check-nu",
           ('pressed', 'selected', "check-nc"),
           ('pressed', "check-nu"),
           ('active', 'selected', "check-nc"),
           ('active', "check-nu"),
           ('disabled', 'selected', "check-dc"),
           ('selected', "check-nc"),
           ('disabled', "check-du"),
           {'width':24, 'sticky': "w"})
         }
# end of theme extract - don't forget to add comma at end when inserting
     })

style.theme_use('yummy') # 'default'

widg = Checkbutton(fr, text='Cheese')
widg1 = Checkbutton(fr, text='Tomato')
widg.grid(column=0,row=18,sticky='nsew', padx=5, pady=5)
widg1.grid(column=0,row=19,sticky='nsew', padx=5, pady=5)
run_state(fr,widg,widg1)
root.mainloop()