For the same PyQt4 code, the layout looks quite equivalent on Linux and Windows. But with MacOSX, we see that :
- the elements seems to take a little more space (mostly bt_bookmark which doesn't shrink to the expected size)
- a lot of space is used between the elements (that's the most annoying thing)
How could it be shrink to the minimum? Is there a margin policy that we need to set globally or anything else?
Here is the code used for the test case :
from PyQt4 import QtGui, QtCore
import sys
class GUI(QtGui.QWidget):
def __init__(self):
super(GUI, self).__init__()
vbox_layout = QtGui.QVBoxLayout()
for i in range(4):
hbox_layout = QtGui.QHBoxLayout()
bt_bookmark = QtGui.QPushButton()
bt_bookmark.setGeometry(0, 0, 15, 15)
bt_bookmark.setIcon(QtGui.QIcon("./bookmark_on.png"))
hbox_layout.addWidget(bt_bookmark)
hbox_layout.addWidget(QtGui.QPushButton("Button1"))
hbox_layout.addWidget(QtGui.QLabel("Some text here."))
hbox_layout.addWidget(QtGui.QPushButton("Button2"))
hbox_layout.addWidget(QtGui.QPushButton("Button3"))
vbox_layout.addLayout(hbox_layout)
self.setLayout(vbox_layout)
self.setWindowTitle("Test Layout")
self.show()
self.resize_window_to_minimum()
def resize_window_to_minimum(self):
# http://stackoverflow.com/a/28667119/446302
def _func_to_call():
self.resize(self.minimumSizeHint())
QtCore.QTimer.singleShot(500, _func_to_call)
if __name__ == "__main__":
app = QtGui.QApplication([])
gui = GUI()
sys.exit(app.exec_())
And the captures :