pyDEA.core.gui_modules package¶
Submodules¶
pyDEA.core.gui_modules.categories_checkbox_gui module¶
This module contains class responsible for displaying and configuring categories.
-
pyDEA.core.gui_modules.categories_checkbox_gui.
MIN_COLUMN_WIDTH
¶ int
minimum column width.
-
pyDEA.core.gui_modules.categories_checkbox_gui.
MIN_COLUMN_WIDTH_NAME
¶ int
minimum text width of the column.
-
pyDEA.core.gui_modules.categories_checkbox_gui.
HEIGHT_WITHOUT_CHECKBOXES
¶ int
widget height.
-
pyDEA.core.gui_modules.categories_checkbox_gui.
COUNT_TO_NAME
¶ dict of int to str
dictionary that maps index to parameter name.
-
class
pyDEA.core.gui_modules.categories_checkbox_gui.
CategoriesCheckBox
(parent, label_text, add_headers, params, category_type, *args, **kw)[source]¶ Bases:
tkinter.ttk.Labelframe
This class implement a widget for displaying and configuring categories.
-
parent
¶ Tk object
widget parent.
-
frame_with_boxes
¶ Frame
frame for check buttons.
-
canvas
¶ StyledCanvas
canvas for all objects of this widget.
-
options
¶ dict of str to list of IntVar and int
dictionary that maps category name to two IntVar objects that keep track of the state of check buttons and grid row index. The first check button is used for checking if category is non-discretionary. The second check button is used for checking if category is weakly disposal.
-
nb_entries
¶ int
total number of categories.
-
add_headers
¶ bool
if set to True, the widget displays column headers, if set to False column headers are not displayed.
-
category_objects
¶ dict of list of Tk objects
dictionary that maps category name to a list with three elements. The first element is Label with category name, the remaining elements are Checkbuttons used for non-discretionary and weakly disposal categories.
-
params
¶ Parameters
parameters of the model.
-
category_type
¶ str
INPUT_CATEGORIES or OUTPUT_CATEGORIES, defines type of categories (input or output).
Parameters: - parent (Tk object) – widget parent.
- label_text (str) – text that will be displayed on top of this widget.
- add_headers (bool) – if set to True, the widget displays column headers, if set to False column headers are not displayed.
- params (Parameters) – parameters of the model.
- category_type (str) – INPUT_CATEGORIES or OUTPUT_CATEGORIES, defines type of categories (input or output).
-
add_category
(category_name)[source]¶ Adds a given category to this object. If the given category already exists, it won’t be added again. Category names are assumed to be unique.
Parameters: category_name (str) – name of the category to add.
-
change_category_name
(old_name, new_name)[source]¶ Changes category name if such a category is present.
Parameters: - old_name (str) – previous category name that should be changed.
- new_name (str) – new category name.
-
on_select_box
(box, count)[source]¶ This method is called when the user clicks on a Checkbutton. It updates corresponding parameters that must be changed after clicking on Checkbutton.
Parameters: - box (Label) – Label that stores category name.
- count (int) – index of the Checkbutton that distinguishes between Checkbuttons responsible for non-discretionary categories and weakly disposal categories.
-
pyDEA.core.gui_modules.custom_canvas_gui module¶
This module contains StyledCanvas class.
pyDEA.core.gui_modules.data_frame_gui module¶
This module contains DataFrame class that implements a Notebook with two tabs for loading input data and displaying solution.
-
class
pyDEA.core.gui_modules.data_frame_gui.
DataFrame
(parent, params_frame, current_categories, data_from_params_file, str_var_for_input_output_boxes, *args, **kw)[source]¶ Bases:
tkinter.ttk.Notebook
This class is a Notebook with two tabs: one tab is used for loading and editing input data, the other tab is used for displaying solution.
-
parent
¶ Tk object
parent of this widget
Note
Parent must have object progress_bar, which value can be reset as follows:
>>> parent.progress_bar["value"] = 0
-
solution_tab
¶ Frame
tab used for displaying solution
-
data_tab
¶ Frame
tab used for loading, displaying and editing input data
Parameters: - parent (Tk object) – parent of this widget
- params_frame (ParamsFrame) – frame with parameters
- current_categories (list of str) – list of current categories, this list might be modified by this class
- data_from_params_file (StringVar) – StringVar object that contains name of data file. It is used for communication between this frame and parameters frame. This argument is necessary for data_tab creation
- str_var_for_input_output_boxes (ObserverStringVar) – object that contains current input and output categories and notifies table with data when data is loaded and some categories need to be checked. This argument is necessary for data_tab creation
-
pyDEA.core.gui_modules.data_tab_frame_gui module¶
This module contains class DataTabFrame that creates tab with all data.
-
class
pyDEA.core.gui_modules.data_tab_frame_gui.
DataTabFrame
(parent, params_frame, current_categories, data_from_params_file, str_var_for_input_output_boxes, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
This class creates frame with all widgets needed for working with data (e.g. loading, saving, modifying, etc.)
-
parent
¶ Tk object
parent of the frame.
-
data_from_params_file
¶ StringVar
StringVar object that contains name of data file. It is used for communication between this frame and parameters frame. When parameters are uploaded from file, then file name with data might be updated, and, hence, this frame must also be updated. If file name is set to empty string, then this framed is cleared (everything will be deleted). If file name points to actual file, then data from this file will be uploaded and displayed on this frame
-
panel
¶ LabelFrame
frame that holds table with data and name of the currently loaded data file
-
table
¶ TableFrameWithInputOutputBox
object that knows how to display data in table and how to modify it
-
params_frame
¶ Notebook
frame with parameters. When all data is cleared, then we also need to clear parameters
-
data
¶ list of list of str or float
stores all loaded or entered data without categories, for example:
>>> [["A", 1, 2, 3], ["B", 1, "", 5], ["C", "", "a", "b"]]
-
if_text_modified_str
¶ StringVar
is used for adding star to file name if it was modified. Technically it is not necessary to store this variable, but it is used in unit tests.
-
sheet_name
¶ str
name of the sheet in xls-file from where data has been loaded
NavigationForTableFrame
frame that knows how to navigate table with data
-
table_modifier_frame
¶ TableModifierFrame
frame that adds and removes rows and columns of data table
Parameters: - parent (Tk object) – parent of this frame
- params_frame (Notebook) – frame with parameters. When all data is cleared, then we also need to clear parameters
- current_categories (list of str) – list with categories, it is shared and modified by several objects
- data_from_params_file (StringVar) – StringVar object that contains name of data file. It is used for communication between this frame and parameters frame
- str_var_for_input_output_boxes (ObserverStringVar) – object that contains current input and output categories and notifies table with data when data is loaded and some categories need to be checked
-
call_dialog
(names)[source]¶ Calls dialogue that asks user to specify sheet name from where data should be loaded.
Parameters: names (list of str) – list of sheet names Returns: name of the selected sheet if sheet was selected, empty string if user pressed cancel Return type: (str)
-
clear_all_on_btn_click
()[source]¶ Clears all data if user agrees.
Asks the user if he/she wants to clear all data, clears all data if user agrees. This method is called when user presses button “Clear all”.
-
create_widgets
(current_categories, str_var_for_input_output_boxes)[source]¶ Creates widgets on this frame.
Parameters: - current_categories (list of str) – list of current categories (might be empty).
- str_var_for_input_output_boxes (ObserverStringVar) – object that contains current input and output categories and notifies table with data when data is loaded and some categories need to be checked.
-
get_data_file_name
()[source]¶ Returns name of a file with data if it was loaded.
File name is stored in label frame.
-
load_file
()[source]¶ Asks user which data file should be loaded and loads specified file.
Only xls, xlsx and csv files are allowed.
-
on_data_modify
(*args)[source]¶ Adds star to label frame when data was modified.
Parameters: *args – are not used in this method, but are provided by StringVar trace routine.
-
on_params_file_change
(*args)[source]¶ Loads data or clears all after parameters are loaded from file.
If file with parameters contains data file, then this data will be attempted to load. If file with parameters doesn’t contain data file (or user specified to load parameters without data), then all previously loaded data will remain.
Parameters: *args – are not used in this methods and are provided by trace method of StringVar
-
read_coefficients
()[source]¶ Converts coefficients into a proper data structure used for running algorithms.
Returns: see read_data_from_xls for details
-
save_data
()[source]¶ Saves data to an existing or new file.
This method is called when user presses “Save” button. If user modified open data file, then modifications will be saved in this file. If user typed data, this method redirects user to save_data_as() method.
-
save_data_as
()[source]¶ Saves data to a new file.
Calls dialogue to ask user where to save file and saves data file there. Default extension is .xls.
-
save_data_to_given_file
(data_file, sheet_name='Data')[source]¶ Saves data to a given file.
Parameters: - data_file (str) – file name where data should be stored.
- sheet_name (str) – sheet name where data should be stored.
- to "Data". (Defaults) –
-
show_data
(categories, coefficients, dmu_name)[source]¶ Fills table with data.
Parameters: - categories (list of str) – list with categories that will
- in the first table row (appear) –
- coefficients (list of list of str or float) – data that will appear after categories. Each contained list will be displayed on a new table row
- dmu_name (str) – text that appear in the same line with categories before the categories appear
-
pyDEA.core.gui_modules.load_xls_gui module¶
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.
-
class
pyDEA.core.gui_modules.load_xls_gui.
AskSheetName
(parent, names, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
This class is responsible for asking the user to specify the sheet name of the xls-file where input data is.
-
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.
Parameters: - parent (Toplevel) – new window where this Frame will be situated.
- names (list of str) – list of available sheet names.
-
cancel
(event=None)[source]¶ This method is called if the user presses Cancel button. In this case sheet name is set to empty string.
Parameters: event (Tk event, optional) – event that is given when the button is pressed. It is ignored in this method.
-
pyDEA.core.gui_modules.options_frame_gui module¶
This module contains OptionsFrame class used for displaying and modifying some of the parameters.
-
pyDEA.core.gui_modules.options_frame_gui.
COUNT_TO_NAME_RADIO_BTN
¶ dict of {(str, int) to str}
dictionary that maps parameter name and count to a valid value. This structure is used to identify parameter value used for display depending on parameter name and count. Count is simply a value of IntVar used in Radiobutton
Warning
COUNT_TO_NAME_RADIO_BTN and all methods that use it must be modified if COUNT_TO_NAME_RADIO_BTN ever changes.
-
class
pyDEA.core.gui_modules.options_frame_gui.
OptionsFrame
(parent, params, current_categories, input_categories_frame, output_categories_frame, name='Options', *args, **kw)[source]¶ Bases:
tkinter.ttk.Labelframe
This class creates Checkbuttons and Radiobuttons for displaying and modifying some of the parameters.
-
params
¶ Parameters
object with all parameters. Some of the parameter values are modified in this class.
-
current_categories
¶ list of str
list of categories.
-
input_categories_frame
¶ CategoriesCheckBox
frame with input categories. It is needed in this class to read what categories are input.
-
output_categories_frame
¶ CategoriesCheckBox
frame with output categories. It is needed in this class to read what categories are output.
-
categorical_box
¶ Combobox
Combobox for choosing categorical category.
-
combobox_text_var
¶ StringVar
text variable of categorical_box.
-
options
¶ dict of str to IntVar
dictionary that stores IntVars of Radiobuttons and Checkbuttons.
Example
>>> options = {"RETURN_TO_SCALE": IntVar(), "ORIENTATION": IntVar()}
-
multi_tol_strvar
¶ StringVar
StringVar object that stores tolerance of multiplier model.
-
max_slack_box
¶ Checkbutton
Checkbutton for the option “Two phase”.
Parameters: - parent (Tk object) – parent of this widget.
- params (Parameters) – object with all parameters. Some of the parameter values are modified in this class.
- current_categories (list of str) – list of categories.
- input_categories_frame (CategoriesCheckBox) – frame with input categories. It is needed in this class to read what categories are input.
- output_categories_frame (CategoriesCheckBox) – frame with output categories. It is needed in this class to read what categories are output.
- name (str, optional) – name of the LabelFrame that this class represents, defaults to Options.
-
change_categorical_box
()[source]¶ Updates categories that can be chosen as categorical category when the user clicks on the Combobox.
-
on_categorical_box_change
(*args)[source]¶ Updates value of the CATEGORICAL_CATEGORY in parameters. This method is called when the user clicks on the Combobox and chooses one item from the drop-down list.
Parameters: *args – are provided by the StringVar trace method and are ignored in this method.
-
on_check_box_click
(var, name)[source]¶ Updates parameter specified by the Checkbutton in the parameter object when the user clicks on the Checkbutton.
Parameters: - var (IntVar) – IntVar of the Checkbutton.
- name (str) – name of the parameter that is the key in options dictionary.
-
on_multi_tol_change
(*args)[source]¶ Updates parameter MULTIPLIER_MODEL_TOLERANCE in the parameter object when the user modifies the content of the Entry widget that stores multiplier model tolerance.
Parameters: *args – are provided by the StringVar trace method and are ignored in this method.
-
radio_btn_change
(name, *args)[source]¶ Actions that happen when user clicks on a Radiobutton. Changes the corresponding parameter values and options.
Parameters: - name (str) – name of the parameter that is a key in options dictionary.
- *args – are provided by IntVar trace method and are ignored in this method.
-
set_categorical_box
(categorical_param)[source]¶ Sets the value of Combobox with categorical category according to a given value if this value is in the list of values of this Combobox. If the given value is not in the list of values, a warning is displayed.
Parameters: categorical_param (str) – value of the categorical category.
-
set_check_btns
()[source]¶ Goes through all Checkbuttons and changes their values according to the values stored in parameter object. Might display warnings.
-
set_multi_tol
()[source]¶ Sets the value of Entry with multiplier model tolerance according to a given value if this value is valid (non-negative float). If the given value is invalid, a warning is displayed.
-
set_one_check_btn
(param_name)[source]¶ Sets value of a given set of Checkbutton according to its value stored in parameter object if this value is valid. Might display warnings.
Parameters: param_name (str) – name of parameter whose value must be changed.
-
set_one_radio_btn
(param_name, valid_values)[source]¶ Sets value of a given set of Radiobuttons according to its value stored in parameter object if this value is valid. Might display warnings.
Parameters: - param_name (str) – name of parameter whose value must be changed.
- valid_values (list of str) – list of valid values that this parameter might take.
-
pyDEA.core.gui_modules.params_frame_gui module¶
This module contains class ParamsFrame which is responsible for all operations with parameters.
-
pyDEA.core.gui_modules.params_frame_gui.
MAX_FILE_LBL_LENGTH
¶ int
maximum length of the label with file name.
-
pyDEA.core.gui_modules.params_frame_gui.
TEXT_FOR_PARAMS_LBL
¶ str
text displayed on one of the labels.
-
class
pyDEA.core.gui_modules.params_frame_gui.
ParamsFrame
(parent, current_categories, data_from_params_file, str_var_for_input_output_boxes, weights_status_str, *args, **kw)[source]¶ Bases:
tkinter.ttk.Notebook
This class implements various operations with parameters like loading and saving from and to file, modifying parameters values.
-
parent
¶ Tk object
parent of this widget.
-
params
¶ Parameters
Parameters object with values of all parameters.
-
current_categories
¶ list of str
list of current valid categories.
-
input_categories
¶ CategoriesCheckBox
frame for displaying input categories.
-
output_categories
¶ CategoriesCheckBox
frame for displaying output categories.
-
params_from_file_lbl
¶ Label
label for displaying file name if parameters were loaded from file.
-
data_from_params_file
¶ StringVar
StringVar object used for communication of this widget with DataFrame. Changing the value of data_from_params_file triggers changes in DataFrame (like clearing all data and loading data from file).
-
str_var_for_input_output_boxes
¶ ObserverStringVar
ObserverStringVar object used for storing input and output categories and for tracking changes in input and output categories.
-
weight_tab
¶ WeightFrame
widget used for displaying and editing weights.
-
load_without_data
¶ IntVar
IntVar object used for Checkbutton, if its value is 1, then parameters will be loaded from file without data, if its value is 0, then parameters will be loaded from file with data.
-
options_frame
¶ OptionsFrame
widget used for displaying and modifying some of the parameters.
Parameters: - parent (Tk object) – parent of this widget.
- current_categories (list of str) – list of current valid categories.
- data_from_params_file (StringVar) – StringVar object used for communication of this widget with DataFrame. Changing the value of data_from_params_file triggers changes in DataFrame (like clearing all data and loading data from file).
- str_var_for_input_output_boxes (ObserverStringVar) – ObserverStringVar object used for storing input and output categories and for tracking changes in input and output categories.
- weights_status_str (StringVar) – StringVar object used for changing label of weights editor, for details see WeightFrame.
-
add_categories
(name, frame, categories_container)[source]¶ Adds input or output categories to a specified widget with categories from parameters.
Parameters: - name (str) – name of the parameter where categories come from, possible values INPUT_CATEGORIES, OUTPUT_CATEGORIES.
- frame (CategoriesCheckBox) – widget where categories will be added.
- categories_container (list of str) – list of categories where categories from parameters will be added.
-
change_category_name
(old_name, new_name)[source]¶ Changes category name in parameters and all widgets to a new name. If new name is empty string, then some of the parameters might be lost (for example, weight restrictions will be lost).
Parameters: - old_name (str) – old name of the category.
- new_name (str) – new name of the category.
-
change_weight_tab_name
(new_name)[source]¶ Changes name of weights editor tab.
Parameters: new_name (str) – new name for weights editor tab.
Loads data if possible and sets widgets to proper values depending on parameters.
Parameters: - file_name (str) – file name of file with parameters. It is needed to display it on parameters frame.
- params_to_restore (dict of str to str) – dictionary of previous values of parameters. They are used in order to restore previous values if loading of data from file fails.
-
pyDEA.core.gui_modules.scrollable_frame_gui module¶
This module contains classes that implement multi-platform scrolling for frames. Code is mainly borrowed from web and slightly modified. Unfortunately, I don’t have web-page address any more.
-
class
pyDEA.core.gui_modules.scrollable_frame_gui.
MouseWheel
(root, factor=1)[source]¶ Bases:
object
This class bind scrolling events to a scroll object.
-
class
pyDEA.core.gui_modules.scrollable_frame_gui.
VerticalScrolledFrame
(parent, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
A pure Tkinter scrollable frame that actually works! Use the ‘interior’ attribute to place widgets inside the scrollable frame Construct and pack/place/grid normally This frame only allows vertical scrolling.
-
canvas
¶ StyledCanvas
canvas.
-
interior
¶ frame
frame where all widgets are palced.
Parameters: parent (Tk object) – parent of this widget. -
pyDEA.core.gui_modules.solution_frame_gui module¶
This module contains classes responsible for displaying solution in GUI.
-
class
pyDEA.core.gui_modules.solution_frame_gui.
SolutionFrame
(parent, *args, **kw)[source]¶ Bases:
tkinter.ttk.Notebook
This class is responsible for creating tabs with various information about solution to a given problem.
-
parent
¶ Tk object
parent of this widget.
-
last_modified_tab
¶ int
index of the last modified tab.
-
nb_tabs
¶ int
total number of tabs.
-
all_tabs
¶ list of Frame
list of all tabs.
-
nb_filled_tabs
¶ int
number of filled tabs.
Parameters: parent (Tk object) – parent of this widget. -
add_sheet
(tab_name)[source]¶ Creates a tab with a given name.
Parameters: tab_name (str) – tab name. Returns: created tab. Return type: Frame
-
create_default_tabs
(solutions, params_to_print, all_params, run_date, total_seconds, ranks, categorical)[source]¶ Creates all tabs.
Parameters: - solutions (list of Solution) – list with solutions that must be displayed, can have 1, 2 or 4 elements.
- params_to_print (Parameters) – parameters that should be displayed.
- all_params (list of str) – list with strings that should appear before printing every solution from solutions.
- run_date (datetime) – date and time when the problem was solved.
- total_seconds (float) – time (in seconds) needed to solve the problem.
- ranks (list of dict of str to double) – list that contains dictionaries that map DMU code to peel the onion rank.
- categorical (str) – name of the categorical variable used in categorical analysis.
-
modify_tab_names
()[source]¶ Modifies tab names according to the names that were passed as a parameter when tab was created.
-
show_solution
(solutions, params_to_print, all_params, run_date, total_seconds, ranks=None, categorical=None)[source]¶ Displays a given solution.
Parameters: - solutions (list of Solution) – list with solutions that must be displayed, can have 1, 2 or 4 elements.
- params_to_print (Parameters) – parameters that should be displayed.
- all_params (list of str) – list with strings that should appear before printing every solution from solutions.
- run_date (datetime) – date and time when the problem was solved.
- total_seconds (float) – time (in seconds) needed to solve the problem.
- ranks (list of dict of str to double, optional) – list that contains dictionaries that map DMU code to peel the onion rank.
- categorical (str, optional) – name of the categorical variable used in categorical analysis.
-
-
class
pyDEA.core.gui_modules.solution_frame_gui.
SolutionFrameWithText
(parent, *args, **kw)[source]¶ Bases:
pyDEA.core.gui_modules.solution_frame_gui.SolutionFrame
This class creates a different frame for displaying solution as a plain text instead of table.
Note
this works much faster than tables.
pyDEA.core.gui_modules.solution_tab_frame_gui module¶
This module contains class responsible for displaying solution on the screen.
-
pyDEA.core.gui_modules.solution_tab_frame_gui.
MAX_FILE_PARAMS_LBL_LENGTH
¶ int
module constant that describes maximum length of the label with a file name
-
class
pyDEA.core.gui_modules.solution_tab_frame_gui.
SolutionTabFrame
(parent, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
This class is responsible for displaying solution on the screen. It extends Frame class.
-
parent
¶ Tk object that can contain Frame
parent that can contain Frame, MUST implement method change_solution_tab_name(str).
-
data_from_file_lbl
¶ Label
label that contains file name with data if specified.
-
solution_tab
¶ SolutionFrameWithText
notebook with tabs describing solution.
-
model_solutions
¶ list of Solution
list with one or more solutions that have been generated after running algorithm.
-
param_strs
¶ list of str
list with strings that should appear before printing every solution from model_solutions.
-
ranks
¶ list of list of int
list of ranks corresponding to every solution from model_solutions, ranks are generated by peel-the-onion algorithm.
-
categorical
¶ str
name of the categorical variable used in categorical analysis.
-
progress_bar
¶ Progressbar
progress bar to show how solution is loaded or saved to file.
-
status_lbl
¶ Label
label for displaying solution status.
-
solution_format_var
¶ IntVar
IntVar object that tracks which file format is chosen for solution.
-
ask_file_name_to_save
(ext_code)[source]¶ Calls asksaveasfilename dialogue to ask the user where file should be saved. If file without extension is entered, default extension will be used (.xlsx). This method is used to mock this object for unit tests.
Parameters: ext_code (int) – code for file extension 1 - xlsx, 2 - xls.
-
on_save_solution
()[source]¶ Saves solution to file.
This method is called when save solution button is pressed. If there is a solution, this method will ask user to provide a file name where solution should be stored. If a valid name is provided, solution is saved to that file. Allowed file formats are: .xls and .xlsx. Default file extension is .xlsx.
If the user checked ‘csv’ as solution output format, then the user will be asked to choose a directory where all csv files will be written.
-
show_solution
(solutions, params, param_strs, run_date, total_seconds, ranks=None, categorical=None)[source]¶ Displays solution on the screen.
Parameters: - solutions (list of Solution) – list of solutions (might contain just one solution) that have been generated after running algorithm.
- params (Parameters) – object with parameters that will be written to file on the Parameters page.
- param_strs (list of str) – list with strings that should appear before printing every solution from model_solutions.
- ranks (list of list of int) – list of ranks corresponding to every solution from model_solutions, ranks are generated by peel-the-onion algorithm.
- categorical (str) – name of the categorical variable used in categorical analysis.
-
pyDEA.core.gui_modules.table_gui module¶
This module contains classes responsible for displaying input data in a table (TableFrame and TableFrameWithInputOutputBox). It also contains many classes necessary for TableFrameWithInputOutputBox.
-
pyDEA.core.gui_modules.table_gui.
CELL_WIDTH
¶ int
constant that defined width of a cell in a table
Bases:
tkinter.ttk.Checkbutton
Custom Checkbutton widget that provides deselect method.
IntVar
0 if not selected, 1 otherwise.
Parameters: - parent (Tk object) – parent of this widget.
- var (IntVar) – variable that controls if Checkbutton is selected.
Deselects Checkbutton.
-
class
pyDEA.core.gui_modules.table_gui.
DefaultCategoriesAndDMUModifier
(cells, current_categories)[source]¶ Bases:
object
This class is responsible for adding automatic category and DMU names if user starts typing data without providing such names first.
-
cells
¶ list of list of SelfValidatingEntry
list of all Entry widgets with data.
-
current_categories
¶ list of str
list of categories.
Parameters: - cells (list of list of SelfValidatingEntry) – list of all Entry widgets with data.
- current_categories (list of str) – list of categories.
-
change_state_if_needed
(entry, entry_state, row, col)[source]¶ Writes automatic category and DMU names if they were not specified before.
Parameters: - entry (SelfValidatingEntry) – Entry widget the content of which was modified.
- entry_state (int) – constant that describes entry state, for details see dea_utils module.
- row (int) – row index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
- col (int) – column index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
-
Bases:
pyDEA.core.gui_modules.table_gui.ObserverCheckbutton
This class follows state of another ObserverCheckbutton that is used to select input or output categories. This class is used in order to skip checking if data is valid second time. The first Checkbutton has already performed this check.
IntVar
variable that is set to 1 when Checkbutton is selected, to 0 otherwise.
IntVar
variable of the other Checkbutton that must deselected if this Checkbutton is selected.
Tk object
frame that holds this Checkbutton.
Warning
it is important for the parent to be gridded in the same column as the entire column of table entries is gridded, because this class uses parent grid column index to determine the column where the category name can be read from.
CategoriesCheckBox
frame that displays selected input or output categories.
Note
if this Checkbutton is used to select input categories, category_frame must be CategoriesCheckBox object that displays selected input categories. if this Checkbutton is used to select output categories, category_frame must be CategoriesCheckBox object that displays selected output categories.
CategoriesCheckBox
frame that displays selected input or output categories. If category_frame displays input categories, then opposite_category_frame must display output categories, and vice versa.
list of str
list of categories. This class might modify this list by removing invalid categories and adding the valid ones.
list of list of SelfValidatingEntry
all entry widgets collected in list.
list of list of str or float
input data.
int
describes type of the observer, for possible values see dea_utils.
callable function
this function is called when name of a category was changed.
StringVar
variable of the combobox used for selecting categorical category.
ObserverCheckbutton
Checkbutton that changes state first. This Checkbutton changes its state to the same state as main_box, but does not do extra things that have been already performed by main_box (changes to current_categories, for example).
Changes state of Checkbutton when data was modified depending on the state of main_box.
Parameters: - entry (SelfValidatingEntry) – Entry widget whose content was modified.
- entry_state (int) – state of the Entry widget after content modification, for possible values see dea_utils module.
- row (int) – row index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
- col (int) – column index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
Bases:
tkinter.ttk.Checkbutton
This class implements Checkbutton for choosing input/output categories.
IntVar
variable that is set to 1 when Checkbutton is selected, to 0 otherwise.
IntVar
variable of the other Checkbutton that must deselected if this Checkbutton is selected.
Tk object
frame that holds this Checkbutton.
Warning
it is important for the parent to be gridded in the same column as the entire column of table entries is gridded, because this class uses parent grid column index to determine the column where the category name can be read from.
CategoriesCheckBox
frame that displays selected input or output categories.
Note
if this Checkbutton is used to select input categories, category_frame must be CategoriesCheckBox object that displays selected input categories. if this Checkbutton is used to select output categories, category_frame must be CategoriesCheckBox object that displays selected output categories.
CategoriesCheckBox
frame that displays selected input or output categories. If category_frame displays input categories, then opposite_category_frame must display output categories, and vice versa.
list of str
list of categories. This class might modify this list by removing invalid categories and adding the valid ones.
list of list of SelfValidatingEntry
all entry widgets collected in list.
list of list of str or float
input data.
int
describes type of the observer, for possible values see dea_utils.
callable function
this function is called when name of a category was changed.
StringVar
variable of the combobox used for selecting categorical category.
Arguments are the same as attributes.
Changes state of Checkbutton when data was modified.
Parameters: - entry (SelfValidatingEntry) – Entry widget whose content was modified.
- entry_state (int) – state of the Entry widget after content modification, for possible values see dea_utils module.
- row (int) – row index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
- col (int) – column index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
Changes state of Checkbutton when data or categories were modified. Also modifies current_categories if needed. This widget becomes disabled if invalid category name value or input data value were provided by user.
Parameters: - entry (SelfValidatingEntry) – Entry widget whose content was modified.
- entry_state (int) – state of the Entry widget after content modification, for possible values see dea_utils module.
- row (int) – row index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
- col (int) – column index of entry widget. It is the real grid value, we need to subtract 2 to get internal index.
Deselects Checkbutton.
Note
method _process() is not called in this case.
Disables Checkbutton.
Parameters: - internal_col (int) – internal column index.
- category_name (str) – name of category.
Finds category name stored in the corresponding Entry widget based on where parent of Checkbutton was gridded.
Returns: category name, might be empty string. Return type: str
Selects Checkbutton.
Note
method _process() is not called in this case.
-
class
pyDEA.core.gui_modules.table_gui.
PanelTextObserver
(if_text_modified_str)[source]¶ Bases:
object
This class changes StringVar value that is traced in other classes.
-
if_text_modified_str
¶ StringVar
StringVar object that changes value when this observer is notified.
-
-
class
pyDEA.core.gui_modules.table_gui.
SelfValidatingEntry
(parent, data, all_cells, *args, **kw)[source]¶ Bases:
tkinter.ttk.Entry
This class implement Entry widget that knows how to highlight invalid data. It also notifies other widgets if the content of Entry changes. Other widgets must implement method change_state_if_needed(). Such widgets should be appended to the list of listening widgets called observers.
-
text_value
¶ StringVar
textvariable of Entry widget that calls method on_text_changed when the content on Entry changes.
-
observers
¶ list of objects that implement method change_state_if_needed
list of widgets or other objects that must be notified if the content of Entry changes.
-
data_row
¶ int
row index in data table which should be modified when the content of Entry changes.
-
data_column
¶ int
column index in data table which should be modified when the content of Entry changes.
-
data
¶ list of list of srt or float
data that will be modified.
-
modify_data
¶ bool
True if data should be modified, False otherwise. It is usually set to False when data is uploaded from file.
-
panel_text_observer
¶ PanelTextObserver
object that is notified when data changes. This object is responsible for adding star to file name when data was modified.
-
all_cells
¶ list of list of SelfValidatingEntry
refernce where all cells are stored.
- Warning: all cells must be created before any cell content
- can be modified.
Parameters: - parent (Tk object) – parent of this Entry widget.
- data (list of list of srt or float) – input data that will be modified.
- all_cells (list of list of SelfValidatingEntry) –
refernce where all cells are stored.
- Warning: all cells must be created before any cell content
- can be modified.
-
modify_data_if_needed
(row, col)[source]¶ Modifies data if modify_data is set to True. Adds empty strings to data when user modifies Entry for which data_row or/and data_column are equal to -1. Updates data with new values entered by user.
Parameters: - row (int) – row where Entry is gridded
- col (int) – column where Entry is gridded
-
notify_observers
(entry_state, row, col)[source]¶ Notifies all observers stored in list of observers that data was modified.
Parameters: - entry_state (int) – state of the Entry widget that describes if data is valid after modification, for possible values see dea_utils module.
- row (int) – row where Entry is gridded.
- col (int) – column where Entry is gridded.
-
-
class
pyDEA.core.gui_modules.table_gui.
TableFrame
(parent, data, nb_rows=20, nb_cols=5)[source]¶ Bases:
tkinter.ttk.Frame
This class is a base class that defines minimal functionality of a table.
-
parent
¶ Tk object
parent of this widget.
-
nb_rows
¶ int
number of rows of the table.
-
nb_cols
¶ int
number of columns of the table.
-
cells
¶ list of list of Entry
list with Entry widgets (or derivatives of Entry) that describes the table and its content.
-
canvas
¶ Canvas
canvas that holds all widgets (it is necessary to make the table scrollable).
-
frame_with_table
¶ Frame
frame that holds all widgets.
Parameters: - parent (Tk object) – parent of this widget.
- nb_rows (int, optional) – number of rows of the table, defaults to 20.
- nb_cols (int, optional) – number of columns of the table, defaults to 5.
-
before_cell_clear
(cell)[source]¶ This method is called before data is cleared from a given cell. In this class this method does nothing, but can be redefined in children classes.
Parameters: - cell (Entry) – cell that will be cleared after call
- this method. (to) –
-
before_cell_destroy
(cell)[source]¶ This method is called before a table cell is destroyed. In this class this method does nothing, but can be redefined in children classes.
Parameters: cell (Entry) – cell that will be destroyed after call to this method.
-
check_value
(count)[source]¶ This method is called in read_coefficients method to check what values must be returned for data instance construction. In this class it always returns True and can be redefined in children classes.
-
create_entry_widget
(parent)[source]¶ Creates Entry widget.
Parameters: parent (Tk object) – parent of the Entry widget. Returns: created Entry widget. Return type: Entry
-
read_coefficients
()[source]¶ Converts data stored as a list to a proper dictionary necessary for constructing data instance.
-
remove_column
(column_index)[source]¶ Removes column with a specified index from the table. If column index is zero or larger than the total number of columns of the table, no column is removed.
Parameters: column_index (int) – index of the column to remove. Returns: True if column was removed, False otherwise. Return type: bool
-
-
class
pyDEA.core.gui_modules.table_gui.
TableFrameWithInputOutputBox
(parent, params_frame, combobox_text_var, current_categories, str_var_for_input_output_boxes, if_text_modified_str, data, nb_rows=20, nb_cols=5)[source]¶ Bases:
pyDEA.core.gui_modules.table_gui.TableFrame
Extends TableFrame with extra functionality necessary for data modification and choosing input and output categories.
-
params_frame
¶ ParamsFrame
frame with parameters, this class communicates with params_frame when data is loaded or modified.
-
combobox_text_var
¶ StringVar
StringVar object that stores categorical category.
-
panel_text_observer
¶ PanelTextObserver
observer that adds star to label frame of the parent of this widget. This class notifies panel_text_observer when data was modified.
-
frames
¶ list of Frame
list of frames that hold Checkbuttons for choosing input and output categories.
-
row_checkboxes
¶ list of Checkbutton
list of Checkbuttons used for removing rows.
-
col_checkboxes
¶ list of Checkbutton
list of Checkbuttons used for removing columns.
-
current_categories
¶ list of str
list of current valid categories. This class might modify this list.
-
str_var_for_input_output_boxes
¶ StringVar
StringVar object that is used for communication with ParamsFrame. If the content of str_var_for_input_output_boxes was modified, it means that data was loaded from parameters file and input and output categories must be checked depending on parameters file.
-
data
¶ list of list of str or float
input data, it might be modified by this class.
Parameters: - parent (Tk object) – parent of this widget.
- params_frame (ParamsFrame) – frame with parameters, this class communicates with params_frame when data is loaded or modified.
- combobox_text_var (StringVar) – StringVar object that stores categorical category.
- current_categories (list of str) – list of current valid categories. This class might modify this list.
- str_var_for_input_output_boxes (StringVar) – StringVar object that is used for communication with ParamsFrame. If the content of str_var_for_input_output_boxes was modified, it means that data was loaded from parameters file and input and output categories must be checked depending on parameters file.
- if_text_modified_str (StringVar) – StringVar object that is used by PanelTextObserver, its content is modified when data was modified.
- data (list of list of str or float) – input data, it might be modified by this class.
- nb_rows (int, optional) – number of rows of the table, defaults to 20.
- nb_cols (int, optional) – number of columns of the table, defaults to 5.
-
add_row
()[source]¶ Adds one row to the end of table.
- Note: When data is spread across several pages, addition of
- row must also update the display of data. This functionality is implemented in TableModifierFrame.
-
add_row_check_box
(row_index)[source]¶ Adds Checkbutton used for removing rows to a given row.
Parameters: row_index (int) – index of row to which Checkbutton must be added.
-
add_rows_to_fill_visible_frame
()[source]¶ Adds rows to table to fill the frame. Usually adds a bit more and scroll gets activated. Exact number of added rows depends on operating system, height of widgets and screen size.
-
before_cell_clear
(cell)[source]¶ This method is called before data is cleared from a given cell. It sets fields of the given cell to initial values.
Parameters: cell (SelfValidatingEntry) – cell that will be cleared after call to this method.
-
before_cell_destroy
(cell)[source]¶ This method is called before a table cell is destroyed. Notifies observers if data is not empty.
Parameters: cell (SelfValidatingEntry) – cell that will be destroyed after call to this method.
-
check_value
(count)[source]¶ This method is called in read_coefficients method to check what values must be returned for data instance construction.
Parameters: count (int) – data column index. Returns: True if the category in the given column index is not an empty string, False otherwise. Return type: bool
-
create_entry_widget
(parent)[source]¶ Creates SelfValidatingEntry widget.
Parameters: parent (Tk object) – parent of the SelfValidatingEntry widget. Returns: created SelfValidatingEntry widget. Return type: SelfValidatingEntry
-
deselect_all_boxes
()[source]¶ Deselects all Checkbuttons used for choosing input and output categories.
-
display_data
(start_row=0)[source]¶ Displays data starting from a given data row. This method is usually called by NavigationForTableFrame when data spans across several pages and users clicks on page navigation buttons.
Parameters: start_row (int, optional) – index of input data starting from which data should be displayed, defaults to 0.
-
get_check_boxes
(column_index)[source]¶ Gets Checkbuttons used for selecting input and output categories for a given column.
Parameters: column_index (int) – index of the column for which Checkbuttons must be returned. Returns: tuple of observers or None, None if no observers were found. Return type: tuple of ObserverCheckbutton, FollowingObserverCheckbutton
-
load_visible_data
()[source]¶ Displays data in the table. First, it adds more rows to fill the frame, second, it displays data that fits the table.
-
on_load_categories
(*args)[source]¶ Selects input and output categories when data is loaded from parameters file. Args are provided by the StringVar trace methods and are ignored in this method.
-
remove_column
(column_index)[source]¶ Removes column with a specified index from the table. If column index is zero or larger than the total number of columns of the table, no column is removed.
Parameters: column_index (int) – index of the column to remove. Returns: True if column was removed, False otherwise. Return type: bool
-
remove_row
(row_index)[source]¶ Removes data row with a specified index from the table. Row is not physically removed. If row_index is zero or larger than the total number of rows, no row is removed.
Parameters: row_index (int) – index of the row to remove. Returns: True if row was deleted, False otherwise. Return type: bool
-
pyDEA.core.gui_modules.table_modifier_gui module¶
This module contains class TableModifierFrame that creates buttons for adding and removing rows and columns from data table.
-
class
pyDEA.core.gui_modules.table_modifier_gui.
TableModifierFrame
(parent, table, clear_all_fnc, set_navigation, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
This class creates buttons for adding and removing rows and columns from data table.
-
table
¶ TableFrameWithInputOutputBox
data table.
-
row_str_var
¶ StringVar
stores number of rows that should be added to the data table.
-
col_str_var
¶ StringVar
stores number of columns that should be added to the data table.
callable
function that sets number of pages to a given number, for details see navigation_frame_gui module.
Parameters: - parent (Tk object) – parent of this frame.
- table (TableFrameWithInputOutputBox) – data table.
- clear_all_fnc (callable) – function that should be called when “Clear all” button is pressed.
- set_navigation (callable) – function that sets number of pages to a given number, for details see navigation_frame_gui module.
-
add_columns
()[source]¶ Adds columns to the data table. Number of columns is specified in Spinbox. If invalid value is given in Spinbox, only one column is added. Columns are added to the end of the table.
-
add_rows
()[source]¶ Adds rows to the data table. Number of rows is specified in Spinbox. If invalid value is given in Spinbox, only one row is added. Rows are added to the end of the table.
-
create_widgets
(clear_all_fnc)[source]¶ Creates widgets of this frame.
Parameters: clear_all_fnc (function) – function that should be called when “Clear all” button is pressed.
-
get_nb_to_add
(str_var)[source]¶ Calculates valid number of rows or columns that should be added to the data table.
Parameters: str_var (StringVar) – StringVar object that stores number of rows or columns that must be added to the data table. Returns: positive integer number if str_var stores such a number, 1 if negative or invalid value is stored in str_var. Return type: int Example
>>> table.row_str_var.set(10) >>> tabel.get_nb_to_add(table.row_str_var) 10 >>> table.row_str_var.set(-1) >>> tabel.get_nb_to_add(table.row_str_var) 1 >>> table.row_str_var.set("abc") >>> tabel.get_nb_to_add(table.row_str_var) 1
-
pyDEA.core.gui_modules.text_for_weights_gui module¶
This module contains TextForWeights class which is a text widget used for displaying and editing weight restrictions.
-
pyDEA.core.gui_modules.text_for_weights_gui.
TEXT_WIDTH_VAL
¶ int
width of Text widget.
-
pyDEA.core.gui_modules.text_for_weights_gui.
TEXT_HEIGHT_VAL
¶ int
heigth of Text widget.
-
class
pyDEA.core.gui_modules.text_for_weights_gui.
TextForWeights
(parent, weight_name, examples, current_categories, params, param_name, is_price_ratio_constraint=False, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
Implements text widget used for displaying and editing weight restrictions.
-
parent
¶ Tk object
parent of this widget.
-
weight_name
¶ str
text describing type of weight restrictions, e.g. absolute, virtual, etc.
-
examples
¶ str
string with an example of usage of this type of weight restrictions, e.g. I1 <= 2.
-
current_categories
¶ list of str
list of current categories.
-
params
¶ Parameters
parameters.
-
param_name
¶ str
parameter name that corresponds to this type of weight restrictions, e.g. ABS_WEIGHT_RESTRICTIONS.
-
text
¶ Text
text widget used for displaying weight restrictions.
-
error_tag_exists
¶ bool
if set to True, means that there are invalid weight restrictions, False otherwise.
-
errors_strvar
¶ StringVar
is used for storing and displaying error messages for invalid weight restrictions.
-
is_price_ratio
¶ bool
if True price ratio constraints are expected to be entered, if False other constraint types are expected to be entered. Defaults to False.
Parameters: - parent (Tk object) – parent of this widget.
- weight_name (str) – text describing type of weight restrictions, e.g. absolute, virtual, etc.
- examples (str) – string with an example of usage of this type of weight restrictions, e.g. I1 <= 2.
- current_categories (list of str) – list of current categories.
- params (Parameters) – parameters.
- param_name (str) – parameter name that corresponds to this type of weight restrictions, e.g. ABS_WEIGHT_RESTRICTIONS.
- is_price_ratio (bool) – if True price ratio constraints are expected to be entered, if False other constraint types are expected to be entered. Defaults to False.
-
get_all_errors
(error_list)[source]¶ Returns given list of errors as one string.
Parameters: error_list (list of str) – list of strings to concatenate. Returns: concatenated string. Return type: str
-
pyDEA.core.gui_modules.text_frame_gui module¶
This module contains TextFrame class that is responsible for displaying solution tabs in text widget.
-
class
pyDEA.core.gui_modules.text_frame_gui.
TextFrame
(parent, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
Implements text widget for displaying one solution tab.
-
name
¶ str
solution tab name.
-
text_writer
¶ SolutionTextWriter
object that knows how to format data.
Parameters: parent (Tk object) – parent of this widget. -
select_all
(event)[source]¶ Selects all data in the text widget. This event is called when user presses Control-Key-a or Control-Key-A.
Returns: string break. Return type: str
-
pyDEA.core.gui_modules.weight_frame_gui module¶
This module contains class WeightFrame that is used as a tab in parameters frame to edit and display weights.
-
class
pyDEA.core.gui_modules.weight_frame_gui.
WeightFrame
(parent, current_categories, params, weights_status_str, *args, **kw)[source]¶ Bases:
tkinter.ttk.Frame
This class represents weights editor. It allows to display, modify and validate weights.
-
parent
¶ Tk object
parent of this widget.
-
current_categories
¶ list of str
list of current categories, this list is not modified by this class.
-
params
¶ Parameters
Parameters object with all parameter values.
Note
This class does not change values in Parameters object until the weight restrictions are validated, see on_validate_weights().
-
weights_status_str
¶ StringVar
StringVar object that is used to show an error if it occurred after validating weights.
-
abs_weights
¶ TextForWeights
text widget for displaying and editing absolute weight restrictions.
-
virtual_weights
¶ TextForWeights
text widget for displaying and editing virtual weight restrictions.
-
price_ratio_weights
¶ TextForWeights
text widget for displaying and editing price-ratio weight restrictions.
Parameters: - parent (Tk object) – parent of this widget.
- current_categories (list of str) – list of current categories, this list is not modified by this class.
- params (Parameters) – Parameters object with all parameter values
- weights_status_str (StringVar) – StringVar object that is used to show an error if it occurred after validating weights.
-
add_weights
()[source]¶ Adds weight restrictions stored in params to the appropriate text widgets if such weight restrictions can be parsed and contain categories that are also present in current_categories.
-