Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
en:chapter1 [2018/10/28 11:00] hlinke |
en:chapter1 [2019/07/28 10:24] hlinke [Hello World] |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== VEGASPython ====== | + | ====== VEGASPython |
- | + | ||
- | ===== VEGASPython | + | ===== Chapter 1 Introduction to VEGASPython |
- | ==== Chapter 1 Introduction | + | ==== Introduction ==== |
- | + | ||
- | === Introduction | + | |
VEGAS is one of the few video editing applications that provide an open interface to add functionality to the application. | VEGAS is one of the few video editing applications that provide an open interface to add functionality to the application. | ||
The VEGAS scripting interface is based on a programming platform from Microsoft called .NET. | The VEGAS scripting interface is based on a programming platform from Microsoft called .NET. | ||
Zeile 20: | Zeile 17: | ||
Python is used in many application domains including: Web and Internet Development, | Python is used in many application domains including: Web and Internet Development, | ||
- | You can find more detail son Python on the official website: [[http:// | + | You can find more details about Python on the official website: [[http:// |
For historical reasons there are two versions of Python language avilable: Python 2.x and Python 3.x. Unfortunately Python 3.x includes a lot of incvompatible changes to the Python language so that version 2.x has still to be maintained, as a lot of solutions are based on this version | For historical reasons there are two versions of Python language avilable: Python 2.x and Python 3.x. Unfortunately Python 3.x includes a lot of incvompatible changes to the Python language so that version 2.x has still to be maintained, as a lot of solutions are based on this version | ||
VEGASPython is also based on Python 2.x. | VEGASPython is also based on Python 2.x. | ||
- | Several different | + | PythonNet: |
- | VEGASPython is based on a Pythonimplementation called IRONPython. IronPython is an open source implementation of Python | + | Several different |
- | The current version (in 2018) is 2.7.9. At the moment the comunity is working | + | VEGASPython |
- | If you want to know more about IRONPython you can get more information on the official website [[http:// | + | An older version of VEGASPythion was based on IronPython. IronPython is an open source implementation of Python for .NET. The development had been started by Microsoft but is now given to an open community that is still active and provides regularly new updated versions of IRONPython. |
+ | If you want to know more about IRONPython you can get more information on the official website [[http:// | ||
+ | The main problem of IRONPython is the incompatibility with several standard Python moduels like openCV and NumPy. Especially openCV is interesting for Video editing. | ||
- | Very good and detailed information about IRONPython can be found in the book " | + | Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a .NET application. |
- | === Hello World === | + | |
+ | ==== Hello World ==== | ||
Nearly all programming tutorials start with the so called "Hello World" program. This is a very simple program that provide the text "Hello World" as an output. | Nearly all programming tutorials start with the so called "Hello World" program. This is a very simple program that provide the text "Hello World" as an output. | ||
Zeile 44: | Zeile 44: | ||
I assume that you have installed VEGASPython accoriding to the installation description - [[en: | I assume that you have installed VEGASPython accoriding to the installation description - [[en: | ||
- | == the interactive VEGASPython Window == | + | === the interactive VEGASPython Window |
We will start using the interactive VEGASPython window it allows a very fast and easy Python script creation and execution. | We will start using the interactive VEGASPython window it allows a very fast and easy Python script creation and execution. | ||
You open the window in VEGAS via "View - Extensions - VEGASPython Interactive Window" | You open the window in VEGAS via "View - Extensions - VEGASPython Interactive Window" | ||
- | {{: | + | {{: |
This opens the interactive VEGASPython Window: | This opens the interactive VEGASPython Window: | ||
- | {{: | + | {{: |
The interactive VEGASPython Window consists of two textboxes. | The interactive VEGASPython Window consists of two textboxes. | ||
Zeile 65: | Zeile 65: | ||
The VEGASPython window can float over the VEGAS UI or can be docked into the user interface like all other VEGAS windows. | The VEGASPython window can float over the VEGAS UI or can be docked into the user interface like all other VEGAS windows. | ||
- | == The program == | + | === The program |
In VEGASPython the standard "Hello World" script is very easy: | In VEGASPython the standard "Hello World" script is very easy: | ||
Enter: | Enter: | ||
<code python> | <code python> | ||
- | print(" | + | print (" |
</ | </ | ||
Zeile 76: | Zeile 76: | ||
The text "Hello World" will be printed into the Output textbox. | The text "Hello World" will be printed into the Output textbox. | ||
- | The result should look similar as in the image below. | ||
- | |||
- | {{: | ||
If you did something wrong then you will see an error message in the Output textbox. | If you did something wrong then you will see an error message in the Output textbox. | ||
Zeile 84: | Zeile 81: | ||
When you mastered this script then you have already mastered a big step to be able to write VEGASPython scripts. | When you mastered this script then you have already mastered a big step to be able to write VEGASPython scripts. | ||
- | === Introduction to the Python Language === | + | ==== Introduction to the Python Language |
- | It is not the intention of this tutorial | + | It is not the intention of this tutorial to provide a complete Python tutorial. I will only show you the items you need to know to be able to create or modify VEGASPython scripts. |
+ | VEGASPython is based on Python 3.x. Therefore the Python 3 syntax has to be used. | ||
- | == Functions == | + | === Functions |
In the Hello World script we saw already two important concepts of Python: functions and strings. | In the Hello World script we saw already two important concepts of Python: functions and strings. | ||
- | **print()** is a function that is build into Python and print text into the output textbox. | + | **print** is a function that is build into Python and print text into the output textbox. |
A lot of functions are already included in Python. But you can also define your own functions and you import functions from so called libraries. We will cover this later. | A lot of functions are already included in Python. But you can also define your own functions and you import functions from so called libraries. We will cover this later. | ||
Zeile 109: | Zeile 107: | ||
- | == Variables == | + | === Variables |
In addition to function you also need variables to store information. | In addition to function you also need variables to store information. | ||
A variable has a name, a datatype and a value. | A variable has a name, a datatype and a value. | ||
Zeile 118: | Zeile 116: | ||
* If you create a variable x, x = 3, then Python assumes its an integer. | * If you create a variable x, x = 3, then Python assumes its an integer. | ||
* If you assign x = 1.5 then Python knows its not an integer but floating point number. | * If you assign x = 1.5 then Python knows its not an integer but floating point number. | ||
- | |||
- | You can even change the datatype by assigning a new value - but this is not recommended. | ||
Please try this: | Please try this: | ||
<code Python> | <code Python> | ||
- | x=5 | + | numberVariable |
- | print(x) | + | print (numberVariable) |
- | x=0.5 | + | floatVariable |
- | print(x) | + | print (floatVariable) |
- | x=" | + | stringVariable |
- | print (x) | + | print (stringVariable) |
</ | </ | ||
- | This is a big difference to most other programming languages where you ahev to define the datatype of all variables before you can use them. | + | This is a big difference to most other programming languages where you have to define the datatype of all variables before you can use them. |
= Variable naming = | = Variable naming = | ||
A variable name must begin with a letter (upper or lower case) or an underscore. | A variable name must begin with a letter (upper or lower case) or an underscore. | ||
- | Variables cannot start with a number and are case sensitive. | + | Variables cannot start with a number and are case sensitive. The variables x and X are different variables. |
- | + | ||
- | The names are case sensitive. The variables x and X are different variables. | + | |
By convention variables are often camel cased, meaning the first letter is small and the next words are all capital. | By convention variables are often camel cased, meaning the first letter is small and the next words are all capital. | ||
Zeile 154: | Zeile 149: | ||
- | === Access to VEGAS === | + | ==== Access to VEGAS ==== |
Already with the few items we have seen of Python in this chapter we can already access the VEGAS application. | Already with the few items we have seen of Python in this chapter we can already access the VEGAS application. | ||
Zeile 162: | Zeile 157: | ||
pyVEGAS has the datatype " | pyVEGAS has the datatype " | ||
+ | |||
For now you only have to know that the datatype " | For now you only have to know that the datatype " | ||
Zeile 169: | Zeile 165: | ||
<code python> | <code python> | ||
- | print(pyVEGAS.Version) | + | print (pyVEGAS.Version) |
</ | </ | ||
This command prints the current version of VEGAS into the Output textbox: Version 16.0 (Build 261). | This command prints the current version of VEGAS into the Output textbox: Version 16.0 (Build 261). | ||
- | |||
- | {{: | ||
== Conclusion === | == Conclusion === |