Create entry (rows, extras, buttons. Entry stuff on rows 0-2, spanning cols 0-2. Buttons on row 99, cols 1, 2.
(self, ok_text='OK')
| 87 | self.wait_window() |
| 88 | |
| 89 | def create_widgets(self, ok_text='OK'): # Do not replace. |
| 90 | """Create entry (rows, extras, buttons. |
| 91 | |
| 92 | Entry stuff on rows 0-2, spanning cols 0-2. |
| 93 | Buttons on row 99, cols 1, 2. |
| 94 | """ |
| 95 | # Bind to self the widgets needed for entry_ok or unittest. |
| 96 | self.frame = frame = Frame(self, padding=10) |
| 97 | frame.grid(column=0, row=0, sticky='news') |
| 98 | frame.grid_columnconfigure(0, weight=1) |
| 99 | |
| 100 | entrylabel = Label(frame, anchor='w', justify='left', |
| 101 | text=self.message) |
| 102 | self.entryvar = StringVar(self, self.text0) |
| 103 | self.entry = Entry(frame, width=30, textvariable=self.entryvar) |
| 104 | self.error_font = Font(name='TkCaptionFont', |
| 105 | exists=True, root=self.parent) |
| 106 | self.entry_error = Label(frame, text=' ', foreground='red', |
| 107 | font=self.error_font) |
| 108 | # Display or blank error by setting ['text'] =. |
| 109 | entrylabel.grid(column=0, row=0, columnspan=3, padx=5, sticky=W) |
| 110 | self.entry.grid(column=0, row=1, columnspan=3, padx=5, sticky=W+E, |
| 111 | pady=[10,0]) |
| 112 | self.entry_error.grid(column=0, row=2, columnspan=3, padx=5, |
| 113 | sticky=W+E) |
| 114 | |
| 115 | self.create_extra() |
| 116 | |
| 117 | self.button_ok = Button( |
| 118 | frame, text=ok_text, default='active', command=self.ok) |
| 119 | self.button_cancel = Button( |
| 120 | frame, text='Cancel', command=self.cancel) |
| 121 | |
| 122 | self.button_ok.grid(column=1, row=99, padx=5) |
| 123 | self.button_cancel.grid(column=2, row=99, padx=5) |
| 124 | |
| 125 | def create_extra(self): pass # Override to add widgets. |
| 126 |