Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 272358a29dcac700c15f72584b3d4e55 > files > 616

python3-docs-3.7.10-1.1.mga7.noarch.rpm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>Graphic User Interface FAQ &#8212; Python 3.7.10 documentation</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.7.10 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="“Why is Python Installed on my Computer?” FAQ" href="installed.html" />
    <link rel="prev" title="Python on Windows FAQ" href="windows.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/faq/gui.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="installed.html" title="“Why is Python Installed on my Computer?” FAQ"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="windows.html" title="Python on Windows FAQ"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.10 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python Frequently Asked Questions</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="graphic-user-interface-faq">
<h1><a class="toc-backref" href="#id2">Graphic User Interface FAQ</a><a class="headerlink" href="#graphic-user-interface-faq" title="Permalink to this headline">¶</a></h1>
<div class="contents topic" id="contents">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#graphic-user-interface-faq" id="id2">Graphic User Interface FAQ</a></p>
<ul>
<li><p><a class="reference internal" href="#general-gui-questions" id="id3">General GUI Questions</a></p></li>
<li><p><a class="reference internal" href="#what-platform-independent-gui-toolkits-exist-for-python" id="id4">What platform-independent GUI toolkits exist for Python?</a></p>
<ul>
<li><p><a class="reference internal" href="#tkinter" id="id5">Tkinter</a></p></li>
<li><p><a class="reference internal" href="#wxwidgets" id="id6">wxWidgets</a></p></li>
<li><p><a class="reference internal" href="#qt" id="id7">Qt</a></p></li>
<li><p><a class="reference internal" href="#gtk" id="id8">Gtk+</a></p></li>
<li><p><a class="reference internal" href="#kivy" id="id9">Kivy</a></p></li>
<li><p><a class="reference internal" href="#fltk" id="id10">FLTK</a></p></li>
<li><p><a class="reference internal" href="#opengl" id="id11">OpenGL</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#what-platform-specific-gui-toolkits-exist-for-python" id="id12">What platform-specific GUI toolkits exist for Python?</a></p></li>
<li><p><a class="reference internal" href="#tkinter-questions" id="id13">Tkinter questions</a></p>
<ul>
<li><p><a class="reference internal" href="#how-do-i-freeze-tkinter-applications" id="id14">How do I freeze Tkinter applications?</a></p></li>
<li><p><a class="reference internal" href="#can-i-have-tk-events-handled-while-waiting-for-i-o" id="id15">Can I have Tk events handled while waiting for I/O?</a></p></li>
<li><p><a class="reference internal" href="#i-can-t-get-key-bindings-to-work-in-tkinter-why" id="id16">I can’t get key bindings to work in Tkinter: why?</a></p></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="general-gui-questions">
<h2><a class="toc-backref" href="#id3">General GUI Questions</a><a class="headerlink" href="#general-gui-questions" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="what-platform-independent-gui-toolkits-exist-for-python">
<h2><a class="toc-backref" href="#id4">What platform-independent GUI toolkits exist for Python?</a><a class="headerlink" href="#what-platform-independent-gui-toolkits-exist-for-python" title="Permalink to this headline">¶</a></h2>
<p>Depending on what platform(s) you are aiming at, there are several.  Some
of them haven’t been ported to Python 3 yet.  At least <a class="reference internal" href="#tkinter">Tkinter</a> and <a class="reference internal" href="#qt">Qt</a>
are known to be Python 3-compatible.</p>
<div class="section" id="tkinter">
<h3><a class="toc-backref" href="#id5">Tkinter</a><a class="headerlink" href="#tkinter" title="Permalink to this headline">¶</a></h3>
<p>Standard builds of Python include an object-oriented interface to the Tcl/Tk
widget set, called <a class="reference internal" href="../library/tk.html#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
Mac OS X, Windows, and Unix platforms.</p>
</div>
<div class="section" id="wxwidgets">
<h3><a class="toc-backref" href="#id6">wxWidgets</a><a class="headerlink" href="#wxwidgets" title="Permalink to this headline">¶</a></h3>
<p>wxWidgets (<a class="reference external" href="https://www.wxwidgets.org">https://www.wxwidgets.org</a>) is a free, portable GUI class
library written in C++ that provides a native look and feel on a
number of platforms, with Windows, Mac OS X, GTK, X11, all listed as
current stable targets.  Language bindings are available for a number
of languages including Python, Perl, Ruby, etc.</p>
<p><a class="reference external" href="https://www.wxpython.org">wxPython</a> is the Python binding for
wxwidgets.  While it often lags slightly behind the official wxWidgets
releases, it also offers a number of features via pure Python
extensions that are not available in other language bindings.  There
is an active wxPython user and developer community.</p>
<p>Both wxWidgets and wxPython are free, open source, software with
permissive licences that allow their use in commercial products as
well as in freeware or shareware.</p>
</div>
<div class="section" id="qt">
<h3><a class="toc-backref" href="#id7">Qt</a><a class="headerlink" href="#qt" title="Permalink to this headline">¶</a></h3>
<p>There are bindings available for the Qt toolkit (using either <a class="reference external" href="https://riverbankcomputing.com/software/pyqt/intro">PyQt</a> or <a class="reference external" href="https://wiki.qt.io/PySide">PySide</a>) and for KDE (<a class="reference external" href="https://techbase.kde.org/Languages/Python/Using_PyKDE_4">PyKDE4</a>).
PyQt is currently more mature than PySide, but you must buy a PyQt license from
<a class="reference external" href="https://www.riverbankcomputing.com/commercial/license-faq">Riverbank Computing</a>
if you want to write proprietary applications.  PySide is free for all applications.</p>
<p>Qt 4.5 upwards is licensed under the LGPL license; also, commercial licenses
are available from <a class="reference external" href="https://www.qt.io/licensing/">The Qt Company</a>.</p>
</div>
<div class="section" id="gtk">
<h3><a class="toc-backref" href="#id8">Gtk+</a><a class="headerlink" href="#gtk" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference external" href="https://wiki.gnome.org/Projects/PyGObject">GObject introspection bindings</a>
for Python allow you to write GTK+ 3 applications.  There is also a
<a class="reference external" href="https://python-gtk-3-tutorial.readthedocs.io">Python GTK+ 3 Tutorial</a>.</p>
<p>The older PyGtk bindings for the <a class="reference external" href="https://www.gtk.org">Gtk+ 2 toolkit</a> have
been implemented by James Henstridge; see &lt;<a class="reference external" href="http://www.pygtk.org">http://www.pygtk.org</a>&gt;.</p>
</div>
<div class="section" id="kivy">
<h3><a class="toc-backref" href="#id9">Kivy</a><a class="headerlink" href="#kivy" title="Permalink to this headline">¶</a></h3>
<p><a class="reference external" href="https://kivy.org/">Kivy</a> is a cross-platform GUI library supporting both
desktop operating systems (Windows, macOS, Linux) and mobile devices (Android,
iOS).  It is written in Python and Cython, and can use a range of windowing
backends.</p>
<p>Kivy is free and open source software distributed under the MIT license.</p>
</div>
<div class="section" id="fltk">
<h3><a class="toc-backref" href="#id10">FLTK</a><a class="headerlink" href="#fltk" title="Permalink to this headline">¶</a></h3>
<p>Python bindings for <a class="reference external" href="http://www.fltk.org">the FLTK toolkit</a>, a simple yet
powerful and mature cross-platform windowing system, are available from <a class="reference external" href="http://pyfltk.sourceforge.net">the
PyFLTK project</a>.</p>
</div>
<div class="section" id="opengl">
<h3><a class="toc-backref" href="#id11">OpenGL</a><a class="headerlink" href="#opengl" title="Permalink to this headline">¶</a></h3>
<p>For OpenGL bindings, see <a class="reference external" href="http://pyopengl.sourceforge.net">PyOpenGL</a>.</p>
</div>
</div>
<div class="section" id="what-platform-specific-gui-toolkits-exist-for-python">
<h2><a class="toc-backref" href="#id12">What platform-specific GUI toolkits exist for Python?</a><a class="headerlink" href="#what-platform-specific-gui-toolkits-exist-for-python" title="Permalink to this headline">¶</a></h2>
<p>By installing the <a class="reference external" href="https://pypi.org/project/pyobjc/">PyObjc Objective-C bridge</a>, Python programs can use Mac OS X’s
Cocoa libraries.</p>
<p><a class="reference internal" href="windows.html#windows-faq"><span class="std std-ref">Pythonwin</span></a> by Mark Hammond includes an interface to the
Microsoft Foundation Classes and a Python programming environment
that’s written mostly in Python using the MFC classes.</p>
</div>
<div class="section" id="tkinter-questions">
<h2><a class="toc-backref" href="#id13">Tkinter questions</a><a class="headerlink" href="#tkinter-questions" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-do-i-freeze-tkinter-applications">
<h3><a class="toc-backref" href="#id14">How do I freeze Tkinter applications?</a><a class="headerlink" href="#how-do-i-freeze-tkinter-applications" title="Permalink to this headline">¶</a></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 <span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TCL_LIBRARY</span></code> and <span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TK_LIBRARY</span></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="http://tix.sourceforge.net/">http://tix.sourceforge.net/</a>).</p>
<p>Build Tix with SAM enabled, perform the appropriate call to
<code class="xref c c-func docutils literal notranslate"><span class="pre">Tclsam_init()</span></code>, etc. inside Python’s
<code class="file docutils literal notranslate"><span class="pre">Modules/tkappinit.c</span></code>, and link with libtclsam and libtksam (you
might include the Tix libraries as well).</p>
</div>
<div class="section" id="can-i-have-tk-events-handled-while-waiting-for-i-o">
<h3><a class="toc-backref" href="#id15">Can I have Tk events handled while waiting for I/O?</a><a class="headerlink" href="#can-i-have-tk-events-handled-while-waiting-for-i-o" title="Permalink to this headline">¶</a></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 class="xref c c-func docutils literal notranslate"><span class="pre">XtAddInput()</span></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.html#tkinter-file-handlers"><span class="std std-ref">File Handlers</span></a>.</p>
</div>
<div class="section" id="i-can-t-get-key-bindings-to-work-in-tkinter-why">
<h3><a class="toc-backref" href="#id16">I can’t get key bindings to work in Tkinter: why?</a><a class="headerlink" href="#i-can-t-get-key-bindings-to-work-in-tkinter-why" title="Permalink to this headline">¶</a></h3>
<p>An often-heard complaint is that event handlers bound to events with the
<code class="xref py py-meth docutils literal notranslate"><span class="pre">bind()</span></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>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Graphic User Interface FAQ</a><ul>
<li><a class="reference internal" href="#general-gui-questions">General GUI Questions</a></li>
<li><a class="reference internal" href="#what-platform-independent-gui-toolkits-exist-for-python">What platform-independent GUI toolkits exist for Python?</a></li>
<li><a class="reference internal" href="#what-platform-specific-gui-toolkits-exist-for-python">What platform-specific GUI toolkits exist for Python?</a></li>
<li><a class="reference internal" href="#tkinter-questions">Tkinter questions</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="windows.html"
                        title="previous chapter">Python on Windows FAQ</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="installed.html"
                        title="next chapter">“Why is Python Installed on my Computer?” FAQ</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/faq/gui.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="installed.html" title="“Why is Python Installed on my Computer?” FAQ"
             >next</a> |</li>
        <li class="right" >
          <a href="windows.html" title="Python on Windows FAQ"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.10 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python Frequently Asked Questions</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001-2021, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Feb 26, 2021.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.3.1.
    </div>

  </body>
</html>