bspy.viewer

class Viewer(tkinter.Tk):

A tkinter viewer (tkinter.Tk) that hosts a SplineOpenGLFrame, a treeview full of splines, and a set of controls to adjust and view the selected splines.

See Also

Graphics: A graphics engine to display splines. It launches a Viewer and issues commands to the viewer.

Examples

Creates a Viewer, lists three splines, drawing (selecting) the third, and launches the viewer (blocks on the main loop).

>>> viewer = Viewer()
>>> viewer.list(spline1)
>>> viewer.list(spline2)
>>> viewer.draw(spline3)
>>> viewer.mainloop()
Viewer( *args, SplineOpenGLFrame=<class 'bspy.splineOpenGLFrame.SplineOpenGLFrame'>, workQueue=None, **kw)

Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.

treeview
def frame(self):

Return identifier for decorative frame of this widget if present.

frameMode
scale
splineList
solidList
splineDrawList
splineRadius
adjust
workQueue
def list( self, spline, name=None, fillColor=None, lineColor=None, options=None, draw=False, parentIID=''):

List a Spline, Boundary, or Solid in the treeview. Can be called before viewer is running.

def show( self, spline, name=None, fillColor=None, lineColor=None, options=None, draw=False, parentIID=''):

List a Spline, Boundary, or Solid in the treeview. Can be called before viewer is running.

def draw( self, spline, name=None, fillColor=None, lineColor=None, options=None):

List a Spline, Boundary, or Solid in the treeview and draw it in the viewer. Can be called before viewer is running.

def save_splines(self):
def load_splines(self):
def erase_all(self):

Stop drawing all splines. Splines remain in the treeview.

def remove(self):

Remove splines from the treeview.

def empty(self):

Stop drawing all splines and remove them from the treeview.

def set_background_color(self, r, g=None, b=None, a=None):

Set the background color.

Parameters
  • r (float, int or array-like of floats or ints): The red value [0, 1] as a float, [0, 255] as an int, or the rgb or rgba value as floats or ints (default).
  • g (float or int): The green value [0, 1] as a float or [0, 255] as an int.
  • b (float or int): The blue value [0, 1] as a float or [0, 255] as an int.
  • a (float, int, or None): The alpha value [0, 1] as a float or [0, 255] as an int. If None then alpha is set to 1.
def update(self):

Update the spline draw list, set the default view, reset the bounds, and refresh the frame.

@staticmethod
def get_fill_color(spline):

Gets the fill color of the spline (only useful for nInd >= 2).

Parameters
  • spline (Spline): The referenced spline.
Returns
  • fillColor (numpy.array): Array of four floats (r, g, b, a) in the range [0, 1].
@staticmethod
def set_fill_color(spline, r, g=None, b=None, a=None):

Set the fill color of the spline (only useful for nInd >= 2).

Parameters
  • spline (Spline): The referenced spline.
  • r (float, int or array-like of floats or ints): The red value [0, 1] as a float, [0, 255] as an int, or the rgb or rgba value as floats or ints (default).
  • g (float or int): The green value [0, 1] as a float or [0, 255] as an int.
  • b (float or int): The blue value [0, 1] as a float or [0, 255] as an int.
  • a (float, int, or None): The alpha value [0, 1] as a float or [0, 255] as an int. If None then alpha is set to 1.
@staticmethod
def get_line_color(spline):

Gets the line color of the spline.

Parameters
  • spline (Spline): The referenced spline.
Returns
  • lineColor (numpy.array): Array of four floats (r, g, b, a) in the range [0, 1].
@staticmethod
def set_line_color(spline, r, g=None, b=None, a=None):

Set the line color of the spline.

Parameters
  • spline (Spline): The referenced spline.
  • r (float, int or array-like of floats or ints): The red value [0, 1] as a float, [0, 255] as an int, or the rgb or rgba value as floats or ints (default).
  • g (float or int): The green value [0, 1] as a float or [0, 255] as an int.
  • b (float or int): The blue value [0, 1] as a float or [0, 255] as an int.
  • a (float, int, or None): The alpha value [0, 1] as a float or [0, 255] as an int. If None then alpha is set to 1.
@staticmethod
def get_options(spline):

Gets the draw options for the spline.

Parameters
  • spline (Spline): The referenced spline.
Returns
  • options (int bitwise or (|) of zero or more of the following values:):
    • SplineOpenGLFrame.HULL Draw the convex hull of the spline (the coefficients). Off by default.
    • SplineOpenGLFrame.SHADED Draw the spline shaded (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.BOUNDARY Draw the boundary of the spline in the line color (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.ISOPARMS Draw the lines of constant knot values of the spline in the line color (only useful for nInd >= 2). Off by default.
@staticmethod
def set_options(spline, options):

Set the draw options for the spline.

Parameters
  • spline (Spline): The referenced spline.
  • options (int bitwise or (|) of zero or more of the following values:):
    • SplineOpenGLFrame.HULL Draw the convex hull of the spline (the coefficients). Off by default.
    • SplineOpenGLFrame.SHADED Draw the spline shaded (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.BOUNDARY Draw the boundary of the spline in the line color (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.ISOPARMS Draw the lines of constant knot values of the spline in the line color (only useful for nInd >= 2). Off by default.
@staticmethod
def get_animate(spline):

Get the independent variable that is animated (None if there is none).

Parameters
  • spline (Spline): The referenced spline.
Returns
  • animate (int or None): The index of the independent variable that is animated (None is there is none).
@staticmethod
def set_animate(spline, animate):

Set the independent variable that is animated (None if there is none).

Parameters
  • spline (Spline): The referenced spline.
  • animate (int or None): The index of the independent variable that is animated (None is there is none).
Inherited Members
tkinter.Tk
master
children
tk
loadtk
destroy
readprofile
report_callback_exception
tkinter.Misc
deletecommand
tk_strictMotif
tk_bisque
tk_setPalette
wait_variable
waitvar
wait_window
wait_visibility
setvar
getvar
getint
getdouble
getboolean
focus_set
focus
focus_force
focus_get
focus_displayof
focus_lastfor
tk_focusFollowsMouse
tk_focusNext
tk_focusPrev
after
after_idle
after_cancel
bell
clipboard_get
clipboard_clear
clipboard_append
grab_current
grab_release
grab_set
grab_set_global
grab_status
option_add
option_clear
option_get
option_readfile
selection_clear
selection_get
selection_handle
selection_own
selection_own_get
send
lower
tkraise
lift
winfo_atom
winfo_atomname
winfo_cells
winfo_children
winfo_class
winfo_colormapfull
winfo_containing
winfo_depth
winfo_exists
winfo_fpixels
winfo_geometry
winfo_height
winfo_id
winfo_interps
winfo_ismapped
winfo_manager
winfo_name
winfo_parent
winfo_pathname
winfo_pixels
winfo_pointerx
winfo_pointerxy
winfo_pointery
winfo_reqheight
winfo_reqwidth
winfo_rgb
winfo_rootx
winfo_rooty
winfo_screen
winfo_screencells
winfo_screendepth
winfo_screenheight
winfo_screenmmheight
winfo_screenmmwidth
winfo_screenvisual
winfo_screenwidth
winfo_server
winfo_toplevel
winfo_viewable
winfo_visual
winfo_visualid
winfo_visualsavailable
winfo_vrootheight
winfo_vrootwidth
winfo_vrootx
winfo_vrooty
winfo_width
winfo_x
winfo_y
update_idletasks
bindtags
bind
unbind
bind_all
unbind_all
bind_class
unbind_class
mainloop
quit
nametowidget
register
configure
config
cget
keys
pack_propagate
propagate
pack_slaves
slaves
place_slaves
grid_anchor
anchor
grid_bbox
bbox
grid_columnconfigure
columnconfigure
grid_location
grid_propagate
grid_rowconfigure
rowconfigure
grid_size
size
grid_slaves
event_add
event_delete
event_generate
event_info
image_names
image_types
tkinter.Wm
wm_aspect
aspect
wm_attributes
attributes
wm_client
client
wm_colormapwindows
colormapwindows
wm_command
command
wm_deiconify
deiconify
wm_focusmodel
focusmodel
wm_forget
forget
wm_frame
wm_geometry
geometry
wm_grid
grid
wm_group
group
wm_iconbitmap
iconbitmap
wm_iconify
iconify
wm_iconmask
iconmask
wm_iconname
iconname
wm_iconphoto
iconphoto
wm_iconposition
iconposition
wm_iconwindow
iconwindow
wm_manage
manage
wm_maxsize
maxsize
wm_minsize
minsize
wm_overrideredirect
overrideredirect
wm_positionfrom
positionfrom
wm_protocol
protocol
wm_resizable
resizable
wm_sizefrom
sizefrom
wm_state
state
wm_title
title
wm_transient
transient
wm_withdraw
withdraw
class Graphics:

A graphics engine to script and display splines. It launches a Viewer and issues commands to the viewer.

Parameters
  • variableDictionary (dict): A dictionary of variable names, typically locals(), used to assign names to splines.
See Also

Viewer: A tkinter app (tkinter.Tk) that hosts a SplineOpenGLFrame, a treeview full of splines, and a set of controls to adjust and view the selected splines.

Examples

Launch a Viewer and tell it to draw some splines.

>>> graphics = Graphics(locals())
>>> graphics.draw(spline1)
>>> graphics.draw(spline2)
>>> graphics.draw(spline3)
Graphics(variableDictionary)
workQueue
appThread
variableDictionary
def list( self, spline, name=None, fillColor=None, lineColor=None, options=None, draw=False):

List a Spline, Boundary, or Solid in the treeview. Can be called before viewer is running.

def show( self, spline, name=None, fillColor=None, lineColor=None, options=None, draw=False):

List a Spline, Boundary, or Solid in the treeview. Can be called before viewer is running.

def draw( self, spline, name=None, fillColor=None, lineColor=None, options=None):

List a Spline, Boundary, or Solid in the treeview and draw it in the viewer. Can be called before viewer is running.

def erase_all(self):

Stop drawing all splines. Splines remain in the treeview.

def empty(self):

Stop drawing all splines and remove them from the treeview.

def set_background_color(self, r, g=None, b=None, a=None):

Set the background color.

Parameters
  • r (float, int or array-like of floats or ints): The red value [0, 1] as a float, [0, 255] as an int, or the rgb or rgba value as floats or ints (default).
  • g (float or int): The green value [0, 1] as a float or [0, 255] as an int.
  • b (float or int): The blue value [0, 1] as a float or [0, 255] as an int.
  • a (float, int, or None): The alpha value [0, 1] as a float or [0, 255] as an int. If None then alpha is set to 1.
def update(self):

Update the spline draw list and refresh the frame.

@staticmethod
def get_fill_color(spline):

Gets the fill color of the spline (only useful for nInd >= 2).

Parameters
  • spline (Spline): The referenced spline.
Returns
  • fillColor (numpy.array): Array of four floats (r, g, b, a) in the range [0, 1].
@staticmethod
def set_fill_color(spline, r, g=None, b=None, a=None):

Set the fill color of the spline (only useful for nInd >= 2).

Parameters
  • spline (Spline): The referenced spline.
  • r (float, int or array-like of floats or ints): The red value [0, 1] as a float, [0, 255] as an int, or the rgb or rgba value as floats or ints (default).
  • g (float or int): The green value [0, 1] as a float or [0, 255] as an int.
  • b (float or int): The blue value [0, 1] as a float or [0, 255] as an int.
  • a (float, int, or None): The alpha value [0, 1] as a float or [0, 255] as an int. If None then alpha is set to 1.
@staticmethod
def get_line_color(spline):

Gets the line color of the spline.

Parameters
  • spline (Spline): The referenced spline.
Returns
  • lineColor (numpy.array): Array of four floats (r, g, b, a) in the range [0, 1].
@staticmethod
def set_line_color(spline, r, g=None, b=None, a=None):

Set the line color of the spline.

Parameters
  • spline (Spline): The referenced spline.
  • r (float, int or array-like of floats or ints): The red value [0, 1] as a float, [0, 255] as an int, or the rgb or rgba value as floats or ints (default).
  • g (float or int): The green value [0, 1] as a float or [0, 255] as an int.
  • b (float or int): The blue value [0, 1] as a float or [0, 255] as an int.
  • a (float, int, or None): The alpha value [0, 1] as a float or [0, 255] as an int. If None then alpha is set to 1.
@staticmethod
def get_options(spline):

Gets the draw options for the spline.

Parameters
  • spline (Spline): The referenced spline.
Returns
  • options (int bitwise or (|) of zero or more of the following values:):
    • SplineOpenGLFrame.HULL Draw the convex hull of the spline (the coefficients). Off by default.
    • SplineOpenGLFrame.SHADED Draw the spline shaded (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.BOUNDARY Draw the boundary of the spline in the line color (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.ISOPARMS Draw the lines of constant knot values of the spline in the line color (only useful for nInd >= 2). Off by default.
@staticmethod
def set_options(spline, options):

Set the draw options for the spline.

Parameters
  • spline (Spline): The referenced spline.
  • options (int bitwise or (|) of zero or more of the following values:):
    • SplineOpenGLFrame.HULL Draw the convex hull of the spline (the coefficients). Off by default.
    • SplineOpenGLFrame.SHADED Draw the spline shaded (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.BOUNDARY Draw the boundary of the spline in the line color (only useful for nInd >= 2). On by default.
    • SplineOpenGLFrame.ISOPARMS Draw the lines of constant knot values of the spline in the line color (only useful for nInd >= 2). Off by default.
@staticmethod
def get_animate(spline):

Get the independent variable that is animated (None if there is none).

Parameters
  • spline (Spline): The referenced spline.
Returns
  • animate (int or None): The index of the independent variable that is animated (None is there is none).
@staticmethod
def set_animate(spline, animate):

Set the independent variable that is animated (None if there is none).

Parameters
  • spline (Spline): The referenced spline.
  • animate (int or None): The index of the independent variable that is animated (None is there is none).