I have a column list colList = ['A','B','C','D']
which is displayed along with checkbox to user, user checks the checkbox and clicks submit button. On submit i want to get the column of the check values only.
I am using Tkinter, Grid structure.
Code is as follows.
from tkinter import filedialog
from tkinter import *
import tkinter as tk
def command_to_extract():
print('Extract button pressed')
#this function will display which checkbox is checked and display the column name - But I am not able to write the check condition for checking the value of checkbox
root = Tk()
button3 = Button(text="Extract", command=command_to_extract, width=30, anchor=NW)
button3.grid(row=4, column=4)
lbl31 = Label(master=root, text="Select the column(s) for output csv file", width=30, anchor=NW)
lbl31.grid(row=5, column=2)
colList = ['A','B','C','D']
columnDictionary = { i : colList[i] for i in range(0, len(colList) ) } # To Make a dictionary from a List
p = 0 #variable for column
#this double for loop for 2X2 display of checkbox
for i in range(0, 2): #row
for j in range(0, 2): #column
Checkbutton(master=root, text = colList[p], variable = var[], onvalue = 1, offvalue = 0, width=40, anchor=NW).grid(row = i, column = j)
p = p + 1
mainloop()
Problem arises when i need to select only few checkbox, then how to distinguish one checkbox with other. Also i need to get the column name such as weither variable = var[]
to use or some other way. Please help me out.