[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: Pixmap alignment in QPushButtons.
From:       Patrick Stinson <patrickkidd () gmail ! com>
Date:       2020-04-26 23:28:22
Message-ID: 941A9C04-8C22-44EA-A364-B9B1D25495E6 () gmail ! com
[Download RAW message or body]

One reason might be that it is quite easy to write your own button that paints how \
you like it which makes this a minor issue. I posted something about this on the qt \
forum recently. Whatever you do, just make sure you use QIcon to paint the image.

> On Apr 26, 2020, at 1:39 PM, Raymond Osborn <rayosborn@mac.com> wrote:
> 
> Thanks for the advice. I realized after writing my last message that it can't be \
> an issue with the MacOS per se because PyQt v5.9 still works without problem on the \
> current MacOS.  
> I must admit that I have been surprised by how muted the response to all the MacOS \
> issues has been. Relatively little shows up on Google. I think most package \
> developers like me have created their own work-arounds - for example, we are all \
> adding extra repaint calls when setting the text in QLineEdit boxes. However, I \
> have tried a number of hacks, such as tweaking stylesheets, to get these \
> QPushButtons to look better without success. 
> Ray
> 
> > On Apr 26, 2020, at 3:46 PM, Patrick Stinson <patrickkidd@gmail.com> wrote:
> > 
> > It sounds like you have some testing to do if you want to isolate the problem. If \
> > it were me, I would not assume it is a PyQt5 problem until you've ruled out both \
> > the Qt version and the macOS version. 
> > However, a simple Qt bug report with the versions you know that it occurs in \
> > would probably be sufficient. You will need a simple working code example to do \
> > that and a pyqt example is usually sufficient. 
> > I would not assume that the Qt devs know about this problem purely based on the \
> > fact that it's been there for over two years. Just perform a search on the Qt bug \
> > reporting system, and if you don't find one then report a new one. If they can \
> > reproduce it, they'll assign a level of importance (probably not super high) and \
> > that will be all you can do in light of fixing the problem yourself - or more \
> > likely - finding a workaround for your particular application. 
> > -Patrick
> > 
> > > On Apr 26, 2020, at 11:16 AM, Raymond Osborn <rayosborn@mac.com> wrote:
> > > 
> > > I do nearly all my testing in conda environments, and as far as I can tell, the \
> > > PyQt and Qt dependencies seem to require the versions to be nearly the same. I \
> > > also don't know if this is dependent on the MacOS version. The problems seem to \
> > > coincide with the release of MacOS 10.13 (High Sierra) in 2017, so it might \
> > > just be that the Qt developers didn't keep up with some change in the Mac APIs \
> > > after v5.10. However, the problems have now persisted for over two years \
> > > through four PyQt versions, so I hope they are aware that this is still an \
> > > issue. 
> > > Ray 
> > > 
> > > > On Apr 26, 2020, at 12:13 PM, Patrick Stinson <patrickkidd@gmail.com> wrote:
> > > > 
> > > > I recall posting or commenting on a Qt bug report about vertical alignment or \
> > > > something similar, but I can't remember what it was. 
> > > > Are you saying that this behavior occurs when changing to PyQt5-5.11 but \
> > > > using the same Qt version? If this is a bug and actually not expected \
> > > > behavior then my initial suspicion would be that it is a function of Qt and \
> > > > not PyQt5.  
> > > > Generally speaking, Qt is not the most stable and reliable framework out \
> > > > there. It's pretty good, but I would say the philosophy tends toward the new \
> > > > versus the stable. I have been working with it for over 20 years and expect \
> > > > regression bugs whenever I update to a newer version. 
> > > > 
> > > > > On Apr 26, 2020, at 7:58 AM, Raymond Osborn <rayosborn@mac.com> wrote:
> > > > > 
> > > > > Since PyQt 5.11, the MacOS version of  PyQt5 appears to have had a number \
> > > > > of issues, mostly to do with failing to repaint text boxes (e.g., see \
> > > > > https://bugreports.qt.io/browse/QTBUG-68521 and \
> > > > > https://bugreports.qt.io/browse/QTBUG-68740). There were reports that this \
> > > > > had been fixed by 5.12, but that has not been my experience. I haven't had \
> > > > > time to check on 5.14 yet. Everything seems to be fine on Linux, at least \
> > > > > with 5.12.  
> > > > > I am writing to ask if anyone has also experienced an issue with the \
> > > > > alignment of pixmaps in QPushButtons. I have subclassed QPushButton with \
> > > > > the following code: 
> > > > > class NXColorButton(QtWidgets.QPushButton):
> > > > > 
> > > > > def __init__(self, parent=None):
> > > > > super(NXColorButton, self).__init__(parent)
> > > > > self.setFixedSize(20, 20)
> > > > > self.setIconSize(QtCore.QSize(12, 12))
> > > > > pixmap = QtGui.QPixmap(QtCore.QSize(12, 12))
> > > > > pixmap.fill(QtGui.QColor(QtCore.Qt.white))
> > > > > self.setIcon(QtGui.QIcon(pixmap))
> > > > > 
> > > > > In PyQt 5.9, this produced the following button on the right:
> > > > > <Color Button PyQt 5.9.7.png>
> > > > > 
> > > > > In PyQt 5.14.2, it produces this:
> > > > > <Color Button PyQt 5.14.2.png>
> > > > > 
> > > > > When I query the sizes, they agree with the values in the code, but \
> > > > > although the pixel map is square, the QPushButton below it is clearly not \
> > > > > 20x20. It's rectangular for a start. I can make it nearly square if I \
> > > > > increase the size to 30x30. For comparison, the QLineEdit box to the left \
> > > > > is 21 pixels high. 
> > > > > I can write up a bug report but I wanted to find out if this is a known \
> > > > > issue or easy to fix. 
> > > > > — 
> > > > > Ray Osborn
> > > > 
> > > 
> > 
> 


[Attachment #3 (text/html)]

<html><head><meta http-equiv="content-type" content="text/html; \
charset=utf-8"></head><body dir="auto"><div dir="ltr">One reason might be that it is \
quite easy to write your own button that paints how you like it which makes this a \
minor issue. I posted something about this on the qt forum recently. Whatever you do, \
just make sure you use QIcon to paint the image.</div><div dir="ltr"><br><blockquote \
type="cite">On Apr 26, 2020, at 1:39 PM, Raymond Osborn &lt;rayosborn@mac.com&gt; \
wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><meta \
http-equiv="Content-Type" content="text/html; charset=utf-8">Thanks for the advice. I \
realized after writing my last message that it can't be an issue with the MacOS per \
se because PyQt v5.9 still works without problem on the current MacOS.&nbsp;<div \
class=""><br class=""></div><div class="">I must admit that I have been surprised by \
how muted the response to all the MacOS issues has been. Relatively little shows up \
on Google. I think most package developers like me have created their own \
work-arounds - for example, we are all adding extra repaint calls when setting the \
text in QLineEdit boxes. However, I have tried a number of hacks, such as tweaking \
stylesheets, to get these QPushButtons to look better without success.</div><div \
class=""><br class=""></div><div class="">Ray<br class=""><div><br \
class=""><blockquote type="cite" class=""><div class="">On Apr 26, 2020, at 3:46 PM, \
Patrick Stinson &lt;<a href="mailto:patrickkidd@gmail.com" \
class="">patrickkidd@gmail.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" \
content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; line-break: after-white-space;" class="">It sounds like you \
have some testing to do if you want to isolate the problem. If it were me, I would \
not assume it is a PyQt5 problem until you've ruled out both the Qt version and the \
macOS version.<div class=""><br class=""></div><div class="">However, a simple Qt bug \
report with the versions you know that it occurs in would probably be sufficient. You \
will need a simple working code example to do that and a pyqt example is usually \
sufficient.<div class=""><br class=""></div><div class="">I would not assume that the \
Qt devs know about this problem purely based on the fact that it's been there for \
over two years. Just perform a search on the Qt bug reporting system, and if you \
don't find one then report a new one. If they can reproduce it, they'll assign a \
level of importance (probably not super high) and that will be all you can do in \
light of fixing the problem yourself - or more likely - finding a workaround for your \
particular application.</div><div class=""><br class=""></div><div \
class="">-Patrick<br class=""><div class=""><br class=""><blockquote type="cite" \
class=""><div class="">On Apr 26, 2020, at 11:16 AM, Raymond Osborn &lt;<a \
href="mailto:rayosborn@mac.com" class="">rayosborn@mac.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" \
content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; line-break: after-white-space;" class="">I do nearly all my \
testing in conda environments, and as far as I can tell, the PyQt and Qt dependencies \
seem to require the versions to be nearly the same. I also don't know if this is \
dependent on the MacOS version. The problems seem to coincide with the release of \
MacOS 10.13 (High Sierra) in 2017, so it might just be that the Qt developers didn't \
keep up with some change in the Mac APIs after v5.10. However, the problems have now \
persisted for over two years through four PyQt versions, so I hope they are aware \
that this is still an issue.<div class=""><br class=""></div><div \
class="">Ray&nbsp;<br class=""><div class=""><br class=""><blockquote type="cite" \
class=""><div class="">On Apr 26, 2020, at 12:13 PM, Patrick Stinson &lt;<a \
href="mailto:patrickkidd@gmail.com" class="">patrickkidd@gmail.com</a>&gt; \
wrote:</div><br class="Apple-interchange-newline"><div class=""><meta \
http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div \
style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: \
after-white-space;" class=""><div class="">I recall posting or commenting on a Qt bug \
report about vertical alignment or something similar, but I can't remember what it \
was.</div><div class=""><br class=""></div><div class="">Are you saying that this \
behavior occurs when changing to PyQt5-5.11 but using the same Qt version? If this is \
a bug and actually not expected behavior then my initial suspicion would be that it \
is a function of Qt and not PyQt5.&nbsp;</div><div class=""><br class=""></div><div \
class="">Generally speaking, Qt is not the most stable and reliable framework out \
there. It's pretty good, but I would say the philosophy tends toward the new versus \
the stable. I have been working with it for over 20 years and expect regression bugs \
whenever I update to a newer version.</div><div class=""><br class=""></div><div \
class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On \
Apr 26, 2020, at 7:58 AM, Raymond Osborn &lt;<a href="mailto:rayosborn@mac.com" \
class="">rayosborn@mac.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" \
content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; line-break: after-white-space;" class=""><meta \
http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div \
style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: \
after-white-space;" class="">Since PyQt 5.11, the MacOS version of &nbsp;PyQt5 \
appears to have had a number of issues, mostly to do with failing to repaint text \
boxes (e.g., see&nbsp;<a href="https://bugreports.qt.io/browse/QTBUG-68521" \
class="">https://bugreports.qt.io/browse/QTBUG-68521</a>&nbsp;and&nbsp;<a \
href="https://bugreports.qt.io/browse/QTBUG-68740" \
class="">https://bugreports.qt.io/browse/QTBUG-68740</a>). There were reports that \
this had been fixed by 5.12, but that has not been my experience. I haven't had time \
to check on 5.14 yet.&nbsp;Everything seems to be fine on Linux, at least with \
5.12.&nbsp;<div class=""><br class=""></div><div class="">I am writing to ask if \
anyone has also experienced an issue with the alignment of pixmaps in QPushButtons. I \
have subclassed QPushButton with the following code:</div><div class=""><br \
class=""></div><div class="">class NXColorButton(QtWidgets.QPushButton):<br \
class=""><br class="">&nbsp; &nbsp; def __init__(self, parent=None):<br \
class="">&nbsp; &nbsp; &nbsp; &nbsp; super(NXColorButton, self).__init__(parent)<br \
class="">&nbsp; &nbsp; &nbsp; &nbsp; self.setFixedSize(20, 20)<br class="">&nbsp; \
&nbsp; &nbsp; &nbsp; self.setIconSize(QtCore.QSize(12, 12))<br class="">&nbsp; &nbsp; \
&nbsp; &nbsp; pixmap = QtGui.QPixmap(QtCore.QSize(12, 12))<br class="">&nbsp; &nbsp; \
&nbsp; &nbsp; pixmap.fill(QtGui.QColor(QtCore.Qt.white))<br class="">&nbsp; &nbsp; \
&nbsp; &nbsp; self.setIcon(QtGui.QIcon(pixmap))<br class=""><br class=""></div><div \
class="">In PyQt 5.9, this produced the following button on the right:</div><div \
class=""><span id="cid:4208008A-38F2-4656-A550-6F142B88DAA2" class="">&lt;Color \
Button PyQt 5.9.7.png&gt;</span></div><div class=""><br class=""></div><div \
class="">In PyQt 5.14.2, it produces this:</div><div class=""><span \
id="cid:20D03483-26D9-42D7-AC80-448F2292DE93" class="">&lt;Color Button PyQt \
5.14.2.png&gt;</span></div><div class=""><br class=""></div><div class="">When I \
query the sizes, they agree with the values in the code, but although the pixel map \
is square, the QPushButton below it is clearly not 20x20. It's rectangular for a \
start. I can make it nearly square if I increase the size to 30x30. For comparison, \
the QLineEdit box to the left is 21 pixels high.</div><div class=""><br \
class=""></div><div class="">I can write up a bug report but I wanted to find out if \
this is a known issue or easy to fix.</div><div class=""><br class=""></div><div \
class="">—&nbsp;</div><div class="">Ray \
Osborn</div></div></div></div></blockquote></div><br \
class=""></div></div></div></blockquote></div><br \
class=""></div></div></div></blockquote></div><br \
class=""></div></div></div></div></blockquote></div><br \
class=""></div></div></blockquote></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic