[PyQt] pyuic4 does not generate alignment for LayoutItem in grid layout?

Johoski, Timothy R timothy.r.johoski at intel.com
Sun Jul 28 02:04:52 BST 2013


> 
> On Tue, 23 Jul 2013 18:26:22 +0000, "Johoski, Timothy R"
> <timothy.r.johoski at intel.com> wrote:
> > Hi, in Qt designer, I added a push button into a grid layout, 
> > right-clicked on that widget and chose Layout Alignment->Top.  Qt
> designer
> > correctly shows the button aligned to the top.  However, pyuic4's
> generated
> > code does not set the alignment for the button.  I'm thinking pyuic4
> should
> > pass the alignment as the last argument to QGridLayout.addWidget?  I 
> > am currently working around this by explicitly setting the alignment 
> > on the LayoutItems in my code, but I suspect that pyuic4 should be 
> > doing this
> for
> > me?
> > 
> > In the following snapshots, notice that the "Aliases:" and "Browse..."
> > widgets are aligned to the top in Qt designer, but in the middle in 
> > the generated code.
> > 
> > Qt designer's view: 
> > https://www.dropbox.com/s/ex8edlskvh1uep3/DesignerSnapshot.jpg
> > pyuic4 generated result: 
> > https://www.dropbox.com/s/8vrhbvjiaw8qlrz/pyuic4PreviewSnapshot.jpg
> > 
> > ui file: 
> > https://www.dropbox.com/s/ynvjn8e4nbtt69o/LayoutItemAlignmentIssue.ui
> > pyuic4 generated code: 
> > https://www.dropbox.com/s/byn51xuj4qd58mq/ui_LayoutItemAlignmentIssue.
> > py
> > 
> > My versions:
> >   - Windows 7, Linux SLES 10
> >   - PyQt4-4.10.1
> >   - Python-2.7.4
> 
> 
> From: Phil Thompson 
> Sent: Friday, July 26, 2013 1:41 AM
> 
> Fixed in tonight's snapshots.
> 
> Thanks,
> Phil

hi Phil, thanks for the quick fix.  I finally got around to trying it
out and it works great for cases where I'm setting either Horizontal
or Vertical layout alignment, but when I set both, pyuic4 encounters
an error.  I glanced through the diff of the snapshot and made a hacky
fix in my copy of uiparser.gridPosition() which is now working fine
for me, you can find it here:
  https://www.dropbox.com/s/ixe9rrl5dqytn1v/uiparser.gridPosition.py

I'm a newbie to this stuff, so probably you'll know a better way to
implement the OR'ing of alignments...

In case you'd like a test case, I updated the example ui file here to set
both horizontal and vertical alignments:
  https://www.dropbox.com/s/ynvjn8e4nbtt69o/LayoutItemAlignmentIssue.ui

Thanks much,
Tim



More information about the PyQt mailing list