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.
create_widgets()[source]

Creates widgets of this object.

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.
remove_all_categories()[source]

Removes all categories.

remove_category(category_name)[source]

Removes given category, destroys all widgets associated with this category and updates corresponding parameters.

Parameters:category_name (str) – category name.
update_scroll_region()[source]

Updates scrolling region.

pyDEA.core.gui_modules.custom_canvas_gui module

This module contains StyledCanvas class.

class pyDEA.core.gui_modules.custom_canvas_gui.StyledCanvas(parent, *args, **kw)[source]

Bases: tkinter.Canvas

Implements Canvas object with a custom background colour.

Parameters:parent (Tk object) – parent of this widget.

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
change_solution_tab_name(new_name)[source]

Changes name of the solution tab. This method is needed to add star (*) to unsaved solution and to remove star.

Parameters:new_name (str) – new name for the solution tab
create_widgets(data_tab)[source]

Creates tabs of the notebook.

reset_progress_bar()[source]

Resets progress bar of the parent frame to zero.

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

navigation_frame

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()[source]

Clears all data.

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
remove_star_from_panel()[source]

Removes star from data file name if it was there.

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
show_loaded_data(file_name)[source]

Loads data file.

This method asks user from what sheet data must be loaded if there are more then 1 sheet in data file. Changes name of data file in label frame and calls method that displays data in the table.

Parameters:file_name (str) – data file
pyDEA.core.gui_modules.data_tab_frame_gui.remove_star(file_name)[source]

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.
create_widgets(names)[source]

Creates appropriate widgets.

Parameters:names (list of str) – list of available sheet names.
ok(event=None)[source]

This method is called if the user presses OK button. In this case sheet name is set to the currently selected value in Combobox.

Parameters:event (Tk event, optional) – event that is given when the button is pressed. It is ignored in this method.

pyDEA.core.gui_modules.navigation_frame_gui module

This module contains class NavigationForTableFrame.

class pyDEA.core.gui_modules.navigation_frame_gui.NavigationForTableFrame(parent, table, *args, **kw)[source]

Bases: tkinter.ttk.Frame

This class is responsible for navigation over the table object. Table rows are displayed page by page. This class provides buttons that allow to navigate from page to page.

table (TableFrame or any object that has attribute nb_rows and

implements display_data method): table that should be navigated.

goto_spin

Spinbox

Spinbox widget that allows to enter page number and to switch between pages.

text_var_nb_pages

StringVar

text variable that shows total number of pages.

current_page_str

StringVar

text variable that stores currently displayed page.

Parameters:
  • parent (Tk object) – parent for this frame.
  • table (TableFrameWithInputOutputBox) – table with multiple pages that will be navigated by this frame.
create_widgets()[source]

Creates all necessary widgets for navigation.

on_page_change(*args)[source]

Displays a page which number is currently stored in current_page_str.

This method is called in show_next_page(), show_prev_page() and when the user enters data and presses Enter. args are supplied by Return event. If the entered value is invalid, then the first page is displayed. If the entered value is zero or negative, then the first page is isplayed. If the entered value is larger than the total number of pages, then the last page is displayed.

reset_navigation()[source]

Resets navigation parameters.

Sets current page number to 1 and total number of pages to zero.

set_navigation(nb_data_pages, reset_curr_page=True)[source]

Sets navigation parameters.

Sets current page number to 1 and total number of pages to nb_data_pages.

Parameters:
  • nb_data_pages (int) – new value for the total number of pages.
  • reset_curr_page (bool) – True is current page must be reset to 1, False otherwise.
show_next_page()[source]

Displays next page.

This method is called when user presses button ‘>>’. If the last page is currently displayed and the method is called, then the call to this method is ignored.

show_prev_page()[source]

Displays previous page.

This method is called when user presses button ‘<<’. If the first page is currently displayed and the method is called, then the call to this method is ignored.

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.

create_widgets()[source]

Creates all widgets.

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.
set_params_values()[source]

Reads all parameter values from the parameter object (params) and sets all widgets and options to these read values. Might display warnings if invalid values are stored in parameter object.

set_radio_btns()[source]

Goes through all Radiobuttons and changes their values according to the values stored in parameter object. Might display warnings.

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.
clear_all()[source]

Clears all parameters and corresponding widgets.

create_widgets(weights_status_str)[source]

Creates all widgets.

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.
load_file()[source]

Loads parameters from file specified by the user.

on_save_params()[source]

Saves current parameter values to a file from where the parameters were loaded. This file name is displayed. If no file name is displayed (i.e. parameters were not previously loaded from file), then asksaveasfilename dialogue is called.

on_save_params_as()[source]

Calls asksaveasfilename dialogue and saves current values of parameters to the specified file.

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.

add_scrolling(scrollingArea, xscrollbar=None, yscrollbar=None)[source]
static build_function_onMouseWheel(widget, orient, scrollbar, factor=1)[source]
mouseWheel_bind(widget)[source]
mouseWheel_unbind()[source]
onMouseWheel(event)[source]
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
clear_all_tabs()[source]

Clears all tabs.

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.
create_tab(name)[source]

Creates a tab with a given name.

Parameters:name (str) – name of the tab.
modify_tab_names()[source]

Modifies tab names according to the names that were passed as a parameter when tab was created.

remove_unused_tabs()[source]

Removes unused tabs.

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.
create_widgets()[source]

Creates appropriate widgets on this frame.

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.
update_data_file_name(new_data_file_name)[source]

Updates label with data file name.

Parameters:new_data_file_name (str) – new value of the data file name

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

class pyDEA.core.gui_modules.table_gui.CheckbuttonWithVar(parent, var, *args, **kw)[source]

Bases: tkinter.ttk.Checkbutton

Custom Checkbutton widget that provides deselect method.

var

IntVar

0 if not selected, 1 otherwise.

Parameters:
  • parent (Tk object) – parent of this widget.
  • var (IntVar) – variable that controls if Checkbutton is selected.
deselect()[source]

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.
class pyDEA.core.gui_modules.table_gui.FollowingObserverCheckbutton(parent, var, opposite_var, category_frame, opposite_category_frame, current_categories, cells, observer_type, params_frame, data, combobox_text_var, main_box, *args, **kw)[source]

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.

var

IntVar

variable that is set to 1 when Checkbutton is selected, to 0 otherwise.

opposite_var

IntVar

variable of the other Checkbutton that must deselected if this Checkbutton is selected.

parent

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.

category_frame

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.

opposite_category_frame

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.

current_categories

list of str

list of categories. This class might modify this list by removing invalid categories and adding the valid ones.

cells

list of list of SelfValidatingEntry

all entry widgets collected in list.

data

list of list of str or float

input data.

observer_type

int

describes type of the observer, for possible values see dea_utils.

change_category_name

callable function

this function is called when name of a category was changed.

combobox_text_var

StringVar

variable of the combobox used for selecting categorical category.

main_box

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).

change_state_if_needed(entry, entry_state, row, col)[source]

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.
class pyDEA.core.gui_modules.table_gui.ObserverCheckbutton(parent, var, opposite_var, category_frame, opposite_category_frame, current_categories, cells, observer_type, change_category_name, data, combobox_text_var, *args, **kw)[source]

Bases: tkinter.ttk.Checkbutton

This class implements Checkbutton for choosing input/output categories.

var

IntVar

variable that is set to 1 when Checkbutton is selected, to 0 otherwise.

opposite_var

IntVar

variable of the other Checkbutton that must deselected if this Checkbutton is selected.

parent

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.

category_frame

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.

opposite_category_frame

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.

current_categories

list of str

list of categories. This class might modify this list by removing invalid categories and adding the valid ones.

cells

list of list of SelfValidatingEntry

all entry widgets collected in list.

data

list of list of str or float

input data.

observer_type

int

describes type of the observer, for possible values see dea_utils.

change_category_name

callable function

this function is called when name of a category was changed.

combobox_text_var

StringVar

variable of the combobox used for selecting categorical category.

Arguments are the same as attributes.

change_state_based_on_data(entry, entry_state, row, col)[source]

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.
change_state_if_needed(entry, entry_state, row, col)[source]

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.
deselect()[source]

Deselects Checkbutton.

Note

method _process() is not called in this case.

disable(internal_col, category_name)[source]

Disables Checkbutton.

Parameters:
  • internal_col (int) – internal column index.
  • category_name (str) – name of category.
get_category()[source]

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
select()[source]

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.

change_state_if_needed()[source]

Changes value of internal StringVar object.

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.
notify_panel_observer()[source]

Notifies panel observer that data was modified.

on_text_changed(*args)[source]

This method is called each time the content of Entry is modified. It highlights invalid data, changes data if needed and notifies other objects when data was changed. Args are provided by StringVar trace method, but are not used.

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.
add_column()[source]

Adds one column to the end of the table.

add_row()[source]

Adds one row to the end of the table.

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.

clear_all_data()[source]

Clears all data from all cells.

create_entry_widget(parent)[source]

Creates Entry widget.

Parameters:parent (Tk object) – parent of the Entry widget.
Returns:created Entry widget.
Return type:Entry
create_widgets()[source]

Creates all widgets.

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
remove_row(row_index)[source]

Removes row with a specified index from the table. 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
should_remove_row(row_index)[source]

Checks if row with a specified row index can be removed.

Parameters:row_index (int) – index of the row to remove.
Returns:True if row_index is >= 1 and < total number of rows, 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_column()[source]

Adds one column to the end of table.

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
clear_all_data()[source]

Clears all data from all cells and clears input data.

create_entry_widget(parent)[source]

Creates SelfValidatingEntry widget.

Parameters:parent (Tk object) – parent of the SelfValidatingEntry widget.
Returns:created SelfValidatingEntry widget.
Return type:SelfValidatingEntry
create_widgets()[source]

Creates widgets of this class.

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
get_data_index(row_index)[source]
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.

set_navigation

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
remove_columns()[source]

Removes columns that are checked in checkboxes for removal. First column cannot be removed.

remove_rows()[source]

Removes rows that are checked in checkboxes for removal. First row cannot be removed.

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.
create_widgets(weight_name)[source]

Creates all widgets.

delete_weights()[source]

Removes all weight restrictions.

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
insert_weight(weight)[source]

Add a given weight restriction in the end of the text widget.

Parameters:weight (str) – string that describes a given weight restriction.
validate_weights()[source]

Checks if all weight restrictions are valid.

Returns:True if all weight restrictions are valid, False otherwise.
Return type:bool

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.
clear_all_data()[source]

Removes all text from text widget.

create_widgets()[source]

Creates all widgets.

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
write(row_index, column_index, data)[source]

Writes given data to the text widget.

Parameters:
  • row_index (int) – row index.
  • column_index (int) – column index.
  • data (str) – text to write.
write_text(data)[source]

Writes given data to text widget.

Parameters:data (str) – string that should be displayed.

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.

create_widgets()[source]

Creates all widgets.

on_validate_weights()[source]

Validates weights of all text widgets and displays an error if some of the weights are invalid.

Note

Parameters object is modified by this method.

remove_all_weights()[source]

Removes all weight restrictions from all text widgets.

Note

Parameters object is not affected by this. All weight restrictions will still be there. Parameters are updated only when they are validated, i.e. when the user presses validate weights button or run button.

Module contents