schrodinger.ui.qt.periodictable module

A simple periodic table widget that allows the user to select a single element.

Example usage:

self.table_dialog = PeriodicTableDialog(self) self.table_dialog.exec() symbol = self.periodic_table_dlg.getSymbol()

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.ui.qt.periodictable.ElementButton(text, tip, colors)

Bases: QToolButton

A toolbutton that is checkable (stays depressed) and is colored. the use of style sheets makes these buttons not only colored, but also square so that the Periodic Table looks like an actual clickable periodic table rather than a collection of rounded buttons.

__init__(text, tip, colors)

Create an ElementButton instance

Parameters:
  • text (str) – The text of the button

  • tip (str) – The button tooltip

  • colors (tuple) – The button colors - a two item tuple (normal button color, color when depressed). Should be strings in a color format that Qt style sheets accept.

setPeriodicStyle(colors)

Set the color and style of the button. The use of a StyleSheet allows the button to be colored and square.

Parameters:

colors (tuple) – The button colors - a two item tuple (normal button color, color when depressed). Should be strings in a color format that Qt style sheets accept.

class schrodinger.ui.qt.periodictable.PeriodicTableDialog(parent=None, default_element=6, max_element=118, title='Choose Element', dummy_name='')

Bases: SDialog

A simple periodic table widget that allows the user to select a single element.

ELEMENTS = [('Hydrogen', 'H', 0, 0), ('Helium', 'He', 17, 0), ('Lithium', 'Li', 0, 1), ('Beryllium', 'Be', 1, 1), ('Boron', 'B', 12, 1), ('Carbon', 'C', 13, 1), ('Nitrogen', 'N', 14, 1), ('Oxygen', 'O', 15, 1), ('Fluorine', 'F', 16, 1), ('Neon', 'Ne', 17, 1), ('Sodium', 'Na', 0, 2), ('Magnesium', 'Mg', 1, 2), ('Aluminium', 'Al', 12, 2), ('Silicon', 'Si', 13, 2), ('Phosphorus', 'P', 14, 2), ('Sulphur', 'S', 15, 2), ('Chlorine', 'Cl', 16, 2), ('Argon', 'Ar', 17, 2), ('Potassium', 'K', 0, 3), ('Calcium', 'Ca', 1, 3), ('Scandium', 'Sc', 2, 3), ('Titanium', 'Ti', 3, 3), ('Vanadium', 'V', 4, 3), ('Chromium', 'Cr', 5, 3), ('Manganese', 'Mn', 6, 3), ('Iron', 'Fe', 7, 3), ('Cobalt', 'Co', 8, 3), ('Nickel', 'Ni', 9, 3), ('Copper', 'Cu', 10, 3), ('Zinc', 'Zn', 11, 3), ('Gallium', 'Ga', 12, 3), ('Germanium', 'Ge', 13, 3), ('Arsenic', 'As', 14, 3), ('Selenium', 'Se', 15, 3), ('Bromine', 'Br', 16, 3), ('Krypton', 'Kr', 17, 3), ('Rubidium', 'Rb', 0, 4), ('Strontium', 'Sr', 1, 4), ('Yttrium', 'Y', 2, 4), ('Zirconium', 'Zr', 3, 4), ('Niobium', 'Nb', 4, 4), ('Molybdenum', 'Mo', 5, 4), ('Technetium', 'Tc', 6, 4), ('Ruthenium', 'Ru', 7, 4), ('Rhodium', 'Rh', 8, 4), ('Palladium', 'Pd', 9, 4), ('Silver', 'Ag', 10, 4), ('Cadmium', 'Cd', 11, 4), ('Indium', 'In', 12, 4), ('Tin', 'Sn', 13, 4), ('Antimony', 'Sb', 14, 4), ('Tellurium', 'Te', 15, 4), ('Iodine', 'I', 16, 4), ('Xenon', 'Xe', 17, 4), ('Cesium', 'Cs', 0, 5), ('Barium', 'Ba', 1, 5), ('Lanthanum', 'La', 2, 5), ('Cerium', 'Ce', 3, 9), ('Praseodymium', 'Pr', 4, 9), ('Neodymium', 'Nd', 5, 9), ('Promethium', 'Pm', 6, 9), ('Samarium', 'Sm', 7, 9), ('Europium', 'Eu', 8, 9), ('Gadolinium', 'Gd', 9, 9), ('Terbium', 'Tb', 10, 9), ('Dysprosium', 'Dy', 11, 9), ('Holmium', 'Ho', 12, 9), ('Erbium', 'Er', 13, 9), ('Thulium', 'Tm', 14, 9), ('Ytterbium', 'Yb', 15, 9), ('Lutetium', 'Lu', 16, 9), ('Hafnium', 'Hf', 3, 5), ('Tantalum', 'Ta', 4, 5), ('Tungsten', 'W', 5, 5), ('Rhenium', 'Re', 6, 5), ('Osmium', 'Os', 7, 5), ('Iridium', 'Ir', 8, 5), ('Platinum', 'Pt', 9, 5), ('Gold', 'Au', 10, 5), ('Mercury', 'Hg', 11, 5), ('Thallium', 'Tl', 12, 5), ('Lead', 'Pb', 13, 5), ('Bismuth', 'Bi', 14, 5), ('Polonium', 'Po', 15, 5), ('Astatine', 'At', 16, 5), ('Radon', 'Rn', 17, 5), ('Francium', 'Fr', 0, 6), ('Radium', 'Ra', 1, 6), ('Actinium', 'Ac', 2, 6), ('Thorium', 'Th', 3, 10), ('Protactinium', 'Pa', 4, 10), ('Uranium', 'U', 5, 10), ('Neptunium', 'Np', 6, 10), ('Plutonium', 'Pu', 7, 10), ('Americium', 'Am', 8, 10), ('Curium', 'Cm', 9, 10), ('Berkelium', 'Bk', 10, 10), ('Californium', 'Cf', 11, 10), ('Einsteinium', 'Es', 12, 10), ('Fermium', 'Fm', 13, 10), ('Mendelevium', 'Md', 14, 10), ('Nobelium', 'No', 15, 10), ('Lawrencium', 'Lr', 16, 10), ('Rutherfordium', 'Rf', 3, 6), ('Dubnium', 'Db', 4, 6), ('Seaborgium', 'Sg', 5, 6), ('Bohrium', 'Bh', 6, 6), ('Hassium', 'Hs', 7, 6), ('Meitnerium', 'Mt', 8, 6), ('Darmstadtium', 'Ds', 9, 6), ('Roentgenium', 'Rg', 10, 6), ('Copernicium', 'Cn', 11, 6), ('Nihonium', 'Nh', 12, 6), ('Flerovium', 'Fl', 13, 6), ('Moscovium', 'Mc', 14, 6), ('Livermorium', 'Lv', 15, 6), ('Tennessine', 'Ts', 16, 6), ('Oganesson', 'Og', 17, 6)]
DU_SYMBOL = 'DU'
DU_ELEMENT = -2
DU_BUTTON_ID = 500
__init__(parent=None, default_element=6, max_element=118, title='Choose Element', dummy_name='')

Create a PeriodicTable instance

Parameters:
  • parent (QWidget) – Dialog’s parent.

  • default_element (int) – Default selected element.

  • max_element (int) – Number of elements displayed in the widget.

  • title (str) – The Dialog window title

  • show_dummy – Dummy name, if showing of dummy element is desired

layOut()

Lay out the periodic table

buttonChecked(button_id)

Record the element that was just selected by the user

showEvent(event)

Reimplemented showEvent event. Checks self.current_button.

Parameters:

event (QShowEvent) – Show event.

getElement()

Returns atomic number of a selected element.

Return type:

int

Returns:

Atomic number of a selected element.

getSymbol()

Returns symbol of a selected element.

Return type:

str

Returns:

Symbol of a selected element.

getButtonId()

Returns button ID of a selected element.

Return type:

int

Returns:

Button ID

class schrodinger.ui.qt.periodictable.PeriodicTableDialogSingleClick(parent=None, default_element=6, max_element=118, title='Choose Element')

Bases: PeriodicTableDialog

This provides a version of the Periodic Table widget that doesn’t have OK/Cancel buttons, and will emit a signal and close itself when an element is toggled.

elementSelected

A pyqtSignal emitted by instances of the class.

__init__(parent=None, default_element=6, max_element=118, title='Choose Element')

Create a PeriodicTable instance

Parameters:
  • parent (QWidget) – Dialog’s parent.

  • default_element (int) – Default selected element.

  • max_element (int) – Number of elements displayed in the widget.

  • title (str) – The Dialog window title

  • show_dummy – Dummy name, if showing of dummy element is desired

emitElementSelected(button_index)
class schrodinger.ui.qt.periodictable.PeriodicTableDialogMultipleClick

Bases: PeriodicTableDialog

This provides a version of the Periodic Table widget in which allows user to select/deselect multiple elements at once.

__init__()

Create a PeriodicTable instance

Parameters:
  • parent (QWidget) – Dialog’s parent.

  • default_element (int) – Default selected element.

  • max_element (int) – Number of elements displayed in the widget.

  • title (str) – The Dialog window title

  • show_dummy – Dummy name, if showing of dummy element is desired

updateSelectedElements(button_id, checked)

Allows user to select multiple elements at once from periodic elements

Parameters:
  • button_id (int) – Button ID used in self.button_group

  • checked (bool) – true if the button is checked, or false if the button is unchecked

setSelectedElements(elements)

Setter to update selected_elements

Parameters:

elements (list) – list of elements to update _selected_elements

getSelectedElements()

Getter for current _selected_elements

Return type:

set

Returns:

set of latest selected_elements

showEvent(event)

Reimplemented showEvent event to uncheck the default element

Parameters:

event (QShowEvent) – Show event.