Il 18/10/2016 16:56, Michael Torrie ha scritto:
On 10/18/2016 02:33 AM, Mark Summerfield wrote:
When I started out I used Qt Designer to produce .ui files (XML) and
then used the Qt uic tool to convert this to C++ (although you can
convert to Python using pyuic). I then studied the code and learnt
from that. And it turns out that it isn't very hard. There is
QVBoxLayout - widgets one above the other; QHBoxLayout; widgets side
by side; QGridLayout - widgets in a grid. The only complication is
when you nest these, say a QVBoxLayout inside a QHBoxLayout inside a
QGridLayout; but in practice, once you've done it a few times it
isn't hard to picture. However, I know highly skilled people who
prefer to use Qt Designer, so it is no big deal either way.
I am certainly not highly skilled. But I definitely do use the Designer
for everything related to the GUI. I don't, however, use uic or pyuic.
What I recommend these days is to use the xml .ui file directly in your
program to create the objects for you. In C++ with an EXE, you can
incorporate the .ui file into the executable as a resource. In Python,
I would just bundle it with all the other resources I might be using.
For custom widgets I either build a simple plugin for Designer that lets
me use the widgets as any other in the visual layout. Alternatively,
I'll just change the class type in properties.
The way you use the .ui file loader is to create a class in Python,
usually for each window or dialog, and subclass it from the appropriate
Qt type such as QDialog. Then in the __init__() method, you call
PyQt.uic.loadUi and it brings all the widgets in and initializes them
and adds them to the QDialog you are defining. And if you follow the
naming scheme for your callbacks of on_widgetname_signalName(), it will
auto connect them. For example, if my button was called "myButton", I
could name a slot to be on_myButton_clicked() and it would connect
automatically. PySides allows something similar with QUiLoader. I use a
wrapper class that Sebastion Wiesner wrote to make it closer to a
one-liner wrapper function like PyQt offers.
What are the differences between PySides and PyQt... apart the licence?
Is PySides usable as PyQt?
I agree with you about making GUIs programmatically being not hard,
especially when one is learning. When I first started using Qt, coming
from GTK, I had to get used to a similar but different boxing model. In
GTK, when packing widgets you specify both the expansion and spacing
while packing. In Qt, you have explicit spacers to insert into the
boxes. I'm not sure which method is better.
So you have some experience on GTK and QT. Could you spend some time to
describe a few differences? What do you like with Gtk and what you
don't? And for Qt?
When you worked with Gtk, have you used Glade as GUI Builder? Could you
compare Glade and QT Designer?
--
https://mail.python.org/mailman/listinfo/python-list