How can I retrieve the value from multiple Checkbuttons when Checkbutton are generated in a method?
The method button which have to retrieve value checked
def __download(self, url: Entry, button: Button):
"""
download video infos video and display checkbox
:return:
"""
try:
url = url.get()
video: Video = Video()
if button['text'] != 'Download':
video.url = url
video.video = YouTube(url)
self.__display_video_title(video)
self.__display_video_thumbnail(video)
resolution = video._get_video_resolution()
# checkbox are created here
self.__display_checkbox(resolution, video)
button['text'] = 'Download'
else:
# need to get the value here
pass
except exceptions.RegexMatchError:
print('the url is not correct')
except exceptions.VideoPrivate:
print('Can\'t reach the video')
except exceptions.VideoUnavailable:
print('this video is unavailable')
the method which creates the Checkbuttons
def __display_checkbox(self, resolution: list, video: Video):
x_checkbox = 25
var = StringVar()
checkbox_title = Label(self.app, border=None, font='Terminal 15 bold', bg='#f1faee', fg='#457b9d',
text='Choose your resolution')
checkbox_title.place(x=280, y=85)
for res in resolution:
Checkbutton(self.app, text=res, bg='#f1faee', variable=var, onvalue=res, offvalue='off').place(x=x_checkbox, y=120)
x_checkbox += 100