Interface creation/ru: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Created page with "{{Docnav/ru |PySide |Разработка диалогов }}")
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<languages/>
<languages/>


{{Docnav
{{Docnav/ru
|[[PySide|PySide]]
|[[PySide/ru|PySide]]
|[[Dialog_creation|Dialog creation]]
|[[Dialog_creation/ru|Разработка диалогов]]
}}
}}


{{TOCright}}
{{TOCright}}


<span id="Introduction"></span>
== Введение ==
== Введение ==


Line 17: Line 18:
{{Caption|Two general methods to create interfaces, by including the interface in the Python file, or by using {{incode|.ui}} files.}}
{{Caption|Two general methods to create interfaces, by including the interface in the Python file, or by using {{incode|.ui}} files.}}


<span id="Description"></span>
== Описание ==
== Описание ==


Существует два способа создания интерфейсов с применением PySide.
There are typically two ways of creating interfaces with PySide.


<span id="Interface_in_a_.ui_file"></span>
=== Interface in a .ui file ===
=== Интерфейс записанный в .ui файл ===


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 30: Line 33:
* 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>
=== Interface completely in Python code ===
=== Интерфейс полностью созданный с помощью Python кода ===


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 42: Line 46:




{{Docnav
{{Docnav/ru
|[[PySide|PySide]]
|[[PySide/ru|PySide]]
|[[Dialog_creation|Dialog creation]]
|[[Dialog_creation/ru|Разработка диалогов]]
}}
}}



Latest revision as of 10:40, 18 March 2023

Введение

Power users have the possibility of creating interfaces to help them produce complex tools for their custom addons, such as macros or full workbenches.

Interfaces are created using PySide, which is a library for using Qt with Python.

Two general methods to create interfaces, by including the interface in the Python file, or by using .ui files.

Описание

Существует два способа создания интерфейсов с применением PySide.

Интерфейс записанный в .ui файл

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.

Интерфейс полностью созданный с помощью Python кода

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.

Примеры этого метода см. в разделе Interface creation completely in Python.