pygmi.main#

Main module for PyGMI.

This module comprises a series of classes which are responsible for the primary interface to the software. Credit must go to PyQt’s examples, upon which some of this was originally based.

Although the main interface is controlled here, the content of the menus and routines is not. The menus and corresponding classes are found within the pygmi packages.

Classes#

Arrow

Class responsible for drawing arrows on the main interface.

DiagramItem

Diagram Item.

DiagramScene

Diagram Scene.

MainWidget

Widget class to call the main interface.

Startup

Class to provide a startup display while PyGMI loads into memory.

Functions#

main([nocgs])

Entry point for the PyGMI software.

Module Contents#

class pygmi.main.Arrow(start_item, end_item, parent=None)#

Bases: PyQt6.QtWidgets.QGraphicsLineItem

Class responsible for drawing arrows on the main interface.

Parameters:
  • parent (parent, optional) – Reference to the parent routine. The default is None.

  • start_item (DiagramItem) – Starting DiagramItem object.

  • end_item (DiagramItem) – End DiagramItem object.

arrow_head#

Arrow head polygon.

Type:

QPolygonF

my_start_item#

Starting DiagramItem object. This will send information to my_end_item

Type:

DiagramItem

my_end_item#

End DiagramItem object. This will get information from my_start_item

Type:

DiagramItem

my_color#

Color

Type:

QtCore colour

boundingRect()#

Bounding Rectangle.

Overloaded bounding rectangle. This is necessary to ensure that the line and arrowhead are cleaned properly when moving.

Returns:

tmp

Return type:

QtCore.QRectF

paint(painter, option, widget=None)#

Overloaded paint method.

Parameters:
  • painter (QPainter)

  • option (QStyleOptionGraphicsItem)

  • widget (QWidget, optional)

class pygmi.main.DiagramItem(diagram_type, context_menu, my_class, parent)#

Bases: PyQt6.QtWidgets.QGraphicsPolygonItem

Diagram Item.

Parameters:
  • parent (parent, optional) – Reference to the parent routine. The default is None.

  • diagram_type (str) – string denoting the diagram type. Can be ‘StartEnd’, ‘Conditional’ or ‘Step’

  • context_menu (dict) – Dictionary of context menu options

  • my_class (object) – Class that the diagram item is linked to.

arrows#

list of Arrow objects

Type:

list

diagram_type#

string denoting the diagram type. Can be ‘StartEnd’, ‘Conditional’ or ‘Step’

Type:

str

context_menu#

Dictionary of context menu options

Type:

dict

my_class#

Class that the diagram item is linked to.

Type:

object

text_item#

Text label associated with item.

Type:

None or QtWidgets.QGraphicsTextItem

my_class_name#

Class name being referenced

Type:

str

add_arrow(arrow)#

Add Arrow.

Parameters:

arrow (Arrow) – Arrow object to add.

update_indata()#

Routine to add datasets.

contextMenuEvent(event)#

Overloaded context menu event.

Parameters:

event (N/A)

mouseDoubleClickEvent(event)#

Mouse double click event.

This event is used to activate an item. It does this by calling the settings() method of the item. The event also changes the colour of the item to reflect whether it is busy working.

remove_arrow(arrow)#

Remove a single Arrow.

Parameters:

arrow (Arrow) – Arrow object to remove.

remove_arrows()#

Remove Arrows. Uses the remove_arrow method.

settings(nodialog=False)#

Routine Settings.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

iflag – Returns a boolean reflecting success of the my_class.settings() method.

Return type:

bool

class pygmi.main.DiagramScene(item_menu, parent=None)#

Bases: PyQt6.QtWidgets.QGraphicsScene

Diagram Scene.

Parameters:
  • parent (parent, optional) – Reference to the parent routine. The default is None.

  • item_menu (QtWidgets.QMenu) – Item menu.

mousePressEvent(mouse_event)#

Overloaded Mouse Press Event.

Parameters:

mouse_event (QGraphicsSceneMouseEvent) – mouse event.

selected_item_info()#

Display info about selected item.

mouseMoveEvent(mouse_event)#

Overloaded Mouse Move Event.

Parameters:

mouse_event (QGraphicsSceneMouseEvent) – mouse event.

mouseReleaseEvent(mouse_event)#

Overloaded Mouse Release Event.

Parameters:

mouse_event (QGraphicsSceneMouseEvent) – mouse event.

class pygmi.main.MainWidget(parent=None, nocgs=True)#

Bases: PyQt6.QtWidgets.QMainWindow

Widget class to call the main interface.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

pdlg#
Type:

list

context_menu#
Type:

dictionary

setupui()#

Set up UI.

Return type:

None.

add_to_context(txt)#

Add to a context menu.

Each dataset type which PyGMI uses can have its own context menu. This method allows for the definition of each group of context menu items under a user defined text label.

Parameters:

txt (str) – Label for a group of context menu items

bring_to_front()#

Bring the selected item to front.

clearprocesslog()#

Clear the process log.

delete_item()#

Delete the selected item from main interface.

keyPressEvent(event)#

Intercept key press for custom key presses.

Parameters:

event (QKeyEvent) – Key press event object.

Return type:

None.

get_indata()#

Get input data from the selected item on the main interface.

Returns:

idata – Input list of PyGMI Data (pygmi.raster.datatypes.Data)

Return type:

list

get_outdata()#

Get output data from the selected item on the main interface.

Returns:

odata – Output list of PyGMI Data (pygmi.raster.datatypes.Data)

Return type:

list

help_docs()#

Help Routine.

item_insert(item_type, item_name, class_name, projimport=False, **kwargs)#

Item insert.

Insert an item on the main interface. The item is an object passed by one of the menu.py routines and is one of the algorithms chosen on the main PyGMI menu.

Parameters:
  • item_type (str) – str describing the shape of the graphic used to describe the item.

  • item_name (str) – str describing the name of the item to be displayed.

  • class_name (object) – class to be called when double clicking on the item.

Returns:

item – Return a DiagramItem object

Return type:

DiagramItem

launch_context_item(newitem)#

Launch a context menu item, using output data.

Parameters:

newitem (custom class) – newitem is the class to be called by the context menu item

launch_context_item_indata(newitem)#

Launch a context menu item, using input data.

Parameters:

newitem (custom class) – newitem is the class to be called by the context menu item

linepointer()#

Select line pointer.

pointer()#

Select pointer.

process_is_active(isactive=True)#

Change process log colour when a process is active.

Parameters:

isactive (bool, optional) – boolean variable indicating if a process is active.

load()#

Load project state from JSON file.

Return type:

None.

save()#

Save project state to a JSON file.

Return type:

None.

run()#

Run entire script.

Return type:

None.

send_to_back()#

Send the selected item to the back.

showdatainfo(txt)#

Show text in the dataset information panel.

Parameters:

txt (str) – Message to be displayed in the datainfo panel

showlog(txt, replacelast=False)#

Show text on the process log.

Parameters:
  • txt (str) – Message to be displayed in the process log

  • replacelast (bool, optional) – flag to indicate whether the last row on the log should be overwritten.

update_pdlg(dlg)#

Clean deleted objects in self.pdlg and appends a new object.

self.pdlg allows for modeless dialogues to remain in existence until they are closed

Parameters:

dlg (object) – Object to be appended to self.pdlg

class pygmi.main.Startup(pbarmax, parent=None)#

Bases: PyQt6.QtWidgets.QDialog

Class to provide a startup display while PyGMI loads into memory.

Parameters:
  • parent (parent, optional) – Reference to the parent routine. The default is None.

  • pbarmax (int) – Progress bar maximum value.

update()#

Update the text on the dialog.

pygmi.main.main(nocgs=False)#

Entry point for the PyGMI software.