diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/python~3.12/faq%2Fgui.html | |
new repository
Diffstat (limited to 'devdocs/python~3.12/faq%2Fgui.html')
| -rw-r--r-- | devdocs/python~3.12/faq%2Fgui.html | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/devdocs/python~3.12/faq%2Fgui.html b/devdocs/python~3.12/faq%2Fgui.html new file mode 100644 index 00000000..f870fa98 --- /dev/null +++ b/devdocs/python~3.12/faq%2Fgui.html @@ -0,0 +1,8 @@ + <h1>Graphic User Interface FAQ</h1> <ul> <li><a class="reference internal" href="#general-gui-questions" id="id2">General GUI Questions</a></li> <li><a class="reference internal" href="#what-gui-toolkits-exist-for-python" id="id3">What GUI toolkits exist for Python?</a></li> <li> +<p><a class="reference internal" href="#tkinter-questions" id="id4">Tkinter questions</a></p> <ul> <li><a class="reference internal" href="#how-do-i-freeze-tkinter-applications" id="id5">How do I freeze Tkinter applications?</a></li> <li><a class="reference internal" href="#can-i-have-tk-events-handled-while-waiting-for-i-o" id="id6">Can I have Tk events handled while waiting for I/O?</a></li> <li><a class="reference internal" href="#i-can-t-get-key-bindings-to-work-in-tkinter-why" id="id7">I can’t get key bindings to work in Tkinter: why?</a></li> </ul> </li> </ul> +<ul class="simple"> </ul> <section id="general-gui-questions"> <h2>General GUI Questions</h2> </section> <section id="what-gui-toolkits-exist-for-python"> <h2>What GUI toolkits exist for Python?</h2> <p>Standard builds of Python include an object-oriented interface to the Tcl/Tk widget set, called <a class="reference internal" href="../library/tk#tkinter"><span class="std std-ref">tkinter</span></a>. This is probably the easiest to install (since it comes included with most <a class="reference external" href="https://www.python.org/downloads/">binary distributions</a> of Python) and use. For more info about Tk, including pointers to the source, see the <a class="reference external" href="https://www.tcl.tk">Tcl/Tk home page</a>. Tcl/Tk is fully portable to the macOS, Windows, and Unix platforms.</p> <p>Depending on what platform(s) you are aiming at, there are also several alternatives. A <a class="reference external" href="https://wiki.python.org/moin/GuiProgramming#Cross-Platform_Frameworks">list of cross-platform</a> and <a class="reference external" href="https://wiki.python.org/moin/GuiProgramming#Platform-specific_Frameworks">platform-specific</a> GUI frameworks can be found on the python wiki.</p> </section> <section id="tkinter-questions"> <h2>Tkinter questions</h2> <section id="how-do-i-freeze-tkinter-applications"> <h3>How do I freeze Tkinter applications?</h3> <p>Freeze is a tool to create stand-alone applications. When freezing Tkinter applications, the applications will not be truly stand-alone, as the application will still need the Tcl and Tk libraries.</p> <p>One solution is to ship the application with the Tcl and Tk libraries, and point to them at run-time using the <code>TCL_LIBRARY</code> and <code>TK_LIBRARY</code> environment variables.</p> <p>To get truly stand-alone applications, the Tcl scripts that form the library have to be integrated into the application as well. One tool supporting that is SAM (stand-alone modules), which is part of the Tix distribution (<a class="reference external" href="https://tix.sourceforge.net/">https://tix.sourceforge.net/</a>).</p> <p>Build Tix with SAM enabled, perform the appropriate call to <code>Tclsam_init()</code>, etc. inside Python’s <code>Modules/tkappinit.c</code>, and link with libtclsam and libtksam (you might include the Tix libraries as well).</p> </section> <section id="can-i-have-tk-events-handled-while-waiting-for-i-o"> <h3>Can I have Tk events handled while waiting for I/O?</h3> <p>On platforms other than Windows, yes, and you don’t even need threads! But you’ll have to restructure your I/O code a bit. Tk has the equivalent of Xt’s <code>XtAddInput()</code> call, which allows you to register a callback function which will be called from the Tk mainloop when I/O is possible on a file descriptor. See <a class="reference internal" href="../library/tkinter#tkinter-file-handlers"><span class="std std-ref">File Handlers</span></a>.</p> </section> <section id="i-can-t-get-key-bindings-to-work-in-tkinter-why"> <h3>I can’t get key bindings to work in Tkinter: why?</h3> <p>An often-heard complaint is that event handlers <a class="reference internal" href="../library/tkinter#bindings-and-events"><span class="std std-ref">bound</span></a> to events with the <code>bind()</code> method don’t get handled even when the appropriate key is pressed.</p> <p>The most common cause is that the widget to which the binding applies doesn’t have “keyboard focus”. Check out the Tk documentation for the focus command. Usually a widget is given the keyboard focus by clicking in it (but not for labels; see the takefocus option).</p> </section> </section> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/faq/gui.html" class="_attribution-link">https://docs.python.org/3.12/faq/gui.html</a> + </p> +</div> |
