Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create child window and communicate with parent in TkInter
    primarykey
    data
    text
    <p>I'm creating some dialogs using TkInter and need to be able to open a child sub-window (modal or modeless) on clicking a button in the parent. The child would then allow a data record to be created and this data (either the record or if the operation was cancelled) needs to be communicated back to the parent window. So far I have:</p> <pre><code>import sel_company_dlg from Tkinter import Tk def main(): root = Tk() myCmp = sel_company_dlg.SelCompanyDlg(root) root.mainloop() if __name__ == '__main__': main() </code></pre> <p>This invokes the top level dialog which allows the user to select a company. The company selection dialog looks like this:</p> <pre><code>class SelCompanyDlg(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent_ = parent self.frame_ = Frame( self.parent_ ) // .. more init stuff .. self.btNew_ = Button( self.frame_, text="New ...", command=self.onNew ) def onNew(self): root = Toplevel() myCmp = company_dlg.CompanyDlg(root) </code></pre> <p>On clicking the <strong>New ...</strong> button, a Create Company dialog is displayed which allows the user to fill in company details and click on create or cancel. Here's the opening bit of that:</p> <pre><code>class CompanyDlg(Frame): def __init__(self, parent): Frame.__init__(self, parent) // etc. </code></pre> <p>I'm struggling with the best way of invoking the child dialog in <code>onNew()</code> - what I have works but I'm not convinced it's the best approach and also, I can't see how to communicate the details to and from the child dialog.</p> <p>I've tried looking at online tutorials / references but what I've found is either too simplistic or focuses on things like <code>tkMessageBox.showinfo()</code> which iss not what I want.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload