简体   繁体   中英

How to translate a file from ui to py for pyside2?

I am trying to translate a file from a ui file in python I am writing a team

pyside-uic "C:\test.ui" -x -o "C:\test.py"

in team squad, but it tells me that there is no such team. Changed to "pyside2-uic" but still did not help Tell me how to fix it? Python 3.7.6 and Pyside2. I tried to use

import sys, pprint
from pysideuic import compileUi
pyfile = open("[path to output python file]\output.py", 'w')
compileUi("[path to input ui file]\input.ui", pyfile, False, 4,
False)
pyfile.close()

but module pysideuic not found. What else can i do? I haven't installed pyside2-tools or pyside-tools for some reason, so if I need to download them somewhere, tell me how. I already tried downloading through pip but it didn't work.

I'm not sure that I fully understood your question as "team squad" isn't clear for me. But I'm sure that you need to install pyside2-tools as UI compiler is a part of this package. And I want to mention that pyside-uic was removed starting from some python version (I think 3.8, but not sure). With actual version you should use following command (linux example, but for windows it is very similar):

uic -g python -o <ouput_python_file> <input_ui_file>
<resources>
   <include location="ui.files.qrc"/>
</resources>

actually, ui is folder, like this: D:\\qt5_design\\project\\ui\\files.qrc

pyrcc5 files.qrc -o ui.files.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM