File selection dialog which checks that the file may be created.
| 245 | |
| 246 | |
| 247 | class SaveFileDialog(FileDialog): |
| 248 | |
| 249 | """File selection dialog which checks that the file may be created.""" |
| 250 | |
| 251 | title = "Save File Selection Dialog" |
| 252 | |
| 253 | def ok_command(self): |
| 254 | file = self.get_selection() |
| 255 | if os.path.exists(file): |
| 256 | if os.path.isdir(file): |
| 257 | self.master.bell() |
| 258 | return |
| 259 | d = Dialog(self.top, |
| 260 | title="Overwrite Existing File Question", |
| 261 | text="Overwrite existing file %r?" % (file,), |
| 262 | bitmap='questhead', |
| 263 | default=1, |
| 264 | strings=("Yes", "Cancel")) |
| 265 | if d.num != 0: |
| 266 | return |
| 267 | else: |
| 268 | head, tail = os.path.split(file) |
| 269 | if not os.path.isdir(head): |
| 270 | self.master.bell() |
| 271 | return |
| 272 | self.quit(file) |
| 273 | |
| 274 | |
| 275 | # For the following classes and modules: |
no outgoing calls
no test coverage detected
searching dependent graphs…