TextWindow¶
-
class
decida.TextWindow.
TextWindow
(parent=None, **kwargs)¶ Bases:
decida.ItclObjectx.ItclObjectx
,Tkinter.Frame
synopsis:
Text window graphical user-interface.
TextWindow is a graphical user-interface wrapper around the Tkinter Text widget. On menus, it provides several ways to reformat the displayed text, such as lining up rows, (true) wrapping text, piping the text through sort, awk, or some other command. TextWindow also has text searching and text highlighting. And there are many other tools.
The DeCiDa application twin simply instantiates one TextWindow object.
constructor arguments:
parent (Tkinter handle, default=None)
handle of frame or other widget to pack text-window in. If this is not specified, top-level is created.**kwargs (dict)
configuration-options or optionoptions:
file (str)
name of file to read into text-windowresults:
- Sets up text window with menu at top.
- Configures binding for sending commands to program when user types
- return.
configuration options:
verbose (bool, default=False)
enable verbose modetext_height (int, default=24)
Height of TextWindow window in charstext_width (int, default=80)
Width of TextWindow window in charstext_background (str, default=”GhostWhite”)
Background of TextWindow windowtext_foreground (str, default=”blue”)
Foreground of TextWindow windowprogcmd (str, default=””)
Prefix of command to send user-input to program. The progcmd capability is not yet implemented.prompt (str, default=”>”)
Prompt to place in text window. The progcmd capability is not yet implemented.wait (bool, default=False)
wait in main-loop until window is destroyeddestroy (bool, default=False)
destroy main windowexample:
>>> twin = TextWindow(wait=False) >>> twin.enter("abc") >>> twin.wait()
public methods:
- public methods from ItclObjectx
-
choose_color
()¶ set highlight color using color dialog.
results:
- Display Tk color dialog (depends on the system)
- Set the color which is to be used to highlight lines of the Text window.
-
choose_comment_char
()¶ set comment character.
results:
- Display dialog to choose a comment character.
- Type in the comment character, which is used by some of the Edit tools.
-
clear
()¶ delete all text.
results:
- The Text window is cleared of all text.
-
delete_lines
(highlightedflag=False)¶ delete lines of text.
arguments:
highlightedflag (bool, default=False)
If True, delete highlighted lines, else delete unhighlighted lines.results:
- Text window lines are deleted: if highlightedflag is True, delete only highlighted lines, otherwise delete unhighlighted lines.
-
enter
(input)¶ enter text.
arguments:
input (str, default=None)
Lines of text to enter into the Text window.results:
- The input lines are entered into the Text window.
-
fileread
(file=None)¶ read file.
arguments:
file (str, default=None)
Name of a file to read and display/edit. If file is not specified, then a file dialog is used to find a file to read in.results:
- Once a file name is found, and it is a valid file, then it is read in and displayed in the Text window.
-
filesave
()¶ save file using current file name.
results:
- Save the contents of the Text window to the current file name, which is established when a file is read-in, or a file is specified to write to.
-
filesaveas
()¶ save file using filesave dialog.
arguments:
file (str, default=None)
Name of a file to save the Text contents to. If file is not specified, then a file dialog is used to find a file name to create or over-write.results:
- Once a file name is found, and it is a valid file, then it is written or over-written with the contents of the Text window.
-
find
(texttofind)¶ find text.
arguments:
texttofine (str)
Text to locate in the Text window.results:
- If text is found, the Text window view is shifted to the line where the found text resides and the text is highlighted in red foreground.
-
get
()¶ return text from begtext to endtext marks.
results:
- Return text between begtext and endtext marks, including newlines. The begtext and endtext marks are established by (text) highlighting a region of the Text window contents.
-
getall
()¶ return all text.
results:
- Return all of the Text window contents, including newlines.
-
gethighlightedlinelist
()¶ get highlighted lines of text as a list.
results:
- Return list of lines of text which are highlighted.
-
getlinelist
()¶ return lines of text as a list.
results:
- Return all of the Text window contents, split into a list by newlines.
-
help
()¶ help callback.
results:
- Help FrameNotebook is displayed.
-
highlight_clear
(lineno=None)¶ clear highlighting.
arguments:
lineno (int, default=None)
line number to clear highlighting.results:
- Clear highlighting from specified line (lineno).
-
highlight_line
(lineno)¶ highlight a line of text.
arguments:
lineno (int, default=None)
line number to highlight.results:
- Highlight specified line.
-
highlight_lines
()¶ highlight lines of text.
results:
- Highlight lines where text is selected, or insert cursor is placed.
-
static
is_commented
(s, comment_char='#')¶ return true if line begins with a comment character.
arguments:
s (str)
A line of textcomment_char (str, default=”#”)
The specified comment characterresults:
- If the specified comment character is the first character in s, return True, else False.
-
join_spectre
()¶ join spectre netlist continued lines.
-
join_spice
()¶ join spice netlist continued lines.
-
static
linecol
(linespec)¶ convert a linespec into line and column
arguments:
linespec (str)
Tk line-specification string in the format line.colresults:
- returns the line, col where line and col are integers
-
lineup
()¶ line up all un-commented lines.
-
lineupcsv
()¶ line up all un-commented lines.
-
pipethrough
()¶ pipe text lines through command.
-
pipethrough_awk
()¶ pipe text lines through command.
-
pipethrough_sort
()¶ pipe text lines through command.
-
redo
()¶ redo last change.
results:
- Last Text window editing change which was undone is redone.
-
shift_highlighted_lines
(shift_left=False)¶ shift highlighted lines right or left.
arguments:
shift_left (bool, default=False)
If True, shift left, otherwise shift right.results:
- Highlighted text is shifted right or left by 4 characters. For left-shift, only lines that have 4 spaces to spare at the beginning of the line are shifted.
-
splitup
()¶ split up text lines.
-
tbprint
()¶ print.
results:
- print Text window contents, using the current print command.
-
trimlines
()¶ trim lines of text.
-
truewrap
()¶ wrap text lines by modifying text.
results:
- The contents of the Text display are modified such that each line of text is limited to 80 characters or less.
-
undo
()¶ undo last change.
results:
- Last Text window editing change is undone.
-
wait
(text=None)¶ wait in main-loop until main window is destroyed.
arguments:
text (str, default=None)
If text is specified, a button is displayed with the text in the button. Clicking the button releases the application from the main event-loop.results:
- If no text is displayed, then the application waits for the TextWindow instance to somehow be destroyed. If text was specified, then the application waits until the button is clicked.
-
wrap
()¶ wrap text.
results:
- The Text window wrap display is toggled. The actual contents of the Text window are not changed.