expand event handler This inserts the original text in place of the button in the Text widget, removes the button and updates the Squeezer instance. If the original text is dangerously long, i.e. expanding it could cause a performance degradation, ask the user for c
(self, event=None)
| 136 | ) |
| 137 | |
| 138 | def expand(self, event=None): |
| 139 | """expand event handler |
| 140 | |
| 141 | This inserts the original text in place of the button in the Text |
| 142 | widget, removes the button and updates the Squeezer instance. |
| 143 | |
| 144 | If the original text is dangerously long, i.e. expanding it could |
| 145 | cause a performance degradation, ask the user for confirmation. |
| 146 | """ |
| 147 | if self.is_dangerous is None: |
| 148 | self.set_is_dangerous() |
| 149 | if self.is_dangerous: |
| 150 | confirm = messagebox.askokcancel( |
| 151 | title="Expand huge output?", |
| 152 | message="\n\n".join([ |
| 153 | "The squeezed output is very long: %d lines, %d chars.", |
| 154 | "Expanding it could make IDLE slow or unresponsive.", |
| 155 | "It is recommended to view or copy the output instead.", |
| 156 | "Really expand?" |
| 157 | ]) % (self.numoflines, len(self.s)), |
| 158 | default=messagebox.CANCEL, |
| 159 | parent=self.text) |
| 160 | if not confirm: |
| 161 | return "break" |
| 162 | |
| 163 | index = self.text.index(self) |
| 164 | self.base_text.insert(index, self.s, self.tags) |
| 165 | self.base_text.delete(self) |
| 166 | self.editwin.on_squeezed_expand(index, self.s, self.tags) |
| 167 | self.squeezer.expandingbuttons.remove(self) |
| 168 | |
| 169 | def copy(self, event=None): |
| 170 | """copy event handler |