External Eclipse tool for Qt.ui to .py with pyuic

I am using PyDev in Eclipse with Qt integration. Using an external tool, I can create a python source in a .py from a qt.ui file. This is an external tool: http://permalink.gmane.org/gmane.comp.python.xy.devel/413 The problem is that the generated python.py file is named MyGeneratedFile.ui.py. How can I adapt an external tool to the extension of the generated file without .ui, thus MyGeneratedFile.py?

+5
source share
3 answers

So the problem boils down to $ {resource_loc} , as it gives you the full path name /path/to/file/filename.ui - Yes, it includes .ui , so when you say $ {resource_loc} .py it means /path/to/file/filename.ui.py

So, probably the easiest way to fix this problem, since I could not find a way to get eclipse to remove the file extension for me, I made a very small script to work.

You may need to modify it a bit to work for your installation in pyuic.

/ 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:

  • PyUIC-> Main-> Location: / usr / bin / pyuicEclipse --- obviously change this to your
  • PyUIC- > Main- > : ${resource_loc}
  • PyUIC- > - " "
  • PyUIC- > - " "
  • PyUIC- > Common - File, .

linux, , , , , :)

+10

- Eclipse DOS platinummonkey bash script. , :

@echo off
set pyUICCommand="pyuic"
set fname=%1
set fname=%fname:.ui=.py%
%pyUICCommand% -o %fname% %1
+5

, .

:

  • : pyuic_run. ( - )
  • : python ( pyside-uic.exe, )
  • . pyuic.py( , pyside-uic.exe, ). , . "$ {resource_loc}" ( )
  • : " " ( )
  • In the assembly: disable "Build before launch" # not needed here
  • In the environment: no change
  • In general: activate the "File" option and specify the path: $ {parent-path} / $ {name-without-extension} .py

Note that $ {parent-path} and $ {name-sans-extension} are arguments available through the pathtools plugin.

If you apply this and then run the configuration in the .ui resource file, you will see a new .py file.

+1
source

All Articles