Main GUI class
- class discopygal.gui.gui.GUI
The RMP GUI class, handles all the boilerplate code for having GUI capable Qt projects
Any GUI application should derive from this class, and set somewhere in the layout the property ‘graphicsView’ to a QGraphicsView. The function you should override in this case is setupUi()
- add_circle_segment(radius: float, center_x: float, center_y: float, start_angle: float, end_angle: float, clockwise, fill_color=19, line_color=2)
Add a circle segment to the scene and return the object associated with it
- Parameters:
radius (
float
) – radius of circlecenter_x (
float
) – x position of circle centercenter_y (
float
) – y position of circle centerstart_angle (
float
) – start angle of circle segmentend_angle (
float
) – end angle of circle segmentclockwise (
bool
) – draw from start to end clockwise or counter-clockwisefill_color (
QtGui.QColor
) – color of the interior of circleline_color (
QtGui.QColor
) – color of the circle segment
- Returns:
circle segment
- Return type:
- add_disc(r, x, y, fill_color=2, line_color=2)
Add a disc to the scene with radius r centered at (x, y) and return the object associated with it
- Parameters:
r (
float
) – radius of discx (
float
) – x position of center of discy (
float
) – y position of center of discfill_color (
QtGui.QColor
) – color of the interior of discline_color (
QtGui.QColor
) – color of the boundary of disc
- Returns:
disc
- Return type:
- add_disc_robot(r, x, y, text='', fill_color=2, line_color=2)
Add a disc robot to the scene with radius r centered at (x, y) and return the object associated with it
- Parameters:
r (
float
) – radius of discx (
float
) – x position of center of discy (
float
) – y position of center of disctext (
str
) – label of the robotfill_color (
QtGui.QColor
) – color of the interior of disc
- Returns:
disc robot
- Return type:
- add_polygon(points, fill_color=2, line_color=2, text='', pos=None)
Add a polygon to the scene and return the object associated with it
- Parameters:
points (list<(
float
,float
)>) – list of points of polygonfill_color (
QtGui.QColor
) – color of the interior of polygonline_color (
QtGui.QColor
) – color of the boundary of polygonpos (
QtCore.QPointF
) – initial position of polygon (used for animation). If none first vertex is chosen.
- Returns:
polygon
- Return type:
- add_polygon_with_holes(points, holes, fill_color=2, line_color=19)
Add a polygon with holes to the scene and return the object associated with it
- Parameters:
points (list<(
float
,float
)>) – list of points of polygonholes (list<list<(
float
,float
)>>) – list of holes, each hole is a list of pointsfill_color (
QtGui.QColor
) – color of the interior of polygonline_color (
QtGui.QColor
) – color of the boundary of polygon
- Returns:
polygon
- Return type:
- add_segment(x1, y1, x2, y2, line_color=2, opacity=1.0)
Add a segment to the scene and return the object associated with it
- Parameters:
x1 (
float
) – x1 position of start endpointy1 (
float
) – y1 position of start endpointx2 (
float
) – x2 position of end endpointy2 (
float
) – y2 position of end endpointline_color (
QtGui.QColor
) – color of the segmentopacity (
float
) – opacity of the segment
- Returns:
segment
- Return type:
- add_segment_angle(x1, y1, length, angle, line_color=2)
Add an angled segment to the scene and return the object associated with it
- Parameters:
x1 (
float
) – x1 position of start endpointy1 (
float
) – y1 position of start endpointlength (
float
) – length of segmentangle (
float
) – angle (in radians) of segmentline_color (
QtGui.QColor
) – color of the segment
- Returns:
angled segment
- Return type:
- add_text(text, x, y, size, color=2)
Add a text label to the scene and return the object associated with it
- Parameters:
text (
str
) – text labelx (
float
) – x position of text labely (
float
) – y position of text labelsize (
int
) – size of labelcolor (
QtGui.QColor
) – color of the label
- Returns:
text label
- Return type:
- animation_finished()
Function that is called when the ‘finished’ signal is fired Empties the queue and calls the finished action defined by the program
- animation_finished_action()
Function reference that is called when animation is finished
- base_line_width = 1.0
Base (default) line width
- base_text_size = 2.0
Base (default) text size
- clear_scene()
Clear the scene of all objects
- empty_queue()
Empty the animation queue
- get_field(key)
Get the text of field with key <key> in the GUI
- Parameters:
key (
str
) – key of line edit- Returns:
text of selected line edit
- Return type:
str
- graphicsView = None
QGraphicsView widget where everything is drawn
- height = 1000
Screen height
- is_queue_paused()
Return true if the queue is paused.
- Returns:
True
if paused- Return type:
bool
- is_queue_playing()
Return true if the queue is paused.
- Returns:
True
if paused- Return type:
bool
- labels = {}
Dictionary of all UI labels
- lineEdits = {}
Dictionary of all UI line inputs
- linear_translation_animation(obj, ix, iy, x, y, duration=1000)
Create a new linear translation animation for obj starting at ix, iy and ending at x, y
- Parameters:
obj (
QObject
) – object to animateix (
float
) – x position of startiy (
float
) – y position of startx (
float
) – x position of endy (
float
) – y position of endduration (
int
) – duration of animation
- Returns:
animation object
- Return type:
QPropertyAnimation
- mainWindow = None
MainWindowPlus main window
- parallel_animation(*animations)
Create an animation from a set of animations that will run in parallel
- Parameters:
*animations (
QPropertyAnimation
,QPropertyAnimation
, …) – the animations we want to run in parallel- Returns:
parallel animation group object
- Return type:
QParallelAnimationGroup
- pause_animation(duration=1000)
Create an animation that does nothing
- Parameters:
duration (
int
) – duration of animation- Returns:
animation object
- Return type:
QPropertyAnimation
- pause_queue()
Pause an animation
- play_queue()
Play (and empty) the animation queue (Either play from start or resume a paused animation)
- progressBars = {}
Dictionary of all UI progress bars
- pushButtons = {}
Dictionary of all UI push buttons
- queue_animation(*animations)
Add an animation to the animation queue
- Parameters:
*animations (
QPropertyAnimation
,QPropertyAnimation
, …) – the animations we want to add to queue
- redraw()
Redraw the scene with updated parameters
- scene = None
GraphicsScenePlus scene that contains all the objects
- segment_angle_animation(obj, ix, iy, ia, x, y, a, clockwise, duration=2000)
Create an animation for angle segment starting at ix, iy with angle ia ending at x, y, angle a
- Parameters:
obj (
QObject
) – object to animateix (
float
) – x position of start segmentiy (
float
) – y position of start segmentia (
float
) – rotation of the start segmentx (
float
) – x position of end segmenty (
float
) – y position of end segmenta (
float
) – rotation of the end segmentclockwise (
bool
) – rotate the segment clocwiseduration (
int
) – duration of animation
- Returns:
animation object
- Return type:
QPropertyAnimation
- sequence = None
QSequentialAnimationGroup sequence of animation
- set_animation_finished_action(action)
Set the function to be called when the animation finishes playing
- Parameters:
action (function<()->()>) – action to be called when animation finished
- set_button_text(key, s)
Set the text of the button with key <key> in the GUI
- Parameters:
key (
str
) – key of the pushbuttons (
str
) – new label of pushbutton
- set_field(key, s)
Set the text of field with key <key> in the GUI
- Parameters:
key (
str
) – key of line edits (
str
) – new text for line edit
- set_label(key, s, color=2)
Set the text of label with key <key> in the GUI
- Parameters:
key (
str
) – key of labels (
str
) – new label textcolor (
QColor
) – color of label
- set_logic(key, logic)
Set the function to be called when the button with key <key> in the GUI is pressed
- Parameters:
key (
str
) – key of pushbuttonlogic (function<()->()>) – function that is connected to the button
- set_program_name(s)
Set the program’s name (title of the window)
- Parameters:
s (
str
) – new window title
- set_progressbar_value(key, n: int)
Set the value of the progressBar with key <key>
- Parameters:
key (
str
) – key of the progress barn (
int
) – value of the progress bar
- setupUi()
Setup the UI layout of the application. Should be overridded by any GUI application and define a custom layout.
- stop_queue()
Stop (and empty) the animation queue
- text_animation(obj, text: int)
Create an animation that changes the text of an object
- Parameters:
obj (
QObject
) – object to animatetext (
int
) – the new label we want to set
- Returns:
animation object
- Return type:
QPropertyAnimation
- translation_animation(obj, func, duration=1000)
Create a general translation animation for obj. func is path from the unit interval I to R^2
- Parameters:
obj (
QObject
) – object to animatefunc (
function
<I -> R^2>) – a function representing a path from unit interal I to R^2duration (
int
) – duration of animation
- Returns:
animation object
- Return type:
QPropertyAnimation
- value_animation(obj, v_begin, v_end, duration=1000)
Create an animation that changes the value of an object
- Parameters:
obj (
QObject
) – object to animatev_begin (
object
) – the start value of the objectv_end (
object
) – the end value of the objectduration (
int
) – duration of animation
- Returns:
animation object
- Return type:
QPropertyAnimation
- visibility_animation(obj, visible)
Create an animation the changes the visibility of an object
- Parameters:
obj (
QObject
) – object to animatevisible (
bool
) – the visibility we wat to set
- Returns:
animation object
- Return type:
QPropertyAnimation
- width = 1600
Screen width
- zoom = 1.0
View zoom