pyworkflow.gui.canvas module

This module extends the functionalities of a normal Tkinter Canvas. The new Canvas class allows to easily display Texboxes and Edges that can be interactively dragged and clicked.

class pyworkflow.gui.canvas.Cable(canvas, src, srcConnector, dst, dstConnector)[source]

Bases: object

dstMoved(dx, dy)[source]
paint()[source]
paintPlugs()[source]
srcMoved(dx, dy)[source]
updateCoords()[source]
class pyworkflow.gui.canvas.Canvas(parent, tooltipCallback=None, tooltipDelay=1500, **kwargs)[source]

Bases: tkinter.Canvas, pyworkflow.gui.widgets.Scrollable

Canvas to draw some objects. It will really contains a Frame, a Canvas and scrollbars

addItem(item)[source]
clear()[source]

Clear all items from the canvas

createCable(src, srcSocket, dst, dstSocket)[source]
createEdge(srcItem, dstItem)[source]
createRoundedTextbox(text, x, y, bgColor='#99DAE8', textColor='black')[source]
createTextCircle(text, x, y, bgColor='#99DAE8', textColor='black')[source]
createTextbox(text, x, y, bgColor='#99DAE8', textColor='black')[source]
drawGraph(graph, layout=None, drawNode=None)[source]

Draw a graph in the canvas. nodes in the graph should have x and y. If layout is not None, it will be used to reorganize the node positions. Provide drawNode if you want to customize how to create the boxes for each graph node.

getCoordinates(event)[source]

Converts the events coordinates to canvas coordinates

getImage(img)[source]
getRunsFont()[source]
hideTooltip(e=None)[source]
move_start(event)[source]
multipleItemsSelected()[source]

Returns True if more than one box selected, False otherwise. TODO: add numItemsSelected as attribute to Canvas class and update when selection changes

onButton1Release(event)[source]
onClick(event)[source]
onControlClick(event)[source]
onDoubleClick(event)[source]
onDrag(event)[source]
onLeave(event)[source]
onMotion(event)[source]
onRightClick(e=None)[source]
selectItem(item)[source]
updateScrollRegion()[source]
zoomerM(event)[source]
zoomerP(event)[source]
class pyworkflow.gui.canvas.ColoredConnector(canvas, x, y, name, fillColor='blue', outline='black')[source]

Bases: pyworkflow.gui.canvas.Connector

class pyworkflow.gui.canvas.Connector(canvas, x, y, name)[source]

Bases: pyworkflow.gui.canvas.Item

Default connector has no graphical representation (hence, it’ss invisible). Subclasses offer different looks

move(dx, dy)[source]
paintPlug(canvas, x, y)[source]

Should be implemented by the subclasses

paintSocket()[source]

Should be implemented by the subclasses

class pyworkflow.gui.canvas.Edge(canvas, source, dest)[source]

Bases: object

Edge between two objects

paint()[source]
updateColor(value)[source]
updateDst(dx, dy)[source]
updateSrc(dx, dy)[source]
class pyworkflow.gui.canvas.Item(canvas, x, y)[source]

Bases: object

BOTTOM = 2
LEFT = 3
RIGHT = 1
TOP = 0
addPositionListener(listenerFunc)[source]
addSelectionListener(listenerFunc)[source]
addSocket(name, socketClass, verticalLocation, fillColor='blue', outline='black', position=None)[source]
countSockets(verticalLocation)[source]
getBottomConnectorCoordinates()[source]
getCenter(x1, y1, x2, y2)[source]
getConnectorsCoordinates()[source]
getCorners()[source]
getDimensions()[source]
getInputConnectorCoordinates()[source]
getLeftConnectorCoordinates()[source]
getOutputConnectorCoordinates()[source]
getRightConnectorCoordinates()[source]
getSelected()[source]
getSocket(name)[source]
getSocketCoords(name)[source]
getSocketCoordsAt(verticalLocation, position=1, socketsCount=1)[source]
getSocketsAt(verticalLocation)[source]
getTopConnectorCoordinates()[source]
getUpDownConnectorsCoordinates()[source]
lift()[source]
move(dx, dy)[source]
moveTo(x, y)[source]

Move TextBox to a new position (x,y)

paintSocket(socket)[source]
paintSockets()[source]
relocateSockets(verticalLocation, count)[source]
setSelected(value)[source]
socketSeparation = 12
verticalFlow = True
class pyworkflow.gui.canvas.Oval(canvas, x, y, radio, color='green', anchor=None)[source]

Bases: object

Oval or circle

paint()[source]
selectionListener(value)[source]
updateSrc(dx, dy)[source]
class pyworkflow.gui.canvas.Rectangle(canvas, x, y, width, height=None, color='green', anchor=None)[source]

Bases: object

paint()[source]
selectionListener(value)[source]
updateSrc(dx, dy)[source]
class pyworkflow.gui.canvas.RoundConnector(canvas, x, y, name, fillColor='blue', outline='black')[source]

Bases: pyworkflow.gui.canvas.ColoredConnector

paintPlug()[source]

Should be implemented by the subclasses

paintSocket()[source]

Should be implemented by the subclasses

radius = 3
class pyworkflow.gui.canvas.RoundedTextBox(canvas, text, x, y, bgColor, textColor='black')[source]

Bases: pyworkflow.gui.canvas.TextItem

getDimensions()[source]
class pyworkflow.gui.canvas.SquareConnector(canvas, x, y, name, fillColor='blue', outline='black')[source]

Bases: pyworkflow.gui.canvas.ColoredConnector

halfside = 3
paintPlug()[source]

Should be implemented by the subclasses

paintSocket()[source]

Should be implemented by the subclasses

class pyworkflow.gui.canvas.TextBox(canvas, text, x, y, bgColor, textColor='black')[source]

Bases: pyworkflow.gui.canvas.TextItem

class pyworkflow.gui.canvas.TextCircle(canvas, text, x, y, bgColor, textColor='black')[source]

Bases: pyworkflow.gui.canvas.TextItem

class pyworkflow.gui.canvas.TextItem(canvas, text, x, y, bgColor, textColor='black')[source]

Bases: pyworkflow.gui.canvas.Item

This class will serve to paint and store rectangle boxes with some text. x and y are the coordinates of the center of this item

lift()[source]
move(dx, dy)[source]
paint()[source]

Paint the object in a specific position.

pyworkflow.gui.canvas.findClosestConnectors(item1, item2)[source]
pyworkflow.gui.canvas.findClosestPoints(list1, list2)[source]
pyworkflow.gui.canvas.findStrictClosestConnectors(item1, item2)[source]
pyworkflow.gui.canvas.findUpDownClosestConnectors(item1, item2)[source]
pyworkflow.gui.canvas.getConnectors(itemSource, itemDest)[source]