[IronPython] Can't install IronPython Tools for Visual Studio

Lukáš Duběda loocas at duber.cz
Mon May 3 19:30:02 CEST 2010


Thanks for pointing that out, Curt,

now, for such a trivial function I can imagine substituting
it with a Lambda, however, how would I use a more complex
function?

I found out exactly that when not passing any arguments
the function works like this:

def functName(self, sender):
     ....
     pass

(XamlDef.FindName('btnCreate')).Click += functName


This has worked flawlessly, as soon as I need to pass it
an argument. I haven't found a way to do that.


Thanks again, cheers,

Lukáš Duběda
Director
[T] +420 602 444 164

duber studio(tm)
[M] info at duber.cz
[W] http://www.duber.cz

[A] R.A.Dvorského 601, Praha 10
[A] 10900, Czech Republic, Europe

Curt Hagenlocher wrote:
> The problem is this line:
> controls['Button']['btnCreate'].Click += printHello("HELLO WORLD")
>  
> This executes the function printHello("HELLO WORLD") and tries to add 
> the result -- None -- as an event handler. Something like the following 
> should probably work:
>  
> controls['Button']['btnCreate'].Click += lambda s, e: printHello("HELLO 
> WORLD")
> 
> On Mon, May 3, 2010 at 4:33 AM, Lukáš Duběda <loocas at duber.cz 
> <mailto:loocas at duber.cz>> wrote:
> 
>     Ok, I now risk being kicked out from this list for
>     spamming :D but I have to take my chances. Btw: I'm
>     still waiting for a bung of WPF books to arrive, so,
>     please bear with me.
> 
>     Here's a primitive app I'm trying to build in VS2010
>     using IPy and, to me, the new WPF stuff.
> 
>     XAML and the Python Code attached.
> 
>     Now, when I try to build the app, I get an error:
> 
>     "Event addition expected callable object, got NoneType"
> 
>     Can anyone explain to me why I'm getting this error?
>     As I said, I'm more used to WinForms and adding a function
>     definition to a control this way has always worked. Even
>     more so as I copied some of the code, incl. the even
>     addition from this site:
>     http://www.ironpython.info/index.php/XAML_GUI_Events_Example
> 
>     Thank you very much (again) in advance, I really do appretiate
>     all your support.
> 
>     Lukáš Duběda
>     Director
>     [T] +420 602 444 164
> 
>     duber studio(tm)
>     [M] info at duber.cz <mailto:info at duber.cz>
>     [W] http://www.duber.cz <http://www.duber.cz/>
> 
>     [A] R.A.Dvorského 601, Praha 10
>     [A] 10900, Czech Republic, Europe
> 
> 
>     niki wrote:
> 
>         Jimmy Schementi wrote:
> 
> 
> 
>                    <http://ironpython.net/ironpython/tools/>
>                  
>                  <http://ironpython.net/ironpython/tools/>http://ironpython.net/ironpython/tools/
> 
>                    should probably be updated to not link to the express
>                 version.
> 
> 
>             You're absolutely right; the "Visual Studio 2010" link on
>             http://ironpython.net/tools/ now goes to the general VS2010
>             site (
>             <http://microsoft.com/visualstudio/>http://microsoft.com/visualstudio/),
>             and
>              <http://ironpython.net/tools/download/>http://ironpython.net/tools/download/
>             now has the installation instructions from the walkthrough,
>             so that should clear up any confusion.
> 
> 
>         Is it Isolated shell or Integrated shell?
> 
>         Niki
>         _______________________________________________
>         Users mailing list
>         Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
>         http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> 
> 
>     import clr
>     clr.AddReference('PresentationFramework')
> 
>     from System.Windows.Markup import XamlReader
>     from System.Windows import Application
>     from System.IO import FileStream, FileMode
> 
>     XamlDef = XamlReader.Load(FileStream('WPF_Test_01.xaml', FileMode.Open))
> 
>     def Waddle(c, d):
>        s = str(c.__class__)
>        if "System.Windows.Controls." in str(c) and hasattr(c,"Name") and
>     c.Name.Length>0:
>            ControlType = s[s.find("'")+1:s.rfind("'")]
>            if ControlType not in d:
>                d[ControlType] = {}
>            d[ControlType][c.Name] = c
>        if hasattr(c,"Children"):
>            for cc in c.Children:
>                Waddle(cc, d)
>        elif hasattr(c,"Child"):
>            Waddle(c.Child, d)
>        elif hasattr(c,"Content"):
>            Waddle(c.Content, d)
> 
>     def printToLabel(passedControl, passedInput):
>            passedControl.Content = passedInput
> 
>     def printHello(txt):
>        print txt
> 
>     controls = {}
>     Waddle(XamlDef, controls)
> 
>     #controls['Button']['btnCreate'].Click +=
>     printToLabel(controls['Label']['lblOutput'],
>     controls['Button']['btnCreate'].Content)
> 
>     controls['Button']['btnCreate'].Click += printHello("HELLO WORLD")
> 
>     Application().Run(XamlDef)
> 
>     <?xml version="1.0" encoding="utf-8"?>
>     <Project DefaultTargets="Build"
>     xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
>      <PropertyGroup>
>        <Configuration Condition=" '$(Configuration)' == ''
>     ">Debug</Configuration>
>        <SchemaVersion>2.0</SchemaVersion>
>        <ProjectGuid>{cab7a050-6da5-4796-8d39-1205d7984933}</ProjectGuid>
>        <ProjectHome>.</ProjectHome>
>        <StartupFile>WPF_Test_01.py</StartupFile>
>        <SearchPath>
>        </SearchPath>
>        <WorkingDirectory>.</WorkingDirectory>
>        <IsWindowsApplication>True</IsWindowsApplication>
>        <AssemblyName>WPF_Test_01</AssemblyName>
>        <Name>WPF_Test_01</Name>
>        <RootNamespace>WPF_Test_01</RootNamespace>
>      </PropertyGroup>
>      <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
>        <DebugSymbols>true</DebugSymbols>
>        <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
>      </PropertyGroup>
>      <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
>        <DebugSymbols>true</DebugSymbols>
>        <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
>      </PropertyGroup>
>      <ItemGroup>
>        <None
>     Include="D:\Scripts\Tests\WPF_Test\WPF_Test_01\WPF_Test_01\WPF_Test_01.py"
>     />
>        <None
>     Include="D:\Scripts\Tests\WPF_Test\WPF_Test_01\WPF_Test_01\WPF_Test_01.xaml"
>     />
>        <None Include="WPF_Test_01.py" />
>        <None Include="WPF_Test_01.xaml" />
>      </ItemGroup>
>     </Project>
>     _______________________________________________
>     Users mailing list
>     Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
>     http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list