pyplt.gui.util package

Submodules

pyplt.gui.util.colours module

This module defines the hexadecimal codes of various colours commonly used throughout the GUI of PLT.

pyplt.gui.util.help module

This module contains a number of classes specifying the content for each of the help/about dialogs throughout PLT.

class pyplt.gui.util.help.AboutBox(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

‘About’ window containing text on the details of the PLT software and its license.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the pyplt.gui.mainmenu.MainMenu window.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.BeginnerStep1HelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in Step 1 of the BeginnerMenu.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for Step 1 of the BeginnerMenu.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.BeginnerStep2HelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in Step 2 of the BeginnerMenu.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for Step 2 of the BeginnerMenu.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.BeginnerStep3HelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in Step 3 of the BeginnerMenu.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for Step 3 of the BeginnerMenu.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.BeginnerStep4HelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in Step 4 of the BeginnerMenu.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for Step 4 of the BeginnerMenu.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.BeginnerStep5HelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in Step 5 of the BeginnerMenu.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for Step 5 of the BeginnerMenu.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.FSHelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in the Feature Selection tab.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the Feature Selection tab.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.HelpDialog(parent_window)

Bases: tkinter.Toplevel

Base class for help dialog windows used to assist the user throughout the GUI.

Initializes the window widget.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.LoadDataHelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in the Load Data tab.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the Load Data tab.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.MainHelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in the pyplt.gui.mainmenu.MainMenu window.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the MainMenu.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.PLHelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in the Preference Learning tab.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the Preference Learning tab.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.PreprocHelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in the Preprocessing tab.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the Preprocessing tab.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.RankDerivationHelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user with the rank derivation methods when loading the dataset.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the LoadingParamsWindow.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.
class pyplt.gui.util.help.ResultsHelpDialog(parent_window)

Bases: pyplt.gui.util.help.HelpDialog

Help dialog window to assist the user in the experiment report window.

Extends pyplt.gui.util.help.HelpDialog.

Initializes the window widget with the help text for the experiment report window.

Parameters:parent_window (tkinter.Toplevel) – the window which this window widget will be stacked on top of.

pyplt.gui.util.styles module

This module defines the various styles used for ttk widgets throughout PLT.

pyplt.gui.util.styles.configure_styles(themed_style)

Define the styles used for ttk widgets throughout the GUI.

pyplt.gui.util.supported_methods module

This module specifies which algorithms and methods are supported by the GUI of PLT.

This module also provides generic helper functions to create instances of algorithm/method classes given enumerated constants representing them.

Developers who would like to add new feature selection methods, preference learning algorithms, and evaluation methods to the GUI of PLT, can do so easily by adding the algorithm/method class and GUI menu class (if applicable) to the dicts declared in this module:

  • supported_fs_methods – for feature selection methods (in Expert Mode);
  • supported_algorithms – for preference learning algorithms (in Expert Mode);
  • supported_algorithms_beginner – for preference learning algorithms (in Beginner Mode);
  • supported_evaluation_methods – for evaluation methods (in Expert Mode).
pyplt.gui.util.supported_methods.get_algorithm_instance(algorithm_enum, params=None, beginner_mode=False)

Create an instance of the preference learning algorithm class represented by the given enum constant.

Each enumerated constant of type pyplt.util.enums.PLAlgo in the supported_algorithms dict corresponds to a class of type (extending) pyplt.plalgorithms.base.PLAlgorithm.

If params is specified, the instance is initialized with the given algorithm parameter values. Otherwise, the default values are used.

Parameters:
  • algorithm_enum (pyplt.util.enums.PLAlgo) – the algorithm type (enum).
  • params (dict or None, optional) –

    optional algorithm parameter values in the form of a dict (default None). The keys of the dict should match the keywords of the arguments that would be passed to the corresponding pyplt.plalgorithms.base.PLAlgorithm constructor. For example, for the Backpropagation algorithm the dict should contain the following items:

    • ann_topology: the topology of the neurons in the network
    • learn_rate: the learning rate
    • error_threshold: the error threshold
    • epochs: the number of epochs
    • activation_functions: the activation functions for each neuron layer in the network

    On the other hand, for the RankSVM algorithm the dict should contain the following items:

    • kernel: the kernel name
    • gamma: the gamma kernel parameter value
    • degree: the degree kernel parameter value
  • beginner_mode (bool, optional) – specifies whether or not the algorithm is being used in the beginner mode (default False).
Returns:

an instance of the class corresponding to the given algorithm.

Return type:

pyplt.plalgorithms.base.PLAlgorithm

Raises:

InvalidParameterValueException – if the user attempted to use a value smaller or equal to 0.0 for the gamma parameter of the RankSVM algorithm.

pyplt.gui.util.supported_methods.get_eval_method_instance(eval_method_enum, params=None)

Create an instance of the evaluation method class represented by the given enum constant.

Each enumerated constant of type pyplt.util.enums.EvaluatorType in the supported_evaluation_methods dict corresponds to a class of type (extending) pyplt.evaluation.base.Evaluator.

If params is specified, the instance is initialized with the given evaluation method parameter values. Otherwise, the default values are used.

Parameters:
  • eval_method_enum (pyplt.util.enums.EvaluatorType) – the evaluation method type (enum).
  • params (dict or None, optional) –

    optional evaluation method parameter values in the form of a dict (default None). The keys of the dict should match the keywords of the arguments that would be passed to the corresponding pyplt.evaluation.base.Evaluator constructor. For example, for the Holdout method, the dict should contain the following items:

    • test_proportion: a float specifying the proportion of data to be used as training data (the rest is to be used as test data) or None

    On the other hand, for the KFoldCrossValidation method, the dict should contain the following items:

    • k: the number of folds to uniformly split the data into when using the automatic approach or None
    • test_folds: an array specifying the fold index for each sample in the dataset when using the manual approach or None
Returns:

an instance of the class corresponding to the given evaluation method.

Return type:

pyplt.evaluation.base.Evaluator

Raises:
  • InvalidParameterValueException – if the user attempts to use a value smaller than 2 for the k parameter of K-Fold Cross Validation.
  • MissingManualFoldsException – if the user chooses to specify folds manually for cross validation but fails to load the required file containing the fold IDs.
pyplt.gui.util.supported_methods.get_fs_method_instance(fs_method_enum, params=None)

Create an instance of the feature selection method class represented by the given enum constant.

Each enumerated constant of type pyplt.util.enums.FSMethod in the supported_fs_methods dict corresponds to a class of type (extending) pyplt.fsmethods.base.FeatureSelectionMethod.

If params is specified, the instance is initialized with the given feature selection method parameter values. Otherwise, the default values are used.

Parameters:
  • fs_method_enum (pyplt.util.enums.FSMethod) – the feature selection method type (enum).
  • params (dict or None, optional) – optional feature selection method parameter values in the form of a dict (default None). The keys of the dict should match the keywords of the arguments that would be passed to the corresponding pyplt.fsmethods.base.FeatureSelectionMethod constructor.
Returns:

an instance of the class corresponding to the given feature selection method.

Return type:

pyplt.fsmethods.base.FeatureSelectionMethod

pyplt.gui.util.tab_locking module

This module defines two classes which manage the locking and unlocking of tabs in ttk.Notebook widgets.

class pyplt.gui.util.tab_locking.LockableTab(parent, parent_window)

Bases: tkinter.Frame

Base class for creating ttk.Notebook tabs that are easily locked and unlocked.

Extends the class tkinter.Frame.

Initializes the tab.

The locking and unlocking mechanism works by switching between which child frame of the base frame self._base is raised. The ‘locked’ frame of standard type LockedFrame is raised when the tab is to be locked whereas the ‘unlocked’ frame is raised when the tab is to be unlocked. The ‘unlocked’ frame is specified by the user by implementing the abstract method get_normal_frame(). The method extends the __init__() method in tk.Frame.

Parameters:
  • parent (tkinter widget) – the parent widget of this LockableTab widget.
  • parent_window (tkinter.Toplevel) – the window which will contain this LockableTab widget.
get_base_frame()

Return the base frame widget.

get_normal_frame()

Abstract method to be implemented in subclasses to return the ‘unlocked’ frame.

lock()

Raise the ‘locked’ child frame of the base frame over the ‘unlocked’ child frame of the base frame.

unlock()

Raise the ‘unlocked’ child frame of the base frame over the ‘locked’ child frame of the base frame.

class pyplt.gui.util.tab_locking.LockedFrame(parent)

Bases: tkinter.Frame

Standard class to be used as the ‘locked’ frame in a LockableTab object.

Extends the class tkinter.Frame.

Populates the frame with a simple label indicating the tab’s status as ‘locked’.

Parameters:parent (tkinter widget) – the parent widget of this LockableFrame widget.

pyplt.gui.util.text module

This module contains a number of helper functions for displaying text properly in the GUI.

pyplt.gui.util.text.real_param_name(param_name)

Receive a parameter name and return the grammatically-correct version of its name.

Parameters:param_name (str) – the parameter name as used internally by PLT.
Returns:the grammatically-correct version of param_name.
Return type:str
pyplt.gui.util.text.real_type_name(type_name)

Receive a method type name and return the grammatically-correct version of its name.

Parameters:type_name (str) – the method type name as used internally by PLT.
Returns:the grammatically-correct version of type_name.
Return type:str

pyplt.gui.util.windowstacking module

class pyplt.gui.util.windowstacking.Mode

Bases: enum.Enum

Class specifying enumerated constants for the different modes of window stacking.

Extends enum.Enum.

OPEN_ONLY = 1
WITH_CLOSE = 0
pyplt.gui.util.windowstacking.disable_parent(self, parent, mode)

Change state of parent window to ‘disabled’.

Parameters:
  • self (tkinter.Toplevel) – the new window being stacked on top.
  • parent (tkinter.Toplevel) – the parent of the new window widget to be stacked above it.
  • mode (pyplt.gui.util.windowstacking.Mode) – the window stacking mode.
pyplt.gui.util.windowstacking.on_close(new_window, parent)

Restore the parent window and all its children widgets to their ‘normal’ state and bring it back on top.

The parent window is elevated back to the topmost level of the stack of windows.

This method is toggled when a stacked window is closed and its stacking mode was set to WITH_CLOSE.

Parameters:
  • new_window (tkinter.Toplevel) – the stacked window being closed.
  • parent (tkinter.Toplevel) – the parent window of new_window.
pyplt.gui.util.windowstacking.place_window(self, parent, position=1)

Set the geometry of child window to a given position relative to the parent window’s geometry.

Parameters:
  • self (tkinter.Toplevel) – the new window being stacked on top.
  • parent (tkinter.Toplevel) – the parent of the new window widget to be stacked above it.
  • position (int: 0 or 1, optional) – the position at which to place the new window relative to the parent window’s geometry. If 0, the new window will be placed directly on top of the parent window. If 1, the new window will be placed to the side of the parent window (default 1).
pyplt.gui.util.windowstacking.stack_window(new_win, parent_win)

Elevate the new window to the topmost level of the stack of windows.

Parameters:
  • new_win (tkinter.Toplevel) – the new window to be stacked on top.
  • parent_win (tkinter.Toplevel) – the parent window of new_win.

Module contents

This package defines a number of utility classes for the GUI of PLT.