Core widgets
pydetecdiv.app.gui.core.widgets.TabWidgets
Definition of widgets to display Tabs in a Tabbed window
- class pydetecdiv.app.gui.core.widgets.TabWidgets.TabbedWindow(title: str)
Bases:
QTabWidgetA class for tabbed windows. These windows are displayed in the MDI area of the main window.
- set_top_tab(widget: QWidget, title: str) None
Set the main tab for this tabbed window, i.e. the reference tab that cannot be closed
- Parameters:
widget – the widget to display in the top tab
title – the title of the top tab
- closeEvent(event: QCloseEvent) None
Close the current tabbed widget window
- Parameters:
event – the close event
- close_tab(index: int) None
Close the tab with the specified index
- Parameters:
index – the index of the tab to close
- show_plot(df: DataFrame, title: str = 'Plot') None
Open a viewer tab to plot a graphic from a pandas dataframe
- Parameters:
df – the data to plot
title – the title for the plot tab
pydetecdiv.app.gui.core.widgets.viewers
Module defining classes for generic viewer API
- class pydetecdiv.app.gui.core.widgets.viewers.GraphicsView(parent: QWidget = None, **kwargs)
Bases:
QGraphicsViewA generic widget for graphics visualization (image, drawings, etc.) using layers
- setup(scene: QGraphicsScene = None) None
Sets up the GraphicsView, adding a scene and a background layer
- Parameters:
scene – the scene to add to the GraphicsView. If None, then a generic Scene will be added
- zoom_set_value(value: float) None
Sets the zoom to the desired value
- Parameters:
value – the value (integer, 100 representing 1:1)
- zoom_fit() None
Set the zoom value to fit the image in the viewer
- addLayer(name: str = None, background: bool = False) Layer
Adds a layer item to the Scene
- Parameters:
background – if True, the layer is a background layer
- Returns:
the added layer
- move_layer(origin: int, destination: int) None
Move layer from its current z position to another one
- Parameters:
origin – the origin z position
destination – the destination z position
- class pydetecdiv.app.gui.core.widgets.viewers.Scene(parent: QWidget = None, **kwargs)
Bases:
QGraphicsSceneA generic scene attached to a GraphicsView, containing graphics items, and reacting to user input (key press, mouse,…)
- property viewer: GraphicsView
A convenience property returning the scene’s viewer
- Returns:
the scene’s viewer (GraphicsViewer)
- view(index: int = 0) GraphicsView
A convenience method to return any view associated with the scene
- Parameters:
index – the index of the view
- Returns:
the requested view
- keyPressEvent(event: QKeyEvent) None
Detect when a key is pressed and perform the corresponding action: * QKeySequence.Delete: delete the selected item
- Parameters:
event – the key pressed event
- mousePressEvent(event: QGraphicsSceneMouseEvent) None
Detect when the left mouse button is pressed and perform the action corresponding to the currently checked drawing tool
- Parameters:
event – the mouse press event
- mouseMoveEvent(event: QGraphicsSceneMouseEvent) None
Detect mouse movement and apply the appropriate method according to the currently checked drawing tool and key modifier
- Parameters:
event – the mouse move event
- wheelEvent(event: QGraphicsSceneWheelEvent) None
DOES NOT WORK Action triggered by using the mouse wheel
- delete_item(graphics_item: QGraphicsItem) None
remove a graphics item from the scene. The QGraphicsItem object is not deleted though and can be added back to the scene
- Parameters:
graphics_item – the graphics item to remove
- unselect_items(event: QGraphicsSceneMouseEvent) None
Unselect all selected items
- Parameters:
event – the mouse press event
- select_Item(event: QGraphicsSceneMouseEvent) None
Select the current area/Item
- Parameters:
event – the mouse press event
- get_selected_Item() QAbstractGraphicsShapeItem | None
Return the selected Item
- Returns:
the selected Item
- duplicate_selected_Item(event: QGraphicsSceneMouseEvent) QGraphicsRectItem | None
Duplicate the currently selected Item at the current mouse position
- Parameters:
event – the mouse press event
- get_colliding_ShapeItems(item: QAbstractGraphicsShapeItem) list[QAbstractGraphicsShapeItem]
Retrieve all ShapeItems colliding with the item in this scene
- Parameters:
item – the item to check
- Returns:
a list of colliding items
- move_Item(event: QGraphicsSceneMouseEvent) QGraphicsRectItem | QGraphicsEllipseItem
Move the currently selected Item if it is movable
- Parameters:
event – the mouse move event
- draw_Item(event: QGraphicsSceneMouseEvent) QGraphicsRectItem
Draw or redraw the currently selected Item if it is movable
- Parameters:
event – the mouse press event
- regions() list[QGraphicsRectItem]
the list of regions in the scene
- set_Item_width(width: int)
Sets the width of the selected item
- Parameters:
width – the width value
- set_Item_height(height: int)
Sets the height of the selected item
- Parameters:
height – the height value
- display_Item_size(item: QGraphicsRectItem) None
Displays the item size in the Drawing tools palette
- Parameters:
item – the item
- add_point(event: QGraphicsSceneMouseEvent) QGraphicsEllipseItem
Draw a point :param event: the mouse press event
- points() list[QGraphicsEllipseItem]
the list of points in the scene
- layers() list
the list of layers in the scene
- item_dict() dict
Returns a dictionary with all items in a scene
- class pydetecdiv.app.gui.core.widgets.viewers.Layer(viewer: GraphicsView, **kwargs)
Bases:
QGraphicsItemA graphics item containing sub-items in order to define layer behaviour
- property zIndex: int
A convenience method returning the Z index of the Layer
- Returns:
the z index
- move_up() None
Moves the layer up one level
- move_down() None
Moves the layer down one level
- toggleVisibility() None
Toggles visibility of the layer
- addItem(item: QGraphicsItem) QGraphicsItem
Adds an item to the layer
- Parameters:
item – the added item
- Returns:
the added item
- boundingRect() QRectF
Returns the bounding rect of the layer, which contains all children
- Returns:
the bounding rect of the layer
- paint(painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget = Ellipsis)
Paint method added to comply with the implementation of abstract class
- class pydetecdiv.app.gui.core.widgets.viewers.BackgroundLayer(viewer: GraphicsView, **kwargs)
Bases:
LayerA particular layer that is always at the bottom of a scene
- property zIndex: int
A convenience method returning the Z index of the Layer. As this is a background layer, the Z index should always be 0
- Returns:
the z index