PySide/ja: Difference between revisions

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


{{Docnav
|[[Pivy|Pivy]]
|[[Interface_creation|Interface creation]]
}}

{{TOCright}}

<span id="Introduction"></span>
<div class="mw-translate-fuzzy">
<div class="mw-translate-fuzzy">
<H2>PySide</H2>
<H2>PySide</H2>
</div>
</div>


<div class="mw-translate-fuzzy">
[http://en.wikipedia.org/wiki/PySide PySide]はクロスプラットフォームのGUIツールキットQtのPythonバインディングです。 FreeCADはPython内部のすべてのGUI(Graphic User Interface)目的にPySideを使用します。 PySideは、以前にFreeCADによってGUIに使用されていたPyQtパッケージに代わるものです。 PySideはより許容されるライセンスを持っています。 違いの詳細については[http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt PySideとPyQtの違い]を参照してください。
[http://en.wikipedia.org/wiki/PySide PySide]はクロスプラットフォームのGUIツールキットQtのPythonバインディングです。 FreeCADはPython内部のすべてのGUI(Graphic User Interface)目的にPySideを使用します。 PySideは、以前にFreeCADによってGUIに使用されていたPyQtパッケージに代わるものです。 PySideはより許容されるライセンスを持っています。 違いの詳細については[http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt PySideとPyQtの違い]を参照してください。
</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.
FreeCADのユーザは、多くの場合、内蔵のインタフェースを使用してすべてのことを達成します。 しかし、操作をカスタマイズしたいユーザのために[[Python_scripting_tutorial | Python Scripting Tutorial]]で文書化されているPythonインターフェースがあります。 FreeCAD用のPythonインターフェースは、優れた柔軟性とパワーを持っていました。 そのユーザとの対話のために、PythonとFreeCADはPySideを使用します。これはこのページで文書化されているものです。


In the past, FreeCAD used PyQt, another Qt binding for Python, but in 2013 ([https://github.com/FreeCAD/FreeCAD/commit/1dc122dc9a commit 1dc122dc9a]) the project migrated to PySide because it has a more permissible [[License|License]].
Pythonはコードを与える 'print'ステートメントを提供します。
{{Code|code=
print 'Hello World'
}}
Pythonのprint文では、見た目や振る舞いを制御できるのは限られています。 PySideは、不足しているコントロールを提供し、Pythonの組み込み機能では不十分な環境(FreeCADマクロファイル環境など)も処理します。


For more information see:
PySideの機能は次のとおりです。
* [https://en.wikipedia.org/wiki/PySide Wikipedia:PySide]
* [https://wiki.qt.io/Differences_Between_PySide_and_PyQt Differences Between PySide and PyQt]


[[File:PySideScreenSnapshot1.jpg]]
[[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==
to:


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.
[[File:PySideScreenSnapshot2.jpg]]

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}}, 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.
{{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}}
==Examples of PySide use==


<div class="mw-translate-fuzzy">
<div class="mw-translate-fuzzy">
* [[PySide_Beginner_Examples|Beginner PySide Examples]] ( Hello World、お知らせ、テキストを入力、番号を入力
* [[PySide_Beginner_Examples|Beginner PySide Examples]] ( Hello World、お知らせ、テキストを入力、番号を入力
* [[PySide_Medium_Examples|Medium PySide Examples]] (ウィンドウのサイズ変更、ウィジェットの非表示、ポップアップメニュー、マウスの位置、マウスイベント)
* [[PySide_Intermediate_Examples|PySide Intermediate Examples]] (ウィンドウのサイズ変更、ウィジェットの非表示、ポップアップメニュー、マウスの位置、マウスイベント)
* [[PySide_Advanced_Examples|Advanced PySide Examples]] (ウィジェットなど)
* [[PySide_Advanced_Examples|Advanced PySide Examples]] (ウィジェットなど)
</div>
</div>


<div class="mw-translate-fuzzy">
彼らは主題を3つの部分に分け、PySide、PythonそしてFreeCAD内部への露出のレベルによって区別しました。最初のページには概要と背景資料があり、PySideとそのまとめ方について説明していますが、2ページ目と3ページ目は、ほとんどが異なるレベルのコード例です。
彼らは主題を3つの部分に分け、PySide、PythonそしてFreeCAD内部への露出のレベルによって区別しました。最初のページには概要と背景資料があり、PySideとそのまとめ方について説明していますが、2ページ目と3ページ目は、ほとんどが異なるレベルのコード例です。
</div>

その意図は、問題に取り組むユーザがコードを簡単にコピーして自分の作業に貼り付け、必要に応じてそれを修正し、FreeCADによる問題解決に戻ることができるように、関連ページがPySideを実行する単純なPythonコードを提供することです。うまくいけば、彼らはPySideの質問に対する答えを探すためにインターネットを越えて追いかけに行く必要はありません。同時にこのページは、Web上で利用可能なさまざまな包括的なPySideチュートリアルと参照サイトを置き換えることを意図していません。


<div class="mw-translate-fuzzy">
<div class="mw-translate-fuzzy">
その意図は、問題に取り組むユーザがコードを簡単にコピーして自分の作業に貼り付け、必要に応じてそれを修正し、FreeCADによる問題解決に戻ることができるように、関連ページがPySideを実行する単純なPythonコードを提供することです。うまくいけば、彼らはPySideの質問に対する答えを探すためにインターネットを越えて追いかけに行く必要はありません。同時にこのページは、Web上で利用可能なさまざまな包括的なPySideチュートリアルと参照サイトを置き換えることを意図していません。
{{docnav|Pivy|Scripted objects}}
</div>
</div>
{{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.
{{Userdocnavi}}


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]]
* [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}}


<div class="mw-translate-fuzzy">
[[Category:Developer]]
{{docnav|Pivy|Scripted objects}}
</div>


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

Latest revision as of 16:26, 4 April 2024

PySide

PySideはクロスプラットフォームのGUIツールキットQtのPythonバインディングです。 FreeCADはPython内部のすべてのGUI(Graphic User Interface)目的にPySideを使用します。 PySideは、以前にFreeCADによってGUIに使用されていたPyQtパッケージに代わるものです。 PySideはより許容されるライセンスを持っています。 違いの詳細についてはPySideとPyQtの違いを参照してください。

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 (commit 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

彼らは主題を3つの部分に分け、PySide、PythonそしてFreeCAD内部への露出のレベルによって区別しました。最初のページには概要と背景資料があり、PySideとそのまとめ方について説明していますが、2ページ目と3ページ目は、ほとんどが異なるレベルのコード例です。

その意図は、問題に取り組むユーザがコードを簡単にコピーして自分の作業に貼り付け、必要に応じてそれを修正し、FreeCADによる問題解決に戻ることができるように、関連ページがPySideを実行する単純なPythonコードを提供することです。うまくいけば、彼らはPySideの質問に対する答えを探すためにインターネットを越えて追いかけに行く必要はありません。同時にこのページは、Web上で利用可能なさまざまな包括的なPySideチュートリアルと参照サイトを置き換えることを意図していません。

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

Pivy
Scripted objects