I have been making a GUI with Tkinter in Python 2.7 and I want to trigger the checkbox from within the code such that the checkbox get ticked whenever that function is read. For e.g Suppose I am reading a list of strings and whenever I come across a word in the list called 'enable' I need to trigger that definite checkbox from an array of other checkboxes, such that it gets ticked; so whenever I run the program that checkbox, from an array of other checkboxes, is ticked. For now what this checkbox is doing if we check it it sends out the value enabled or disabled to the function force_download_function(i, var.get()). But I also want to make sure if we are reading from a list and we come across the word 'enabled' it shows a tick on that checkbox number equivalent to the index of the word 'enabled'
def make_force_download_button(i):
var = StringVar()
force_download_button_array[i] = Checkbutton(top, variable=var, onvalue='enabled', offvalue='disabled', command=lambda: force_download_function(i, var.get()))
force_download_button_array[i].deselect()
force_download_button_array[i].pack()
force_download_button_array[i].place(height=30, width=30, x=420, y=(65 + ((i - 1) * 60)))
Aucun commentaire:
Enregistrer un commentaire