views:

336

answers:

3

In the PyWin32 demos folder, the win32gui_dialog.py sample uses the classic windows controls. Can the Windows Vista themed buttons also be displayed using PyWin32, and if so, how? I'm using ActivePython 3.1, if that makes any difference.

Sample:

PyWin32

+2  A: 

Short answer: a resounding YES.

I know that this is possible because I have seen it being done before. but I am not entirely certain as to how it is done.

At the very least, you can use IronPython and use Windows' builtin .NET framework by wielding clr.

If you are not interested in IronPython, then might you consider something along the lines of easyGUI or TkInter?

inspectorG4dget
I'd rather not use IronPython. Do you still know where you have seen it being done before?
Reshure
Using TkInter now.
Reshure
Reshure, in that case you should use the `ttk` module. See http://tkdocs.com/tutorial
Sridhar Ratnakumar
+1  A: 

You'll need to add a side-by-side manifest specifying a correct version of ComCtl32.dll to the Python interpreter. Fortunately there is no need to change the interpreter executable itself.

  • Create a file named python.exe.manifest in the directory containing python.exe.
  • Put the following contents in that file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly 
   xmlns="urn:schemas-microsoft-com:asm.v1" 
   manifestVersion="1.0">
 <assemblyIdentity 
    processorArchitecture="x86" 
    version="5.1.0.0"
    type="win32"
    name="python.exe"/>
 <description>Python</description>
 <dependency>
  <dependentAssembly>
    <assemblyIdentity
         type="win32"
         name="Microsoft.Windows.Common-Controls"
         version="6.0.0.0"
         publicKeyToken="6595b64144ccf1df"
         language="*"
         processorArchitecture="x86"/>
  </dependentAssembly>
 </dependency>
</assembly>

You may want to copy python.exe.manifest to pythonw.exe.manifest too.

atzz
Thanks, but that didn't seem to work. Nothing happened.
Reshure
If the script runs under PythonWin.exe, then probably the manifest should be PythonWin.exe.manifest.
ΤΖΩΤΖΙΟΥ
I'm running from python.exe (ActivePython 3.1)
Reshure
Maybe it needs to be for the Python dll? I do know that the manifest is the way to change this, so it might take some experimentation.
Matthew Talbert
A: 

Have you tried using 'winxpgui' module instead of 'win32gui' module?

I'm not sure if there's a 'winvistagui' or 'win7gui' module, but 'winxpgui' does exist and may work, as it has a manifest included.

Tamás Szelei
I've tried winxp, but it didn't work.
Reshure