lib package

Submodules

lib.app_utils module

Module app_utils: This module contains useful methods for dealing with Mari.

class MariAppUtils[source]

Bases: object

This class contains useful methods for interacting with the Mari application.

MARI_2_6v3_VERSION_NUMBER = 20603300

Defining Mari version release constants

MARI_3_0v1_VERSION_NUMBER = 30001210
classmethod checkSupportedMariVersion(mari_version='MARI_2_6v3_VERSION_NUMBER')[source]

This method checks for a Mari version that is supported by the plugin.

Parameters:mari_versionstr or int that is constant defining the version of Mari to check against.

return: bool determining if the current Mari version is supported.

rtype: bool

classmethod getMariQApplicationInstance()[source]

This method returns the current Mari QApplication instance.

Returns:PySide.QtCore.QApplication object that is the Mari top-level instance.
Return type:PySide.QtCore.QApplication

lib.callbacks module

Module callbacks: This module contains objects for dealing with customized callbacks in Mari.

class Publisher[source]

Bases: object

This class creates a watcher that can be subscribed to in order to perform the necessary callbacks.

The constructor.

Returns:None
register_subscriber(subscriber)[source]

This method adds a subscriber.

Parameters:subscriberSubscriber subscriber object.
notify(reason=None, *args, **kwargs)[source]

This method notifies all currently subscribed observers.

Parameters:reasonstr message indicating what the reason for the status change is.
class Subscriber(publisher)[source]

Bases: object

This base class creates a Subscriber to the Publisher object and watches for changes.

The constructor.

Parameters:publisherPublisher publisher object.
Returns:None
update(reason, *args, **kwargs)[source]

This method is called on the Subscriber object whenever the publisher is updated. Should be overloaded in order to perform additional actions once the publisher has received a change in the status.

Parameters:reasonstr message indicating what the reason for the status change is.
Returns:None
class ProjectChangedPublisher[source]

Bases: lib.callbacks.Publisher

This class publishes project change events (opening/closing/switching) in Mari and notifies all subscribers to it as necessary.

class ProjectChangedSubscriber(publisher)[source]

Bases: lib.callbacks.Subscriber

This class subscribes to project change events (opening/closing/switching) in Mari and performs actions as necessary.

The constructor.

Parameters:publisher
Returns:
update(reason, *args, **kwargs)[source]

This method makes all necessary changes when a project has changed its state in Mari.

Parameters:
  • reason
  • args
  • kwargs
Returns:

project_opened()[source]

This method is run whenever a new project is opened in Mari.

project_closed()[source]

This method is run whenever a current project is closed in Mari.

lib.cliUtils module

Module cliUtils: This module provides useful methods for dealing with the Command Line interface.

class ParseArgs(description=None, *args)[source]

Bases: object

This class contains methods for parsing arguments from the command line. Can be overloaded to provide custom command line arguments.

Reads in the command line arguments passed by the user.

Parameters:
  • descriptionstr containing help about the module being run.
  • args

    str arguments that indicate what additional arguments are to be read in.

    Currently supports:

    • mode
    • files
    • output
    • overwriteExisting
Returns:

None

addArguments(*args)[source]

This method adds/configures the available command line arguments. Can be overloaded for adding custom arguments.

Returns:None
getLoggingLevel()[source]

This retrieves the desired logging level. By default is set to INFO level.

Returns:int corresponding to chosen logging level
Return type:int
getFiles()[source]

This method retrieves a semicolon-separated list of files passed in as arguments. Returns a list of the file paths.

Returns:list of file paths
Return type:list
getOutputPath()[source]

This method returns the output path that is passed in as an argument.

Returns:str to file path
Return type:str
getOverwriteExisting()[source]

This method returns the value that was passed for choosing to overwrite existing files in place.

Defaults to True.

Returns:bool
Return type:bool

lib.fileUtils module

Module convertUiFiles: This looks through for .ui files and converts them to .py files in-place.

Tip

You can use this module from the command line to convert your .ui files from Qt Designer.

Sample command:

python fileUtils.py -f inputFile.ui -o outputFile.py

If no output argument is specified, the file will be written to the same location of the input file by default.

class ConvertUiFiles(outputFile=None, overwriteExisting=None, backupExisting=False, files=None)[source]

Bases: object

This class contains methods for converting Qt UI files to .py scripts.

The constructor. This also initiates the conversion of .ui to .py files.

Parameters:
  • filesstring or list of file(s) to be converted.
  • outputFilestr determining where to write the output file.
  • overwriteExistingbool determining if existing .py files should be overwritten in place.
  • backupExistingbool determining if existing .py files should be backed up before being overwritten. Has no effect if overwriteExisting is False.
Returns:

None

Return type:

None`

static getUiFiles(basePath)[source]

This method gets all available .ui files for conversion.

Parameters:basePathstr to path of root directory
Returns:list of files in base directory path
Return type:list
static convertUiToPyFile(sourceFile, outputFile=None, overwriteExisting=True, backupExisting=False)[source]

This method compiles the .ui files to .py files.

Parameters:
  • sourceFilestr to path of source file.
  • outputFilestr to path of output file destination.
  • overwriteExistingbool determining if existing file(s) should be overwritten with output file(s).
  • backupExistingbool determining if existing file should be backed up before being overwritten.
Returns:

None

lib.jsonutils module

Module jsonutils: contains methods for reading/writing to JSON format.

class JSONUtils[source]

Bases: object

This class contains useful methods for working with serializing JSON data.

static read(path)[source]

Given a JSON-formatted file, reads the data from it. Returns the equivalent Python object

Parameters:pathstr that determines where open() will attempt to read data from
Returns:Depending on type of JSON object stored, returns Python equivalent. Defaults to dict.
Return type:dict
static write(path, data, mode='w')[source]

Writes data to a external JSON-formatted file.

Parameters:
  • pathstr that determines where the data is written to
  • datadict containing keys and values to be written in JSON format.
  • mode

    str determining the mode which the file is written as. Acceptable identifiers:

    • ‘w’: write-only mode. Overwrites all existing data.
    • ‘a’: append mode. Appends to existing data.
Returns:

None

lib.pyside_utils module

Module pyside_utils: This module contains classes useful for dealing with PySide in Mari.

get_mari_main_window()[source]

This method returns the main Mari QMainWindow instance as a QWidget.

Returns:QWidget

lib.reload module

Module reload: This module contains methods for reloading the entire toolkit from within the host application.

class Reloader(name='stkMariTools')[source]

Bases: object

This class contains methods for reloading the toolkit from source.

The constructor.

Parameters:namestr containing name of the top-level root module to reload. Defaults to the name of the top-level module based on the package name in the filesystem.
toolkit_module_name = 'stkMariTools'

Get name of the top-level module name to be reloaded.

reloadModule(name, *args)[source]

This method reloads the toolkit.

Parameters:namestr containing name of the top-level root module to reload.

lib.ui_utils module

Module ui_utils: This module contains useful classes for dealing with the Mari UI.

class MariToolsMenuItem(actionIdentifier=None, actionCommand=None, actionPath=None, actionIcon=None, addBefore='')[source]

Bases: object

This base class is used for adding a Mari Menu item.

The constructor.

Parameters:
  • actionIdentifierstr determining the name of the menu command in the UI.
  • actionCommandstr that is a function to be run when the command is executed.
  • actionPathstr determining where the command will show up in the UI
  • addBeforestr indicating which menu item this menu item should appear before in the ordering of the menu.
  • actionIcon

    str determining what icon the action will have in the Mari menu.

    Tip

    This should be the name of any valid icon in the /Mari/Bundle/Media/Icons directory e.g. (‘About’)

Returns:

registerMariToolsPlugin()[source]

This method acts as a identifier method to be run automatically in order to register this plugin within Mari.

Returns:
addMariToolsMenuItem()[source]

This method should be overriden in subclasses to add a Mari menu item.

Returns:
class MariWidget(parent=None, title='', widgetType='window', *args, **kwargs)[source]

Bases: PySide.QtGui.QMainWindow

This class instantiates a QWidget that can either be a standalone window or a dockable palette in Mari.

The constructor.

Parameters:
  • parentQWidget to parent the created widget to. If None specified, will default to the Mari main window instance.
  • titlestr determining the title that will appear in the window. Must be a unique name.
  • widgetTypestr determining the type of widget that will be created. Acceptable values are: - ‘window’ : Creates a standalone QWidget in a separate window. - ‘palette’ : Creates widgets inside a dock-able Mari palette.
  • args
  • kwargs
Returns:

None

logger = <logging.Logger object at 0x00000000066F74A8>
defineUi(*args, **kwargs)[source]

This abstract method should be overloaded to handle defining the actual UI interface.

It is run before populateData() and makeConnections().

Returns:
initializeUi(title, widgetType, *args, **kwargs)[source]

This creates the UI and shows it.

Parameters:
  • titlestr determining the title that will appear in the window. Must be a unique name.
  • widgetTypestr determining the type of widget that will be created. Acceptable values are: - ‘window’ : Creates a standalone QWidget in a separate window. - ‘palette’ : Creates widgets inside a dock-able Mari palette.
  • args
  • kwargs
Returns:

None

makeConnections(*args, **kwargs)[source]

This abstract method should be implemented to handle connecting QSignals/QSlots.

Returns:None
restoreUIStates(*args, **kwargs)[source]

This method should be overloaded to handle restoring previous UI states from QSettings. It is called after makeConnections().

Parameters:
  • args
  • kwargs
Returns:

populateData(*args, **kwargs)[source]

This abstract method should be implemented to populate any data needed to the widget UI controls.

Returns:
cancelAction()[source]

This method closes the widget. Any UI widget which is intended to close the UI should call this instance method.

Returns:
hidePalette()[source]

This method hides the palette. Any UI widget which is intended to hide the palette should call this instance method.

Returns:
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000667A508>
closeEvent(event)[source]

This overrides the base event in QWidget.

Removes the widget from garbage collection protection.

Parameters:event
Returns:

lib.widget_utils module

Module widget_utils: This module contains classes that define custom UI widgets used in Mari.

class MariQTableWidget(parent=None, *args, **kwargs)[source]

Bases: PySide.QtGui.QTableWidget

This subclass of QTableWidget provides additional features for use in Mari.

keyPressEvent(event)[source]

Overrides the base class method to catch key events. Catch copy shortcut key in order to implement custom clipboard copy method.

Parameters:event
Returns:None
copyTableData()[source]

This method copies the current data selected to the clipboard.

Returns:
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x000000000691E548>

Module contents

Module __init__.py: This module ...