Module gpanel
[hide private]
[frames] | no frames]

Module gpanel

source code


Module to create a graphics window of default size 501x501 pixels (client drawing area)
using a coordinate system with x-axis from left to right, y-axis from bottom to top
(called user coordinates, default range 0..1, 0..1).

The module provides a global namespace for GPanel class methods. It also contaisn
the class GPane that can be used to embed a GPanel graphics window together with
other widgets in a GUI application.

The drawing methods perform drawing operation in an offscreen buffer (QPixmap)
and automatically renders it on the screen, so the graphics is shown step-by-step.

User coordinates:  (ux, uy)
Pixel coordinates: (px, py) (screen pixels)
Transformation: px = px(ux), py = py(uy)
Pixel coordinate range: 0..winWidth - 1 (inclusive), 0..winHeight - 1 (inclusive); (0,0) upper left corner, x to the right, y downwards
User coordinate range: xmin..xmax (inclusive), ymin..ymax (inclusive); (0,0) lower left corner, x to the right, y upwards.

Transformation: user(ux, uy) to pixel(px, py):
(width = winWidth - 1, height = winHeight - 1)
px = a * ux + b
py = c * uy + d
with a = width / (xmax - xmin)
b = width * xmin / (xmin - xmax)
c = height / (ymin - ymax)
d = height * ymax / (ymax - ymin)

Inverse:
ux = (px - b) / a
uy = (py - d) / c

Because of the transformation from float to pixel coordinates, some rounding errors
may happen. If you need pixel accuracy, define a GPanel window with some user defined width x height,
e.g. makeGPanal(Size(501, 401)). Define then user coordinates in the range 0..width-1, 0..height-1, e.g.
window(0, 500, 0, 400). Now pixels in the range 0..500 x 0..400 (inclusive) may be addressed with no
rounding errors. (This is a total of 501 x 401 pixels.)

If you prefer a coordinate system with the origin at the upper left corner, define the y-range in reverse
order, e.g. window(0, 500, 400, 0).

WARNING: Because PyQt is not thread-safe, in principle all graphics drawings should be
executed in the GUI thread (for GPanel the main thread or a GUI callback).

In order to get notifications for keyboard and mouse callbacks, the main thread should
not be blocked otherwise than within the keep() function.

Typical program:

from pygpanel import *

makeGPanel(0, 10, 0, 10)
for ypt in range(0, 11, 1):
    line(0, ypt, 10 - ypt, 0)
    time.sleep(0.1) # to see what happens
keep()

keep() is blocking and keeps the graphics window open until the close button is hit or the
Python process terminates.

Classes [hide private]
  _WindowNotInitialized
  Size
Class that defines the pair width, height of dimension attributes.
  GPanel
Class to create a graphics window of default size 501x501 pixels (client drawing area) using a coordinate system with x-axis from left to right, y-axis from bottom to top (called user coordinates, default range 0..1, 0..1).
  GPane
Functions [hide private]
 
_isGPanelValid() source code
 
makeGPanel(*args, **kwargs)
Constructs a GPanel and displays a non-resizable graphics window.
source code
 
addCloseListener(closeListener)
Registers the given function that is called when the title bar close button is hit.
source code
 
addKeyPressListener(onKeyPressed)
Registers a callback that is invoked when a key is pressed (and the graphics window has the focus).
source code
 
addKeyReleaseListener(onKeyReleased)
Registers a callback that is invoked when a key is released (and the graphics window has the focus).
source code
 
addMouseDragListener(onMouseDragged)
Registers a callback that is invoked when the mouse is moved while a mouse button is pressed (drag).
source code
 
addMousePressListener(onMousePressed)
Registers a callback that is invoked when a mouse button is pressed.
source code
 
addMouseReleaseListener(onMouseReleased)
Registers a callback that is invoked when a mouse button is releases.
source code
 
arc(radius, startAngle, spanAngle)
Draws a circle sector with center at the current graph cursor position, given radius and given start and span angles.
source code
 
arrow(*args)
Draws an arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] @param pt1 the starting point
source code
 
bgColor(*args)
Same as setBgColor().
source code
 
chord(radius, startAngle, spanAngle)
Draws a circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).
source code
 
circle(radius)
Draws a circle with center at the current graph cursor position with given radius in horizontal window coordinates.
source code
 
clear()
Clears the graphics window and the offscreen buffer used by the window (fully paint with background color).
source code
 
delay(delayTime)
Stop execution for given delay time.
source code
 
doubleArrow(*args)
Draws a double arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] (arrowheads on both ends).
source code
 
draw(*args)
Draws a line form current graph cursor position to (x, y).
source code
 
drawGrid(*args)
Draws a coordinate system with annotated axes.
source code
 
ellipse(a, b)
Draws an ellipse with center at the current graph cursor position with given axes.
source code
 
enableRepaint(enable)
Enables/Disables automatic repaint in graphics drawing methods.
source code
 
erase()
Same as clear(), but lets the current graph cursor unganged.
source code
 
fill(x, y, *args)
Fills the closed unicolored region with the inner point (x, y) with the replacement color (RGB, RGBA or X11 color string).
source code
 
fillArc(radius, startAngle, spanAngle)
Draws a filled circle sector with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).
source code
 
fillChord(radius, startAngle, spanAngle)
Draws a filled circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).
source code
 
fillCircle(radius)
Draws a filled circle with center at the current graph cursor position with given radius in horizontal window coordinates (fill color = pen color).
source code
 
fillEllipse(a, b)
Draws a filled ellipse with center at the current graph cursor position with given axes (fill color = pen color).
source code
 
fillPath(color)
Closes the path started with startPath() and shows a filled polygon from the saved draw() positions with given color.
source code
 
fillPolygon(*args)
Draws a filled polygon with given list of vertexes (list of [x, y]) (fill color = pen color).
source code
 
fillRectangle(*args)
Draws a filled rectangle (fill color = pen color).
source code
 
fillTriangle(*args)
Draws a filled triangle with given corners.
source code
 
getDividingPoint(*args)
Returns the tuple of user coordinates of the point on the line through the point pt1 = (x1, y1) and the point pt2 = (x2, y2) that is in distance ratio times the length from pt1 to pt2 from pt1.
source code
 
getBitmap()
Returns the QImage of the complete graphics area.
source code
 
getFullImage()
Returns the QImage of the complete graphics area.
source code
 
getImage(filename)
Same as loadImage(filename) (For compatiblity with TigerJython.)
source code
 
loadImage(filename, pic_format=None)
Returns a QImage of the picture loaded from the given file.
source code
 
getPainter()
Returns the QPainter reference used to draw into the offscreen buffer.
source code
 
getPixelColor(*args)
Returns the RGBA color tuple of a pixel with given user coordinates.
source code
 
getPixelColorStr(*args)
Returns the X11 color string of a pixel with given user coordinates.
source code
 
getPos()
Returns a tuple with current graph cursor position (tuple, user coordinates).
source code
float
getPosX()
Returns the current graph cursor x-position (user coordinates).
source code
float
getPosY()
Returns the current graph cursor y-position (user coordinates).
source code
int
getScreenWidth()
Returns the width of the screen (in pixels).
source code
int
getScreenHeight()
Returns the height of the screen (in pixels).
source code
boolean
imageFromData(data, pic_format, x, y)
Draws the picture with given string data in JPEG format at user coordinates of lower left corner.
source code
 
image(*args)
Draws the picture with given file path or given image at given upper-left coordinates.
source code
 
isLeftMouseButton()
Returns True, if the last mouse action was performed with the left mouse button.
source code
 
isRightMouseButton()
Returns True, if the last mouse action was performed with the right mouse button.
source code
 
keep()
Blocks until the title bar's close button is hit.
source code
 
line(*args)
Draws a line with given user start and end coordinates and sets the graph cursor position to the end point.
source code
 
lineWidth(width)
Sets the current pen size (width) (>=1).
source code
 
makeColor(r, g, b)
Returns the tuple (r, g, b).
source code
 
move(*args)
Sets the current graph cursor position to given user coordinates.
source code
 
point(*args)
Draws a single point with current pen size and pen color at given user coordinates.
source code
 
linePlot(*args)
Draws a line plot with given x,y data.
source code
 
pos(*args)
Sets the current graph cursor position to given user coordinates (x, y).
source code
 
polygon(*args)
Draws a filled polygon with given list of vertexes (list of [x, y]) (fill color = pen color).
source code
 
rectangle(*args)
Draws a rectangle.
source code
 
repaint()
Renders the offscreen buffer in the graphics window.
source code
 
recallGraphics()
Restores the saved graphics from the image buffer.
source code
 
restoreGraphics()
Restores the saved graphics from the image buffer.
source code
 
saveGraphics()
Saves the current graphics into a image buffer.
source code
 
setBgColor(*args)
Sets the background color.
source code
 
setColor(*args)
Sets the current pen color.
source code
 
setPaintMode()
Resets the drawing mode to standard (overwriting).
source code
 
setPenColor(*args)
Sets the current pen color.
source code
 
setPenSize(size)
Sets the current pen size (width) (>=1).
source code
 
setTitle(title)
Sets the title in the window title bar.
source code
 
setUserCoords(xmin, xmax, ymin, ymax)
Sets user coordinate system left_x, right_x, bottom_y, top_y (inclusive).
source code
 
setWindowCenter()
Sets the screen position to the center of the screen.
source code
 
setWindowPos(ulx, uly)
Sets the screen position of the graphics window.
source code
 
setXORMode(*args)
Performs pixel color XOR operation with the existing background pixel.
source code
 
startPath()
Starts recording the path vertexes.
source code
 
storeGraphics()
Saves the current graphics into a image buffer.
source code
 
text(*args)
Draws a text at given position (user coordinates).
source code
 
title(title)
Sets the title in the window title bar.
source code
 
toPixel(user)
Returns pixel coordinates (tuple) of given user coordinates (tuple).
source code
 
toPixelHeight(userHeight)
Returns pixel y-increment of given user y-increment (always positive).
source code
 
toPixelWidth(userWidth)
Returns pixel x-increment of given user x-increment (always positive).
source code
 
toPixelX(userX)
Returns pixel x-coordinate of given user x-coordinate.
source code
 
toPixelY(userY)
Returns pixel y-coordinate of given user y-coordinate.
source code
 
toUser(pixel)
Returns user coordinates (tuple) of given pixel coordinates (tuple).
source code
 
toUserHeight(pixelHeight)
Returns user y-increment of given pixel y-increment (always positive).
source code
 
toUserWidth(pixelWidth)
Returns user x-increment of given pixel x-increment (always positive).
source code
 
toUserX(pixelX)
Returns user x-coordinate of given pixel x-coordinate.
source code
 
toUserY(pixelY)
Returns user y-coordinate of given pixel y-coordinate.
source code
 
triangle(*args)
Draws a triangle with given corners.
source code
 
window(xmin, xmax, ymin, ymax)
Sets user coordinate system left_x, right_x, bottom_y, top_y (inclusive).
source code
 
windowPosition(ulx, uly)
Sets the screen position (pixel coordinates of upper left corner).
source code
 
windowCenter()
Sets the window to the center of the screen.
source code
 
_getCoords(*args) source code
 
_get2Coords(*args) source code
 
run(f)
Calls f() in a new thread.
source code
 
getRandomX11Color()
Returns a random X11 color string.
source code
 
linfit(X, Y)
Returns a and b in y = a*x + b for given list X of x values and corresponding list Y of values.
source code
Variables [hide private]
  _p = None
  isTigerJython = False
  x11ColorDict = {"aqua": [0, 255, 255], "cornflower": [100, 149...
The key names used by Qt.
Function Details [hide private]

makeGPanel(*args, **kwargs)

source code 

Constructs a GPanel and displays a non-resizable graphics window. Defaults with no parameter: Window size: 501x501 pixels Window title: "GPanel". User coordinates: 0, 1, 0, 1. Background color: white. Pen color: black. Pen size: 1.

1 Parameter: Size(window_width, window_height). 4 Parameters: xmin, xmax, ymin, ymax.

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • Size - a Size reference to define the dimension of the graphics windows.
  • xmin - left x user coordinate
  • xmax - right x user coordinate
  • ymin - lower y user coordinate
  • ymax - upper y user coordinate
  • kwargs - mousePressed, mouseReleased, mouseDragged, keyPressed, keyReleased, closed

addCloseListener(closeListener)

source code 

Registers the given function that is called when the title bar close button is hit.

If a listener (!= None) is registered, the automatic closing is disabled. To close the window, call sys.exit().

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • closeListener - a callback function called when the close button is hit

addKeyPressListener(onKeyPressed)

source code 

Registers a callback that is invoked when a key is pressed (and the graphics window has the focus).

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onKeyPressed - a callback function called when a key is pressed

addKeyReleaseListener(onKeyReleased)

source code 

Registers a callback that is invoked when a key is released (and the graphics window has the focus).

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onKeyReleased - a callback function called when a key is pressed

addMouseDragListener(onMouseDragged)

source code 

Registers a callback that is invoked when the mouse is moved while a mouse button is pressed (drag).

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onMouseDragged - a callback function called when the moused is dragged

addMousePressListener(onMousePressed)

source code 

Registers a callback that is invoked when a mouse button is pressed. Use isLeftMouseButton() or isRightMouseButton() to check which button used.

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onMousePressed - a callback function called when a mouse button is pressed

addMouseReleaseListener(onMouseReleased)

source code 

Registers a callback that is invoked when a mouse button is releases. Use isLeftMouseButton() or isRightMouseButton() to check which button used.

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onMouseReleased - a callback function called when a mouse button is released

arc(radius, startAngle, spanAngle)

source code 

Draws a circle sector with center at the current graph cursor position, given radius and given start and span angles.

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

arrow(*args)

source code 

Draws an arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] @param pt1 the starting point

Parameters:
  • pt2 - the ending point (where is the arrowhead)
  • size - the length of the arrowhead's triangle (in pixels, default: 10)

    Overloaded versions: points as list/tuple or x, y coordinates

chord(radius, startAngle, spanAngle)

source code 

Draws a circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

circle(radius)

source code 

Draws a circle with center at the current graph cursor position with given radius in horizontal window coordinates.

Parameters:
  • radius - the radius of the circle

clear()

source code 

Clears the graphics window and the offscreen buffer used by the window (fully paint with background color). Sets the current graph cursor position to (0, 0). If enableRepaint(false) only clears the offscreen buffer.

delay(delayTime)

source code 

Stop execution for given delay time.

Parameters:
  • delayTime - the delay time (in ms)

doubleArrow(*args)

source code 

Draws a double arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] (arrowheads on both ends). @param pt1 one end of the arrow

Parameters:
  • pt2 - the other end of the arrow
  • size - the length of the arrowhead's triangle (in pixels, default: 10)

    Overloaded versions: points as list/tuple or x, y coordinates

draw(*args)

source code 

Draws a line form current graph cursor position to (x, y). Sets the graph cursor position to (x, y). Also with one parameter of type complex, list or tuple.

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

drawGrid(*args)

source code 

Draws a coordinate system with annotated axes. (You must increase the user coordinate system at least 10% in both directions.)

Overloaded versions:

drawGrid(x, y): Grid with 10 ticks in range 0..x, 0..y. Label text depends if x, y or int or float

drawGrid(x, y, color): same with given grid color

drawGrid(x1, x2, y1, y2): same with given span x1..x2, y1..y2

drawGrid(x1, x2, y1, y2, color): same with given grid color

drawGrid(x1, x2, y1, y2, x3, y3): same with given number of ticks x3, y3 in x- and y-direction

ellipse(a, b)

source code 

Draws an ellipse with center at the current graph cursor position with given axes.

Parameters:
  • a - the major ellipse axis
  • b - the minor ellipse axis

enableRepaint(enable)

source code 

Enables/Disables automatic repaint in graphics drawing methods.

Parameters:
  • enable - if True, the automatic repaint is enabled; otherwise disabled

fill(x, y, *args)

source code 

Fills the closed unicolored region with the inner point (x, y) with the replacement color (RGB, RGBA or X11 color string). The old color is not given, the color of the current (x, y) pixel is taken.

Parameters:
  • x - the x coordinate of the inner point
  • y - the y coordinate of the inner point
  • color - the old color (RGB list/tuple or X11 color string) (may be omitted)
  • replacementColor - the new color (RGB list/tuple or X11 color string)

fillArc(radius, startAngle, spanAngle)

source code 

Draws a filled circle sector with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east). (fill color = pen color)

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

fillChord(radius, startAngle, spanAngle)

source code 

Draws a filled circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east). (fill color = pen color)

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

fillCircle(radius)

source code 

Draws a filled circle with center at the current graph cursor position with given radius in horizontal window coordinates (fill color = pen color).

Parameters:
  • radius - the radius of the circle

fillEllipse(a, b)

source code 

Draws a filled ellipse with center at the current graph cursor position with given axes (fill color = pen color).

Parameters:
  • a - the major ellipse axis
  • b - the minor ellipse axis

fillPolygon(*args)

source code 

Draws a filled polygon with given list of vertexes (list of [x, y]) (fill color = pen color). 1 parameter: a list/tuple of the corners [x, y] 2 parameters: two lists/tuples x, y of corresponding x-y pairs

fillRectangle(*args)

source code 

Draws a filled rectangle (fill color = pen color).
2 parameters: Center at the current graph cursor position
              and given width and height
4 parameters: Given diagonal

fillTriangle(*args)

source code 

Draws a filled triangle with given corners. 6 parameters: x1, y1, x2, y2, x3, y3 coordinates of corners 3 parameters: [x1, y1], [x2, y2], [x3, y3] lists of corners

getDividingPoint(*args)

source code 

Returns the tuple of user coordinates of the point on the line through the point pt1 = (x1, y1) and the point pt2 = (x2, y2) that is in distance ratio times the length from pt1 to pt2 from pt1. For ratio < 0 the point is in the opposite direction. 3 parameteters: pt1, pt2 (complex/list/tuple), ratio 5 parameteters: x1, y1, x2, y2, ratio

getBitmap()

source code 

Returns the QImage of the complete graphics area. (For compatiblity with TigerJython.)

loadImage(filename, pic_format=None)

source code 

Returns a QImage of the picture loaded from the given file. For pic_format = None, the picture format is guessed from the file data.

Parameters:
  • pic_format - format of picture, supported: "None" (default), "GIF", "JPG", "BMP", "PNG", "PBM", "PGM", "PPM", "TIFF", "XBM" "XPM".

getPixelColor(*args)

source code 

Returns the RGBA color tuple of a pixel with given user coordinates. No params: Returns color at current graph cursor position.

getPixelColorStr(*args)

source code 

Returns the X11 color string of a pixel with given user coordinates. No params: Returns color at current graph cursor position.

getPosX()

source code 

Returns the current graph cursor x-position (user coordinates).

Returns: float
x coordinate of graph cursor

getPosY()

source code 

Returns the current graph cursor y-position (user coordinates).

Returns: float
y coordinate of graph cursor

getScreenWidth()

source code 

Returns the width of the screen (in pixels).

Returns: int
screen width

getScreenHeight()

source code 

Returns the height of the screen (in pixels).

Returns: int
screen height

imageFromData(data, pic_format, x, y)

source code 

Draws the picture with given string data in JPEG format at user coordinates of lower left corner.

Parameters:
  • data - picture data stream in string format
  • pic_format - format of picture, supported: "GIF", "JPG", "BMP", "PNG", "PBM", "PGM", "PPM", "TIFF", "XBM" "XPM"
  • x - x coordinate of lower left corner
  • y - y coordinate of lower left corner
Returns: boolean
True, if operation is successful; otherwise false

image(*args)

source code 

Draws the picture with given file path or given image at given upper-left coordinates. 1st parameter: image path (string) or QImage reference 2nd, 3rd parameters: llx, lly (lower left corner in user coordinates)

keep()

source code 

Blocks until the title bar's close button is hit. Then cleans up the graphics system.

line(*args)

source code 

Draws a line with given user start and end coordinates and sets the graph cursor position to the end point. Also with 2 parameters of type complex, list or tuple. 4 parameters: x1, y1, x2, y2 2 parameters: pt1, pt2 as complex/list/tuple

lineWidth(width)

source code 

Sets the current pen size (width) (>=1). Returns the previouis pen size.

Same as setPenSize(). For TigerJython compatiblity.

Parameters:
  • width - the pen width (>=1)

makeColor(r, g, b)

source code 

Returns the tuple (r, g, b). For compatibility with TigerJython.

move(*args)

source code 

Sets the current graph cursor position to given user coordinates. (without drawing anything). Also with 1 parameter of type complex, list or tuple.

Same as pos().

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

point(*args)

source code 

Draws a single point with current pen size and pen color at given user coordinates. No params: draws a current graph cursor position

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

linePlot(*args)

source code 

Draws a line plot with given x,y data. 1 parameter: a list/tuple of subsequent data points [x, y] 2 parameters: two lists/tuples x, y of corresponding x-y pairs The graph cursor position remains unchanged.

pos(*args)

source code 

Sets the current graph cursor position to given user coordinates (x, y). (without drawing anything). Also with 1 parameter of type complex, list or tuple.

Same as move().

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

polygon(*args)

source code 

Draws a filled polygon with given list of vertexes (list of [x, y]) (fill color = pen color). 1 parameter: a list/tuple of the corners [x, y] 2 parameters: two lists/tuples x, y of corresponding x-y pairs

rectangle(*args)

source code 

Draws a rectangle.
2 parameters: Center at the current graph cursor position
              and given width and height.
4 parameters: Given diagonal

recallGraphics()

source code 

Restores the saved graphics from the image buffer. Use saveGraphics() to save it.

Same as restoreGraphics() (for TigerJython compatibility).

restoreGraphics()

source code 

Restores the saved graphics from the image buffer. Use saveGraphics() to save it.

saveGraphics()

source code 

Saves the current graphics into a image buffer. Use restoreGraphics() to restore it.

setBgColor(*args)

source code 

Sets the background color. All drawings are erased and the current graph cursor is set to (0, 0). 1 parameter: value considered as X11 color string 3 parameters: values considered as RGB (alpha = 255) 4 parameters: values considered as RGBA

setColor(*args)

source code 

Sets the current pen color. 1 parameter: - string value considered as X11 color string

  • list considered as [r, b, g] or [r, g, b, a]
  • tuple considered as (r, b, g) or (r, g, b, a)

3 parameters: values considered as RGB (alpha = 255) 4 parameters: values considered as RGBA

Same as setPenColor(). For TigerJython compatiblity.

setPenColor(*args)

source code 

Sets the current pen color. 1 parameter: - string value considered as X11 color string

  • list considered as [r, b, g] or [r, g, b, a]
  • tuple considered as (r, b, g) or (r, g, b, a)

3 parameters: values considered as RGB (alpha = 255) 4 parameters: values considered as RGBA

setPenSize(size)

source code 

Sets the current pen size (width) (>=1). Returns the previouis pen size. Same as lineWidth().

Parameters:
  • width - the pen width (>=1)

setTitle(title)

source code 

Sets the title in the window title bar.

Parameters:
  • title - the title text

setUserCoords(xmin, xmax, ymin, ymax)

source code 

Sets user coordinate system left_x, right_x, bottom_y, top_y (inclusive). Same as window().

Parameters:
  • xmin - the x coordinate (of a visible pixel) at left border
  • xmax - the x coordinate (of a visible pixel) at right border
  • ymin - the y coordinate (of a visible pixel) at bottom border
  • ymax - the y coordinate (of a visible pixel) at top border

setWindowPos(ulx, uly)

source code 

Sets the screen position of the graphics window.

Parameters:
  • ulx - the upper left corner's x-coordinate
  • ulx - the upper left corner's y-coordinate

setXORMode(*args)

source code 

Performs pixel color XOR operation with the existing background pixel. Be aware that if the background is white, drawing with a white pen shows a black pixel. (Parameter not used, for TigerJython compatibility)

startPath()

source code 

Starts recording the path vertexes. The positions of subsequent draw() operations are saved. The path is used to show a filled polygon when fillPath() is called.

storeGraphics()

source code 

Saves the current graphics into a image buffer. Use restoreGraphics() to restore it.

Same as saveGraphics() (for TigerJython compatibility).

text(*args)

source code 

Draws a text at given position (user coordinates). 1 parameter: at current graph cursor position 2 parameters: target point (comolex/list/tuple), text 3 parameters: x, y, text

title(title)

source code 

Sets the title in the window title bar. Same as setTitle(), for TigerJython compatibility.

Parameters:
  • title - the title text

triangle(*args)

source code 

Draws a triangle with given corners. 6 parameters: x1, y1, x2, y2, x3, y3 coordinates of corners 3 parameters: [x1, y1], [x2, y2], [x3, y3] lists of corners

window(xmin, xmax, ymin, ymax)

source code 

Sets user coordinate system left_x, right_x, bottom_y, top_y (inclusive). Same as setUserCoords(). For TigerJython compatiblity.

Parameters:
  • xmin - the x coordinate (of a visible pixel) at left border
  • xmax - the x coordinate (of a visible pixel) at right border
  • ymin - the y coordinate (of a visible pixel) at bottom border
  • ymax - the y coordinate (of a visible pixel) at top border

Variables Details [hide private]

x11ColorDict

The key names used by Qt. Constant Value Description

Qt.Key_Escape 0x01000000

Qt.Key_Tab 0x01000001

Qt.Key_Backtab 0x01000002

Qt.Key_Backspace 0x01000003

Qt.Key_Return 0x01000004

Qt.Key_Enter 0x01000005 Typically located on the keypad.

Qt.Key_Insert 0x01000006

Qt.Key_Delete 0x01000007

Qt.Key_Pause 0x01000008 The Pause/Break key (Note: Not anything to do with pausing media)

Qt.Key_Print 0x01000009

Qt.Key_SysReq 0x0100000a

Qt.Key_Clear 0x0100000b

Qt.Key_Home 0x01000010

Qt.Key_End 0x01000011

Qt.Key_Left 0x01000012

Qt.Key_Up 0x01000013

Qt.Key_Right 0x01000014

Qt.Key_Down 0x01000015

Qt.Key_PageUp 0x01000016

Qt.Key_PageDown 0x01000017

Qt.Key_Shift 0x01000020

Qt.Key_Control 0x01000021 On Mac OS X, this corresponds to the Command keys.

Qt.Key_Meta 0x01000022 On Mac OS X, this corresponds to the Control keys. On Windows keyboards, this key is mapped to the Windows key.

Qt.Key_Alt 0x01000023

Qt.Key_AltGr 0x01001103 On Windows, when the KeyDown event for this key is sent, the Ctrl+Alt modifiers are also set.

Qt.Key_CapsLock 0x01000024

Qt.Key_NumLock 0x01000025

Qt.Key_ScrollLock 0x01000026

Qt.Key_F1 0x01000030

Qt.Key_F2 0x01000031

Qt.Key_F3 0x01000032

Qt.Key_F4 0x01000033

Qt.Key_F5 0x01000034

Qt.Key_F6 0x01000035

Qt.Key_F7 0x01000036

Qt.Key_F8 0x01000037

Qt.Key_F9 0x01000038

Qt.Key_F10 0x01000039

Qt.Key_F11 0x0100003a

Qt.Key_F12 0x0100003b

Qt.Key_F13 0x0100003c

Qt.Key_F14 0x0100003d

Qt.Key_F15 0x0100003e

Qt.Key_F16 0x0100003f

Qt.Key_F17 0x01000040

Qt.Key_F18 0x01000041

Qt.Key_F19 0x01000042

Qt.Key_F20 0x01000043

Qt.Key_F21 0x01000044

Qt.Key_F22 0x01000045

Qt.Key_F23 0x01000046

Qt.Key_F24 0x01000047

Qt.Key_F25 0x01000048

Qt.Key_F26 0x01000049

Qt.Key_F27 0x0100004a

Qt.Key_F28 0x0100004b

Qt.Key_F29 0x0100004c

Qt.Key_F30 0x0100004d

Qt.Key_F31 0x0100004e

Qt.Key_F32 0x0100004f

Qt.Key_F33 0x01000050

Qt.Key_F34 0x01000051

Qt.Key_F35 0x01000052

Qt.Key_Super_L 0x01000053

Qt.Key_Super_R 0x01000054

Qt.Key_Menu 0x01000055

Qt.Key_Hyper_L 0x01000056

Qt.Key_Hyper_R 0x01000057

Qt.Key_Help 0x01000058

Qt.Key_Direction_L 0x01000059

Qt.Key_Direction_R 0x01000060

Qt.Key_Space 0x20

Qt.Key_Any Key_Space

Qt.Key_Exclam 0x21

Qt.Key_QuoteDbl 0x22

Qt.Key_NumberSign 0x23

Qt.Key_Dollar 0x24

Qt.Key_Percent 0x25

Qt.Key_Ampersand 0x26

Qt.Key_Apostrophe 0x27

Qt.Key_ParenLeft 0x28

Qt.Key_ParenRight 0x29

Qt.Key_Asterisk 0x2a

Qt.Key_Plus 0x2b

Qt.Key_Comma 0x2c

Qt.Key_Minus 0x2d

Qt.Key_Period 0x2e

Qt.Key_Slash 0x2f

Qt.Key_0 0x30

Qt.Key_1 0x31

Qt.Key_2 0x32

Qt.Key_3 0x33

Qt.Key_4 0x34

Qt.Key_5 0x35

Qt.Key_6 0x36

Qt.Key_7 0x37

Qt.Key_8 0x38

Qt.Key_9 0x39

Qt.Key_Colon 0x3a

Qt.Key_Semicolon 0x3b

Qt.Key_Less 0x3c

Qt.Key_Equal 0x3d

Qt.Key_Greater 0x3e

Qt.Key_Question 0x3f

Qt.Key_At 0x40

Qt.Key_A 0x41

Qt.Key_B 0x42

Qt.Key_C 0x43

Qt.Key_D 0x44

Qt.Key_E 0x45

Qt.Key_F 0x46

Qt.Key_G 0x47

Qt.Key_H 0x48

Qt.Key_I 0x49

Qt.Key_J 0x4a

Qt.Key_K 0x4b

Qt.Key_L 0x4c

Qt.Key_M 0x4d

Qt.Key_N 0x4e

Qt.Key_O 0x4f

Qt.Key_P 0x50

Qt.Key_Q 0x51

Qt.Key_R 0x52

Qt.Key_S 0x53

Qt.Key_T 0x54

Qt.Key_U 0x55

Qt.Key_V 0x56

Qt.Key_W 0x57

Qt.Key_X 0x58

Qt.Key_Y 0x59

Qt.Key_Z 0x5a

Qt.Key_BracketLeft 0x5b

Qt.Key_Backslash 0x5c

Qt.Key_BracketRight 0x5d

Qt.Key_AsciiCircum 0x5e

Qt.Key_Underscore 0x5f

Qt.Key_QuoteLeft 0x60

Qt.Key_BraceLeft 0x7b

Qt.Key_Bar 0x7c

Qt.Key_BraceRight 0x7d

Qt.Key_AsciiTilde 0x7e

Qt.Key_nobreakspace 0x0a0

Qt.Key_exclamdown 0x0a1

Qt.Key_cent 0x0a2

Qt.Key_sterling 0x0a3

Qt.Key_currency 0x0a4

Qt.Key_yen 0x0a5

Qt.Key_brokenbar 0x0a6

Qt.Key_section 0x0a7

Qt.Key_diaeresis 0x0a8

Qt.Key_copyright 0x0a9

Qt.Key_ordfeminine 0x0aa

Qt.Key_guillemotleft 0x0ab

Qt.Key_notsign 0x0ac

Qt.Key_hyphen 0x0ad

Qt.Key_registered 0x0ae

Qt.Key_macron 0x0af

Qt.Key_degree 0x0b0

Qt.Key_plusminus 0x0b1

Qt.Key_twosuperior 0x0b2

Qt.Key_threesuperior 0x0b3

Qt.Key_acute 0x0b4

Qt.Key_mu 0x0b5

Qt.Key_paragraph 0x0b6

Qt.Key_periodcentered 0x0b7

Qt.Key_cedilla 0x0b8

Qt.Key_onesuperior 0x0b9

Qt.Key_masculine 0x0ba

Qt.Key_guillemotright 0x0bb

Qt.Key_onequarter 0x0bc

Qt.Key_onehalf 0x0bd

Qt.Key_threequarters 0x0be

Qt.Key_questiondown 0x0bf

Qt.Key_Agrave 0x0c0

Qt.Key_Aacute 0x0c1

Qt.Key_Acircumflex 0x0c2

Qt.Key_Atilde 0x0c3

Qt.Key_Adiaeresis 0x0c4

Qt.Key_Aring 0x0c5

Qt.Key_AE 0x0c6

Qt.Key_Ccedilla 0x0c7

Qt.Key_Egrave 0x0c8

Qt.Key_Eacute 0x0c9

Qt.Key_Ecircumflex 0x0ca

Qt.Key_Ediaeresis 0x0cb

Qt.Key_Igrave 0x0cc

Qt.Key_Iacute 0x0cd

Qt.Key_Icircumflex 0x0ce

Qt.Key_Idiaeresis 0x0cf

Qt.Key_ETH 0x0d0

Qt.Key_Ntilde 0x0d1

Qt.Key_Ograve 0x0d2

Qt.Key_Oacute 0x0d3

Qt.Key_Ocircumflex 0x0d4

Qt.Key_Otilde 0x0d5

Qt.Key_Odiaeresis 0x0d6

Qt.Key_multiply 0x0d7

Qt.Key_Ooblique 0x0d8

Qt.Key_Ugrave 0x0d9

Qt.Key_Uacute 0x0da

Qt.Key_Ucircumflex 0x0db

Qt.Key_Udiaeresis 0x0dc

Qt.Key_Yacute 0x0dd

Qt.Key_THORN 0x0de

Qt.Key_ssharp 0x0df

Qt.Key_division 0x0f7

Qt.Key_ydiaeresis 0x0ff

Qt.Key_Multi_key 0x01001120

Qt.Key_Codeinput 0x01001137

Qt.Key_SingleCandidate 0x0100113c

Qt.Key_MultipleCandidate 0x0100113d

Qt.Key_PreviousCandidate 0x0100113e

Qt.Key_Mode_switch 0x0100117e

Qt.Key_Kanji 0x01001121

Qt.Key_Muhenkan 0x01001122

Qt.Key_Henkan 0x01001123

Qt.Key_Romaji 0x01001124

Qt.Key_Hiragana 0x01001125

Qt.Key_Katakana 0x01001126

Qt.Key_Hiragana_Katakana 0x01001127

Qt.Key_Zenkaku 0x01001128

Qt.Key_Hankaku 0x01001129

Qt.Key_Zenkaku_Hankaku 0x0100112a

Qt.Key_Touroku 0x0100112b

Qt.Key_Massyo 0x0100112c

Qt.Key_Kana_Lock 0x0100112d

Qt.Key_Kana_Shift 0x0100112e

Qt.Key_Eisu_Shift 0x0100112f

Qt.Key_Eisu_toggle 0x01001130

Qt.Key_Hangul 0x01001131

Qt.Key_Hangul_Start 0x01001132

Qt.Key_Hangul_End 0x01001133

Qt.Key_Hangul_Hanja 0x01001134

Qt.Key_Hangul_Jamo 0x01001135

Qt.Key_Hangul_Romaja 0x01001136

Qt.Key_Hangul_Jeonja 0x01001138

Qt.Key_Hangul_Banja 0x01001139

Qt.Key_Hangul_PreHanja 0x0100113a

Qt.Key_Hangul_PostHanja 0x0100113b

Qt.Key_Hangul_Special 0x0100113f

Qt.Key_Dead_Grave 0x01001250

Qt.Key_Dead_Acute 0x01001251

Qt.Key_Dead_Circumflex 0x01001252

Qt.Key_Dead_Tilde 0x01001253

Qt.Key_Dead_Macron 0x01001254

Qt.Key_Dead_Breve 0x01001255

Qt.Key_Dead_Abovedot 0x01001256

Qt.Key_Dead_Diaeresis 0x01001257

Qt.Key_Dead_Abovering 0x01001258

Qt.Key_Dead_Doubleacute 0x01001259

Qt.Key_Dead_Caron 0x0100125a

Qt.Key_Dead_Cedilla 0x0100125b

Qt.Key_Dead_Ogonek 0x0100125c

Qt.Key_Dead_Iota 0x0100125d

Qt.Key_Dead_Voiced_Sound 0x0100125e

Qt.Key_Dead_Semivoiced_Sound 0x0100125f

Qt.Key_Dead_Belowdot 0x01001260

Qt.Key_Dead_Hook 0x01001261

Qt.Key_Dead_Horn 0x01001262

Qt.Key_Back 0x01000061

Qt.Key_Forward 0x01000062

Qt.Key_Stop 0x01000063

Qt.Key_Refresh 0x01000064

Qt.Key_VolumeDown 0x01000070

Qt.Key_VolumeMute 0x01000071

Qt.Key_VolumeUp 0x01000072

Qt.Key_BassBoost 0x01000073

Qt.Key_BassUp 0x01000074

Qt.Key_BassDown 0x01000075

Qt.Key_TrebleUp 0x01000076

Qt.Key_TrebleDown 0x01000077

Qt.Key_MediaPlay 0x01000080 A key setting the state of the media player to play

Qt.Key_MediaStop 0x01000081 A key setting the state of the media player to stop

Qt.Key_MediaPrevious 0x01000082

Qt.Key_MediaNext 0x01000083

Qt.Key_MediaRecord 0x01000084

Qt.Key_MediaPause 0x1000085 A key setting the state of the media player to pause (Note: not the pause/break key)

Qt.Key_MediaTogglePlayPause 0x1000086 A key to toggle the play/pause state in the media player (rather than setting an absolute state)

Qt.Key_HomePage 0x01000090

Qt.Key_Favorites 0x01000091

Qt.Key_Search 0x01000092

Qt.Key_Standby 0x01000093

Qt.Key_OpenUrl 0x01000094

Qt.Key_LaunchMail 0x010000a0

Qt.Key_LaunchMedia 0x010000a1

Qt.Key_Launch0 0x010000a2 On X11 this key is mapped to "My Computer" (XF86XK_MyComputer) key for legacy reasons.

Qt.Key_Launch1 0x010000a3 On X11 this key is mapped to "Calculator" (XF86XK_Calculator) key for legacy reasons.

Qt.Key_Launch2 0x010000a4 On X11 this key is mapped to XF86XK_Launch0 key for legacy reasons.

Qt.Key_Launch3 0x010000a5 On X11 this key is mapped to XF86XK_Launch1 key for legacy reasons.

Qt.Key_Launch4 0x010000a6 On X11 this key is mapped to XF86XK_Launch2 key for legacy reasons.

Qt.Key_Launch5 0x010000a7 On X11 this key is mapped to XF86XK_Launch3 key for legacy reasons.

Qt.Key_Launch6 0x010000a8 On X11 this key is mapped to XF86XK_Launch4 key for legacy reasons.

Qt.Key_Launch7 0x010000a9 On X11 this key is mapped to XF86XK_Launch5 key for legacy reasons.

Qt.Key_Launch8 0x010000aa On X11 this key is mapped to XF86XK_Launch6 key for legacy reasons.

Qt.Key_Launch9 0x010000ab On X11 this key is mapped to XF86XK_Launch7 key for legacy reasons.

Qt.Key_LaunchA 0x010000ac On X11 this key is mapped to XF86XK_Launch8 key for legacy reasons.

Qt.Key_LaunchB 0x010000ad On X11 this key is mapped to XF86XK_Launch9 key for legacy reasons.

Qt.Key_LaunchC 0x010000ae On X11 this key is mapped to XF86XK_LaunchA key for legacy reasons.

Qt.Key_LaunchD 0x010000af On X11 this key is mapped to XF86XK_LaunchB key for legacy reasons.

Qt.Key_LaunchE 0x010000b0 On X11 this key is mapped to XF86XK_LaunchC key for legacy reasons.

Qt.Key_LaunchF 0x010000b1 On X11 this key is mapped to XF86XK_LaunchD key for legacy reasons.

Qt.Key_LaunchG 0x0100010e On X11 this key is mapped to XF86XK_LaunchE key for legacy reasons.

Qt.Key_LaunchH 0x0100010f On X11 this key is mapped to XF86XK_LaunchF key for legacy reasons.

Qt.Key_MonBrightnessUp 0x010000b2

Qt.Key_MonBrightnessDown 0x010000b3

Qt.Key_KeyboardLightOnOff 0x010000b4

Qt.Key_KeyboardBrightnessUp 0x010000b5

Qt.Key_KeyboardBrightnessDown 0x010000b6

Qt.Key_PowerOff 0x010000b7

Qt.Key_WakeUp 0x010000b8

Qt.Key_Eject 0x010000b9

Qt.Key_ScreenSaver 0x010000ba

Qt.Key_WWW 0x010000bb

Qt.Key_Memo 0x010000bc

Qt.Key_LightBulb 0x010000bd

Qt.Key_Shop 0x010000be

Qt.Key_History 0x010000bf

Qt.Key_AddFavorite 0x010000c0

Qt.Key_HotLinks 0x010000c1

Qt.Key_BrightnessAdjust 0x010000c2

Qt.Key_Finance 0x010000c3

Qt.Key_Community 0x010000c4

Qt.Key_AudioRewind 0x010000c5

Qt.Key_BackForward 0x010000c6

Qt.Key_ApplicationLeft 0x010000c7

Qt.Key_ApplicationRight 0x010000c8

Qt.Key_Book 0x010000c9

Qt.Key_CD 0x010000ca

Qt.Key_Calculator 0x010000cb On X11 this key is not mapped for legacy reasons. Use Qt.Key_Launch1 instead.

Qt.Key_ToDoList 0x010000cc

Qt.Key_ClearGrab 0x010000cd

Qt.Key_Close 0x010000ce

Qt.Key_Copy 0x010000cf

Qt.Key_Cut 0x010000d0

Qt.Key_Display 0x010000d1

Qt.Key_DOS 0x010000d2

Qt.Key_Documents 0x010000d3

Qt.Key_Excel 0x010000d4

Qt.Key_Explorer 0x010000d5

Qt.Key_Game 0x010000d6

Qt.Key_Go 0x010000d7

Qt.Key_iTouch 0x010000d8

Qt.Key_LogOff 0x010000d9

Qt.Key_Market 0x010000da

Qt.Key_Meeting 0x010000db

Qt.Key_MenuKB 0x010000dc

Qt.Key_MenuPB 0x010000dd

Qt.Key_MySites 0x010000de

Qt.Key_News 0x010000df

Qt.Key_OfficeHome 0x010000e0

Qt.Key_Option 0x010000e1

Qt.Key_Paste 0x010000e2

Qt.Key_Phone 0x010000e3

Qt.Key_Calendar 0x010000e4

Qt.Key_Reply 0x010000e5

Qt.Key_Reload 0x010000e6

Qt.Key_RotateWindows 0x010000e7

Qt.Key_RotationPB 0x010000e8

Qt.Key_RotationKB 0x010000e9

Qt.Key_Save 0x010000ea

Qt.Key_Send 0x010000eb

Qt.Key_Spell 0x010000ec

Qt.Key_SplitScreen 0x010000ed

Qt.Key_Support 0x010000ee

Qt.Key_TaskPane 0x010000ef

Qt.Key_Terminal 0x010000f0

Qt.Key_Tools 0x010000f1

Qt.Key_Travel 0x010000f2

Qt.Key_Video 0x010000f3

Qt.Key_Word 0x010000f4

Qt.Key_Xfer 0x010000f5

Qt.Key_ZoomIn 0x010000f6

Qt.Key_ZoomOut 0x010000f7

Qt.Key_Away 0x010000f8

Qt.Key_Messenger 0x010000f9

Qt.Key_WebCam 0x010000fa

Qt.Key_MailForward 0x010000fb

Qt.Key_Pictures 0x010000fc

Qt.Key_Music 0x010000fd

Qt.Key_Battery 0x010000fe

Qt.Key_Bluetooth 0x010000ff

Qt.Key_WLAN 0x01000100

Qt.Key_UWB 0x01000101

Qt.Key_AudioForward 0x01000102

Qt.Key_AudioRepeat 0x01000103

Qt.Key_AudioRandomPlay 0x01000104

Qt.Key_Subtitle 0x01000105

Qt.Key_AudioCycleTrack 0x01000106

Qt.Key_Time 0x01000107

Qt.Key_Hibernate 0x01000108

Qt.Key_View 0x01000109

Qt.Key_TopMenu 0x0100010a

Qt.Key_PowerDown 0x0100010b

Qt.Key_Suspend 0x0100010c

Qt.Key_ContrastAdjust 0x0100010d

Qt.Key_MediaLast 0x0100ffff

Qt.Key_unknown 0x01ffffff

Qt.Key_Call 0x01100004 A key to answer or initiate a call (see Qt.Key_ToggleCallHangup for a key to toggle current call state)

Qt.Key_Camera 0x01100020 A key to activate the camera shutter

Qt.Key_CameraFocus 0x01100021 A key to focus the camera

Qt.Key_Context1 0x01100000

Qt.Key_Context2 0x01100001

Qt.Key_Context3 0x01100002

Qt.Key_Context4 0x01100003

Qt.Key_Flip 0x01100006

Qt.Key_Hangup 0x01100005 A key to end an ongoing call (see Qt.Key_ToggleCallHangup for a key to toggle current call state)

Qt.Key_No 0x01010002

Qt.Key_Select 0x01010000

Qt.Key_Yes 0x01010001

Qt.Key_ToggleCallHangup 0x01100007 A key to toggle the current call state (ie. either answer, or hangup) depending on current call state

Qt.Key_VoiceDial 0x01100008

Qt.Key_LastNumberRedial 0x01100009

Qt.Key_Execute 0x01020003

Qt.Key_Printer 0x01020002

Qt.Key_Play 0x01020005

Qt.Key_Sleep 0x01020004

Qt.Key_Zoom 0x01020006

Qt.Key_Cancel 0x01020001

Value:
{"aqua": [0, 255, 255], "cornflower": [100, 149, 237], "crimson": [220\
, 20, 60], "fuchsia": [255, 0, 255], "indigo": [75, 0, 130], "lime": [\
50, 205, 50], "silver": [192, 192, 192], "ghost white": [248, 248, 255\
], "snow": [255, 250, 250], "ghostwhite": [248, 248, 255], "white smok\
e": [245, 245, 245], "whitesmoke": [245, 245, 245], "gainsboro": [220,\
 220, 220], "floral white": [255, 250, 240], "floralwhite": [255, 250,\
 240], "old lace": [253, 245, 230], "oldlace": [253, 245, 230], "linen\
": [250, 240, 230], "antique white": [250, 235, 215], "antiquewhite": \
...