text stringlengths 81 112k |
|---|
Match pattern against the output of func, passing the results as
floats to func. If anything fails, return None.
def _get_dpi_from(cmd, pattern, func):
"""Match pattern against the output of func, passing the results as
floats to func. If anything fails, return None.
"""
try:
out, _ = run... |
Get screen DPI from the OS
Parameters
----------
raise_error : bool
If True, raise an error if DPI could not be determined.
Returns
-------
dpi : float
Dots per inch of the primary screen.
def get_dpi(raise_error=True):
"""Get screen DPI from the OS
Parameters
---... |
Set the data
Parameters
----------
adjacency_mat : ndarray | None
The adjacency matrix.
**kwargs : dict
Keyword arguments to pass to the arrows.
def set_data(self, adjacency_mat=None, **kwargs):
"""Set the data
Parameters
----------
... |
Calculate a size
Parameters
----------
rect : rectangle
The rectangle.
orientation : str
Either "bottom" or "top".
def calc_size(rect, orientation):
"""Calculate a size
Parameters
----------
rect : rectangle
The recta... |
Try to reduce dtype up to a given level when it is possible
dtype = [ ('vertex', [('x', 'f4'), ('y', 'f4'), ('z', 'f4')]),
('normal', [('x', 'f4'), ('y', 'f4'), ('z', 'f4')]),
('color', [('r', 'f4'), ('g', 'f4'), ('b', 'f4'),
('a', 'f4')])]
level ... |
Generate the GLSL code needed to retrieve fake uniform values from a
texture.
uniforms : sampler2D
Texture to fetch uniforms from
uniforms_shape: vec3
Size of texture (width,height,count) where count is the number of float
to be fetched.
collection_index: float
Attribu... |
Generate vertices & indices for a filled and outlined cube
Returns
-------
vertices : array
Array of vertices suitable for use as a VertexBuffer.
filled : array
Indices to use to produce a filled cube.
outline : array
Indices to use to produce an outline of the cube.
def cr... |
Generate vertices & indices for a filled and outlined plane.
Parameters
----------
width : float
Plane width.
height : float
Plane height.
width_segments : int
Plane segments count along the width.
height_segments : float
Plane segments count along the height.
... |
Generate vertices & indices for a filled and outlined box.
Parameters
----------
width : float
Box width.
height : float
Box height.
depth : float
Box depth.
width_segments : int
Box segments count along the width.
height_segments : float
Box segments... |
Create a sphere
Parameters
----------
rows : int
Number of rows (for method='latitude' and 'cube').
cols : int
Number of columns (for method='latitude' and 'cube').
depth : int
Number of depth segments (for method='cube').
radius : float
Sphere radius.
offset... |
Create a cylinder
Parameters
----------
rows : int
Number of rows.
cols : int
Number of columns.
radius : tuple of float
Cylinder radii.
length : float
Length of the cylinder.
offset : bool
Rotate each row by half a column.
Returns
-------
... |
Create a cone
Parameters
----------
cols : int
Number of faces.
radius : float
Base cone radius.
length : float
Length of the cone.
Returns
-------
cone : MeshData
Vertices and faces computed for a cone surface.
def create_cone(cols, radius=1.0, length=... |
Create a 3D arrow using a cylinder plus cone
Parameters
----------
rows : int
Number of rows.
cols : int
Number of columns.
radius : float
Base cylinder radius.
length : float
Length of the arrow.
cone_radius : float
Radius of the cone base.
... |
Generate vertices and indices for an implicitly connected mesh.
The intention is that this makes it simple to generate a mesh
from meshgrid data.
Parameters
----------
xs : ndarray
A 2d array of x coordinates for the vertices of the mesh. Must
have the same dimensions as ys and zs.... |
Generate the vertices for straight lines between nodes.
If it is a directed graph, it also generates the vertices which can be
passed to an :class:`ArrowVisual`.
Parameters
----------
adjacency_mat : array
The adjacency matrix of the graph
node_coords : array
The current coordi... |
Normalize the given coordinate list to the range [0, `scale`].
Parameters
----------
pos : array
Coordinate list
scale : number
The upperbound value for the coordinates range
Returns
-------
pos : array
The rescaled (normalized) coordinates in the range [0, `scale`]... |
Get unique FT_Library handle
def get_handle():
'''
Get unique FT_Library handle
'''
global __handle__
if not __handle__:
__handle__ = FT_Library()
error = FT_Init_FreeType(byref(__handle__))
if error:
raise RuntimeError(hex(error))
return __handle__ |
Return the version of the FreeType library being used as a tuple of
( major version number, minor version number, patch version number )
def version():
'''
Return the version of the FreeType library being used as a tuple of
( major version number, minor version number, patch version number )
'''
... |
Factory function for creating new cameras using a string name.
Parameters
----------
cam_type : str
May be one of:
* 'panzoom' : Creates :class:`PanZoomCamera`
* 'turntable' : Creates :class:`TurntableCamera`
* None : Creates :class:`Camera`
Notes
-----... |
Set the position of the datapoints
def set_data_values(self, label, x, y, z):
"""
Set the position of the datapoints
"""
# TODO: avoid re-allocating an array every time
self.layers[label]['data'] = np.array([x, y, z]).transpose()
self._update() |
mode: string
- "raw" (speed: fastest, size: small, output: ugly, no dash,
no thickness)
- "agg" (speed: slower, size: medium, output: perfect, no dash)
def SegmentCollection(mode="agg-fast", *args, **kwargs):
"""
mode: string
- "raw" (speed: fastest, size: small, output: ugly, ... |
Computes the parameterization of a parametric surface
func: function(u,v)
Parametric function used to build the surface
def surface(func, umin=0, umax=2 * np.pi, ucount=64, urepeat=1.0,
vmin=0, vmax=2 * np.pi, vcount=64, vrepeat=1.0):
"""
Computes the parameterization of a parametric s... |
mode: string
- "raw" (speed: fastest, size: small, output: ugly)
- "agg" (speed: fast, size: small, output: beautiful)
def PointCollection(mode="raw", *args, **kwargs):
"""
mode: string
- "raw" (speed: fastest, size: small, output: ugly)
- "agg" (speed: fast, size: small... |
Append new data to the right side of every line strip and remove
as much data from the left.
Parameters
----------
data : array-like
A data array to append.
def roll_data(self, data):
"""Append new data to the right side of every line strip and remove
... |
Set the complete data for a single line strip.
Parameters
----------
index : int
The index of the line strip to be replaced.
data : array-like
The data to assign to the selected line strip.
def set_data(self, index, data):
"""Set the complete dat... |
Create a program and add it to this MultiProgram.
It is the caller's responsibility to keep a reference to the returned
program.
The *name* must be unique, but is otherwise arbitrary and used for
debugging purposes.
def add_program(self, name=None):
"""Create... |
New program was added to the multiprogram; update items in the
shader.
def _new_program(self, p):
"""New program was added to the multiprogram; update items in the
shader.
"""
for k, v in self._set_items.items():
getattr(p, self._shader)[k] = v |
Attach this tranform to a canvas
Parameters
----------
canvas : instance of Canvas
The canvas.
def attach(self, canvas):
"""Attach this tranform to a canvas
Parameters
----------
canvas : instance of Canvas
The canvas.
"""
... |
Resize handler
Parameters
----------
event : instance of Event
The event.
def on_resize(self, event):
"""Resize handler
Parameters
----------
event : instance of Event
The event.
"""
if self._aspect is None:
r... |
Mouse move handler
Parameters
----------
event : instance of Event
The event.
def on_mouse_move(self, event):
"""Mouse move handler
Parameters
----------
event : instance of Event
The event.
"""
if event.is_dragging:
... |
Mouse wheel handler
Parameters
----------
event : instance of Event
The event.
def on_mouse_wheel(self, event):
"""Mouse wheel handler
Parameters
----------
event : instance of Event
The event.
"""
self.zoom(np.exp(event.... |
Calculates and returns the tangents, normals and binormals for
the tube.
def _frenet_frames(points, closed):
'''Calculates and returns the tangents, normals and binormals for
the tube.'''
tangents = np.zeros((len(points), 3))
normals = np.zeros((len(points), 3))
epsilon = 0.0001
# Compute... |
Depth of the smallest HEALPix cells found in the MOC instance.
def max_order(self):
"""
Depth of the smallest HEALPix cells found in the MOC instance.
"""
# TODO: cache value
combo = int(0)
for iv in self._interval_set._intervals:
combo |= iv[0] | iv[1]
... |
Intersection between the MOC instance and other MOCs.
Parameters
----------
another_moc : `~mocpy.moc.MOC`
The MOC used for performing the intersection with self.
args : `~mocpy.moc.MOC`
Other additional MOCs to perform the intersection with.
Returns
... |
Union between the MOC instance and other MOCs.
Parameters
----------
another_moc : `~mocpy.moc.MOC`
The MOC used for performing the union with self.
args : `~mocpy.moc.MOC`
Other additional MOCs to perform the union with.
Returns
-------
... |
Difference between the MOC instance and other MOCs.
Parameters
----------
another_moc : `~mocpy.moc.MOC`
The MOC used that will be substracted to self.
args : `~mocpy.moc.MOC`
Other additional MOCs to perform the difference with.
Returns
-------
... |
Returns all the pixels neighbours of ``ipix``
def _neighbour_pixels(hp, ipix):
"""
Returns all the pixels neighbours of ``ipix``
"""
neigh_ipix = np.unique(hp.neighbours(ipix).ravel())
# Remove negative pixel values returned by `~astropy_healpix.HEALPix.neighbours`
retur... |
Creates a MOC from a numpy array representing the HEALPix cells.
Parameters
----------
cells : `numpy.ndarray`
Must be a numpy structured array (See https://docs.scipy.org/doc/numpy-1.15.0/user/basics.rec.html).
The structure of a cell contains 3 attributes:
... |
Creates a MOC from a dictionary of HEALPix cell arrays indexed by their depth.
Parameters
----------
json_moc : dict(str : [int]
A dictionary of HEALPix cell arrays indexed by their depth.
Returns
-------
moc : `~mocpy.moc.MOC` or `~mocpy.tmoc.TimeMOC`
... |
Generator giving the NUNIQ HEALPix pixels of the MOC.
Returns
-------
uniq :
the NUNIQ HEALPix pixels iterator
def _uniq_pixels_iterator(self):
"""
Generator giving the NUNIQ HEALPix pixels of the MOC.
Returns
-------
uniq :
the ... |
Loads a MOC from a FITS file.
The specified FITS file must store the MOC (i.e. the list of HEALPix cells it contains) in a binary HDU table.
Parameters
----------
filename : str
The path to the FITS file.
Returns
-------
result : `~mocpy.moc.MOC` or... |
Create a MOC from a str.
This grammar is expressed is the `MOC IVOA <http://ivoa.net/documents/MOC/20190215/WD-MOC-1.1-20190215.pdf>`__
specification at section 2.3.2.
Parameters
----------
value : str
The MOC as a string following the grammar rules.
... |
Serializes a MOC to the JSON format.
Parameters
----------
uniq : `~numpy.ndarray`
The array of HEALPix cells representing the MOC to serialize.
Returns
-------
result_json : {str : [int]}
A dictionary of HEALPix cell lists indexed by their depth... |
Serializes a MOC to the STRING format.
HEALPix cells are separated by a comma. The HEALPix cell at order 0 and number 10 is encoded
by the string: "0/10", the first digit representing the depth and the second the HEALPix cell number
for this depth. HEALPix cells next to each other within a spec... |
Serializes a MOC to the FITS format.
Parameters
----------
uniq : `numpy.ndarray`
The array of HEALPix cells representing the MOC to serialize.
optional_kw_dict : dict
Optional keywords arguments added to the FITS header.
Returns
-------
... |
Serializes the MOC into a specific format.
Possible formats are FITS, JSON and STRING
Parameters
----------
format : str
'fits' by default. The other possible choice is 'json' or 'str'.
optional_kw_dict : dict
Optional keywords arguments added to the FIT... |
Writes the MOC to a file.
Format can be 'fits' or 'json', though only the fits format is officially supported by the IVOA.
Parameters
----------
path : str, optional
The path to the file to save the MOC in.
format : str, optional
The format in which the ... |
Degrades the MOC instance to a new, less precise, MOC.
The maximum depth (i.e. the depth of the smallest HEALPix cells that can be found in the MOC) of the
degraded MOC is set to ``new_order``.
Parameters
----------
new_order : int
Maximum depth of the output degra... |
Set Screen Name
def set_name(self, name):
""" Set Screen Name """
self.name = name
self.server.request("screen_set %s name %s" % (self.ref, self.name)) |
Set Screen Width
def set_width(self, width):
""" Set Screen Width """
if width > 0 and width <= self.server.server_info.get("screen_width"):
self.width = width
self.server.request("screen_set %s wid %i" % (self.ref, self.width)) |
Set Screen Height
def set_height(self, height):
""" Set Screen Height """
if height > 0 and height <= self.server.server_info.get("screen_height"):
self.height = height
self.server.request("screen_set %s hgt %i" % (self.ref, self.height)) |
Set Screen Cursor X Position
def set_cursor_x(self, x):
""" Set Screen Cursor X Position """
if x >= 0 and x <= self.server.server_info.get("screen_width"):
self.cursor_x = x
self.server.request("screen_set %s cursor_x %i" % (self.ref, self.cursor_x)) |
Set Screen Cursor Y Position
def set_cursor_y(self, y):
""" Set Screen Cursor Y Position """
if y >= 0 and y <= self.server.server_info.get("screen_height"):
self.cursor_y = y
self.server.request("screen_set %s cursor_y %i" % (self.ref, self.cursor_y)) |
Set Screen Change Interval Duration
def set_duration(self, duration):
""" Set Screen Change Interval Duration """
if duration > 0:
self.duration = duration
self.server.request("screen_set %s duration %i" % (self.ref, (self.duration * 8))) |
Set Screen Timeout Duration
def set_timeout(self, timeout):
""" Set Screen Timeout Duration """
if timeout > 0:
self.timeout = timeout
self.server.request("screen_set %s timeout %i" % (self.ref, (self.timeout * 8))) |
Set Screen Priority Class
def set_priority(self, priority):
""" Set Screen Priority Class """
if priority in ["hidden", "background", "info", "foreground", "alert", "input"]:
self.priority = priority
self.server.request("screen_set %s priority %s" % (self.ref, self.priority)) |
Set Screen Backlight Mode
def set_backlight(self, state):
""" Set Screen Backlight Mode """
if state in ["on", "off", "toggle", "open", "blink", "flash"]:
self.backlight = state
self.server.request("screen_set %s backlight %s" % (self.ref, self.backlight)) |
Set Screen Heartbeat Display Mode
def set_heartbeat(self, state):
""" Set Screen Heartbeat Display Mode """
if state in ["on", "off", "open"]:
self.heartbeat = state
self.server.request("screen_set %s heartbeat %s" % (self.ref, self.heartbeat)) |
Set Screen Cursor Mode
def set_cursor(self, cursor):
""" Set Screen Cursor Mode """
if cursor in ["on", "off", "under", "block"]:
self.cursor = cursor
self.server.request("screen_set %s cursor %s" % (self.ref, self.cursor)) |
Clear Screen
def clear(self):
""" Clear Screen """
widgets.StringWidget(self, ref="_w1_", text=" " * 20, x=1, y=1)
widgets.StringWidget(self, ref="_w2_", text=" " * 20, x=1, y=2)
widgets.StringWidget(self, ref="_w3_", text=" " * 20, x=1, y=3)
widgets.StringWidget(self, ref="_w4_... |
Add String Widget
def add_string_widget(self, ref, text="Text", x=1, y=1):
""" Add String Widget """
if ref not in self.widgets:
widget = widgets.StringWidget(screen=self, ref=ref, text=text, x=x, y=y)
self.widgets[ref] = widget
return self.widgets[ref] |
Add Title Widget
def add_title_widget(self, ref, text="Title"):
""" Add Title Widget """
if ref not in self.widgets:
widget = widgets.TitleWidget(screen=self, ref=ref, text=text)
self.widgets[ref] = widget
return self.widgets[ref] |
Add Horizontal Bar Widget
def add_hbar_widget(self, ref, x=1, y=1, length=10):
""" Add Horizontal Bar Widget """
if ref not in self.widgets:
widget = widgets.HBarWidget(screen=self, ref=ref, x=x, y=y, length=length)
self.widgets[ref] = widget
return self.widgets[ref... |
Add Vertical Bar Widget
def add_vbar_widget(self, ref, x=1, y=1, length=10):
""" Add Vertical Bar Widget """
if ref not in self.widgets:
widget = widgets.VBarWidget(screen=self, ref=ref, x=x, y=y, length=length)
self.widgets[ref] = widget
return self.widgets[ref] |
Add Frame Widget
def add_frame_widget(self, ref, left=1, top=1, right=20, bottom=1, width=20, height=4, direction="h", speed=1):
""" Add Frame Widget """
if ref not in self.widgets:
widget = widgets.FrameWidget(
screen=self, ref=ref, left=left, top=top, right=right, bottom=... |
Add Number Widget
def add_number_widget(self, ref, x=1, value=1):
""" Add Number Widget """
if ref not in self.widgets:
widget = widgets.NumberWidget(screen=self, ref=ref, x=x, value=value)
self.widgets[ref] = widget
return self.widgets[ref] |
Delete/Remove A Widget
def del_widget(self, ref):
""" Delete/Remove A Widget """
self.server.request("widget_del %s %s" % (self.name, ref))
del(self.widgets[ref]) |
Orbits the camera around the center position.
Parameters
----------
azim : float
Angle in degrees to rotate horizontally around the center point.
elev : float
Angle in degrees to rotate vertically around the center point.
def orbit(self, azim, elev):
"""... |
Update rotation parmeters based on mouse movement
def _update_rotation(self, event):
"""Update rotation parmeters based on mouse movement"""
p1 = event.mouse_event.press_event.pos
p2 = event.mouse_event.pos
if self._event_value is None:
self._event_value = self.azimuth, self... |
Rotate the transformation matrix based on camera parameters
def _rotate_tr(self):
"""Rotate the transformation matrix based on camera parameters"""
up, forward, right = self._get_dim_vectors()
self.transform.rotate(self.elevation, -right)
self.transform.rotate(self.azimuth, up) |
Convert mouse x, y movement into x, y, z translations
def _dist_to_trans(self, dist):
"""Convert mouse x, y movement into x, y, z translations"""
rae = np.array([self.roll, self.azimuth, self.elevation]) * np.pi / 180
sro, saz, sel = np.sin(rae)
cro, caz, cel = np.cos(rae)
dx = ... |
Set gl configuration for GLFW
def _set_config(c):
"""Set gl configuration for GLFW """
glfw.glfwWindowHint(glfw.GLFW_RED_BITS, c['red_size'])
glfw.glfwWindowHint(glfw.GLFW_GREEN_BITS, c['green_size'])
glfw.glfwWindowHint(glfw.GLFW_BLUE_BITS, c['blue_size'])
glfw.glfwWindowHint(glfw.GLFW_ALPHA_BITS,... |
Process (possible) keyboard modifiers
GLFW provides "mod" with many callbacks, but not (critically) the
scroll callback, so we keep track on our own here.
def _process_mod(self, key, down):
"""Process (possible) keyboard modifiers
GLFW provides "mod" with many callbacks, but not (crit... |
Monkey-patch pyopengl to fix a bug in glBufferSubData.
def _patch():
""" Monkey-patch pyopengl to fix a bug in glBufferSubData. """
import sys
from OpenGL import GL
if sys.version_info > (3,):
buffersubdatafunc = GL.glBufferSubData
if hasattr(buffersubdatafunc, 'wrapperFunction'):
... |
Try getting the given function from PyOpenGL, return
a dummy function (that shows a warning when called) if it
could not be found.
def _get_function_from_pyopengl(funcname):
""" Try getting the given function from PyOpenGL, return
a dummy function (that shows a warning when called) if it
could not ... |
Copy functions from OpenGL.GL into _pyopengl namespace.
def _inject():
""" Copy functions from OpenGL.GL into _pyopengl namespace.
"""
NS = _pyopengl2.__dict__
for glname, ourname in _pyopengl2._functions_to_import:
func = _get_function_from_pyopengl(glname)
NS[ourname] = func |
Fetch a remote vispy font
def _get_vispy_font_filename(face, bold, italic):
"""Fetch a remote vispy font"""
name = face + '-'
name += 'Regular' if not bold and not italic else ''
name += 'Bold' if bold else ''
name += 'Italic' if italic else ''
name += '.ttf'
return load_data_file('fonts/%s... |
Ensure val is Nx(n_col), usually Nx3
def _check_color_dim(val):
"""Ensure val is Nx(n_col), usually Nx3"""
val = np.atleast_2d(val)
if val.shape[1] not in (3, 4):
raise RuntimeError('Value must have second dimension of size 3 or 4')
return val, val.shape[1] |
Convert hex to rgba, permitting alpha values in hex
def _hex_to_rgba(hexs):
"""Convert hex to rgba, permitting alpha values in hex"""
hexs = np.atleast_1d(np.array(hexs, '|U9'))
out = np.ones((len(hexs), 4), np.float32)
for hi, h in enumerate(hexs):
assert isinstance(h, string_types)
of... |
Convert rgb to hex triplet
def _rgb_to_hex(rgbs):
"""Convert rgb to hex triplet"""
rgbs, n_dim = _check_color_dim(rgbs)
return np.array(['#%02x%02x%02x' % tuple((255*rgb[:3]).astype(np.uint8))
for rgb in rgbs], '|U7') |
Convert Nx3 or Nx4 rgb to hsv
def _rgb_to_hsv(rgbs):
"""Convert Nx3 or Nx4 rgb to hsv"""
rgbs, n_dim = _check_color_dim(rgbs)
hsvs = list()
for rgb in rgbs:
rgb = rgb[:3] # don't use alpha here
idx = np.argmax(rgb)
val = rgb[idx]
c = val - np.min(rgb)
if c == 0:... |
Convert Nx3 or Nx4 hsv to rgb
def _hsv_to_rgb(hsvs):
"""Convert Nx3 or Nx4 hsv to rgb"""
hsvs, n_dim = _check_color_dim(hsvs)
# In principle, we *might* be able to vectorize this, but might as well
# wait until a compelling use case appears
rgbs = list()
for hsv in hsvs:
c = hsv[1] * hs... |
Convert Nx3 or Nx4 lab to rgb
def _lab_to_rgb(labs):
"""Convert Nx3 or Nx4 lab to rgb"""
# adapted from BSD-licensed work in MATLAB by Mark Ruzon
# Based on ITU-R Recommendation BT.709 using the D65
labs, n_dim = _check_color_dim(labs)
# Convert Lab->XYZ (silly indexing used to preserve dimensiona... |
Find an adequate value for this field from a dict of tags.
def get(self, tags):
"""Find an adequate value for this field from a dict of tags."""
# Try to find our name
value = tags.get(self.name, '')
for name in self.alternate_tags:
# Iterate of alternates until a non-empty... |
Return the name, arguments, and return type of the first function
definition found in *code*. Arguments are returned as [(type, name), ...].
def parse_function_signature(code):
"""
Return the name, arguments, and return type of the first function
definition found in *code*. Arguments are returned as [(... |
Return a list of (name, arguments, return type) for all function
definition2 found in *code*. Arguments are returned as [(type, name), ...].
def find_functions(code):
"""
Return a list of (name, arguments, return type) for all function
definition2 found in *code*. Arguments are returned as [(type, na... |
Return a list of signatures for each function prototype declared in *code*.
Format is [(name, [args], rtype), ...].
def find_prototypes(code):
"""
Return a list of signatures for each function prototype declared in *code*.
Format is [(name, [args], rtype), ...].
"""
prots = []
lines = code... |
Return a dict describing program variables::
{'var_name': ('uniform|attribute|varying', type), ...}
def find_program_variables(code):
"""
Return a dict describing program variables::
{'var_name': ('uniform|attribute|varying', type), ...}
"""
vars = {}
lines = code.split('\n')
... |
Set gl configuration for SDL2
def _set_config(c):
"""Set gl configuration for SDL2"""
func = sdl2.SDL_GL_SetAttribute
func(sdl2.SDL_GL_RED_SIZE, c['red_size'])
func(sdl2.SDL_GL_GREEN_SIZE, c['green_size'])
func(sdl2.SDL_GL_BLUE_SIZE, c['blue_size'])
func(sdl2.SDL_GL_ALPHA_SIZE, c['alpha_size'])... |
message - text message to be spoken out by the Echo
end_session - flag to determine whether this interaction should end the session
card_obj = JSON card object to substitute the 'card' field in the raw_response
def create_response(self, message=None, end_session=False, card_obj=None,
... |
card_obj = JSON card object to substitute the 'card' field in the raw_response
format:
{
"type": "Simple", #COMPULSORY
"title": "string", #OPTIONAL
"subtitle": "string", #OPTIONAL
"content": "string" #OPTIONAL
}
def create_card(self, title=None, subtitle=... |
Decorator to register intent handler
def intent(self, intent):
''' Decorator to register intent handler'''
def _handler(func):
self._handlers['IntentRequest'][intent] = func
return func
return _handler |
Decorator to register generic request handler
def request(self, request_type):
''' Decorator to register generic request handler '''
def _handler(func):
self._handlers[request_type] = func
return func
return _handler |
Route the request object to the right handler function
def route_request(self, request_json, metadata=None):
''' Route the request object to the right handler function '''
request = Request(request_json)
request.metadata = metadata
# add reprompt handler or some such for default?
... |
Friend method of viewbox to register itself.
def _viewbox_set(self, viewbox):
""" Friend method of viewbox to register itself.
"""
self._viewbox = viewbox
# Connect
viewbox.events.mouse_press.connect(self.viewbox_mouse_event)
viewbox.events.mouse_release.connect(self.vie... |
Friend method of viewbox to unregister itself.
def _viewbox_unset(self, viewbox):
""" Friend method of viewbox to unregister itself.
"""
self._viewbox = None
# Disconnect
viewbox.events.mouse_press.disconnect(self.viewbox_mouse_event)
viewbox.events.mouse_release.disconn... |
Set the range of the view region for the camera
Parameters
----------
x : tuple | None
X range.
y : tuple | None
Y range.
z : tuple | None
Z range.
margin : float
Margin to use.
Notes
-----
The view... |
Get the current view state of the camera
Returns a dict of key-value pairs. The exact keys depend on the
camera. Can be passed to set_state() (of this or another camera
of the same type) to reproduce the state.
def get_state(self):
""" Get the current view state of the camera
... |
Set the view state of the camera
Should be a dict (or kwargs) as returned by get_state. It can
be an incomlete dict, in which case only the specified
properties are set.
Parameters
----------
state : dict
The camera state.
**kwargs : dict
... |
Link this camera with another camera of the same type
Linked camera's keep each-others' state in sync.
Parameters
----------
camera : instance of Camera
The other camera to link.
def link(self, camera):
""" Link this camera with another camera of the same type
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.