Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To create a set of assemblies for your IronPython application so that you can distribute it you can either use pyc.py or SharpDevelop.</p> <p>To compile using pyc.py:</p> <p>ipy.exe pyc.py /main:Program.py Form.py File1.py File2.py ... /target:winexe </p> <p>Given the amount of files in your project you could try using SharpDevelop instead of maintaining a long command line for pyc.py. You will need to create a new IronPython project in SharpDevelop and import your files into the project. You will probably need to import the files one at a time since SharpDevelop lacks a way to import multiple files unless they are in a subfolder.</p> <p>You can then use SharpDevelop to compile your application into an executable and a dll. All the other required files, such as IronPython.dll, Microsoft.Scripting.dll, will be in the bin/debug or bin/release folder. SharpDevelop uses clr.CompileModules and a custom MSBuild task behind the scenes to generate the binaries.</p> <p>Any IronPython packages defined in your project should be usable from your application after compilation.</p> <p>Packaging up the XAML can be done by embedding the xaml as a resource. Then using code similar to the following:</p> <pre><code>import clr clr.AddReference('PresentationFramework') clr.AddReference('System') from System.IO import FileMode, FileStream, Path from System.Reflection import Assembly from System.Windows import Application from System.Windows.Markup import XamlReader executingAssemblyFileName = Assembly.GetEntryAssembly().Location directory = Path.GetDirectoryName(executingAssemblyFileName) xamlFileName = Path.Combine(directory, "Window1.xaml") stream = FileStream(xamlFileName, FileMode.Open) window = XamlReader.Load(stream) app = Application() app.Run(window) </code></pre> <p>SharpDevelop 3.2 does not embed resource files correctly so you will need to use SharpDevelop 4.</p> <p>If you are using IronPython 2.7 you can use the new clr.LoadComponent method that takes an object and either a XAML filename or stream and wires up that object to the XAML.</p> <p>Whilst the C# compiler can compile your XAML into a BAML resource doing the same with IronPython has a few problems. If you do not link the XAML to a class via the x:Class attribute then it is possible to compile the XAML into a BAML resource and have that embedded into your assembly. However you will not get any autogenerated code so you will need to create that code yourself. Another problem is that this will not work out of the box with SharpDevelop. You will need to edit the SharpDevelop.Build.Python.targets file and change the from Python to C#. Trying to use the x:Class attribute will not work since the BAML reader cannot access any associated IronPython class. This is because the generated IL in the compiled IronPython application is very different to that in a C# or VB.NET assembly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload