schrodinger.application.matsci.reportutils module

Utilities for creating MatSci reports.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.matsci.reportutils.Footer(text, height)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

count()

Return number of occurrences of value.

height

Alias for field number 1

index()

Return first index of value.

Raises ValueError if the value is not present.

text

Alias for field number 0

class schrodinger.application.matsci.reportutils.ReportInfo(panel, output_dir, base_name, outputs)

Bases: object

Manages information about the report request. Contains user inputs as well as panel data.

__init__(panel, output_dir, base_name, outputs)

Create an instance and store arguments

Parameters:
  • panel (af2.App) – The panel for which the report is requested
  • output_dir (str) – The directory to write the report files in
  • base_name (str) – The base name for the exported files and folders
  • outputs (list) – The outputs that the user has requested for the report
pdfRequested()

Determine whether a pdf was requested for the report

Return type:bool
Returns:Whether a pdf was requested for the report
imagesRequested()

Determine whether images were requested for the report

Return type:bool
Returns:Whether images were requested for the report
dataRequested()

Determine whether raw data was requested for the report

Return type:bool
Returns:Whether raw data was requested for the report
getPDFPath()

Get the path to the report pdf file

Return type:str
Returns:path to the report pdf file
getCsvFilePath()

Get the path to the data csv file

Return type:str
Returns:path to the data csv file
getImagesDirPath()

Get the path to the images directory

Return type:str
Returns:path to the images directory
setFigures(figures)

Set the figures for the report

Parameters:figures (matplotlib.figure.Figure) – The figures for the report
okToWrite()

Ensure that target files and folders don’t already exist, or if they do, they can be overwritten

Return type:bool
Returns:Whether we are clear to write
class schrodinger.application.matsci.reportutils.PDFBuilder(report_info, left_margin=27.0, top_margin=72.0, right_margin=18.0, bottom_margin=72.0)

Bases: object

Contains features shared by all MatSci PDF builder classes.

__init__(report_info, left_margin=27.0, top_margin=72.0, right_margin=18.0, bottom_margin=72.0)

Create a PDFBuilder instance. Store and initialize variables.

Parameters:
  • report_info (ReportInfo) – The report information object
  • left_margin (int) – The left margin for the pdf
  • top_margin (int) – The top margin for the pdf
  • right_margin (int) – The right margin for the pdf
  • bottom_margin (int) – The bottom margin for the pdf
build()

Build the report pdf. Calls methods that should be defined in derived classes to add flowables and footers.

addFlowables()

Add flowables to the pdf, such as headers, titles, paragraphs, tables and images. Should be defined in derived classes.

addFooters()

Add footers. Should be defined in derived classes.

writeParagraphs(paragraphs)

Add the paragraphs to the pdf as flowables.

Parameters:paragraphs (list) – A list of strings, each of which should be a paragraph
addFigure(figure, box_x, box_y)

Add the figure to the pdf as a flowable.

Parameters:
  • figure (matplotlib.figure.Figure) – The figure to add to the pdf
  • box_x – The width of the box that the image should be fitted in
  • box_y – The height of the box that the image should be fitted in
getTempImageFilename()

Get a temporary image file path and add it to the list of files to be cleaned up.

Return type:str
Returns:A temporary image file path
cleanupTempFiles()

Clean up all the temporary files

getTableStyle(column_headers=True, row_headers=False, align_center=True)

Create a platypus table style based on desired headers and alignment

Parameters:
  • column_headers (bool) – Whether the table columns have headers
  • row_headers (bool) – Whether the table rows have headers
  • align_center (bool) – Whether align center should be used for all cells
Return type:

list of tuples

Returns:

A platypus table style based on desired headers and alignment

addSpacer()

Add a space between the last and next flowables

class schrodinger.application.matsci.reportutils.CanvasWithHeaderAndFooter(*args, **kwargs)

Bases: schrodinger.application.desmond.report_helper.NumberedCanvas

Canvas that automatically adds matsci logo to the header, and allows custom footers in addition to the page number and “Report generated” string.

FOOTERS = {}
__init__(*args, **kwargs)

Create an instance.

drawFixedContents(*args)

Draw fixed pdf contents such as headers, footers and fixed graphics

STATE_ATTRIBUTES = ['_x', '_y', '_fontname', '_fontsize', '_textMode', '_leading', '_currentMatrix', '_fillMode', '_charSpace', '_wordSpace', '_horizScale', '_textRenderMode', '_rise', '_textLineMatrix', '_textMatrix', '_lineCap', '_lineJoin', '_lineDash', '_lineWidth', '_mitreLimit', '_fillColorObj', '_strokeColorObj', '_extgstate']
STATE_RANGE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
absolutePosition(x, y)

return the absolute position of x,y in user space w.r.t. default user space

acroForm

get form from canvas, create the form if needed

addLiteral(s, escaped=1)

introduce the literal text of PDF operations s into the current stream. Only use this if you are an expert in the PDF file format.

addOutlineEntry(title, key, level=0, closed=None)

Adds a new entry to the outline at given level. If LEVEL not specified, entry goes at the top level. If level specified, it must be no more than 1 greater than the outline level in the last call.

The key must be the (unique) name of a bookmark. the title is the (non-unique) name to be displayed for the entry.

If closed is set then the entry should show no subsections by default when displayed.

Example:

c.addOutlineEntry("first section", "section1")
c.addOutlineEntry("introduction", "s1s1", 1, closed=1)
c.addOutlineEntry("body", "s1s2", 1)
c.addOutlineEntry("detail1", "s1s2s1", 2)
c.addOutlineEntry("detail2", "s1s2s2", 2)
c.addOutlineEntry("conclusion", "s1s3", 1)
c.addOutlineEntry("further reading", "s1s3s1", 2)
c.addOutlineEntry("second section", "section1")
c.addOutlineEntry("introduction", "s2s1", 1)
c.addOutlineEntry("body", "s2s2", 1, closed=1)
c.addOutlineEntry("detail1", "s2s2s1", 2)
c.addOutlineEntry("detail2", "s2s2s2", 2)
c.addOutlineEntry("conclusion", "s2s3", 1)
c.addOutlineEntry("further reading", "s2s3s1", 2)

generated outline looks like:

- first section
|- introduction
|- body
|  |- detail1
|  |- detail2
|- conclusion
|  |- further reading
- second section
|- introduction
|+ body
|- conclusion
|  |- further reading

Note that the second “body” is closed.

Note that you can jump from level 5 to level 3 but not from 3 to 5: instead you need to provide all intervening levels going down (4 in this case). Note that titles can collide but keys cannot.

addPageLabel(pageNum, style=None, start=None, prefix=None)

add a PDFPageLabel for pageNum

addPostScriptCommand(command, position=1)

Embed literal Postscript in the document.

With position=0, it goes at very beginning of page stream; with position=1, at current point; and with position=2, at very end of page stream. What that does to the resulting Postscript depends on Adobe’s header :-)

Use with extreme caution, but sometimes needed for printer tray commands. Acrobat 4.0 will export Postscript to a printer or file containing the given commands. Adobe Reader 6.0 no longer does as this feature is deprecated. 5.0, I don’t know about (please let us know!). This was funded by Bob Marshall of Vector.co.uk and tested on a Lexmark 750. See test_pdfbase_postscript.py for 2 test cases - one will work on any Postscript device, the other uses a ‘setpapertray’ command which will error in Distiller but work on printers supporting it.

arc(x1, y1, x2, y2, startAng=0, extent=90)

Draw a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise. These should have x1<x2 and y1<y2.

beginForm(name, lowerx=0, lowery=0, upperx=None, uppery=None)

declare the current graphics stream to be a named form. A graphics stream can either be a page or a form, not both. Some operations (like bookmarking) are permitted for pages but not forms. The form will not automatically be shown in the document but must be explicitly referenced using doForm in pages that require the form.

beginPath()

Returns a fresh path object. Paths are used to draw complex figures. The object returned follows the protocol for a pathobject.PDFPathObject instance

beginText(x=0, y=0, direction=None)

Returns a fresh text object. Text objects are used to add large amounts of text. See PDFTextObject

bezier(x1, y1, x2, y2, x3, y3, x4, y4)

Bezier curve with the four given control points

bookmarkHorizontal(key, relativeX, relativeY, **kw)

w.r.t. the current transformation, bookmark this horizontal.

bookmarkHorizontalAbsolute(key, top, left=0, fit='XYZ', **kw)

Bind a bookmark (destination) to the current page at a horizontal position. Note that the yhorizontal of the book mark is with respect to the default user space (where the origin is at the lower left corner of the page) and completely ignores any transform (translation, scale, skew, rotation, etcetera) in effect for the current graphics state. The programmer is responsible for making sure the bookmark matches an appropriate item on the page.

bookmarkPage(key, fit='Fit', left=None, top=None, bottom=None, right=None, zoom=None)

This creates a bookmark to the current page which can be referred to with the given key elsewhere.

PDF offers very fine grained control over how Acrobat reader is zoomed when people link to this. The default is to keep the user’s current zoom settings. the last arguments may or may not be needed depending on the choice of ‘fitType’.

Fit types and the other arguments they use are:

  • XYZ left top zoom - fine grained control. null or zero for any of the parameters means ‘leave as is’, so “0,0,0” will keep the reader’s settings. NB. Adobe Reader appears to prefer “null” to 0’s.
  • Fit - entire page fits in window
  • FitH top - top coord at top of window, width scaled to fit.
  • FitV left - left coord at left of window, height scaled to fit
  • FitR left bottom right top - scale window to fit the specified rectangle

(question: do we support /FitB, FitBH and /FitBV which are hangovers from version 1.1 / Acrobat 3.0?)

circle(x_cen, y_cen, r, stroke=1, fill=0)

draw a cirle centered at (x_cen,y_cen) with radius r (special case of ellipse)

clipPath(aPath, stroke=1, fill=0, fillMode=None)

clip as well as drawing

cross(x, y, size=5, gap=1, text=None, strokeColor=None, strokeWidth=None, fontSize=3)
delCatalogEntry(key)

you’ll get an error here if it’s not been set

delViewerPreference(pref)

you’ll get an error here if none have been set

doForm(name)

use a form XObj in current operation stream.

The form should either have been defined previously using beginForm … endForm, or may be defined later. If it is not defined at save time, an exception will be raised. The form will be drawn within the context of the current graphics state.

drawAlignedString(x, y, text, pivotChar='.', mode=None, charSpace=0, direction=None, wordSpace=None)

Draws a string aligned on the first ‘.’ (or other pivot character).

The centre position of the pivot character will be used as x. So, you could draw a straight line down through all the decimals in a column of numbers, and anything without a decimal should be optically aligned with those that have.

There is one special rule to help with accounting formatting. Here’s how normal numbers should be aligned on the ‘dot’. Look at the LAST two:

12,345,67
   987.15
    42
-1,234.56
  (456.78)
  (456)
    27 inches
    13cm

Since the last three do not contain a dot, a crude dot-finding rule would place them wrong. So we test for the special case where no pivot is found, digits are present, but the last character is not a digit. We then work back from the end of the string This case is a tad slower but hopefully rare.

drawBoundary
drawCentredString(x, y, text, mode=None, charSpace=0, direction=None, wordSpace=None)

Draws a string centred on the x coordinate.

We’re British, dammit, and proud of our spelling!

drawImage(image, x, y, width=None, height=None, mask=None, preserveAspectRatio=False, anchor='c', anchorAtXY=False, showBoundary=False)

Draws the image (ImageReader object or filename) as specified.

“image” may be an image filename or an ImageReader object.

x and y define the lower left corner of the image you wish to draw (or of its bounding box, if using preserveAspectRation below).

If width and height are not given, the width and height of the image in pixels is used at a scale of 1 point to 1 pixel.

If width and height are given, the image will be stretched to fill the given rectangle bounded by (x, y, x+width, y-height).

If you supply negative widths and/or heights, it inverts them and adjusts x and y accordingly.

The method returns the width and height of the underlying image, since this is often useful for layout algorithms and saves you work if you have not specified them yourself.

The mask parameter supports transparent backgrounds. It takes 6 numbers and defines the range of RGB values which will be masked out or treated as transparent. For example with [0,2,40,42,136,139], it will mask out any pixels with a Red value from 0-2, Green from 40-42 and Blue from 136-139 (on a scale of 0-255).

New post version 2.0: drawImage can center an image in a box you provide, while preserving its aspect ratio. For example, you might have a fixed square box in your design, and a collection of photos which might be landscape or portrait that you want to appear within the box. If preserveAspectRatio is true, your image will appear within the box specified.

If preserveAspectRatio is True, the anchor property can be used to specify how images should fit into the given box. It should be set to one of the following values, taken from the points of the compass (plus ‘c’ for ‘centre’):

nw n ne w c e sw s se

The default value is ‘c’ for ‘centre’. Thus, if you want your bitmaps to always be centred and appear at the top of the given box, set anchor=’n’. There are good examples of this in the output of test_pdfgen_general.py

Unlike drawInlineImage, this creates ‘external images’ which are only stored once in the PDF file but can be drawn many times. If you give it the same filename twice, even at different locations and sizes, it will reuse the first occurrence, resulting in a saving in file size and generation time. If you use ImageReader objects, it tests whether the image content has changed before deciding whether to reuse it.

In general you should use drawImage in preference to drawInlineImage unless you have read the PDF Spec and understand the tradeoffs.

drawInlineImage(image, x, y, width=None, height=None, preserveAspectRatio=False, anchor='c', anchorAtXY=False, showBoundary=False)

See drawImage, which should normally be used instead…

drawInlineImage behaves like drawImage, but stores the image content within the graphics stream for the page. This means that the mask parameter for transparency is not available. It also means that there is no saving in file size or time if the same image is reused.

In theory it allows images to be displayed slightly faster; however, we doubt if the difference is noticeable to any human user these days. Only use this if you have studied the PDF specification and know the implications.

drawPath(aPath, stroke=1, fill=0, fillMode=None)

Draw the path object in the mode indicated

drawRightString(x, y, text, mode=None, charSpace=0, direction=None, wordSpace=None)

Draws a string right-aligned with the x coordinate

drawString(x, y, text, mode=None, charSpace=0, direction=None, wordSpace=None)

Draws a string in the current text styles.

drawText(aTextObject)

Draws a text object

ellipse(x1, y1, x2, y2, stroke=1, fill=0)

Draw an ellipse defined by an enclosing rectangle.

Note that (x1,y1) and (x2,y2) are the corner points of the enclosing rectangle.

endForm(**extra_attributes)

emit the current collection of graphics operations as a Form as declared previously in beginForm.

freeTextAnnotation(contents, DA, Rect=None, addtopage=1, name=None, relative=0, **kw)

DA is the default appearance string???

getAvailableFonts()

Returns the list of PostScript font names available.

Standard set now, but may grow in future with font embedding.

getCatalogEntry(key)
getCurrentPageContent()

Return uncompressed contents of current page buffer.

This is useful in creating test cases and assertions of what got drawn, without necessarily saving pages to disk

getPageNumber()

get the page number for the current page being generated.

getViewerPreference(pref)

you’ll get an error here if none have been set

getpdfdata()

Returns the PDF data that would normally be written to a file. If there is current data a ShowPage is executed automatically. After this operation the canvas must not be used further.

grid(xlist, ylist)

Lays out a grid in current line style. Supply list of x an y positions.

hasForm(name)

Query whether form XObj really exists yet.

highlightAnnotation(contents, Rect, QuadPoints=None, Color=[0.83, 0.89, 0.95], addtopage=1, name=None, relative=0, **kw)

Allows adding of a highlighted annotation.

Rect: Mouseover area to show contents of annotation QuadPoints: List of four x/y points [TOP-LEFT, TOP-RIGHT, BOTTOM-LEFT, BOTTOM-RIGHT]

These points outline the areas to highlight. You can have multiple groups of four to allow multiple highlighted areas. Is in the format [x1, y1, x2, y2, x3, y3, x4, y4, x1, y1, x2, y2, x3, y3, x4, y4] etc QuadPoints defaults to be area inside of passed in Rect

Color: The color of the highlighting.

init_graphics_state()
inkAnnotation(contents, InkList=None, Rect=None, addtopage=1, name=None, relative=0, **kw)
inkAnnotation0(contents, InkList=None, Rect=None, addtopage=1, name=None, relative=0, **kw)
line(x1, y1, x2, y2)

draw a line segment from (x1,y1) to (x2,y2) (with color, thickness and other attributes determined by the current graphics state).

linearGradient(x0, y0, x1, y1, colors, positions=None, extend=True)
lines(linelist)

Like line(), permits many lines to be drawn in one call. for example for the figure:

  |
-- --
  |

crosshairs = [(20,0,20,10), (20,30,20,40), (0,20,10,20), (30,20,40,20)]
canvas.lines(crosshairs)
linkAbsolute(contents, destinationname, Rect=None, addtopage=1, name=None, thickness=0, color=None, dashArray=None, **kw)

rectangular link annotation positioned wrt the default user space. The identified rectangle on the page becomes a “hot link” which when clicked will send the viewer to the page and position identified by the destination.

Rect identifies (lowerx, lowery, upperx, uppery) for lower left and upperright points of the rectangle. Translations and other transforms are IGNORED (the rectangular position is given with respect to the default user space. destinationname should be the name of a bookmark (which may be defined later but must be defined before the document is generated).

You may want to use the keyword argument Border=’[0 0 0]’ to suppress the visible rectangle around the during viewing link.

linkRect(contents, destinationname, Rect=None, addtopage=1, name=None, relative=1, thickness=0, color=None, dashArray=None, **kw)

rectangular link annotation w.r.t the current user transform. if the transform is skewed/rotated the absolute rectangle will use the max/min x/y

linkURL(url, rect, relative=0, thickness=0, color=None, dashArray=None, kind='URI', **kw)

Create a rectangular URL ‘hotspot’ in the given rectangle.

if relative=1, this is in the current coord system, otherwise in absolute page space. The remaining options affect the border appearance; the border is drawn by Acrobat, not us. Set thickness to zero to hide it. Any border drawn this way is NOT part of the page stream and will not show when printed to a Postscript printer or distilled; it is safest to draw your own.

listLoadedFonts0()

Convenience function to list all loaded fonts

pageHasData()

Info function - app can call it after showPage to see if it needs a save

pop_state_stack()
push_state_stack()
radialGradient(x, y, radius, colors, positions=None, extend=True)
rect(x, y, width, height, stroke=1, fill=0)

draws a rectangle with lower left corner at (x,y) and width and height as given.

resetTransforms()

I want to draw something (eg, string underlines) w.r.t. the default user space. Reset the matrix! This should be used usually as follows:

canv.saveState()
canv.resetTransforms()
#...draw some stuff in default space coords...
canv.restoreState() # go back!
restoreState()

restore the graphics state to the matching saved state (see saveState).

rotate(theta)

Rotate the canvas by the angle theta (in degrees).

roundRect(x, y, width, height, radius, stroke=1, fill=0)

Draws a rectangle with rounded corners. The corners are approximately quadrants of a circle, with the given radius.

save()

add page info to each page (page x of y)

saveState()

Save the current graphics state to be restored later by restoreState.

For example:
canvas.setFont(“Helvetica”, 20) canvas.saveState() … canvas.setFont(“Courier”, 9) … canvas.restoreState() # if the save/restore pairs match then font is Helvetica 20 again.
scale(x, y)

Scale the horizontal dimension by x and the vertical by y (with respect to the current graphics state). For example canvas.scale(2.0, 0.5) will make everything short and fat.

setArtBox(size)
setAuthor(author)

identify the author for invisible embedding inside the PDF document. the author annotation will appear in the the text of the file but will not automatically be seen when the document is viewed, but is visible in document properties etc etc.

setBleedBox(size)
setCatalogEntry(key, value)
setCreator(creator)

write a creator into the PDF file that won’t automatically display in the document itself. This should be used to name the original app which is passing data into ReportLab, if you wish to name it.

setCropBox(size, name='crop')

accepts a 2-tuple in points for name+’Box’ size for this and subsequent pages

setDash(array=[], phase=0)

Two notations. pass two numbers, or an array and phase

setDateFormatter(dateFormatter)

accepts a func(yyyy,mm,dd,hh,m,s) used to create embedded formatted date

setEncrypt(encrypt)

Set the encryption used for the pdf generated by this canvas. If encrypt is a string object, it is used as the user password for the pdf. If encrypt is an instance of reportlab.lib.pdfencrypt.StandardEncryption, this object is used to encrypt the pdf. This allows more finegrained control over the encryption settings.

setFillAlpha(a)
setFillColor(aColor, alpha=None)

Takes a color object, allowing colors to be referred to by name

setFillColorCMYK(c, m, y, k, alpha=None)

set the fill color useing negative color values (cyan, magenta, yellow and darkness value). Takes 4 arguments between 0.0 and 1.0

setFillColorRGB(r, g, b, alpha=None)

Set the fill color using positive color description (Red,Green,Blue). Takes 3 arguments between 0.0 and 1.0

setFillGray(gray, alpha=None)

Sets the gray level; 0.0=black, 1.0=white

setFillOverprint(a)
setFont(psfontname, size, leading=None)

Sets the font. If leading not specified, defaults to 1.2 x font size. Raises a readable exception if an illegal font is supplied. Font names are case-sensitive! Keeps track of font name and size for metrics.

setFontSize(size=None, leading=None)

Sets font size or leading without knowing the font face

setKeywords(keywords)

write a list of keywords into the PDF file which shows in document properties. Either submit a single string or a list/tuple

setLineCap(mode)

0=butt,1=round,2=square

setLineJoin(mode)

0=mitre, 1=round, 2=bevel

setLineWidth(width)
setMiterLimit(limit)
setOutlineNames0(*nametree)

nametree should can be a recursive tree like so:

c.setOutlineNames(
  "chapter1dest",
  ("chapter2dest",
   ["chapter2section1dest",
    "chapter2section2dest",
    "chapter2conclusiondest"]
  ), # end of chapter2 description
  "chapter3dest",
  ("chapter4dest", ["c4s1", "c4s2"])
  )

each of the string names inside must be bound to a bookmark before the document is generated.

setOverprintMask(a)
setPageCallBack(func)

func(pageNum) will be called on each page end.

This is mainly a hook for progress monitoring.
Call setPageCallback(None) to clear a callback.
setPageCompression(pageCompression=1)

Possible values None, 1 or 0 If None the value from rl_config will be used. If on, the page data will be compressed, leading to much smaller files, but takes a little longer to create the files. This applies to all subsequent pages, or until setPageCompression() is next called.

setPageDuration(duration=None)

Allows hands-off animation of presentations :-)

If this is set to a number, in full screen mode, Acrobat Reader will advance to the next page after this many seconds. The duration of the transition itself (fade/flicker etc.) is controlled by the ‘duration’ argument to setPageTransition; this controls the time spent looking at the page. This is effective for all subsequent pages.

setPageRotation(rot)

Instruct display device that this page is to be rotated

setPageSize(size)

accepts a 2-tuple in points for paper size for this and subsequent pages

setPageTransition(effectname=None, duration=1, direction=0, dimension='H', motion='I')

PDF allows page transition effects for use when giving presentations. There are six possible effects. You can just guive the effect name, or supply more advanced options to refine the way it works. There are three types of extra argument permitted, and here are the allowed values:

direction_arg = [0,90,180,270]
dimension_arg = ['H', 'V']
motion_arg = ['I','O'] (start at inside or outside)

This table says which ones take which arguments:

PageTransitionEffects = {
    'Split': [direction_arg, motion_arg],
    'Blinds': [dimension_arg],
    'Box': [motion_arg],
    'Wipe' : [direction_arg],
    'Dissolve' : [],
    'Glitter':[direction_arg]
    }

Have fun!

setProducer(producer)

change the default producer value

setStrokeAlpha(a)
setStrokeColor(aColor, alpha=None)

Takes a color object, allowing colors to be referred to by name

setStrokeColorCMYK(c, m, y, k, alpha=None)

set the stroke color useing negative color values (cyan, magenta, yellow and darkness value). Takes 4 arguments between 0.0 and 1.0

setStrokeColorRGB(r, g, b, alpha=None)

Set the stroke color using positive color description (Red,Green,Blue). Takes 3 arguments between 0.0 and 1.0

setStrokeGray(gray, alpha=None)

Sets the gray level; 0.0=black, 1.0=white

setStrokeOverprint(a)
setSubject(subject)

write a subject into the PDF file that won’t automatically display in the document itself.

setTitle(title)

write a title into the PDF file that won’t automatically display in the document itself.

setTrimBox(size)
setViewerPreference(pref, value)

set one of the allowed enbtries in the documents viewer preferences

shade(shading)
showFullScreen0()

Specify that Acrobat Reader should start in full screen mode. showFullScreen() and showOutline() conflict; the one called last wins.

showOutline()

Specify that Acrobat Reader should start with the outline tree visible. showFullScreen() and showOutline() conflict; the one called last wins.

showPage()

Close the current page and possibly start on a new page.

skew(alpha, beta)
stringWidth(text, fontName=None, fontSize=None)

gets width of a string in the given font and size

textAnnotation(contents, Rect=None, addtopage=1, name=None, relative=0, **kw)

Experimental, but works.

textAnnotation0(contents, Rect=None, addtopage=1, name=None, relative=0, **kw)

Experimental, but works.

transform(a, b, c, d, e, f)

adjoin a mathematical transform to the current graphics state matrix. Not recommended for beginners.

translate(dx, dy)

move the origin from the current (0,0) point to the (dx,dy) point (with respect to the current graphics state).

wedge(x1, y1, x2, y2, startAng, extent, stroke=1, fill=0)

Like arc, but connects to the centre of the ellipse. Most useful for pie charts and PacMan!

class schrodinger.application.matsci.reportutils.ReportOutputsDialog(*args, default_base_name='', report_btn=True, images_btn=True, data_btn=True, **kwargs)

Bases: schrodinger.ui.qt.swidgets.SDialog

Dialog for allowing the user to specify requested report outputs. Calls the report generation method of the panel when the user accepts.

DIR_SELECTOR_ID = 'REPORT_UTILS_DIR_SELECTOR_ID'
__init__(*args, default_base_name='', report_btn=True, images_btn=True, data_btn=True, **kwargs)

Create an instance.

Parameters:
  • report_btn (bool) – Whether PDF Report checkbox should be in the dialog
  • images_btn (bool) – Whether Plots checkbox should be in the dialog
  • data_btn (bool) – Whether Data checkbox should be in the dialog
layOut()

Lay out the widgets.

accept()

Get user inputs and call the report generation method of the panel.

Accepted = 1
class DialogCode

Bases: int

__init__ = <method-wrapper '__init__' of sip.enumtype object at 0x325b5e0>
DrawChildren = 2
DrawWindowBackground = 1
IgnoreMask = 4
class PaintDeviceMetric

Bases: int

__init__ = <method-wrapper '__init__' of sip.enumtype object at 0x3801690>
PdmDepth = 6
PdmDevicePixelRatio = 11
PdmDevicePixelRatioScaled = 12
PdmDpiX = 7
PdmDpiY = 8
PdmHeight = 2
PdmHeightMM = 4
PdmNumColors = 5
PdmPhysicalDpiX = 9
PdmPhysicalDpiY = 10
PdmWidth = 1
PdmWidthMM = 3
Rejected = 0
class RenderFlag

Bases: int

__init__ = <method-wrapper '__init__' of sip.enumtype object at 0x2e7f380>
class RenderFlags

Bases: sip.simplewrapper

QWidget.RenderFlags(Union[QWidget.RenderFlags, QWidget.RenderFlag]) QWidget.RenderFlags(QWidget.RenderFlags)

__init__

Initialize self. See help(type(self)) for accurate signature.

acceptDrops(self) → bool
accepted

accepted(self) [signal]

accessibleDescription(self) → str
accessibleName(self) → str
actionEvent(self, QActionEvent)
actions(self) → List[QAction]
activateWindow(self)
addAction(self, QAction)
addActions(self, Iterable[QAction])
adjustSize(self)
autoFillBackground(self) → bool
backgroundRole(self) → QPalette.ColorRole
baseSize(self) → QSize
blockSignals(self, bool) → bool
changeEvent(self, QEvent)
childAt(self, QPoint) → QWidget

childAt(self, int, int) -> QWidget

childEvent(self, QChildEvent)
children(self) → List[QObject]
childrenRect(self) → QRect
childrenRegion(self) → QRegion
clearFocus(self)
clearMask(self)
close(self) → bool
closeEvent(self, QCloseEvent)
colorCount(self) → int
connectNotify(self, QMetaMethod)
contentsMargins(self) → QMargins
contentsRect(self) → QRect
contextMenuEvent(self, QContextMenuEvent)
contextMenuPolicy(self) → Qt.ContextMenuPolicy
create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
createWindowContainer(QWindow, parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = 0) → QWidget
cursor(self) → QCursor
customContextMenuRequested

customContextMenuRequested(self, QPoint) [signal]

customEvent(self, QEvent)
deleteLater(self)
depth(self) → int
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
destroyed

destroyed(self, object: QObject = None) [signal]

devType(self) → int
devicePixelRatio(self) → int
devicePixelRatioF(self) → float
devicePixelRatioFScale() → float
disconnect(self)
disconnectNotify(self, QMetaMethod)
done(self, int)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) → List[QByteArray]
effectiveWinId(self) → sip.voidptr
ensurePolished(self)
enterEvent(self, QEvent)
error(msg)

Display an error dialog with a message

Parameters:msg (str) – The message to display in the error dialog
event(self, QEvent) → bool
eventFilter(self, QObject, QEvent) → bool
exec(self) → int
exec_(self) → int
find(sip.voidptr) → QWidget
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → QObject

findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject

findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → List[QObject]

findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]

finished

finished(self, int) [signal]

focusInEvent(self, QFocusEvent)
focusNextChild(self) → bool
focusNextPrevChild(self, bool) → bool
focusOutEvent(self, QFocusEvent)
focusPolicy(self) → Qt.FocusPolicy
focusPreviousChild(self) → bool
focusProxy(self) → QWidget
focusWidget(self) → QWidget
font(self) → QFont
fontInfo(self) → QFontInfo
fontMetrics(self) → QFontMetrics
foregroundRole(self) → QPalette.ColorRole
frameGeometry(self) → QRect
frameSize(self) → QSize
geometry(self) → QRect
getContentsMargins(self) → Tuple[int, int, int, int]
giveHelp()

Display the help topic for this dialog

grab(self, rectangle: QRect = QRect(QPoint(0, 0), QSize(-1, -1))) → QPixmap
grabGesture(self, Qt.GestureType, flags: Union[Qt.GestureFlags, Qt.GestureFlag] = Qt.GestureFlags())
grabKeyboard(self)
grabMouse(self)

grabMouse(self, Union[QCursor, Qt.CursorShape])

grabShortcut(self, Union[QKeySequence, QKeySequence.StandardKey, str, int], context: Qt.ShortcutContext = Qt.WindowShortcut) → int
graphicsEffect(self) → QGraphicsEffect
graphicsProxyWidget(self) → QGraphicsProxyWidget
hasFocus(self) → bool
hasHeightForWidth(self) → bool
hasMouseTracking(self) → bool
hasTabletTracking(self) → bool
height(self) → int
heightForWidth(self, int) → int
heightMM(self) → int
hide(self)
hideEvent(self, QHideEvent)
info(msg)

Display an information dialog with a message

Parameters:msg (str) – The message to display in the information dialog
inherits(self, str) → bool
initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
inputMethodHints(self) → Qt.InputMethodHints
inputMethodQuery(self, Qt.InputMethodQuery) → Any
insertAction(self, QAction, QAction)
insertActions(self, QAction, Iterable[QAction])
installEventFilter(self, QObject)
isActiveWindow(self) → bool
isAncestorOf(self, QWidget) → bool
isEnabled(self) → bool
isEnabledTo(self, QWidget) → bool
isFullScreen(self) → bool
isHidden(self) → bool
isLeftToRight(self) → bool
isMaximized(self) → bool
isMinimized(self) → bool
isModal(self) → bool
isRightToLeft(self) → bool
isSignalConnected(self, QMetaMethod) → bool
isSizeGripEnabled(self) → bool
isVisible(self) → bool
isVisibleTo(self, QWidget) → bool
isWidgetType(self) → bool
isWindow(self) → bool
isWindowModified(self) → bool
isWindowType(self) → bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
keyboardGrabber() → QWidget
killTimer(self, int)
layout(self) → QLayout
layoutDirection(self) → Qt.LayoutDirection
leaveEvent(self, QEvent)
locale(self) → QLocale
logicalDpiX(self) → int
logicalDpiY(self) → int
lower(self)
mapFrom(self, QWidget, QPoint) → QPoint
mapFromGlobal(self, QPoint) → QPoint
mapFromParent(self, QPoint) → QPoint
mapTo(self, QWidget, QPoint) → QPoint
mapToGlobal(self, QPoint) → QPoint
mapToParent(self, QPoint) → QPoint
mask(self) → QRegion
maximumHeight(self) → int
maximumSize(self) → QSize
maximumWidth(self) → int
metaObject(self) → QMetaObject
metric(self, QPaintDevice.PaintDeviceMetric) → int
minimumHeight(self) → int
minimumSize(self) → QSize
minimumSizeHint(self) → QSize
minimumWidth(self) → int
mouseDoubleClickEvent(self, QMouseEvent)
mouseGrabber() → QWidget
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
move(self, QPoint)

move(self, int, int)

moveEvent(self, QMoveEvent)
moveToThread(self, QThread)
nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) → Tuple[bool, int]
nativeParentWidget(self) → QWidget
nextInFocusChain(self) → QWidget
normalGeometry(self) → QRect
objectName(self) → str
objectNameChanged

objectNameChanged(self, str) [signal]

open(self)
overrideWindowFlags(self, Union[Qt.WindowFlags, Qt.WindowType])
overrideWindowState(self, Union[Qt.WindowStates, Qt.WindowState])
paintEngine(self) → QPaintEngine
paintEvent(self, QPaintEvent)
paintingActive(self) → bool
palette(self) → QPalette
parent(self) → QObject
parentWidget(self) → QWidget
physicalDpiX(self) → int
physicalDpiY(self) → int
pos(self) → QPoint
previousInFocusChain(self) → QWidget
property(self, str) → Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

raise_(self)
receivers(self, PYQT_SIGNAL) → int
rect(self) → QRect
reject(self)
rejected

rejected(self) [signal]

releaseKeyboard(self)
releaseMouse(self)
releaseShortcut(self, int)
removeAction(self, QAction)
removeEventFilter(self, QObject)
render(self, QPaintDevice, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: Union[QWidget.RenderFlags, QWidget.RenderFlag] = QWidget.RenderFlags(QWidget.DrawWindowBackground|QWidget.DrawChildren))

render(self, QPainter, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: Union[QWidget.RenderFlags, QWidget.RenderFlag] = QWidget.RenderFlags(QWidget.DrawWindowBackground|QWidget.DrawChildren))

repaint(self)

repaint(self, int, int, int, int) repaint(self, QRect) repaint(self, QRegion)

reset()

Reset the panel when the Reset button is pressed. Must be re-implemented in a subclass

resize(self, QSize)

resize(self, int, int)

resizeEvent(self, QResizeEvent)
restoreGeometry(self, Union[QByteArray, bytes, bytearray]) → bool
result(self) → int
saveGeometry(self) → QByteArray
scroll(self, int, int)

scroll(self, int, int, QRect)

sender(self) → QObject
senderSignalIndex(self) → int
setAcceptDrops(self, bool)
setAccessibleDescription(self, str)
setAccessibleName(self, str)
setAttribute(self, Qt.WidgetAttribute, on: bool = True)
setAutoFillBackground(self, bool)
setBackgroundRole(self, QPalette.ColorRole)
setBaseSize(self, int, int)

setBaseSize(self, QSize)

setContentsMargins(self, int, int, int, int)

setContentsMargins(self, QMargins)

setContextMenuPolicy(self, Qt.ContextMenuPolicy)
setCursor(self, Union[QCursor, Qt.CursorShape])
setDisabled(self, bool)
setEnabled(self, bool)
setFixedHeight(self, int)
setFixedSize(self, QSize)

setFixedSize(self, int, int)

setFixedWidth(self, int)
setFocus(self)

setFocus(self, Qt.FocusReason)

setFocusPolicy(self, Qt.FocusPolicy)
setFocusProxy(self, QWidget)
setFont(self, QFont)
setForegroundRole(self, QPalette.ColorRole)
setGeometry(self, QRect)

setGeometry(self, int, int, int, int)

setGraphicsEffect(self, QGraphicsEffect)
setHidden(self, bool)
setInputMethodHints(self, Union[Qt.InputMethodHints, Qt.InputMethodHint])
setLayout(self, QLayout)
setLayoutDirection(self, Qt.LayoutDirection)
setLocale(self, QLocale)
setMask(self, QBitmap)

setMask(self, QRegion)

setMaximumHeight(self, int)
setMaximumSize(self, int, int)

setMaximumSize(self, QSize)

setMaximumWidth(self, int)
setMinimumHeight(self, int)
setMinimumSize(self, int, int)

setMinimumSize(self, QSize)

setMinimumWidth(self, int)
setModal(self, bool)
setMouseTracking(self, bool)
setObjectName(self, str)
setPalette(self, QPalette)
setParent(self, QWidget)

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

setProperty(self, str, Any) → bool
setResult(self, int)
setShortcutAutoRepeat(self, int, enabled: bool = True)
setShortcutEnabled(self, int, enabled: bool = True)
setSizeGripEnabled(self, bool)
setSizeIncrement(self, int, int)

setSizeIncrement(self, QSize)

setSizePolicy(self, QSizePolicy)

setSizePolicy(self, QSizePolicy.Policy, QSizePolicy.Policy)

setStatusTip(self, str)
setStyle(self, QStyle)
setStyleSheet(self, str)
setTabOrder(QWidget, QWidget)
setTabletTracking(self, bool)
setToolTip(self, str)
setToolTipDuration(self, int)
setUpdatesEnabled(self, bool)
setVisible(self, bool)
setWhatsThis(self, str)
setWindowFilePath(self, str)
setWindowFlag(self, Qt.WindowType, on: bool = True)
setWindowFlags(self, Union[Qt.WindowFlags, Qt.WindowType])
setWindowIcon(self, QIcon)
setWindowIconText(self, str)
setWindowModality(self, Qt.WindowModality)
setWindowModified(self, bool)
setWindowOpacity(self, float)
setWindowRole(self, str)
setWindowState(self, Union[Qt.WindowStates, Qt.WindowState])
setWindowTitle(self, str)
sharedPainter(self) → QPainter
show(self)
showEvent(self, QShowEvent)
showFullScreen(self)
showMaximized(self)
showMinimized(self)
showNormal(self)
signalsBlocked(self) → bool
size(self) → QSize
sizeHint(self) → QSize
sizeIncrement(self) → QSize
sizePolicy(self) → QSizePolicy
stackUnder(self, QWidget)
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) → int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
statusTip(self) → str
style(self) → QStyle
styleSheet(self) → str
tabletEvent(self, QTabletEvent)
testAttribute(self, Qt.WidgetAttribute) → bool
thread(self) → QThread
timerEvent(self, QTimerEvent)
toolTip(self) → str
toolTipDuration(self) → int
tr(self, str, disambiguation: str = None, n: int = -1) → str
underMouse(self) → bool
ungrabGesture(self, Qt.GestureType)
unsetCursor(self)
unsetLayoutDirection(self)
unsetLocale(self)
update(self)

update(self, QRect) update(self, QRegion) update(self, int, int, int, int)

updateGeometry(self)
updateMicroFocus(self)
updatesEnabled(self) → bool
visibleRegion(self) → QRegion
warning(msg)

Display a warning dialog with a message

Parameters:msg (str) – The message to display in the warning dialog
whatsThis(self) → str
wheelEvent(self, QWheelEvent)
width(self) → int
widthMM(self) → int
winId(self) → sip.voidptr
window(self) → QWidget
windowFilePath(self) → str
windowFlags(self) → Qt.WindowFlags
windowHandle(self) → QWindow
windowIcon(self) → QIcon
windowIconChanged

windowIconChanged(self, QIcon) [signal]

windowIconText(self) → str
windowIconTextChanged

windowIconTextChanged(self, str) [signal]

windowModality(self) → Qt.WindowModality
windowOpacity(self) → float
windowRole(self) → str
windowState(self) → Qt.WindowStates
windowTitle(self) → str
windowTitleChanged

windowTitleChanged(self, str) [signal]

windowType(self) → Qt.WindowType
x(self) → int
y(self) → int
schrodinger.application.matsci.reportutils.save_figure(figure, file_path, panel)

Exports the figure to a file, showing an error if it fails.

Parameters:
  • figure (matplotlib.figure.Figure) – The figure to export
  • file_path (str) – The path to the image file to be created
  • panel (af2.App) – The panel to show any error in
Return type:

bool

Returns:

Whether the image export was successful

schrodinger.application.matsci.reportutils.save_images(report_info)

Save all images in the report information object to the output directory

Parameters:report_info (ReportInfo) – The report information object containing the figures
schrodinger.application.matsci.reportutils.sub_script(text, size=10)
Parameters:
  • text (str or int or float) – The text to write as a subscript
  • size (int) – The font size of the subscript
Return type:

str

Returns:

The text formatted to appear as a subscript in the report

schrodinger.application.matsci.reportutils.super_script(text, size=10)
Parameters:
  • text (str or int or float) – The text to write as a superscript
  • size (int) – The font size of the superscript
Return type:

str

Returns:

The text formatted to appear as a superscript in the report