seamm_widgets package
Submodules
seamm_widgets.check_tree module
A Tk widget for a tree of checkboxes.
- class seamm_widgets.check_tree.CheckTree(parent, *args, columns=[], **kwargs)[source]
Bases:
LabeledWidget
Class to provide a tree of checkboxes.
- bbox(item, column=None)[source]
Return the bonding box for the item.
For the item with iid item, if the item is currently visible, this method returns a tuple (x, y, w, h), where (x, y) are the coordinates of the upper left corner of that item relative to the widget, and w and h are the width and height of the item in pixels. If the item is not visible, the method returns an empty string.
If the optional column argument is omitted, you get the bounding box of the entire row. To get the bounding box of one specific column of the item’s row, use column=C where C is either the integer index of the column or its column identifier.
- column(cid, option=None, **kw)[source]
This method configures the appearance of the logical column specified by cid, which may be either a column index or a column identifier. To configure the icon column, use a cid value of ‘#0’.
Each column in a Treeview widget has its own set of options from this table:
- anchor
The anchor that specifies where to position the content of the column. The default value is ‘w’.
- id
The column name. This option is read-only and set when the constructor is called.
- minwidth
Minimum width of the column in pixels; the default value is 20.
- stretch
If this option is True, the column’s width will be adjusted when the widget is resized. The default setting is 1.
- width
Initial width of the column in pixels; the default is 200.
If no option value or any other keyword argument is supplied, the method returns a dictionary of the column options for the specified column.
To interrogate the current value of an option named X , use an argument option=X.
To set one or more column options, you may pass keyword arguments using the option names shown above, e.g., anchor=tk.CENTER to center the column contents.
- delete(*items)[source]
The arguments are iid values. All the items in the widget that have matching iid values are destroyed, along with all their descendants.
- detach(*items)[source]
The arguments are iid values. All the items in the widget that have matching iid values are removed from the visible widget, along with all their descendants.
The items are not destroyed. You may reattach them to the visible tree using the .move() method described below.
- exists(iid)[source]
Returns True if there exists an item in the widget with the given iid, or False otherwise. If an item is not currently visible because it was removed with the .detach() method, it is still considered to exist for the purposes of the .exists() method.
- focus(iid=None)[source]
If you don’t provide an argument to this method, you get back either the iid of the item that currently has focus, or ‘’ if no item has focus.
You can give focus to an item by passing its iid as the argument to this method.
- get(parent='', as_dict=False)[source]
Get the selected items.
- Parameters:
parent (str = "") – Get selected children of the parent. Defaults to the entire tree.
as_dict (bool = False) – Return a dictionary keyed by the branching nodes, rather than a flat list.
- Returns:
[str] or dict(str
- Return type:
str|dict(str: str|dict(…)
- get_children(item=None)[source]
Returns a tuple of the iid values of the children of the item specified by the item argument. If the argument is omitted, you get a tuple containing the iid values of the top-level items.
- get_leaves(item=None)[source]
Returns the iid values of all leaves of the tree belove of the item specified by the item argument. If the argument is omitted, it gives the leaves for the entire tree.
- heading(cid, option=None, **kw)[source]
Use this method to configure the column heading that appears at the top of the widget for the column specified by cid, which may be either a column index or a column identifier. Use a cid argument value of ‘#0’ to configure the heading over the icon column.
Each heading has its own set of options with these names and values:
- anchor
An anchor that specifies how the heading is aligned within the column; see Section 5.5, “Anchors”. The default value is tk.W.
- command
A procedure to be called when the user clicks on this column heading.
- image
To present a graphic in the column heading (either with or instead of a text heading), set this option to an image, as specified in Section 5.9, “Images”.
- text
The text that you want to appear in the column heading.
If you supply no keyword arguments, the method will return a dictionary showing the current settings of the column heading options.
To interrogate the current value of some heading option X, use an argument of the form option=X; the method will return the current value of that option.
You can set one or more heading options by supplying them as keyword arguments such as “anchor=tk.CENTER”.
- identify_column(x)[source]
Given an x coordinate, this method returns a string of the form ‘#n’ that identifies the column that contains that x coordinate.
Assuming that the icon column is displayed, the value of n is 0 for the icon column; 1 for the second physical column; 2 for the third physical column; and so on. Recall that the physical column number may be different from the logical column number in cases where you have rearranged them using the displaycolumns argument to the Treeview constructor.
If the icon column is not displayed, the value of n is 1 for the first physical column, 2 for the second, and so on.
- identify_element(x, y)[source]
Returns the name of the element at location (x, y) relative to the widget, or ‘’ if no element appears at that position. Element names are discussed in Section 50, “The ttk element layer”.
- identify_region(x, y)[source]
Given the coordinates of a point relative to the widget, this method returns a string indicating what part of the widget contains that point. Return values may include:
- ‘nothing’
The point is not within a functional part of the widget.
- ‘heading’
The point is within one of the column headings.
- ‘separator’
The point is located within the column headings row, but on the separator between columns. Use the .identify_column() method to determine which column is located just to the left of this separator.
- ‘tree’
The point is located within the icon column.
- ‘cell’
The point is located within an item row but not within the icon column.
- identify_row(y)[source]
If y-coordinate y is within one of the items, this method returns the iid of that item. If that vertical coordinate is not within an item, this method returns an empty string.
- index(iid)[source]
This method returns the index of the item with the specified iid relative to its parent, counting from zero.
- insert(parent, index, iid=None, open=False, selected=False, state=True, tags=[], text='', values=[])[source]
This method adds a new item to the tree, and returns the item’s iid value.
- Parameters:
parent (str) – To insert a new top-level item, make this argument an empty string. To insert a new item as a child of an existing item, make this argument the parent item’s iid.
index (int or 'end') – This argument specifies the position among this parent’s children where you want the new item to be added. For example, to insert the item as the new first child, use a value of zero; to insert it after the parent’s first child, use a value of 1; and so on. To add the new item as the last child of the parent, make this argument’s value ‘end’.
iid (str = None) – You may supply an iid for the item as a string value. If you don’t supply an iid, one will be generated automatically and returned by the method.
open (bool) – This option specifies whether this item will be open initially. If you supply open=False, this item will be closed. If you supply open=True, the item’s children will be visible whenever the item itself is visible. The default value is False.
selected (bool = False) – Whether the item is initially selected.
state (bool = True) – Whether to correct the state of the tree, default=True
tags ([str] = []) – You may supply one or more tag strings to be associated with this item. The value may be either a single string or a sequence of strings.
text (str = "") – You may supply text to be displayed within the icon column of this item. If given, this text will appear just to the right of the icon, and also to the right of the image if provided.
values ([str] = []) – This argument supplies the data items to be displayed in each column of the item. The values are supplied in logical column order. If too few values are supplied, the remaining columns will be blank in this item; if too many values are supplied, the extras will be discarded.
- invoke(iid, recursive=True)[source]
Change the state of the item ‘iid’ just as if clicked.
- Parameters:
iid (str) – The unique id of the item in the tree.
recursive (bool) – Change all children, grandchildren, etc. if True
- Returns:
The return from any command invoked by changing the state.
- Return type:
any
- item(iid, option=None, **kw)[source]
Use this method to set or retrieve the options within the item specified by iid. Refer to the .insert() method above for the names of the item options.
With no arguments, it returns a dictionary whose keys are the option names and the corresponding values are the settings of those options. To retrieve the value of a given option, pass the option’s name as its second argument. To set one or more options, pass them as keyword arguments to the method.
- move(iid, parent, index)[source]
Move the item specified by iid to the values under the item specified by parent at position index. The parent and index arguments work the same as those arguments to the .index() method.
- next(iid)[source]
If the item specified by iid is not the last child of its parent, this method returns the iid of the following child; if it is the last child of its parent, this method returns an empty string. If the specified item is a top-level item, the method returns the iid of the next top-level item, or an empty string if the specified item is the last top-level item.
- parent(iid)[source]
If the item specified by iid is a top-level item, this method returns an empty string; otherwise it returns the iid of that item’s parent.
- prev(iid)[source]
If the item specified by iid is not the first child of its parent, this method returns the iid of the previous child; otherwise it returns an empty string. If the specified item is a top-level item, this method returns the iid of the previous top-level item, or an empty string if it is the first top-level item.
- see(iid)[source]
This method ensures that the item specified by iid is visible. Any of its ancestors that are closed are opened. The widget is scrolled, if necessary, so that the item appears.
- selection_add(items)[source]
In addition to any items already selected, add the specified items. The argument may be either a single iid or a sequence of iids.
- selection_remove(items)[source]
Unselect any items specified by the argument, which may be a single iid or a sequence of iids.
- selection_set(items)[source]
Only the specified items will be selected; if any other items were selected before, they will become unselected.
- selection_toggle(items)[source]
The argument may be a single iid or a sequence of iids. For each item specified by the argument, if it was selected, unselect it; if it was unselected, select it.
- set(iid, column=None, value=None)[source]
Use this method to retrieve or set the column values of the item specified by iid. With one argument, the method returns a dictionary: the keys are the column identifiers, and each related value is the text in the corresponding column.
With two arguments, the method returns the data value from the column of the selected item whose column identifier is the column argument. With three arguments, the item’s value for the specified column is set to the third argument.
- set_children(item, *newChildren)[source]
Use this method to change the set of children of the item whose iid is item. The newChildren argument is a sequence of iid strings. Any current children of item that are not in newChildren are removed.
- state(iid='', recursive=True)[source]
Determine the state of this item, and optionally its subtree.
- Parameters:
iid (str) – The item to check, or entire tree if “”
recursive (bool) – Whether to check the subtree
- Returns:
“checked”, “unchecked”, or “mixed”
- Return type:
str
- tag_bind(tagName, sequence=None, callback=None)[source]
This method binds the event handler specified by the callback argument to all items that have tag tagName. The sequence and callback arguments work the same as the sequence and func arguments of the .bind() method described in Section 26, “Universal widget methods”.
- tag_configure(tagName, option=None, **kw)[source]
This method can either interrogate or set options that affect the appearance of all the items that have tag tagName. Tag options include:
- ‘background’
The background color.
- ‘font’
The text font.
- ‘foreground’
The foreground color.
- ‘image’
An image to be displayed in items with the given tag.
When called with one argument, it returns a dictionary of the current tag options. To return the value of a specific option X, use X as the second argument.
To set one or more options, use keyword arguments such as foreground=’red’.
seamm_widgets.html_widgets module
tkinter HTML text widgets
MIT License
- class seamm_widgets.html_widgets.Bind[source]
Bases:
object
- IMAGE = 'image'
- KEY = 'bind'
- LINK = 'link'
- class seamm_widgets.html_widgets.Defs[source]
Bases:
object
- DEFAULT_TEXT_FONT_FAMILY = ('Segoe ui', 'Calibri', 'Helvetica', 'TkTextFont')
- FONT_SIZE = 14
- HEADINGS_FONT_SIZE = {'h1': 32, 'h2': 24, 'h3': 18, 'h4': 16, 'h5': 13, 'h6': 10}
- PREFORMATTED_FONT_FAMILY = ('Courier', 'DejaVu Sans Mono', 'TkFixedFont')
- class seamm_widgets.html_widgets.Fnt[source]
Bases:
object
- FAMILY = 'family'
- KEY = 'font'
- OVERSTRIKE = 'overstrike'
- SIZE = 'size'
- SLANT = 'slant'
- UNDERLINE = 'underline'
- WEIGHT = 'weight'
- class seamm_widgets.html_widgets.HTML[source]
Bases:
object
List of supported HTML tags and attrs
- class Attrs[source]
Bases:
object
- HEIGHT = 'height'
- HREF = 'href'
- SRC = 'src'
- STYLE = 'style'
- TYPE = 'type'
- WIDTH = 'width'
- HEADING_TAGS = ('h1', 'h2', 'h3', 'h4', 'h5', 'h6')
- NEW_LINE_TAGS = ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'div', 'p', 'pre', 'code')
- STYLE_TAGS = ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'div', 'p', 'pre', 'code', 'a', 'b', 'strong', 'i', 'em', 'u', 'mark', 'span')
- class Style[source]
Bases:
object
- BACKGROUND_COLOR = 'background-color'
- COLOR = 'color'
- FONT_FAMILY = 'font-family'
- FONT_SIZE = 'font-size'
- TEXT_ALIGN = 'text-align'
- TEXT_DECORATION = 'text-decoration'
- class StyleTextDecoration[source]
Bases:
object
- LINE_THROUGH = 'line-through'
- UNDERLINE = 'underline'
- TEXT_ALIGN_TAGS = ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'div', 'p', 'pre', 'code')
- class Tag[source]
Bases:
object
- A = 'a'
- B = 'b'
- BR = 'br'
- CODE = 'code'
- DIV = 'div'
- EM = 'em'
- H1 = 'h1'
- H2 = 'h2'
- H3 = 'h3'
- H4 = 'h4'
- H5 = 'h5'
- H6 = 'h6'
- I = 'i'
- IMG = 'img'
- LI = 'li'
- MARK = 'mark'
- OL = 'ol'
- P = 'p'
- PRE = 'pre'
- SPAN = 'span'
- STRONG = 'strong'
- U = 'u'
- UL = 'ul'
- class seamm_widgets.html_widgets.HTMLLabel(*args, html=None, **kwargs)[source]
Bases:
HTMLText
HTML label widget
- class seamm_widgets.html_widgets.HTMLScrolledText(*args, html=None, **kwargs)[source]
Bases:
_ScrolledText
HTML scrolled text widget
- class seamm_widgets.html_widgets.HTMLText(*args, html=None, **kwargs)[source]
Bases:
HTMLScrolledText
HTML text widget
- class seamm_widgets.html_widgets.WCfg[source]
Bases:
object
- BACKGROUND = 'background'
- FOREGROUND = 'foreground'
- JUSTIFY = 'justify'
- KEY = 'config'
- TABS = 'tabs'
seamm_widgets.keywords module
A Tk scrolled frame containing and handling keywords.
This megawidget displays a list of keywords that the user can add to and also delete. It provides tab completion as the user types, highlights incorrect keywords in red and generally helps the user find the keywords they wish.
- class seamm_widgets.keywords.Keywords(master, metadata=None, keywords='', width=None, anchor='n', height=None, mousewheel_speed=2, scroll_horizontally=True, xscrollbar=None, scroll_vertically=True, yscrollbar=None, background=None, logger=<Logger seamm_widgets.keywords (WARNING)>, **kwargs)[source]
Bases:
ScrolledFrame
A widget to handle manual input of keywords with optional values
- handle_keyword(keyword, row, w_name, value, before, action, changed)[source]
Handle typing in a combobox for the keyword
- Parameters:
keyword – the MOPAC keyword
w_name – the widget name
value – the value after the keystroke
before – the value before the keystroke
action – 0 for deletion, 1 for insertion
changed – the text being inserted or deleted
- property keywords
The current keywords, reflecting changes in the widgets
- property metadata
The current metadata
- post_cb(row)[source]
Handle post command for the combobox ‘w’
- Parameters:
w_name – the name of the widget (from %W)
- validate_keyword_value(keyword, w_name, value, before, action, changed)[source]
Handle typing in a combobox for the keyword
- Parameters:
keyword – the MOPAC keyword
w_name – the widget name
value – the value after the keystroke
before – the value before the keystroke
action – 0 for deletion, 1 for insertion
changed – the text being inserted or deleted
seamm_widgets.labeled_combobox module
Labeled combobox widget.
The goal of these widgets is twofold: to make it easier for developers to implement dialogs with compound widgets, and to naturally standardize the user interface presented to the user.
- class seamm_widgets.labeled_combobox.LabeledCombobox(parent, *args, **kwargs)[source]
Bases:
LabeledWidget
- configure(**kwargs)[source]
Configure resources of a widget.
The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys.
- show(*args)[source]
Show only the specified subwidgets. ‘all’ or no arguments reverts to showing all
- property value
seamm_widgets.labeled_entry module
Labeled entry widget.
The goal of these widgets is twofold: to make it easier for developers to implement dialogs with compound widgets, and to naturally standardize the user interface presented to the user.
seamm_widgets.labeled_widget module
Base class for labeled widgets.
The goal of these widgets is twofold: to make it easier for developers to implement dialogs with compound widgets, and to naturally standardize the user interface presented to the user.
seamm_widgets.mousewheel_support module
Add support for the mousewheel to scrolled widgets
Based on a version: # Version: 0.22 # Author: Miguel Martinez Lopez # Uncomment the next line to see my email # print(“Author’s email: “, # “61706c69636163696f6e616d656469646140676d61696c2e636f6d”.decode(“hex”))
with minor changes.
seamm_widgets.periodic_table module
A Tk scrolled frame with a periodic table of elements
This megawidget displays a periodic table for selecting one or optionally several elements. It works with a list of element symbols.
- class seamm_widgets.periodic_table.PeriodicTable(master, labelanchor='n', logger=<Logger seamm_widgets.periodic_table (WARNING)>, command=None, **kwargs)[source]
Bases:
LabeledWidget
A widget to handle manual input of keywords with optional values
- property command
A command to execute when an element is selected.
- property disabled
The elements that are disabled.
- property elements
seamm_widgets.property_table module
A Tk scrolled frame containing and handling a table of properties.
This megawidget displays a list of properties that the user can add to and also delete.
- class seamm_widgets.property_table.PropertyTable(master, metadata=None, properties='', logger=<Logger seamm_widgets.property_table (WARNING)>, labeltext='', **kwargs)[source]
Bases:
ScrolledFrame
A widget to handle manual input of property names
- property metadata
The current metadata
- property properties
The current properties, reflecting changes in the widgets
seamm_widgets.scrolled_columns module
A ttk-based widget for columns of widgets, with fixed titles and scrolling
This widgets has two areas: a row of titles across the top and a scrolled frame below it. It is used to make a table of widgets with fixed column headers.
seamm_widgets.scrolled_frame module
A Tk scrolled frame widget compatible with tkinter.ttk
Based on a version: # Version: 0.22 # Author: Miguel Martinez Lopez # Uncomment the next line to see my email # print(“Author’s email: “, # “61706c69636163696f6e616d656469646140676d61696c2e636f6d”.decode(“hex”))
with minor changes.
- class seamm_widgets.scrolled_frame.ScrolledFrame(master, width=None, anchor='n', height=None, mousewheel_speed=2, scroll_horizontally=True, xscrollbar=None, scroll_vertically=True, yscrollbar=None, background=None, inner_frame=<class 'tkinter.ttk.Frame'>, **kwargs)[source]
Bases:
Frame
- property height
- property width
seamm_widgets.scrolled_labelframe module
A Tk scrolled frame widget compatible with tkinter.ttk
Based on a version: # Version: 0.22 # Author: Miguel Martinez Lopez # Uncomment the next line to see my email # print(“Author’s email: “, # “61706c69636163696f6e616d656469646140676d61696c2e636f6d”.decode(“hex”))
with minor changes.
- class seamm_widgets.scrolled_labelframe.ScrolledLabelFrame(master, text=None, labelanchor=None, labelwidget=None, underline=None, width=None, anchor='n', height=None, mousewheel_speed=2, scroll_horizontally=True, xscrollbar=None, scroll_vertically=True, yscrollbar=None, background=None, inner_frame=<class 'tkinter.ttk.Frame'>, **kwargs)[source]
Bases:
Labelframe
- property height
- property width
seamm_widgets.search_criteria module
A Tk widget for gathering criteria for e.g. a search.
This widget provides a table of criteria, plus a ‘+’ button to add another row to the table. Each criterion is implemented as a “Criterion” widget, which has the following subwidgets:
- inclusion
A combobox giving an introductory condition, such as ‘with’ or ‘without’, or ‘contains’ or ‘does not contain’.
- field
A combobox giving the field to search, e.g. ‘keyword’ or ‘author’
- operator
A combobox giving the search operator, e.g. ‘<’, ‘>’ or ‘=’
- value
An entry for the value of the, e.g. ‘molecule’ or ‘Doe, John’
- value2
A second optional entry for operators such as ‘between’
Each of these subwidgets is itself a labeled widget, giving more flexibility in composing a reasonable natural language statement, such as:
entries that contain a keyword like molecule entries that do not contain a author like Doe, John
- class seamm_widgets.search_criteria.Criterion(parent, *args, **kwargs)[source]
Bases:
LabeledWidget
Class to provide a line in a search criteria widget.
- callback(event, what)[source]
Call the command for changes in the widget value. Also check the operator value and reconfigure the widget for one or two values if requested.
- set(*args)[source]
Set the values of the widgets as a tuple.
- Parameters:
args ([str] or str, str, str, str ,str) – either a single iterable of length 5 or 5 separate values…
- property two_values
Whether to display two values for e.g. ‘between’.
- class seamm_widgets.search_criteria.SearchCriteria(parent, *args, **kwargs)[source]
Bases:
ScrolledLabelFrame
Class to editable list of criteria for e.g. searching.
- add_row(values=None)[source]
Add a new row to the table.
- Parameters:
values ([5]) – Values to set the criterion widget with.
seamm_widgets.unit_combobox module
Labeled combobox widget with units.
The goal of these widgets is twofold: to make it easier for developers to implement dialogs with compound widgets, and to naturally standardize the user interface presented to the user.
seamm_widgets.unit_entry module
Labeled entry widget with units.
The goal of these widgets is twofold: to make it easier for developers to implement dialogs with compound widgets, and to naturally standardize the user interface presented to the user.
Module contents
seamm_widgets Custom Tk widgets for SEAMM.