An editor window that can serve as an output file. Also the future base class for the Python shell window. This class has no input facilities. Adds binding to open a file at a line to the text widget.
| 56 | |
| 57 | |
| 58 | class OutputWindow(EditorWindow): |
| 59 | """An editor window that can serve as an output file. |
| 60 | |
| 61 | Also the future base class for the Python shell window. |
| 62 | This class has no input facilities. |
| 63 | |
| 64 | Adds binding to open a file at a line to the text widget. |
| 65 | """ |
| 66 | |
| 67 | # Our own right-button menu |
| 68 | rmenu_specs = [ |
| 69 | ("Cut", "<<cut>>", "rmenu_check_cut"), |
| 70 | ("Copy", "<<copy>>", "rmenu_check_copy"), |
| 71 | ("Paste", "<<paste>>", "rmenu_check_paste"), |
| 72 | (None, None, None), |
| 73 | ("Go to file/line", "<<goto-file-line>>", None), |
| 74 | ] |
| 75 | |
| 76 | allow_code_context = False |
| 77 | |
| 78 | def __init__(self, *args): |
| 79 | EditorWindow.__init__(self, *args) |
| 80 | self.text.bind("<<goto-file-line>>", self.goto_file_line) |
| 81 | |
| 82 | # Customize EditorWindow |
| 83 | def ispythonsource(self, filename): |
| 84 | "Python source is only part of output: do not colorize." |
| 85 | return False |
| 86 | |
| 87 | def short_title(self): |
| 88 | "Customize EditorWindow title." |
| 89 | return "Output" |
| 90 | |
| 91 | def maybesave(self): |
| 92 | "Customize EditorWindow to not display save file messagebox." |
| 93 | return 'yes' if self.get_saved() else 'no' |
| 94 | |
| 95 | # Act as output file |
| 96 | def write(self, s, tags=(), mark="insert"): |
| 97 | """Write text to text widget. |
| 98 | |
| 99 | The text is inserted at the given index with the provided |
| 100 | tags. The text widget is then scrolled to make it visible |
| 101 | and updated to display it, giving the effect of seeing each |
| 102 | line as it is added. |
| 103 | |
| 104 | Args: |
| 105 | s: Text to insert into text widget. |
| 106 | tags: Tuple of tag strings to apply on the insert. |
| 107 | mark: Index for the insert. |
| 108 | |
| 109 | Return: |
| 110 | Length of text inserted. |
| 111 | """ |
| 112 | assert isinstance(s, str) |
| 113 | self.text.insert(mark, s, tags) |
| 114 | self.text.see(mark) |
| 115 | self.text.update() |
no outgoing calls
no test coverage detected
searching dependent graphs…