If entry is valid, bind it to 'result' and destroy tk widget. Otherwise leave dialog open for user to correct entry or cancel.
(self, event=None)
| 137 | return entry |
| 138 | |
| 139 | def ok(self, event=None): # Do not replace. |
| 140 | '''If entry is valid, bind it to 'result' and destroy tk widget. |
| 141 | |
| 142 | Otherwise leave dialog open for user to correct entry or cancel. |
| 143 | ''' |
| 144 | self.entry_error['text'] = '' |
| 145 | entry = self.entry_ok() |
| 146 | if entry is not None: |
| 147 | self.result = entry |
| 148 | self.destroy() |
| 149 | else: |
| 150 | # [Ok] moves focus. (<Return> does not.) Move it back. |
| 151 | self.entry.focus_set() |
| 152 | |
| 153 | def cancel(self, event=None): # Do not replace. |
| 154 | "Set dialog result to None and destroy tk widget." |