Modifying Qt designer py code
-
wrote on 29 May 2018, 10:26 last edited by
Hello,
I am a newbie QT designer user and I can't figure out how do I implement my own code in a qt python project. I use pyuic5 -x somefile.ui -o somefile.py to make a .py file from the ui, and that part goes well. The problem is when I edit the py file how do I add my own code?
for example. If I have this code:
from requests import get
fileName =input("Enter filename: ")
fileURL = input("URL path: ")
with open(fileName, "wb") as f:
response = get(fileURL)
f.write(response.content)and I want to implement it in QT Designer py project, how do I do that?
-
Hi and welcome to devnet,
Qt Designer is not a code editor, so you won't write anything there.
When would you like that code to be called ?
-
Hello,
I am a newbie QT designer user and I can't figure out how do I implement my own code in a qt python project. I use pyuic5 -x somefile.ui -o somefile.py to make a .py file from the ui, and that part goes well. The problem is when I edit the py file how do I add my own code?
for example. If I have this code:
from requests import get
fileName =input("Enter filename: ")
fileURL = input("URL path: ")
with open(fileName, "wb") as f:
response = get(fileURL)
f.write(response.content)and I want to implement it in QT Designer py project, how do I do that?
wrote on 30 May 2018, 07:54 last edited by@gigalomaniaczero
In addition to what @SGaist has said, I'll throw in:I have a large Python code base for my project. For that benefit, I sit inside PyCharm, an excellent Python editor/debugger IDE, for all my Qt work, using PyQt5 as the harness from Qt to Python.
For right or for wrong, I do not use Qt Creator, because it is for C++ development, not Python. I manage without "visual" design of my PyQt widgets, and create everything dynamically in Python code.
Depending perhaps on just how much UI design you want to do, and how you feel about literal code instead of interactive design, you might want to consider this approach. I don't know how easy it is to use your
puuic5
compilation principle, and how well the code it produces does or does not mesh with standalone PyQt code. -
wrote on 31 May 2018, 09:26 last edited by
@JonB said in Modifying Qt designer py code:
puuic5
Hi,
I know QT designer is not a code editor and I can't do any coding within the app itself. I use puuic5 to compile the ui xml code to python, but when I edit the py file, i still quite don't understand how do I add the code. I can add some simple actions like button click and few others, but any more complex code doesn't seem to work in the same python logic I used to do things.
-
@JonB said in Modifying Qt designer py code:
puuic5
Hi,
I know QT designer is not a code editor and I can't do any coding within the app itself. I use puuic5 to compile the ui xml code to python, but when I edit the py file, i still quite don't understand how do I add the code. I can add some simple actions like button click and few others, but any more complex code doesn't seem to work in the same python logic I used to do things.
wrote on 31 May 2018, 09:42 last edited by@gigalomaniaczero said in Modifying Qt designer py code:
I can add some simple actions like button click and few others, but any more complex code doesn't seem to work in the same python logic I used to do things.
I don't think anyone is going to know what this might mean.
1/5