Python/tr: Difference between revisions
Skywalker21 (talk | contribs) (Created page with ": Bu örnekte, ilk argüman varsayılan bir değere sahip değildir, bu yüzden her zaman dahil edilmelidir.") |
(Updating to match new version of source page) |
||
(18 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
<div class="mw-translate-fuzzy"> |
|||
{{VeryImportantMessage | (Kasım 2018) FreeCAD başlangıçta Python 2 ile çalışmak üzere tasarlandı. Birçok özellik Python 3 ile çalışıyor, ancak bazıları çalışmıyor. FreeCAD'i Python 3 te tam olarak destekleme işi , devam etmekte olan bir iştir.}} |
{{VeryImportantMessage | (Kasım 2018) FreeCAD başlangıçta Python 2 ile çalışmak üzere tasarlandı. Birçok özellik Python 3 ile çalışıyor, ancak bazıları çalışmıyor. FreeCAD'i Python 3 te tam olarak destekleme işi , devam etmekte olan bir iştir.}} |
||
</div> |
|||
== Tanım == |
== Tanım == |
||
{{TOCright}} |
|||
[https://www.python.org Python] genel amaçlı, büyük uygulamalarda komut dosyası veya [[macros/tr|makro]] oluşturarak bazı görevleri otomatikleştirmek için yaygın olarak kullanılan yüksek seviye bir programlama dilidir. |
[https://www.python.org Python] genel amaçlı, büyük uygulamalarda komut dosyası veya [[macros/tr|makro]] oluşturarak bazı görevleri otomatikleştirmek için yaygın olarak kullanılan yüksek seviye bir programlama dilidir. |
||
Line 10: | Line 14: | ||
Python programlama dili hakkında bilgi edinmek için [[Introduction to Python/tr|Python'a Giriş]] 'e, ardından da FreeCAD'de komut dosyasını başlatmak için [[Python scripting tutorial/tr|Python betik kılavuzu]] ve [[FreeCAD Scripting Basics/tr|FreeCAD betik kılavuzu]]' ne bakın. |
Python programlama dili hakkında bilgi edinmek için [[Introduction to Python/tr|Python'a Giriş]] 'e, ardından da FreeCAD'de komut dosyasını başlatmak için [[Python scripting tutorial/tr|Python betik kılavuzu]] ve [[FreeCAD Scripting Basics/tr|FreeCAD betik kılavuzu]]' ne bakın. |
||
== Readability == |
|||
<div class="mw-translate-fuzzy"> |
|||
Python kodunu yazarken [https://www.python.org/dev/peps/pep-0008/PEP8: Python Kodu için Stil Kılavuzu] 'nu takip etmeniz önerilir. |
Python kodunu yazarken [https://www.python.org/dev/peps/pep-0008/PEP8: Python Kodu için Stil Kılavuzu] 'nu takip etmeniz önerilir. |
||
</div> |
|||
These documents present explanations in a more user-friendly way: |
|||
* [https://realpython.com/python-pep8/ How to Write Beautiful Python Code With PEP 8] |
|||
* [https://realpython.com/documenting-python-code/ Documenting Python Code: A Complete Guide]. |
|||
== Kurallar == |
== Kurallar == |
||
Line 18: | Line 30: | ||
{{Code|code= |
{{Code|code= |
||
Wire = |
Wire = make_wire(pointslist, closed=False, placement=None, face=None, support=None) |
||
}} |
}} |
||
Line 24: | Line 36: | ||
{{Code|code= |
{{Code|code= |
||
Wire = |
Wire = make_wire(pointslist, False, None, None, None) |
||
Wire = |
Wire = make_wire(pointslist, False, None, None) |
||
Wire = |
Wire = make_wire(pointslist, False, None) |
||
Wire = |
Wire = make_wire(pointslist, False) |
||
Wire = |
Wire = make_wire(pointslist) |
||
}} |
}} |
||
: Bu örnekte, ilk argüman varsayılan bir değere sahip değildir, bu yüzden her zaman dahil edilmelidir. |
: Bu örnekte, ilk argüman varsayılan bir değere sahip değildir, bu yüzden her zaman dahil edilmelidir. |
||
* Argümanlar açık anahtarla verildiğinde, isteğe bağlı argümanlar herhangi bir sırayla verilebilir. Bu, aşağıdaki çağrıların eşdeğer olduğu anlamına gelir: |
|||
* When the arguments are given with the explicit key, the optional arguments can be given in any order. This means that the following calls are equivalent: |
|||
{{Code|code= |
{{Code|code= |
||
Wire = |
Wire = make_wire(pointslist, closed=False, placement=None, face=None) |
||
Wire = |
Wire = make_wire(pointslist, closed=False, face=None, placement=None) |
||
Wire = |
Wire = make_wire(pointslist, placement=None, closed=False, face=None) |
||
Wire = |
Wire = make_wire(pointslist, support=None, closed=False, placement=None, face=None) |
||
}} |
}} |
||
* Python kuralları, kodun okunabilirliğini vurgulamaktadır; Özellikle parantezler hemen fonksiyon ismini takip etmeli ve boşluk virgül takip etmelidir. |
|||
* Python's guidelines stress readability of code; in particular, parentheses should immediately follow the function name, and a space should follow a comma. |
|||
{{Code|code= |
{{Code|code= |
||
Line 47: | Line 59: | ||
p2 = Vector(1, 1, 0) |
p2 = Vector(1, 1, 0) |
||
p3 = Vector(2, 0, 0) |
p3 = Vector(2, 0, 0) |
||
Wire = |
Wire = make_wire([p1, p2, p3], closed=True) |
||
}} |
}} |
||
* Kodun birkaç satır üzerinden kesilmesi gerekiyorsa, bu parantez veya parantez içindeki virgül ile yapılmalıdır; ikinci satır öncekiyle aynı hizada olmalıdır. |
|||
* If code needs to be broken over several lines, this should be done at a comma inside brackets or parentheses; the second line should be aligned with the previous one. |
|||
{{Code|code= |
{{Code|code= |
||
Line 56: | Line 68: | ||
2, 4, 5] |
2, 4, 5] |
||
Wire = |
Wire = make_wire(pointslist, |
||
False, None, |
False, None, |
||
None, None) |
None, None) |
||
}} |
}} |
||
* İşlevler, başka bir çizim işlevinin temeli olarak kullanılabilecek bir nesneyi döndürebilir. |
|||
* Functions may return an object that can be used as the base of another drawing function. |
|||
{{Code|code= |
{{Code|code= |
||
Wire = |
Wire = make_wire(pointslist, closed=True, face=True) |
||
Window = |
Window = make_window(Wire, name="Big window") |
||
}} |
}} |
||
== |
== İçe Aktarma == |
||
Python fonksiyonları, modül adı verilen dosyalarda saklanır. Bu modülde herhangi bir işlevi kullanmadan önce, modül {{incode | import}} talimatı ile belgeye dahil edilmelidir. |
|||
Python functions are stored in files called modules. Before using any function in that module, the module must be included in the document with the {{incode|import}} instruction. |
|||
<div class="mw-translate-fuzzy"> |
|||
This creates prefixed functions, that is, {{incode|module.function()}}. This system prevents name clashes with functions that are named the same but that come from different modules. |
|||
Bu, önceden eklenmiş işlevler yaratır, yani, {{incode|module.function ()}}. Bu sistem, aynı adlı ancak farklı modüllerden gelen işlevlerle ad çakışmalarını önler. Örneğin, {{incode | Arch.makeWindow ()}} ve {{incode | myModule.makeWindow ()}} iki işlevi sorunsuz bir şekilde bir arada bulunabilir. |
|||
</div> |
|||
Tam örnekler, gerekli içe aktarmaları ve önceden belirlenmiş fonksiyonları içermelidir. |
|||
Full examples should include the necessary imports and the prefixed functions. |
|||
{{Code|code= |
{{Code|code= |
||
import FreeCAD |
import FreeCAD as App |
||
import Draft |
|||
p1 = |
p1 = App.Vector(0, 0, 0) |
||
p2 = |
p2 = App.Vector(1, 1, 0) |
||
p3 = |
p3 = App.Vector(2, 0, 0) |
||
Wire = Draft. |
Wire = Draft.make_wire([p1, p2, p3], closed=True) |
||
}} |
}} |
||
{{Code|code= |
{{Code|code= |
||
import FreeCAD |
import FreeCAD as App |
||
import Draft |
|||
import Arch |
|||
p1 = |
p1 = App.Vector(0, 0, 0) |
||
p2 = |
p2 = App.Vector(1, 0, 0) |
||
p3 = |
p3 = App.Vector(1, 1, 0) |
||
p4 = |
p4 = App.Vector(0, 2, 0) |
||
pointslist = [p1, p2, p3, p4] |
pointslist = [p1, p2, p3, p4] |
||
Wire = Draft. |
Wire = Draft.make_wire(pointslist, closed=True, face=True) |
||
Structure = Arch. |
Structure = Arch.make_structure(Wire, name="Big pillar") |
||
}} |
}} |
||
{{Powerdocnavi{{#translation:}}}} |
|||
[[Category:API Documentation]] |
|||
[[Category:Developer Documentation]] |
[[Category:Developer Documentation{{#translation:}}]] |
||
[[Category: |
[[Category:API{{#translation:}}]] |
||
[[Category: |
[[Category:Python Code{{#translation:}}]] |
||
[[Category:Glossary{{#translation:}}]] |
Latest revision as of 09:22, 17 October 2021
Tanım
Python genel amaçlı, büyük uygulamalarda komut dosyası veya makro oluşturarak bazı görevleri otomatikleştirmek için yaygın olarak kullanılan yüksek seviye bir programlama dilidir.
FreeCAD'de, Python kodu, grafiksel kullanıcı arayüzüne tıklamak zorunda kalmadan programatik olarak çeşitli elemanlar oluşturmak için kullanılabilir. Ek olarak, FreeCAD'in birçok aracı ve tezgahı Python'da programlanmıştır.
Python programlama dili hakkında bilgi edinmek için Python'a Giriş 'e, ardından da FreeCAD'de komut dosyasını başlatmak için Python betik kılavuzu ve FreeCAD betik kılavuzu' ne bakın.
Readability
Python kodunu yazarken Python Kodu için Stil Kılavuzu 'nu takip etmeniz önerilir.
These documents present explanations in a more user-friendly way:
Kurallar
Bu belgede, Python örnekleri için bazı kurallara uyulmalıdır.
Bu tipik bir fonksiyon imzasıdır.
Wire = make_wire(pointslist, closed=False, placement=None, face=None, support=None)
- Anahtar / değer çiftlerine sahip bağımsız değişkenler, imzada belirtilen varsayılan değerlerle isteğe bağlıdır. Bu, aşağıdaki çağrıların eşdeğer olduğu anlamına gelir:
Wire = make_wire(pointslist, False, None, None, None)
Wire = make_wire(pointslist, False, None, None)
Wire = make_wire(pointslist, False, None)
Wire = make_wire(pointslist, False)
Wire = make_wire(pointslist)
- Bu örnekte, ilk argüman varsayılan bir değere sahip değildir, bu yüzden her zaman dahil edilmelidir.
- Argümanlar açık anahtarla verildiğinde, isteğe bağlı argümanlar herhangi bir sırayla verilebilir. Bu, aşağıdaki çağrıların eşdeğer olduğu anlamına gelir:
Wire = make_wire(pointslist, closed=False, placement=None, face=None)
Wire = make_wire(pointslist, closed=False, face=None, placement=None)
Wire = make_wire(pointslist, placement=None, closed=False, face=None)
Wire = make_wire(pointslist, support=None, closed=False, placement=None, face=None)
- Python kuralları, kodun okunabilirliğini vurgulamaktadır; Özellikle parantezler hemen fonksiyon ismini takip etmeli ve boşluk virgül takip etmelidir.
p1 = Vector(0, 0, 0)
p2 = Vector(1, 1, 0)
p3 = Vector(2, 0, 0)
Wire = make_wire([p1, p2, p3], closed=True)
- Kodun birkaç satır üzerinden kesilmesi gerekiyorsa, bu parantez veya parantez içindeki virgül ile yapılmalıdır; ikinci satır öncekiyle aynı hizada olmalıdır.
a_list = [1, 2, 3,
2, 4, 5]
Wire = make_wire(pointslist,
False, None,
None, None)
- İşlevler, başka bir çizim işlevinin temeli olarak kullanılabilecek bir nesneyi döndürebilir.
Wire = make_wire(pointslist, closed=True, face=True)
Window = make_window(Wire, name="Big window")
İçe Aktarma
Python fonksiyonları, modül adı verilen dosyalarda saklanır. Bu modülde herhangi bir işlevi kullanmadan önce, modül import
talimatı ile belgeye dahil edilmelidir.
Bu, önceden eklenmiş işlevler yaratır, yani, module.function ()
. Bu sistem, aynı adlı ancak farklı modüllerden gelen işlevlerle ad çakışmalarını önler. Örneğin, Arch.makeWindow ()
ve myModule.makeWindow ()
iki işlevi sorunsuz bir şekilde bir arada bulunabilir.
Tam örnekler, gerekli içe aktarmaları ve önceden belirlenmiş fonksiyonları içermelidir.
import FreeCAD as App
import Draft
p1 = App.Vector(0, 0, 0)
p2 = App.Vector(1, 1, 0)
p3 = App.Vector(2, 0, 0)
Wire = Draft.make_wire([p1, p2, p3], closed=True)
import FreeCAD as App
import Draft
import Arch
p1 = App.Vector(0, 0, 0)
p2 = App.Vector(1, 0, 0)
p3 = App.Vector(1, 1, 0)
p4 = App.Vector(0, 2, 0)
pointslist = [p1, p2, p3, p4]
Wire = Draft.make_wire(pointslist, closed=True, face=True)
Structure = Arch.make_structure(Wire, name="Big pillar")
- FreeCAD scripting: Python, Introduction to Python, Python scripting tutorial, FreeCAD Scripting Basics
- Modules: Builtin modules, Units, Quantity
- Workbenches: Workbench creation, Gui Commands, Commands, Installing more workbenches
- Meshes and Parts: Mesh Scripting, Topological data scripting, Mesh to Part, PythonOCC
- Parametric objects: Scripted objects, Viewproviders (Custom icon in tree view)
- Scenegraph: Coin (Inventor) scenegraph, Pivy
- Graphical interface: Interface creation, Interface creation completely in Python (1, 2, 3, 4, 5), PySide, PySide examples beginner, intermediate, advanced
- Macros: Macros, How to install macros
- Embedding: Embedding FreeCAD, Embedding FreeCADGui
- Other: Expressions, Code snippets, Line drawing function, FreeCAD vector math library (deprecated)
- Hubs: User hub, Power users hub, Developer hub