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__(key, /)

Return key in self.

__len__()

Return len(self).

count(value, /)

Return number of occurrences of value.

height

Alias for field number 1

index(value, start=0, stop=9223372036854775807, /)

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.rl_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

property 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.

property 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)
setBlendMode(v)
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(value)

Bases: enum.IntEnum

An enumeration.

Rejected = 0
Accepted = 1
DrawChildren = 2
DrawWindowBackground = 1
IgnoreMask = 4
class PaintDeviceMetric(value)

Bases: enum.Enum

An enumeration.

PdmWidth = 1
PdmHeight = 2
PdmWidthMM = 3
PdmHeightMM = 4
PdmNumColors = 5
PdmDepth = 6
PdmDpiX = 7
PdmDpiY = 8
PdmPhysicalDpiX = 9
PdmPhysicalDpiY = 10
PdmDevicePixelRatio = 11
PdmDevicePixelRatioScaled = 12
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(value)

Bases: enum.Flag

An enumeration.

DrawWindowBackground = 1
DrawChildren = 2
IgnoreMask = 4
acceptDrops(self) bool
accepted

accepted(self) [signal]

accessibleDescription(self) str
accessibleName(self) str
actionEvent(self, a0: QActionEvent)
actions(self) List[QAction]
activateWindow(self)
addAction(self, action: QAction)
addActions(self, actions: Iterable[QAction])
adjustSize(self)
autoFillBackground(self) bool
backgroundRole(self) QPalette.ColorRole
baseSize(self) QSize
blockSignals(self, b: bool) bool
changeEvent(self, a0: QEvent)
childAt(self, p: QPoint) QWidget
childAt(self, ax: int, ay: int) QWidget
childEvent(self, a0: QChildEvent)
children(self) List[QObject]
childrenRect(self) QRect
childrenRegion(self) QRegion
clearFocus(self)
clearMask(self)
close(self) bool
closeEvent(self, a0: QCloseEvent)
colorCount(self) int
connectNotify(self, signal: QMetaMethod)
contentsMargins(self) QMargins
contentsRect(self) QRect
contextMenuEvent(self, a0: QContextMenuEvent)
contextMenuPolicy(self) Qt.ContextMenuPolicy
create(self, window: PyQt6.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
createWindowContainer(window: QWindow, parent: typing.Optional[QWidget] = None, flags: Qt.WindowType = Qt.WindowFlags()) QWidget
cursor(self) QCursor
customContextMenuRequested

customContextMenuRequested(self, pos: QPoint) [signal]

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

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

devType(self) int
devicePixelRatio(self) float
devicePixelRatioF(self) float
devicePixelRatioFScale() float
disconnect(a0: QMetaObject.Connection) bool
disconnect(self) None
disconnectNotify(self, signal: QMetaMethod)
done(self, a0: int)
dragEnterEvent(self, a0: QDragEnterEvent)
dragLeaveEvent(self, a0: QDragLeaveEvent)
dragMoveEvent(self, a0: QDragMoveEvent)
dropEvent(self, a0: QDropEvent)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) List[QByteArray]
effectiveWinId(self) PyQt6.sip.voidptr
ensurePolished(self)
enterEvent(self, event: QEnterEvent)
error(msg)

Display an error dialog with a message

Parameters

msg (str) – The message to display in the error dialog

event(self, a0: QEvent) bool
eventFilter(self, a0: QObject, a1: QEvent) bool
exec(self) int
find(a0: PyQt6.sip.voidptr) QWidget
findChild(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChild(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObject
findChildren(self, type: type, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, name: str = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, type: type, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
findChildren(self, types: Tuple, re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObject]
finished

finished(self, result: int) [signal]

focusInEvent(self, a0: QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, next: bool) bool
focusOutEvent(self, a0: 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
giveHelp()

Display the help topic for this dialog

grab(self, rectangle: QRect = QRect(QPoint(0, 0), QSize(- 1, - 1))) QPixmap
grabGesture(self, type: Qt.GestureType, flags: Qt.GestureFlag = Qt.GestureFlags())
grabKeyboard(self)
grabMouse(self)
grabMouse(self, a0: Union[QCursor, Qt.CursorShape]) None
grabShortcut(self, key: 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, a0: int) int
heightMM(self) int
hide(self)
hideEvent(self, a0: QHideEvent)
info(msg)

Display an information dialog with a message

Parameters

msg (str) – The message to display in the information dialog

inherits(self, classname: str) bool
initPainter(self, painter: QPainter)
inputMethodEvent(self, a0: QInputMethodEvent)
inputMethodHints(self) Qt.InputMethodHint
inputMethodQuery(self, a0: Qt.InputMethodQuery) Any
insertAction(self, before: QAction, action: QAction)
insertActions(self, before: QAction, actions: Iterable[QAction])
installEventFilter(self, a0: QObject)
isActiveWindow(self) bool
isAncestorOf(self, child: QWidget) bool
isEnabled(self) bool
isEnabledTo(self, a0: 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, signal: QMetaMethod) bool
isSizeGripEnabled(self) bool
isVisible(self) bool
isVisibleTo(self, a0: QWidget) bool
isWidgetType(self) bool
isWindow(self) bool
isWindowModified(self) bool
isWindowType(self) bool
keyPressEvent(self, a0: QKeyEvent)
keyReleaseEvent(self, a0: QKeyEvent)
keyboardGrabber() QWidget
killTimer(self, id: int)
layout(self) QLayout
layoutDirection(self) Qt.LayoutDirection
leaveEvent(self, a0: QEvent)
locale(self) QLocale
logicalDpiX(self) int
logicalDpiY(self) int
lower(self)
mapFrom(self, a0: QWidget, a1: QPoint) QPoint
mapFrom(self, a0: QWidget, a1: QPointF) QPointF
mapFromGlobal(self, a0: QPoint) QPoint
mapFromGlobal(self, a0: QPointF) QPointF
mapFromParent(self, a0: QPoint) QPoint
mapFromParent(self, a0: QPointF) QPointF
mapTo(self, a0: QWidget, a1: QPoint) QPoint
mapTo(self, a0: QWidget, a1: QPointF) QPointF
mapToGlobal(self, a0: QPoint) QPoint
mapToGlobal(self, a0: QPointF) QPointF
mapToParent(self, a0: QPoint) QPoint
mapToParent(self, a0: QPointF) QPointF
mask(self) QRegion
maximumHeight(self) int
maximumSize(self) QSize
maximumWidth(self) int
metaObject(self) QMetaObject
metric(self, a0: QPaintDevice.PaintDeviceMetric) int
minimumHeight(self) int
minimumSize(self) QSize
minimumSizeHint(self) QSize
minimumWidth(self) int
mouseDoubleClickEvent(self, a0: QMouseEvent)
mouseGrabber() QWidget
mouseMoveEvent(self, a0: QMouseEvent)
mousePressEvent(self, a0: QMouseEvent)
mouseReleaseEvent(self, a0: QMouseEvent)
move(self, a0: QPoint)
move(self, ax: int, ay: int) None
moveEvent(self, a0: QMoveEvent)
moveToThread(self, thread: QThread)
nativeEvent(self, eventType: QByteArray, message: PyQt6.sip.voidptr) Tuple[bool, PyQt6.sip.voidptr]
nativeParentWidget(self) QWidget
nextInFocusChain(self) QWidget
normalGeometry(self) QRect
objectName(self) str
objectNameChanged

objectNameChanged(self, objectName: str) [signal]

open(self)
overrideWindowFlags(self, type: Qt.WindowType)
overrideWindowState(self, state: Qt.WindowState)
paintEngine(self) QPaintEngine
paintEvent(self, a0: 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, name: 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.

question(msg, button1='OK', button2='Cancel')

Display a question dialog with a message Returns True if first button (default OK) is pressed, False otherwise.

Parameters
  • msg (str) – The message to display in the question dialog

  • button1 (str) – The text to display on first button

  • button2 (str) – The text to display on second button

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

rejected(self) [signal]

releaseKeyboard(self)
releaseMouse(self)
releaseShortcut(self, id: int)
removeAction(self, action: QAction)
removeEventFilter(self, a0: QObject)
render(self, target: QPaintDevice, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: QWidget.RenderFlag = QWidget.RenderFlags(QWidget.DrawWindowBackground | QWidget.DrawChildren))
render(self, painter: QPainter, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: QWidget.RenderFlag = QWidget.RenderFlags(QWidget.DrawWindowBackground | QWidget.DrawChildren)) None
repaint(self)
repaint(self, x: int, y: int, w: int, h: int) None
repaint(self, a0: QRect) None
repaint(self, a0: QRegion) None
reset()

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

resize(self, a0: QSize)
resize(self, w: int, h: int) None
resizeEvent(self, a0: QResizeEvent)
restoreGeometry(self, geometry: QByteArray) bool
result(self) int
saveGeometry(self) QByteArray
screen(self) QScreen
scroll(self, dx: int, dy: int)
scroll(self, dx: int, dy: int, a2: QRect) None
sender(self) QObject
senderSignalIndex(self) int
setAcceptDrops(self, on: bool)
setAccessibleDescription(self, description: str)
setAccessibleName(self, name: str)
setAttribute(self, attribute: Qt.WidgetAttribute, on: bool = True)
setAutoFillBackground(self, enabled: bool)
setBackgroundRole(self, a0: QPalette.ColorRole)
setBaseSize(self, basew: int, baseh: int)
setBaseSize(self, s: QSize) None
setContentsMargins(self, left: int, top: int, right: int, bottom: int)
setContentsMargins(self, margins: QMargins) None
setContextMenuPolicy(self, policy: Qt.ContextMenuPolicy)
setCursor(self, a0: Union[QCursor, Qt.CursorShape])
setDisabled(self, a0: bool)
setEnabled(self, a0: bool)
setFixedHeight(self, h: int)
setFixedSize(self, a0: QSize)
setFixedSize(self, w: int, h: int) None
setFixedWidth(self, w: int)
setFocus(self)
setFocus(self, reason: Qt.FocusReason) None
setFocusPolicy(self, policy: Qt.FocusPolicy)
setFocusProxy(self, a0: QWidget)
setFont(self, a0: QFont)
setForegroundRole(self, a0: QPalette.ColorRole)
setGeometry(self, a0: QRect)
setGeometry(self, ax: int, ay: int, aw: int, ah: int) None
setGraphicsEffect(self, effect: QGraphicsEffect)
setHidden(self, hidden: bool)
setInputMethodHints(self, hints: Qt.InputMethodHint)
setLayout(self, a0: QLayout)
setLayoutDirection(self, direction: Qt.LayoutDirection)
setLocale(self, locale: QLocale)
setMask(self, a0: QBitmap)
setMask(self, a0: QRegion) None
setMaximumHeight(self, maxh: int)
setMaximumSize(self, maxw: int, maxh: int)
setMaximumSize(self, s: QSize) None
setMaximumWidth(self, maxw: int)
setMinimumHeight(self, minh: int)
setMinimumSize(self, minw: int, minh: int)
setMinimumSize(self, s: QSize) None
setMinimumWidth(self, minw: int)
setModal(self, modal: bool)
setMouseTracking(self, enable: bool)
setObjectName(self, name: str)
setPalette(self, a0: QPalette)
setParent(self, parent: QWidget)
setParent(self, parent: QWidget, f: Qt.WindowType) None
setProperty(self, name: str, value: Any) bool
setResult(self, r: int)
setScreen(self, a0: QScreen)
setShortcutAutoRepeat(self, id: int, enabled: bool = True)
setShortcutEnabled(self, id: int, enabled: bool = True)
setSizeGripEnabled(self, a0: bool)
setSizeIncrement(self, w: int, h: int)
setSizeIncrement(self, s: QSize) None
setSizePolicy(self, a0: QSizePolicy)
setSizePolicy(self, hor: QSizePolicy.Policy, ver: QSizePolicy.Policy) None
setStatusTip(self, a0: str)
setStyle(self, a0: QStyle)
setStyleSheet(self, styleSheet: str)
setTabOrder(a0: QWidget, a1: QWidget)
setTabletTracking(self, enable: bool)
setToolTip(self, a0: str)
setToolTipDuration(self, msec: int)
setUpdatesEnabled(self, enable: bool)
setVisible(self, visible: bool)
setWhatsThis(self, a0: str)
setWindowFilePath(self, filePath: str)
setWindowFlag(self, a0: Qt.WindowType, on: bool = True)
setWindowFlags(self, type: Qt.WindowType)
setWindowIcon(self, icon: QIcon)
setWindowIconText(self, a0: str)
setWindowModality(self, windowModality: Qt.WindowModality)
setWindowModified(self, a0: bool)
setWindowOpacity(self, level: float)
setWindowRole(self, a0: str)
setWindowState(self, state: Qt.WindowState)
setWindowTitle(self, a0: str)
sharedPainter(self) QPainter
show(self)
showEvent(self, a0: 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, a0: QWidget)
startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
staticMetaObject = <PyQt6.QtCore.QMetaObject object>
statusTip(self) str
style(self) QStyle
styleSheet(self) str
tabletEvent(self, a0: QTabletEvent)
testAttribute(self, attribute: Qt.WidgetAttribute) bool
thread(self) QThread
timerEvent(self, a0: QTimerEvent)
toolTip(self) str
toolTipDuration(self) int
tr(sourceText: str, disambiguation: typing.Optional[str] = None, n: int = - 1) str
underMouse(self) bool
ungrabGesture(self, type: Qt.GestureType)
unsetCursor(self)
unsetLayoutDirection(self)
unsetLocale(self)
update(self)
update(self, a0: QRect) None
update(self, a0: QRegion) None
update(self, ax: int, ay: int, aw: int, ah: int) None
updateGeometry(self)
updateMicroFocus(self, query: Qt.InputMethodQuery = Qt.ImQueryAll)
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, a0: QWheelEvent)
width(self) int
widthMM(self) int
winId(self) PyQt6.sip.voidptr
window(self) QWidget
windowFilePath(self) str
windowFlags(self) Qt.WindowType
windowHandle(self) QWindow
windowIcon(self) QIcon
windowIconChanged

windowIconChanged(self, icon: QIcon) [signal]

windowIconText(self) str
windowIconTextChanged

windowIconTextChanged(self, iconText: str) [signal]

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

windowTitleChanged(self, title: 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

schrodinger.application.matsci.reportutils.save_matplotlib_figure(figures, pdf_name)

Save or Append the matplotlib figure to a pdf

Parameters
  • figures (list) – list of matplotlib figure to be added to the pdf

  • pdf_name (str) – filename for the pdf file