Interface creation/de: Difference between revisions

From FreeCAD Documentation
(Created page with "=== Oberfläche in einer .ui Datei ===")
No edit summary
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>
<languages/>


{{Docnav/de
== Einführung ==
|[[PySide/de|PySide]]
|[[Dialog_creation/de|Dialogerstellung]]
}}


{{TOCright}}
Intensivnutzer haben die Möglichkeit, [[Interface creation/de|Oberflächen erstellen]] um sie bei der Erstellung komplexer Werkzeuge für ihre benutzerdefinierten [[Addon/de|Erweiterungen]] zu unterstützen, wie z.B. [[macros/de|Makros]] oder vollständige [[workbenches/de|Arbeitsbereiche]].


<span id="Introduction"></span>
Benutzeroberflächen werden mit [[PySide/de|PySide]] erstellt, einer Bibliothek zur Verwendung von Qt mit [[Python/de|Python]].
==Einleitung==

Erfahrene Anwender haben die Möglichkeit, [[Interface_creation/de|Benutzeroberflächen zu erstellen]], die sie bei der Erstellung komplexer Werkzeuge für ihre benutzerdefinierten [[Addon/de|Erweiterungen]] (Addons) unterstützen, wie z.B. [[Macros/de|Makros]] oder vollständige [[Workbenches/de|Arbeitsbereiche]].

Benutzeroberflächen werden mit [[PySide/de|PySide]] erstellt, einer Bibliothek die die Verwendung von Qt mit [[Python/de|Python]] ermöglicht.


[[File:FreeCAD_creating_interfaces.svg|600px]]
[[File:FreeCAD_creating_interfaces.svg|600px]]
{{Caption|Zwei allgemeine Methoden zur Erstellung von Schnittstellen, durch Einfügen der Schnittstelle in die Python Datei oder durch die Verwendung von {{incode|.ui}} Dateien.}}
{{Caption|Zwei allgemeine Methoden zur Erstellung von Schnittstellen, durch Einfügen der Schnittstelle in die Python Datei oder durch die Verwendung von {{incode|.ui}}-Dateien.}}


<span id="Description"></span>
== Beschreibung ==
== Beschreibung ==


Es gibt typischerweise zwei Möglichkeiten, Benutzeroberflächen mit PySide zu erstellen.
Es gibt typischerweise zwei Möglichkeiten, Benutzeroberflächen mit PySide zu erstellen.


<span id="Interface_in_a_.ui_file"></span>
=== Oberfläche in einer .ui Datei ===
===Oberfläche in einer .ui-Datei ===


In this method the interface is defined in a {{incode|.ui}} file (an XML document that defines the structure of the interface), which is then imported into [[Python|Python]] code that uses it. This is the recommended approach.
In this method the interface is defined in a {{incode|.ui}} file (an XML document that defines the structure of the interface), which is then imported into [[Python|Python]] code that uses it. This is the recommended approach.
Line 20: Line 30:
* It allows anybody to look at the interface alone, that is, the {{incode|.ui}} file, without having to run Python code.
* It allows anybody to look at the interface alone, that is, the {{incode|.ui}} file, without having to run Python code.
* The {{incode|.ui}} file may be designed by anybody without programming knowledge.
* The {{incode|.ui}} file may be designed by anybody without programming knowledge.
* The {{incode|.ui}} interface can be used in a standalone window (modal), or in an embedded window (non-modal); therefore, this method is ideal to create custom [[task_panel|task panels]].
* The {{incode|.ui}} interface can be used in a standalone window (modal), or in an embedded window (non-modal); therefore, this method is ideal to create custom [[Task_panel|task panels]].
* Since the {{incode|.ui}} file just describes the "appearance" of the interface, it does not need to be tied to a particular programming language; it may be used both in [[Python|Python]] and C++ code.
* Since the {{incode|.ui}} file just describes the "appearance" of the interface, it does not need to be tied to a particular programming language; it may be used both in [[Python|Python]] and C++ code.


<span id="Interface_completely_in_Python_code"></span>
For examples on this method see [[Interface_creation_with_UI_files|Interface creation with UI files]].
===Oberfläche vollständig im Python-Code ===

=== Interface completely in Python code ===


In this method the entire interface is defined by several Python calls.
In this method the entire interface is defined by several Python calls.
Line 32: Line 41:
* It is not simple to separate the interface from the logic that uses that code, meaning that a user would need to run the [[Python|Python]] file in the correct context in order to see how the interface would look.
* It is not simple to separate the interface from the logic that uses that code, meaning that a user would need to run the [[Python|Python]] file in the correct context in order to see how the interface would look.
* This method has the advantage that several interfaces may be contained within a single document, at the expense of making the file very large.
* This method has the advantage that several interfaces may be contained within a single document, at the expense of making the file very large.
* This method is recommended only for small interfaces that don't define more than a few widgets, for example in [[macros|macros]].
* This method is recommended only for small interfaces that don't define more than a few widgets, for example in [[Macros|macros]].

Beispiele für diese Methode befinden sich unter [[Dialog_creation/de|Dialogerstellung]].



{{Docnav/de
For examples on this method see [[Dialog_creation|Interface creation completely in Python]].
|[[PySide/de|PySide]]
|[[Dialog_creation/de|Dialogerstellung]]
}}


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

Latest revision as of 14:34, 18 August 2023

Einleitung

Erfahrene Anwender haben die Möglichkeit, Benutzeroberflächen zu erstellen, die sie bei der Erstellung komplexer Werkzeuge für ihre benutzerdefinierten Erweiterungen (Addons) unterstützen, wie z.B. Makros oder vollständige Arbeitsbereiche.

Benutzeroberflächen werden mit PySide erstellt, einer Bibliothek die die Verwendung von Qt mit Python ermöglicht.

Zwei allgemeine Methoden zur Erstellung von Schnittstellen, durch Einfügen der Schnittstelle in die Python Datei oder durch die Verwendung von .ui-Dateien.

Beschreibung

Es gibt typischerweise zwei Möglichkeiten, Benutzeroberflächen mit PySide zu erstellen.

Oberfläche in einer .ui-Datei

In this method the interface is defined in a .ui file (an XML document that defines the structure of the interface), which is then imported into Python code that uses it. This is the recommended approach.

  • It allows the programmer to work with the graphical interface separately from the logic that will use it.
  • It allows anybody to look at the interface alone, that is, the .ui file, without having to run Python code.
  • The .ui file may be designed by anybody without programming knowledge.
  • The .ui interface can be used in a standalone window (modal), or in an embedded window (non-modal); therefore, this method is ideal to create custom task panels.
  • Since the .ui file just describes the "appearance" of the interface, it does not need to be tied to a particular programming language; it may be used both in Python and C++ code.

Oberfläche vollständig im Python-Code

In this method the entire interface is defined by several Python calls.

  • This is an older way of working with interfaces.
  • This method produces very verbose code because many details of the interface need to be specified by hand.
  • It is not simple to separate the interface from the logic that uses that code, meaning that a user would need to run the Python file in the correct context in order to see how the interface would look.
  • This method has the advantage that several interfaces may be contained within a single document, at the expense of making the file very large.
  • This method is recommended only for small interfaces that don't define more than a few widgets, for example in macros.

Beispiele für diese Methode befinden sich unter Dialogerstellung.