| 301 | return self.entry |
| 302 | |
| 303 | def validate(self): |
| 304 | try: |
| 305 | result = self.getresult() |
| 306 | except ValueError: |
| 307 | messagebox.showwarning( |
| 308 | "Illegal value", |
| 309 | self.errormessage + "\nPlease try again", |
| 310 | parent = self |
| 311 | ) |
| 312 | return 0 |
| 313 | |
| 314 | if self.minvalue is not None and result < self.minvalue: |
| 315 | messagebox.showwarning( |
| 316 | "Too small", |
| 317 | "The allowed minimum value is %s. " |
| 318 | "Please try again." % self.minvalue, |
| 319 | parent = self |
| 320 | ) |
| 321 | return 0 |
| 322 | |
| 323 | if self.maxvalue is not None and result > self.maxvalue: |
| 324 | messagebox.showwarning( |
| 325 | "Too large", |
| 326 | "The allowed maximum value is %s. " |
| 327 | "Please try again." % self.maxvalue, |
| 328 | parent = self |
| 329 | ) |
| 330 | return 0 |
| 331 | |
| 332 | self.result = result |
| 333 | |
| 334 | return 1 |
| 335 | |
| 336 | |
| 337 | class _QueryInteger(_QueryDialog): |