Boston Python Workshop 5/Friday/Windows set up Python: Difference between revisions

From OpenHatch wiki
Content added Content deleted
(NymzcXeAAzlIbZ)
Line 1: Line 1:
like setting up a shraed folder on a Linux host and a Windows guest, you need to create the folder to share on your host system and add it to your shraed folders list
== Download and install Python ==

If you believe you already have Python installed, please let a staff member know before completing these steps.

<ol>
<li>Click http://python.org/ftp/python/2.7.1/python-2.7.1.msi and choose "run" if you have the option to. Otherwise, save it to your Desktop, then minimize windows to see your desktop, and double click on it to start the installer. Follow the installer instructions to completion.</li>
<li><b>Open a command prompt (we will be doing this multiple times, so make a note of how to do this!)</b>:
* On Windows Vista or Windows 7: click on the Start menu (the Windows logo in the lower left of the screen), type <code>cmd</code> into the Search field directly above the Start menu button, and click on "cmd" in the search results above the Search field.
* On Windows XP: click on the Start menu (the Windows logo in the lower left of the screen), click on "Run...", type <code>cmd</code> into the text box, and hit enter.
<br />
You now have what's called a command prompt. This command prompt is another way of navigating your computer and running programs -- just textually instead of graphically. We are going to be running Python and Python scripts from this command prompt.
</li>
<li>At this <code>C:\</code> prompt that appears, test your Python install by typing

<pre>
\Python27\python.exe
</pre>

and hitting enter. You should see something like
<pre>
Python 2.7.1 (r271:86832, ...) on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
</pre>

You just started Python! The <code>>>></code> indicates that you are at a new type of prompt -- a Python prompt. The command prompt let's you navigate your computer and run programs, and the Python prompt lets you write and run Python code interactively.

</li>
<li>To exit the Python prompt, type

<pre>
exit()
</pre>

and press Enter. This will take you back to the Windows command prompt (the <code>C:\</code> you saw earlier).</li>
</ol>

the materials doesn`t cgrehehnae is my script:import bpyimport randomclass random_mat_panel(bpy.types.Panel): bl_idname = matPanel bl_label = Random Material Assigner bl_space_type = VIEW_3D' bl_region_type = Tools' def draw(self, context): layout = self.layout layout.operator( object.random_material )class mat_assigner(bpy.types.Operator): bl_idname = object.random_material bl_label = Assign Random Material bl_description = Use this to assign a random material bl_options = { REGISTER', UNDO'} searchString = bpy.props.StringProperty(name= Filter ) seedProp = bpy.props.IntProperty(name= Seed ) availableMaterials = [] def invoke(self, context, event): self.randomize() return { FINISHED'} def check(self, context): self.randomize() def randomize(self): random.seed(self.seedProp) self.availableMaterials = [] for mat in bpy.data.materials: if(self.searchString.lower() in mat.name.lower()): self.availableMaterials.append(mat) for ob in bpy.context.selected_objects: randNum = random.randint(0, len(self.availableMaterials)-1) active_material = self.availableMaterials[randNum] def execute(self, context): return { FINISHED'}bpy.utils.register_class(mat_assigner)bpy.utils.register_class(random_mat_panel)

== Success! ==

You have Python installed and configured.

[[Boston Python Workshop 5/Friday|&laquo; Back to the Friday setup page]]

Revision as of 17:34, 5 May 2012

like setting up a shraed folder on a Linux host and a Windows guest, you need to create the folder to share on your host system and add it to your shraed folders list