Esempio n. 1
0
    def __init__(self, fr, widg, widg1=None):
        ''' Used to enable state change

        Creates radio buttons showing states
        Creates check button with "Enabled", useful for testing
            check and radio buttons

        Args:
            fr: frame reference in calling program
            widg: widget reference
            widg1: optional widget
        '''
        self.fr = fr
        self.widg = widg
        self.widg1 = widg1

        # Create radio buttons which will display widget states
        # except alternate and background
        states = [
            'active', 'disabled', 'focus', 'invalid', 'pressed', 'readonly',
            'selected'
        ]

        self.rb = []
        self.state_val = StringVar()
        for iy, state in enumerate(states):
            st_rb = Radiobutton(fr,
                                value=state,
                                text=state,
                                variable=self.state_val,
                                command=self.change_state)
            st_rb.grid(column=0, row=iy + 2, padx=5, pady=5, sticky='nw')
            self.rb.append(st_rb)
            st_rb.state(['disabled'])

        self.enabled = IntVar()
        self.cbOpt = Checkbutton(fr,
                                 text='Enabled',
                                 variable=self.enabled,
                                 command=self.change_state)
        self.cbOpt.grid(column=0, row=0)

        sep = Separator(orient='h')
        sep.grid(column=0, row=1, sticky='ew')