klampt.vis.qtbackend module

klampt.vis.backends.qtbackend.toGlutButton(button)[source]
klampt.vis.backends.qtbackend.toModifierList(modifiers)[source]
class klampt.vis.backends.qtbackend.QtGLWindow(name='OpenGL window', parent=None)[source]

Bases: PyQt5.QtOpenGL.QGLWidget

A basic OpenGL window using Qt. Should not be used directly, use the functions in QtBackend instead.

name

title of the window (only has an effect before calling run())

Type

str

width, height

width/height of the window in screen units. These are initialized from the GLProgram viewport on run(), but thereafter Qt manages them. After, the user must call resize(w,h) to change the dimensions.

Type

int

devwidth, devheight

width/height of the window in OpenGL device pixel units (Note that these may be different from the screen dimensions due to Retina displays)

Type

int

idlesleep_signal(*args, **kwargs)
refresh_signal(*args, **kwargs)
reshape_signal(*args, **kwargs)
setProgram(program)[source]

User will call this to set up the program variable

setParent(self, QWidget)[source]

setParent(self, QWidget, Union[Qt.WindowFlags, Qt.WindowType])

initialize()[source]

Opens a window and initializes. Called internally, and must be in the visualization thread.

hide()[source]

Hides the window, if already shown

show()[source]

Restores from a previous hide call

close()[source]

Qt thread should call close() after this widget should be closed down to stop any existing Qt callbacks.

add_action(hook, short_text, key=None, description=None)[source]

This is called by the user to add actions to the menu bar.

Parameters
  • hook (function) – a python callback function, taking no arguments, called when the action is triggered.

  • short_text (str) – the text shown in the menu bar.

  • key (str, optional) – a shortcut keyboard command (can be ‘k’ or ‘Ctrl+k’).

  • description (str, optional) – if provided, this is a tooltip that shows up when the user hovers their mouse over the menu item.

sizeHint(self)QSize[source]
initializeGL(self)[source]
QtGLWindow.resizeGL(self, int, int)[source]
paintGL(self)[source]
mouseMoveEvent(self, QMouseEvent)[source]
mousePressEvent(self, QMouseEvent)[source]
mouseReleaseEvent(self, QMouseEvent)[source]
keyPressEvent(self, QKeyEvent)[source]
keyReleaseEvent(self, QKeyEvent)[source]
modifiers()[source]

Call this to retrieve modifiers. Called by frontend.

do_idlesleep(duration)[source]
idlesleep(duration=inf)[source]

Externally callable. Sleeps the idle callback for t seconds. If t is not provided, the idle callback is slept forever

do_refresh()[source]
refresh()[source]

Externally callable. Requests a refresh of the window

resizeEvent(event)[source]

Called internally by Qt when Qt resizes the window

do_reshape(w, h)[source]
reshape(w, h)[source]

Externally callable. Reshapes the window

draw_text(point, text, size=12, color=None)[source]

Renders text at the given point (may be 2d or 3d). Frontend should call this to draw text in either the display or display_screen method.

Parameters
  • point (list of floats) – either a 2d or 3d point at which to draw the text

  • text (str) – the text to draw

  • size (int, optional) – if given, it renders a font in the given size.

  • color (list of 3 floats or list of 4 floats) –

class klampt.vis.backends.qtbackend.QtBackend[source]

Bases: object

Backend implementation of OpenGL visualization using Qt. Usually hidden from the user.

To use as a standalone program: Set up your GLProgramInterface, call createWindow to construct new windows and setProgram to set the GLProgram used in that window. Then call run() to start the Qt main loop.

initialize(program_name)[source]
createWindow(name, parent=None)[source]
run()[source]

Starts the main loop

kill()[source]