fsleyes_widgets.texttag

This module provides two classes:

StaticTextTag

The StaticTextTag class is a wx.Panel which contains a StaticText control, and a close button.

TextTagPanel

The TextTagPanel is a panel which contains a control allowing the user to add new tags, and a collection of StaticTextTag controls.

_images/texttagpanel.png
fsleyes_widgets.texttag.complementary_colour(rgb)[source]

Given a RGB colour, estimates a colour which complements it. Used by the StaticTextTag class to generate a foreground (text) colour for a specific background colour.

Taken from the FSLeyes source code (fsleyes.colourmaps.complementaryColour)

class fsleyes_widgets.texttag.StaticTextTag(parent, text=None, bgColour='#aaaaaa', borderColour='#ffcdcd')[source]

Bases: Panel

The StaticTextTag class is a wx.Panel which contains a StaticText control, and a close button. The displayed text and background colour are configurable.

When the close button is pushed, an EVT_STT_CLOSE is generated.

Create a StaticTextTag.

Parameters:
  • parent – The wx parent object.

  • text – Initial text to display.

  • bgColour – Initial background colour.

  • borderColour – Initial border colour.

property closeButton

Returns a reference to the StaticText control used as the close button.

property text

Returns a reference to the StaticText control used for displaying the tag text.

SetBackgroundColour(colour)[source]

Sets the background colour of this StaticTextTag. Also automatically sets the foreground (text) colour to a complementary colour.

SetBorderColour(colour)[source]

Sets the border colour of this StaticTextTag, for when it has focus.

SetText(text)[source]

Sets the text shown on this StaticTextTag.

GetText()[source]

Returns the text shown on this StaticTextTag.

fsleyes_widgets.texttag.EVT_STT_CLOSE = <wx.core.PyEventBinder object>

Identifier for the event generated by a StaticTextTag when its close button is pushed.

fsleyes_widgets.texttag.StaticTextTagCloseEvent

Event object created for an EVT_STT_CLOSE.

class fsleyes_widgets.texttag.TextTagPanel(parent, style=None)[source]

Bases: Panel

The TextTagPanel is a panel which contains a control allowing the user to add new tags, and a collection of StaticTextTag controls.

The TextTagPanel supports the following styles:

TTP_ALLOW_NEW_TAGS

Style flag for use with a TextTagPanel - if set, the user is able to type in tag names that are not known by the AutoTextCtrl.

TTP_ADD_NEW_TAGS

Style flag for use with a TextTagPanel - if set, when the user types in a tag name that is not known by the AutoTextCtrl, that name is added to its list of options.

TTP_NO_DUPLICATES

Style flag for use with a TextTagPanel - if set, the user will be prevented from adding the same tag more than once.

TTP_CASE_SENSITIVE

Style flag for use with a TextTagPanel - if set, the auto-completion options will be case sensitive.

TTP_KEYBOARD_NAV

Style flag for use with a TextTagPanel - if set, the user can use the left and right arrow keys to move between the new tag control and the tags and, when a tag is focused can use the delete/backspace keys to remove it.

The TextTagPanel generates the following events:

EVT_TTP_TAG_REMOVED

Identifier for the event generated when a tag is removed from a TextTagPanel.

EVT_TTP_TAG_ADDED

Identifier for the event generated when a tag is added to a TextTagPanel.

EVT_TTP_TAG_SELECT

Identifier for the event generated when a tag is selected in a TextTagPanel.

Create a TextTagPanel.

Parameters:
  • parent – The wx parent object.

  • style – Style flags. Defaults to TTP_ALLOW_NEW_TAGS | TTP_ADD_NEW_TAGS.

property newTagCtrl

Returns a reference to the AutoTextCtrl.

property tags

Returns a list containing all StaticTextTag widgets.

FocusNewTagCtrl()[source]

Gives focus to the new tag control (an AutoTextCtrl).

SelectTag(tag)[source]

Gives focus to the StaticTextTag control with the specified tag, if it exists.

SetOptions(options, colours=None)[source]

Sets the tag options made available to the user via the AutoTextCtrl.

Parameters:
  • options – A sequence of tags that the user can choose from.

  • colours – A sequence of corresponding colours for each tag.

GetOptions()[source]

Returns a list of all the tags that are currently available to the user.

AddTag(tag, colour=None)[source]

Add a new StaticTextTag to this TextTagPanel.

Parameters:
  • tag – The tag text.

  • colour – The tag background colour.

RemoveTag(tag)[source]

Removes the specified tag.

GetTags()[source]

Returns a list containing all active tags in this TextTagPanel.

ClearTags()[source]

Removes all tags from this TextTagPanel.

GetTagIndex(tag)[source]

Returns the index of the specified tag.

TagCount()[source]

Returns the number of tags currently visible.

HasTag(tag)[source]

Returns True if the given tag is currently shown, False otherwise.

GetTagColour(tag)[source]

Returns the background colour of the specified tag, or None if there is no default colour for the tag.

SetTagColour(tag, colour)[source]

Sets the background colour on all StaticTextTag items which have the given tag text.

fsleyes_widgets.texttag.TTP_ALLOW_NEW_TAGS = 1

Style flag for use with a TextTagPanel - if set, the user is able to type in tag names that are not known by the AutoTextCtrl.

fsleyes_widgets.texttag.TTP_ADD_NEW_TAGS = 2

Style flag for use with a TextTagPanel - if set, when the user types in a tag name that is not known by the AutoTextCtrl, that name is added to its list of options. This flag only has an effect if the TTP_ALLOW_NEW_TAGS flag is also set.

fsleyes_widgets.texttag.TTP_NO_DUPLICATES = 4

Style flag for use with a TextTagPanel - if set, the user will be prevented from adding the same tag more than once.

fsleyes_widgets.texttag.TTP_CASE_SENSITIVE = 8

Style flag for use with a TextTagPanel - if set, the auto-completion options will be case sensitive. This flag only has an effect if the TTP_ALLOW_NEW_TAGS flag is also set.

fsleyes_widgets.texttag.TTP_KEYBOARD_NAV = 16

Style flag for use with a TextTagPanel - if set, the user can use the left and right arrow keys to move between the new tag control and the tags and, when a tag is focused can use the delete/backspace keys to remove it.

fsleyes_widgets.texttag.EVT_TTP_TAG_ADDED = <wx.core.PyEventBinder object>

Identifier for the event generated when a tag is added to a TextTagPanel.

fsleyes_widgets.texttag.TextTagPanelTagAddedEvent

Event generated when a tag is added to a TextTagPanel. A TextTagPanelTagAddedEvent has a single attribute called tag, which contains the tag text.

fsleyes_widgets.texttag.EVT_TTP_TAG_REMOVED = <wx.core.PyEventBinder object>

Identifier for the event generated when a tag is removed from a TextTagPanel.

fsleyes_widgets.texttag.TextTagPanelTagRemovedEvent

Event generated when a tag is removed from a TextTagPanel. A TextTagPanelTagRemovedEvent has a single attribute called tag, which contains the tag text.

fsleyes_widgets.texttag.EVT_TTP_TAG_SELECT = <wx.core.PyEventBinder object>

Identifier for the event generated when a tag is selected in a TextTagPanel.

fsleyes_widgets.texttag.TextTagPanelTagSelectEvent

Event generated when a tag is selected in a TextTagPanel. A TextTagPanelTagSelectEvent has a single attribute called tag, which contains the tag text.