Tkinter marked Checkbutton as check due to config values

时间:2017-08-04 12:31:54

标签: python python-3.x checkbox tkinter

hi i am using a loop to create 10 checkbuttons, but only the last button check the value from config, in another 9 value was set to 1 but they still unmark.

for j in range(len(self.config['Currency'])):
        self.currency_value = IntVar(value=self.config_values[j])
        self.currency_button = Checkbutton(self.top, text=self.currency_tags[j].upper(), variable=self.currency_value)
        if j < 5:
            row_n = 1
            col_n = j
        else:
            row_n = 2
            col_n = j - 5
        self.currency_button.grid(row=row_n, column=col_n, pady=8)

thx for help

1 个答案:

答案 0 :(得分:0)

最好的观点是创建一个checkbuuttuns列表,如Sierra Mountain Tech所说