PySide/ru: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<H2>PySide</H2>
{{docnav|Pivy|FeaturePython Objects}}


==Introduction==
[http://en.wikipedia.org/wiki/PySide PySide] is a Python binding of the cross-platform GUI toolkit Qt. FreeCAD uses PySide for all GUI (Graphic User Intercase) purposes. PySide evolved from the PyQt package which was previously used by FreeCAD for it's GUI. See [http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt Differences Between PySide and PyQt] for more information on the differences.


<div class="mw-translate-fuzzy">
Users of FreeCAD often achieve everything using the built-in interface. But for users who want to customise their operations then the Python interface exists which is documented in the [[Python_scripting_tutorial|Python Scripting Tutorial]]. The Python interface for FreeCAD had great flexibility and power. For it's user interaction Python with FreeCAD uses PySide, which is what is documented on this page.
[http://en.wikipedia.org/wiki/PySide PySide] это привязка Python кросс-платформенного инструментария GUI Qt. FreeCAD использует PySide для всех целей GUI (графический интерфейс пользователя) внутри Python. PySide является альтернативой пакету PyQt, который ранее использовался FreeCAD для своего графического интерфейса. PySide имеет более допустимую лицензию. Увидеть [http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt Differences Between PySide and PyQt] для получения дополнительной информации о различиях.
</div>


== PySide in FreeCAD with Qt5 ==
Python offers the 'print' statement which gives the code:

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=
/usr/share/freecad/Ext/PySide
}}

This module just imports the necessary classes from {{incode|PySide2}}, but 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 it imports {{incode|PySide}}.
{{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
}}

== PySide information ==

Пользователи FreeCAD часто добиваются всего, используя встроенный интерфейс. Но для пользователей, которые хотят настроить свои операции, существует интерфейс Python, который описан в [[Python_scripting_tutorial | Python Scripting Tutorial]]. Интерфейс Python для FreeCAD обладает большой гибкостью и мощью. Для взаимодействия с пользователем Python с FreeCAD использует PySide, что описано на этой странице.

Python предлагает оператор 'print', который дает код:
{{Code|code=
{{Code|code=
print 'Hello World'
print 'Hello World'
}}
}}
С оператором 'print' Python вы имеете только ограниченный контроль над внешним видом и поведением. PySide предоставляет отсутствующий элемент управления, а также обрабатывает среды (такие как среда макрофайловых файлов FreeCAD), где встроенных средств Python недостаточно.
With Python's print statement you have only limited control of the appearance and behaviour. PySide supplies the missing control and also handles environments (such as the FreeCAD macro file environment) where the built-in facilities of Python are not enough.


Возможности PySide варьируются от:
PySide's abilities range from:


[[File:PySideScreenSnapshot1.jpg]]
[[File:PySideScreenSnapshot1.jpg]]


до:
to:


[[File:PySideScreenSnapshot2.jpg]]
[[File:PySideScreenSnapshot2.jpg]]


'''Familiarize yourself with some real-world examples of PySide'''
PySide is described in the following 3 pages which should follow on one from each other:
* [[PySide Beginner Examples]] (Hello World, announcements, enter text, enter number)

* [[PySide_Beginner_Examples|Beginner PySide Examples]] (Hello World, announcements, enter text, enter number)
* [[PySide Intermediate Examples]] (window sizing, hiding widgets, popup menus, mouse position, mouse events)
* [[PySide_Medium_Examples|Medium PySide Examples]] (window sizing, hiding widgets, popup menus, mouse position, mouse events)
* [[PySide Advanced Examples]] (widgets etc.)
* [[PySide_Advanced_Examples|Advanced PySide Examples]] (widgets etc.)


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.
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.
Line 29: Line 59:
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.
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.


<div class="mw-translate-fuzzy">
{{docnav|Pivy|Scripted objects}}
{{docnav|Pivy|Scripted objects}}
</div>

{{Userdocnavi/ru}}


[[Category:Poweruser Documentation/ru]]
[[Category:Poweruser Documentation/ru]]

[[Category:Developer/ru]]

[[Category:Developer Documentation/ru]]
{{clear}}
{{clear}}
<languages/>

Revision as of 22:59, 10 February 2020

Pivy
FeaturePython Objects

Introduction

PySide это привязка Python кросс-платформенного инструментария GUI Qt. FreeCAD использует PySide для всех целей GUI (графический интерфейс пользователя) внутри Python. PySide является альтернативой пакету PyQt, который ранее использовался FreeCAD для своего графического интерфейса. PySide имеет более допустимую лицензию. Увидеть Differences Between PySide and PyQt для получения дополнительной информации о различиях.

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, but 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 it imports PySide.

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

PySide information

Пользователи FreeCAD часто добиваются всего, используя встроенный интерфейс. Но для пользователей, которые хотят настроить свои операции, существует интерфейс Python, который описан в Python Scripting Tutorial. Интерфейс Python для FreeCAD обладает большой гибкостью и мощью. Для взаимодействия с пользователем Python с FreeCAD использует PySide, что описано на этой странице.

Python предлагает оператор 'print', который дает код:

print 'Hello World'

С оператором 'print' Python вы имеете только ограниченный контроль над внешним видом и поведением. PySide предоставляет отсутствующий элемент управления, а также обрабатывает среды (такие как среда макрофайловых файлов FreeCAD), где встроенных средств Python недостаточно.

Возможности PySide варьируются от:

до:

Familiarize yourself with some real-world examples of PySide

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.

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.

Pivy
Scripted objects