PySide/es: Difference between revisions

From FreeCAD Documentation
(Created page with "Category:Developer/es")
(Updating to match new version of source page)
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{docnav|Pivy|FeaturePython Objects}}


{{TOCright}}
==PySide==


==Introduction==

<div class="mw-translate-fuzzy">
[http://en.wikipedia.org/wiki/PySide PySide] es un enlace Python del conjunto de herramientas GUI multiplataforma Qt. FreeCAD utiliza PySide para todos los fines de la GUI (interfaz de usuario gráfica) dentro de Python. PySide es una alternativa al paquete PyQt que fue utilizado anteriormente por FreeCAD para su GUI. PySide tiene una licencia más permisible. Ver [http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt Differences Between PySide and PyQt] Para más información sobre las diferencias.
[http://en.wikipedia.org/wiki/PySide PySide] es un enlace Python del conjunto de herramientas GUI multiplataforma Qt. FreeCAD utiliza PySide para todos los fines de la GUI (interfaz de usuario gráfica) dentro de Python. PySide es una alternativa al paquete PyQt que fue utilizado anteriormente por FreeCAD para su GUI. PySide tiene una licencia más permisible. Ver [http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt Differences Between PySide and PyQt] Para más información sobre las diferencias.
</div>


When you install FreeCAD, you should get both Qt and PySide as part of the package. If you are [[Compiling|compiling]] yourself then you must verify that these two libraries are installed in order for FreeCAD to run correctly. Of course, PySide will only work if Qt is present.
Los usuarios de FreeCAD a menudo logran todo usando la interfaz integrada. Pero para los usuarios que desean personalizar sus operaciones, existe la interfaz de Python que se documenta en el [[Python_scripting_tutorial | Python Scripting Tutorial]]. La interfaz de Python para FreeCAD tenía una gran flexibilidad y potencia. Para su interacción con el usuario, Python con FreeCAD utiliza PySide, que es lo que se documenta en esta página.


In the past, FreeCAD used PyQt, another Qt binding for Python, but in 2013 ([https://github.com/FreeCAD/FreeCAD/commit/1dc122dc9a 1dc122dc9a]) the project migrated to PySide because it has a more permissible [[licence|license]].
Python ofrece la declaración de "print" que proporciona el código:

For more information see:
* [http://en.wikipedia.org/wiki/PySide Wikipedia:PySide]
* [http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt Differences Between PySide and PyQt]

[[File:PySideScreenSnapshot1.jpg]] [[File:PySideScreenSnapshot2.jpg]]
{{Caption|Examples created with PySide. Left: a simple dialog. Right: a more complex dialog with graphs.}}

==PySide in FreeCAD with Qt5==

FreeCAD was developed to be used with Python 2 and Qt4. As these two libraries became obsolete, FreeCAD transitioned to Python 3 and Qt5. In most cases this transition was done without needing to break backwards compatibility.

Normally, the {{incode|PySide}} module provides support for Qt4, while {{incode|PySide2}} provides support for Qt5. However, in FreeCAD there is no need to use {{incode|PySide2}} directly, as a special {{incode|PySide}} module is included to handle Qt5.

This {{incode|PySide}} module is located in the {{incode|Ext/}} directory of an installation of FreeCAD compiled for Qt5.
{{Code|code=
{{Code|code=
/usr/share/freecad/Ext/PySide
print 'Hello World'
}}
}}
Con la declaración de impresión de Python, solo tiene un control limitado de la apariencia y el comportamiento. PySide proporciona el control faltante y también maneja entornos (como el entorno de archivos de macros FreeCAD) donde las instalaciones integradas de Python no son suficientes.


This module just imports the necessary classes from {{incode|PySide2}}, and places them in the {{incode|PySide}} namespace. This means that in most cases the same code can be used with both Qt4 and Qt5, as long as we use the single {{incode|PySide}} module.
Las habilidades de PySide van desde:
{{Code|code=
PySide2.QtCore -> PySide.QtCore
PySide2.QtGui -> PySide.QtGui
PySide2.QtSvg -> PySide.QtSvg
PySide2.QtUiTools -> PySide.QtUiTools
}}

The only unusual aspect is that the {{incode|PySide2.QtWidgets}} classes are placed in the {{incode|PySide.QtGui}} namespace.
{{Code|code=
PySide2.QtWidgets.QCheckBox -> PySide.QtGui.QCheckBox
}}


[[#top|top]]
[[File:PySideScreenSnapshot1.jpg]]


==Examples of PySide use==
hasta:


* [[PySide_Beginner_Examples|PySide Beginner Examples]], hello world, announcements, enter text, enter number.
[[File:PySideScreenSnapshot2.jpg]]
* [[PySide_Intermediate_Examples|PySide Intermediate Examples]], window sizing, hiding widgets, popup menus, mouse position, mouse events.
* [[PySide_Advanced_Examples|PySide Advanced Examples]], many widgets.


The examples of PySide are divided into 3 parts, differentiated by level of exposure to PySide, Python and the FreeCAD internals. The first page has an overview on PySide; the second and third pages are mostly code examples at different levels.
'''Familiarize yourself with some real-world examples of PySide'''
* [[PySide Beginner Examples]] (Hello World, announcements, enter text, enter number)
* [[PySide Intermediate Examples]] (window sizing, hiding widgets, popup menus, mouse position, mouse events)
* [[PySide Advanced Examples]] (widgets etc.)


It is expected that these examples are useful to get started, and afterwards the user can consult other resources online, or the official documentation.
They divide the subject matter into 3 parts, differentiated by level of exposure to PySide, Python and the FreeCAD internals. The first page has overview and background material giving a description of PySide and how it is put together while the second and third pages are mostly code examples at different levels.


[[#top|top]]
The intention is that the associated pages will provide simple Python code to run PySide so that the user working on a problem can easily copy the code, paste it into their own work, adapt it as necessary and return to their problem solving with FreeCAD. Hopefully they don't have to go chasing off across the internet looking for answers to PySide questions. At the same time this page is not intended to replace the various comprehensive PySide tutorials and reference sites available on the web.


==Documentation==
{{docnav|Pivy|FeaturePython Objects}}


There are some differences in handling of widgets in Qt4 (PySide) and Qt5 (PySide2). The programmer should be aware of these incompatibilities, and should consult the official documentation if something doesn't seem to work as expected on a given platform. Nevertheless, Qt4 is considered obsolete, so most development should target Qt5 and Python 3.
{{Userdocnavi/es}}


The PySide documentation refers to the Python-style classes; however, since Qt is originally a C++ library, the same information should be available in the corresponding C++ reference.
[[Category:Poweruser Documentation/es]]
* [https://doc.qt.io/qtforpython/modules.html Qt Modules] available from PySide2 (Qt5).
* [https://doc.qt.io/qt-5/modules-cpp.html All Qt classes by module] in Qt5 for C++.
* [https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/index.html Qt Modules] available from PySide (Qt4).


[[#top|top]]
[[Category:Developer/es]]


{{Powerdocnavi{{#translation:}}}}
[[Category:Developer Documentation]]
[[Category:Developer Documentation{{#translation:}}]]
[[Category:Python Code{{#translation:}}]]
{{clear}}
{{clear}}

Revision as of 21:23, 6 January 2021

Introduction

PySide es un enlace Python del conjunto de herramientas GUI multiplataforma Qt. FreeCAD utiliza PySide para todos los fines de la GUI (interfaz de usuario gráfica) dentro de Python. PySide es una alternativa al paquete PyQt que fue utilizado anteriormente por FreeCAD para su GUI. PySide tiene una licencia más permisible. Ver Differences Between PySide and PyQt Para más información sobre las diferencias.

When you install FreeCAD, you should get both Qt and PySide as part of the package. If you are compiling yourself then you must verify that these two libraries are installed in order for FreeCAD to run correctly. Of course, PySide will only work if Qt is present.

In the past, FreeCAD used PyQt, another Qt binding for Python, but in 2013 (1dc122dc9a) the project migrated to PySide because it has a more permissible license.

For more information see:

Examples created with PySide. Left: a simple dialog. Right: a more complex dialog with graphs.

PySide in FreeCAD with Qt5

FreeCAD was developed to be used with Python 2 and Qt4. As these two libraries became obsolete, FreeCAD transitioned to Python 3 and Qt5. In most cases this transition was done without needing to break backwards compatibility.

Normally, the PySide module provides support for Qt4, while PySide2 provides support for Qt5. However, in FreeCAD there is no need to use PySide2 directly, as a special PySide module is included to handle Qt5.

This PySide module is located in the Ext/ directory of an installation of FreeCAD compiled for Qt5.

/usr/share/freecad/Ext/PySide

This module just imports the necessary classes from PySide2, and places them in the PySide namespace. This means that in most cases the same code can be used with both Qt4 and Qt5, as long as we use the single PySide module.

PySide2.QtCore -> PySide.QtCore
PySide2.QtGui -> PySide.QtGui
PySide2.QtSvg -> PySide.QtSvg
PySide2.QtUiTools -> PySide.QtUiTools

The only unusual aspect is that the PySide2.QtWidgets classes are placed in the PySide.QtGui namespace.

PySide2.QtWidgets.QCheckBox -> PySide.QtGui.QCheckBox

top

Examples of PySide use

The examples of PySide are divided into 3 parts, differentiated by level of exposure to PySide, Python and the FreeCAD internals. The first page has an overview on PySide; the second and third pages are mostly code examples at different levels.

It is expected that these examples are useful to get started, and afterwards the user can consult other resources online, or the official documentation.

top

Documentation

There are some differences in handling of widgets in Qt4 (PySide) and Qt5 (PySide2). The programmer should be aware of these incompatibilities, and should consult the official documentation if something doesn't seem to work as expected on a given platform. Nevertheless, Qt4 is considered obsolete, so most development should target Qt5 and Python 3.

The PySide documentation refers to the Python-style classes; however, since Qt is originally a C++ library, the same information should be available in the corresponding C++ reference.

top