introduction to gui programming in column (the name and url text entry widgetswill grow to take advantage of the extra space similarlywe make the window' column horizontally resizable by setting its weight to if the user changes the dialog' heightthe widgets will keep their relative positions and all of them will be centered within the windowbut if the user changes the dialog' widththe name and url text entry widgets will shrink or grow to fit the available horizontal space self bind(""lambda *ignorenameentry focus_set()self bind(""lambda *ignoreurlentry focus_set()self bind(""self okself bind(""self closeself protocol("wm_delete_window"self closeself grab_set(self wait_window(selfwe created two labelsnameand url:which indicate that they have keyboard accelerators alt+ and alt+uwhich when clicked will give the keyboard focus to their corresponding text entry widgets to make this work we have provided the necessary keyboard bindings we use lambda functions rather than pass the focus_set(methods directly so that we can ignore the event argument we have also provided the standard keyboard bindings (enter and escfor the ok and cancel buttons we use the protocol(method to specify the method to call if the user closes the dialog by clicking the close button the calls to grab_set(and wait_window(are both needed to turn the window into modal dialog def ok(selfevent=none)self name self namevar get(self url self urlvar get(self accepted true self close(if the user clicks ok (or presses enter)this method is called the texts from the tkinter stringvars are copied to correponding instance variables (which are only now created)the self accepted variable is set to trueand we call self close(to close the dialog def close(selfevent=none)self parent focus_set(self destroy(this method is called from the self ok(methodor if the user clicks the window' close box or if the user clicks cancel (or presses escit gives the keyboard focus back to the parent and makes the dialog destroy itself in this context destroy just means that the window and its widgets are destroyedthe addeditform instance continues to exist because the caller has reference to it