I use PyDev in Eclipse with the Qt integration. With an external tool I can create python source in a .py from a qt .ui file. This is the external tool: http://permalink.gmane.org/gmane.comp.python.xy.devel/413 The problem is that the generated python .py file has a name like MyGeneratedFile.ui.py. How can I adapt the external tool to have the extension of the generated file without .ui thus MyGeneratedFile.py ?
So it seems the problem boils down to ${resource_loc}, since this gives you the full path name /path/to/file/filename.ui - Yes, it does include the .ui hence when you say ${resource_loc}.py this translates into /path/to/file/filename.ui.py
So probably the simplest way to correct this problem since I couldn't find a way to make eclipse remove the file extension for me was making a very small script to do work.
You might need to modify it slightly to work for your pyuic installation.
/usr/bin/pyuicEclipse:
#!/bin/bash
pyUICCommand="/usr/bin/pyuic" # change this per your installation
x=$1
f=`basename $x`
d=`dirname $x`
fNoUI="`echo $f | sed 's/\.ui$//'`" # removes .ui extension from file basename
$pyUICCommand -o ${d}/${fNoUI}.py $x
make it executable and the eclipse configuration I used was much simpler:
This works on linux, so if you're on another OS it may need some slight modification, but I hope this solves your problem :)
In the interests of maintaining the cross-platform nature of Eclipse, I've knocked up a DOS equivalent of platinummonkey's bash script. It's not quite so robust, but it does the job:
@echo off
set pyUICCommand="pyuic"
set fname=%1
set fname=%fname:.ui=.py%
%pyUICCommand% -o %fname% %1
There is an easy solution to this problem that requires no scripting at all.
Install pathtools plugin either through Eclipse updates or via the Eclipse marketplace:
Setup an External Tools Configurations option in Eclipse as follows
In Main:
Note that ${parent-path} and ${name-sans-extension} are arguments made available through the pathtools plugin.
If you apply this and then run the configuration on a .ui resource file, you'll see a new .py file created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With