Run Python

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
Run Python is a [[Developer Commands|Developer Command]] for Developer Edition license users only.
+
Run Python is a [[Developer Commands|Developer Command]] for [[Developer Edition]] license users only.
  
 
This command will run python commands within UBot Studio.
 
This command will run python commands within UBot Studio.
Line 7: Line 7:
  
  
== Example ==
+
== Example 1 ==
  
 
<pre>
 
<pre>
Line 17: Line 17:
  
 
</pre>
 
</pre>
 
  
 
Running the script will produce an alert with the words "Hello World" displayed within it.
 
Running the script will produce an alert with the words "Hello World" displayed within it.
Line 23: Line 22:
  
 
[[File:runpython.jpg]]
 
[[File:runpython.jpg]]
 +
 +
 +
== Example 2 ==
 +
 +
<pre>
 +
run python("import winsound
 +
winsound.PlaySound(\"SystemExit\", winsound.SND_ALIAS)")
 +
 +
 +
</pre>
 +
 +
This example uses the winsound module to play a system sound on the system in use.
 +
 +
Running the script will play the windows system exit sound.
 +
 +
 +
== Example 3 ==
 +
 +
<pre>
 +
run python("import clr
 +
clr.AddReference(\'System.Windows.Forms\')
 +
 +
from System.Windows.Forms import Application, Form, Label
 +
 +
form = Form(Text=\"Hello World Form\")
 +
label = Label(Text=\"Hello World!\")
 +
 +
form.Controls.Add(label)
 +
 +
Application.Run(form)")
 +
 +
</pre>
 +
 +
This example creates a labeled form window separate from UBot Studio. Running the script will produce the form window.

Latest revision as of 20:13, 11 November 2017

Run Python is a Developer Command for Developer Edition license users only.

This command will run python commands within UBot Studio.

Commands created with run python will run on all editions, but it will only be editable in node view in the Developer edition.


[edit] Example 1

run python("import clr
clr.AddReference(\"System.Windows.Forms\")
 
from System.Windows.Forms import MessageBox
MessageBox.Show(\"Hello World\")")

Running the script will produce an alert with the words "Hello World" displayed within it.


Runpython.jpg


[edit] Example 2

run python("import winsound
winsound.PlaySound(\"SystemExit\", winsound.SND_ALIAS)")


This example uses the winsound module to play a system sound on the system in use.

Running the script will play the windows system exit sound.


[edit] Example 3

run python("import clr
clr.AddReference(\'System.Windows.Forms\')

from System.Windows.Forms import Application, Form, Label

form = Form(Text=\"Hello World Form\")
label = Label(Text=\"Hello World!\")

form.Controls.Add(label)

Application.Run(form)")

This example creates a labeled form window separate from UBot Studio. Running the script will produce the form window.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox