''' This module contains class AskSheetName that is responsible for
asking the user to specify the sheet name of the xls-file where input
data is.
'''
from tkinter import W, E, N, StringVar
from tkinter.ttk import Frame, Label, Combobox, Button
[docs]class AskSheetName(Frame):
''' This class is responsible for asking the user to
specify the sheet name of the xls-file where input data is.
Attributes:
parent (Toplevel): new window where this Frame will be situated.
names (list of str): list of available sheet names.
sheet_name_str (StringVar): StringVar object used for reading
what sheet was chosen by the user.
Args:
parent (Toplevel): new window where this Frame will be situated.
names (list of str): list of available sheet names.
'''
def __init__(self, parent, names, *args, **kw):
super().__init__(parent, *args, **kw)
self.parent = parent
self.sheet_name_str = StringVar()
self.create_widgets(names)
self.update_idletasks()
[docs] def cancel(self, event=None):
''' This method is called if the user presses Cancel button.
In this case sheet name is set to empty string.
Args:
event (Tk event, optional): event that is given when the
button is pressed. It is ignored in this method.
'''
self.sheet_name_str.set('')
self.parent.destroy()
[docs] def ok(self, event=None):
''' This method is called if the user presses OK button.
In this case sheet name is set to the currently selected value
in Combobox.
Args:
event (Tk event, optional): event that is given when the
button is pressed. It is ignored in this method.
'''
self.parent.destroy()