Qt/PyQt: QGraphicsItem vs. QGraphicsWidget geometry, position, mouse interaction - qt

I am converting a larger program of QGraphicsItems to QGraphicsWidgets (let's call them item and widget for typing sake). Mouse hover fails now because the position and/or rect of the widgets are not the same as the old items. I've boiled down to a simple case with a view, scene, an item and a widget. The blue item renders at 100x50 pix, and hoverEnterEvent occurs as expected. However, the red widget is rendered at half intended width. I can fix this if I reimplement the pure virtual function boundingRect for the widget but the hover event is still only triggered atop the 50x50 left half. What pos/rect/geometry methods do I need to use/override to get the widget to interact properly with the mouse just like the item? Thanks. Here's my sample code
#!/usr/local/bin/python
import os, sys
from PyQt4.Qt import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class MyView(QGraphicsView):
def __init__(self):
QGraphicsView.__init__(self)
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self.scene = QGraphicsScene(self)
self.item = GraphicsItem('item', 100, 50)
self.item.moveBy(50, 50)
self.scene.addItem(self.item)
self.widget = GraphicsWidget('widget', 100, 50)
self.scene.addItem(self.widget)
self.setScene(self.scene)
class GraphicsItem(QGraphicsItem):
def __init__(self, name, width, height):
QGraphicsItem.__init__(self)
self.setAcceptHoverEvents(True)
self.name = name
self.__width = width
self.__height = height
def boundingRect(self):
return QRectF(0, 0, self.__width, self.__height)
def hoverEnterEvent(self, event):
self.__printGeometryDetails()
def paint(self, painter, option, widget):
bgRect = self.boundingRect()
painter.drawRects(bgRect)
painter.fillRect(bgRect, QColor('blue'))
def __printGeometryDetails(self):
print self.name
print ' pos (%.0f, %0.0f)' % (self.pos().x(), self.pos().y())
print ' boundingRect (%.0f, %0.0f, %.0f, %0.0f)' % (self.boundingRect().x(), self.boundingRect().y(), self.boundingRect().width(), self.boundingRect().height())
class GraphicsWidget(QGraphicsWidget):
def __init__(self, name, width, height):
QGraphicsWidget.__init__(self)
self.setAcceptHoverEvents(True)
self.name = name
self.__width = width
self.__height = height
def boundingRect(self):
return QRectF(0, 0, self.__width, self.__height)
def hoverEnterEvent(self, event):
self.__printGeometryDetails()
def paint(self, painter, option, widget):
bgRect = self.boundingRect()
painter.drawRects(bgRect)
painter.fillRect(bgRect, QColor('red'))
def __printGeometryDetails(self):
print self.name
print ' pos (%.0f, %0.0f)' % (self.pos().x(), self.pos().y())
print ' boundingRect (%.0f, %0.0f, %.0f, %0.0f)' % (self.boundingRect().x(), self.boundingRect().y(), self.boundingRect().width(), self.boundingRect().height())
print ' geometry (%.0f, %0.0f, %.0f, %0.0f)' % (self.geometry().x(), self.geometry().y(), self.geometry().width(), self.geometry().height())
print ' rect (%.0f, %0.0f, %.0f, %0.0f)' % (self.rect().x(), self.rect().y(), self.rect().width(), self.rect().height())
if __name__ == '__main__':
app = QApplication(sys.argv)
view = MyView()
view.setGeometry(600, 100, 400, 370)
view.show()
sys.exit(app.exec_())

It does seem to work correctly if you use self.resize(width, height) instead of redefining boundingRect.

Related

QTreeView item's editor position problem?

I have a QTreeView widget in which I have set indentation to 0 with QTreeView::setIndentation(0), but when editing an item, the editor still appears at the indentation level of the default indented behaviour:
I have tried changing the editor position with a QStyledItemDelegate::updateEditorGeometry's method, but it seems that there is a limit to where I can move the editor horizontally, as I cannot move it to a negative offset, past the x == 0 position, like for example QRect(-50, 0, 100, 30).
Any ideas would be greatly appreciated, thanks.
P.S.:
Here is an attempt of a minimal-reproducible-example, but this has another bug: the editor widget does not display when the geometry of the widget in drawRow is changed! The editor works when typing and pressing enter, it's just not displayed! I'll try to figure out what's the difference between my example in the image above and this code.
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sip
class MyTreeWidget(QTreeWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setIndentation(0)
self.setMouseTracking(True)
self.setUniformRowHeights(True)
self.setExpandsOnDoubleClick(False)
self.setColumnCount(1)
self.setHeaderLabels(["Items"])
self.setHeaderHidden(True)
self.header().setVisible(False)
self.header().setStretchLastSection(False)
self.header().setSectionResizeMode(0, QHeaderView.ResizeMode.ResizeToContents)
self.add_items()
self.itemClicked.connect(self.click)
def click(self, item, column):
item.setFlags(
Qt.ItemFlag.ItemIsEditable |
Qt.ItemFlag.ItemIsEnabled |
Qt.ItemFlag.ItemIsSelectable
)
index = self.indexFromItem(item, 0)
self.edit(index)
def drawRow(self, painter, option, index):
model = self.model()
row = index.row()
column = index.column()
item = self.itemFromIndex(index)
widget = self.itemWidget(item, 0)
if widget is not None:
geo = QRect(widget.geometry())
geo.setX(geo.x() + 50)
widget.setGeometry(geo) # <- This line causes the editor's horizontal offset
super().drawRow(painter, option, index)
def add_items(self):
items = [
'Cookie dough',
'Hummus',
'Spaghetti',
'Dal makhani',
'Chocolate whipped cream'
]
parent = None
for item in items:
new_item = QTreeWidgetItem(None)
if parent is not None:
new_item = QTreeWidgetItem(parent)
else:
self.addTopLevelItem(new_item)
new_item.setText(0, item)
new_item.setExpanded(True)
parent = new_item
def edit_last_item(*args):
new_item.setFlags(
Qt.ItemFlag.ItemIsEditable |
Qt.ItemFlag.ItemIsEnabled |
Qt.ItemFlag.ItemIsSelectable
)
index = self.indexFromItem(new_item, 0)
self.edit(index)
print("Editing")
QTimer.singleShot(1000, edit_last_item)
class Window(QWidget):
def __init__(self):
super().__init__()
layout = QVBoxLayout(self)
self.setLayout(layout)
layout.addWidget(MyTreeWidget())
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())
In trying to create a minimal reproducible example as #Parisa.H.R mentioned in the comment, I discovered that in the drawRow method in the QTreeView/QTreeWidget there is some code that adjusts the geometry of item widgets, like so (Python/PyQt example):
class MyTreeView(QTreeView):
def drawRow(self, painter, option, index):
model = self.model()
row = index.row()
column = index.column()
item = self.itemFromIndex(index)
widget = self.itemWidget(item, 0)
geo = ... # <- Code that calculates new geometry
widget.setGeometry(geo) # <- This line causes the editor's horizontal offset
super().drawRow(painter, option, index)
which is what causes the editor widget to be moved horizontally to the right.
Thanks #Parisa.H.R

How do I add qtreeview sub items

How can I add children to my current qtreeview items in the code i provided below? I want it to look something like this:
The code below creates a treeview that is sorted but im not entirely clear on how to add children items. Hope you can help, thanks.
import sys
from PySide import QtGui, QtCore
class SortModel(QtGui.QSortFilterProxyModel):
def __init__(self, *args, **kwargs):
super(SortModel, self).__init__(*args, **kwargs)
def lessThan(self, left, right):
leftData = self.sourceModel().data(left)
rightData = self.sourceModel().data(right)
if leftData:
leftData = leftData.lower()
if rightData:
rightData = rightData.lower()
print('L:', leftData, 'R:', rightData)
return leftData < rightData
class Browser(QtGui.QDialog):
def __init__(self, parent=None):
super(Browser, self).__init__(parent)
self.initUI()
def initUI(self):
self.resize(200, 300)
self.setWindowTitle('Assets')
self.setModal(True)
self.results = ""
self.uiItems = QtGui.QTreeView()
self.uiItems.setAlternatingRowColors(True)
self.uiItems.setSortingEnabled(True)
self.uiItems.sortByColumn(0, QtCore.Qt.AscendingOrder)
self.uiItems.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.uiItems.header().setResizeMode(QtGui.QHeaderView.ResizeToContents)
self._model = self.create_model(self)
self._spmodel = SortModel(self)
self._spmodel.setSourceModel(self._model)
self._spmodel.setDynamicSortFilter(True)
self.uiItems.setModel(self._spmodel)
grid = QtGui.QGridLayout()
grid.setContentsMargins(0, 0, 0, 0)
grid.addWidget(self.uiItems, 0, 0)
self.setLayout(grid)
self.setLayout(grid)
self.uiItems.doubleClicked.connect(self.doubleClickedItem)
self.show()
def doubleClickedItem(self, item):
name = item.data(role=QtCore.Qt.DisplayRole)
print name
def create_model(self, parent):
items = [
'Cookie dough',
'Hummus',
'Spaghetti',
'Dal makhani',
'Chocolate whipped cream'
]
model = QtGui.QStandardItemModel()
model.setHorizontalHeaderLabels(['Name'])
for item in items:
model.appendRow(QtGui.QStandardItem(item))
return model
def showEvent(self, event):
geom = self.frameGeometry()
geom.moveCenter(QtGui.QCursor.pos())
self.setGeometry(geom)
super(Browser, self).showEvent(event)
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape:
# self.hide()
self.close()
event.accept()
else:
super(Browser, self).keyPressEvent(event)
def main():
app = QtGui.QApplication(sys.argv)
ex = Browser()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
You would do this in your create_model method. There are several different ways of appending child rows and columns. Instead of passing a QStandardItem directly to model.appendRow, create it and save it in a variable. Then you can use QStandardItem.appendRow to add children to your top level rows.
I don't know Python and may get the syntax wrong, but the basic pattern is something like this:
std_item = QtGui.QStandardItem ("Dinner")
child_std_item = QtGui.QStandardItem ("Drinks")
std_item.appendRow (child_std_item)
Alternately, you can do this at the model level using model.insertRow and specify the QModelIndex of the parent item. You can get the QModelIndex of an item using model.indexFromItem. Hopefully that's enough to get you going. Each QStandardItem knows its parent, if any, and its children, so it's usually a matter of having the parent available to add/change/remove children.

Restrict item in PyQt4‏ using itemChange()

I tried using the Qt documentation example to restrict the rectangle to the area of the scene but it still fails, someone has an alternative to do this?
My code, the QGraphicsView instance was created in Qt Desginer:
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
from screen import *
class MovableItem(QGraphicsRectItem):
def __init__(self, rectang, *args, **kwargs):
QGraphicsRectItem.__init__(self, rectang, *args, **kwargs)
self.setFlags(QGraphicsItem.ItemIsMovable |
QGraphicsItem.ItemSendsGeometryChanges)
self.pen = QPen(Qt.darkMagenta)
self.pen.setWidth(4)
self.setPen(self.pen)
def itemChange(self, change, value):
if change == QGraphicsItem.ItemPositionChange and self.scene():
# value is the new position.
self.newPos = value.toPointF()
self.rect = self.scene().sceneRect()
if not(self.rect.contains(self.newPos)):
# Keep the item inside the scene rect.
self.newPos.setX(min(self.rect.right(), max(self.newPos.x(), self.rect.left())))
self.newPos.setY(min(self.rect.bottom(), max(self.newPos.y(), self.rect.top())))
return self.newPos
return QGraphicsRectItem.itemChange(self, change, value)
class Main(QWidget, Ui_Form):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.setupUi(self)
self.scene = QGraphicsScene()
self.cena.setScene(self.scene)
self.scene.addPixmap(QPixmap("01.png"))
self. graph = MovableItem(2, 2, 300, 150)
self.scene.addItem(self.graph)
def showEvent(self, event):
self.cena.fitInView(self.scene.sceneRect(), Qt.IgnoreAspectRatio)
app = QApplication(sys.argv)
window = Main()
window.show()
sys.exit(app.exec_())
First:
Use setSceneRect() in your main Main(), to set the size of the scene.
Second:
Actually the example of the documentation is wrong, therefore, to adjust the rectangle to the scene, delete this if and subtract, in min, the parameters right and bottom by the rectangle dimensions right and bottom in setX and setY. Replace this part of your code:
if not(self.rect.contains(self.newPos)):
# Keep the item inside the scene rect.
self.newPos.setX(min(self.rect.right(), max(self.newPos.x(), self.rect.left())))
self.newPos.setY(min(self.rect.bottom(), max(self.newPos.y(), self.rect.top())))
return self.newPos
For:
self.newPos.setX(min(self.rect.right()-self.boundingRect().right(), max(self.newPos.x(), self.rect.left())))
self.newPos.setY(min(self.rect.bottom()-self.boundingRect().bottom(), max(self.newPos.y(), self.rect.top())))
return self.newPos

PyQt: eventFilter to get mouse position in a semi-transparent window

I want to make:
a semi-transparent fullscreen window (rgba(0,0,0,180)).
while moving mouse, display absolute position on label.
user can press on it to get the absolute position of the mouse.
However I cannot achieve the second one. When moving mouse on it, label won't update mouse's position. But I found when moving out of label (after removing layout.setMargin(0) and layout.setSpacing(0)), it works.
# -*- coding: utf-8 -*-
import sys, os, math
from PyQt4 import QtCore, QtGui
class ScreenPositionLabel(QtGui.QWidget):
def __init__(self):
super(ScreenPositionLabel, self).__init__()
self.setStyleSheet("background-color:rgba(0, 0, 0, 180); color:#fff;")
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
#self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, False)
#self.setStyleSheet("QMainWindow{opacity:0.5;}")
self.label = QtGui.QLabel("Please click on screen")
self.label.setAlignment(QtCore.Qt.AlignCenter)
layout = QtGui.QHBoxLayout()
layout.addWidget(self.label)
# remove margin and padding
layout.setMargin(0)
layout.setSpacing(0)
self.setLayout(layout)
self.setMouseTracking(True)
self.installEventFilter(self)
self.label.show()
self.show()
def eventFilter(self, source, event):
if (event.type() == QtCore.QEvent.MouseMove and
event.buttons() == QtCore.Qt.NoButton):
pos = event.pos()
self.label.setText('Please click on screen. ( %d : %d )' % (pos.x(), pos.y()))
elif event.type() == QtCore.QEvent.MouseButtonPress:
pos = event.pos()
print('( %d : %d )' % (pos.x(), pos.y()))
self.close()
return QtGui.QWidget.eventFilter(self, source, event)
app = QtGui.QApplication(sys.argv)
main_window = ScreenPositionLabel()
app.exec_()
Any way to solve this problem? Thanks!
Your 4 questions:
1) I want to make: a semi-transparent fullscreen window (rgba(0,0,0,180)).
Yes, you can. Please use QWidget.setWindowOpacity (self, float level).
2) I want to make: while moving mouse, display absolute position on label.
I recommend using QWidget.mouseMoveEvent (self, QMouseEvent) to get current position your mouse and enable QWidget.setMouseTracking (self, bool enable) for track all mouse movement.
QWidget.setMouseTracking (self, bool enable)
QWidget.mouseMoveEvent (self, QMouseEvent)
3) I want to make: user can press on it to get the absolute position of the mouse.
Using QWidget.mousePressEvent (self, QMouseEvent) to track when mouse press.
4) However I cannot achieve the second one. When moving mouse on it, label won't update mouse's position. But I found when moving out of label (after removing layout.setMargin(0) and layout.setSpacing(0)), it works.
Because in default layout height of QLabel has spacing & margin, then real area isn't all area widget solve it is your solution is OK.
Full example for your solution:
import sys
from PyQt4 import QtGui, QtCore
class QCustomLabel (QtGui.QLabel):
def __init__ (self, parent = None):
super(QCustomLabel, self).__init__(parent)
self.setMouseTracking(True)
self.setTextLabelPosition(0, 0)
self.setAlignment(QtCore.Qt.AlignCenter)
def mouseMoveEvent (self, eventQMouseEvent):
self.setTextLabelPosition(eventQMouseEvent.x(), eventQMouseEvent.y())
QtGui.QWidget.mouseMoveEvent(self, eventQMouseEvent)
def mousePressEvent (self, eventQMouseEvent):
if eventQMouseEvent.button() == QtCore.Qt.LeftButton:
QtGui.QMessageBox.information(self, 'Position', '( %d : %d )' % (self.x, self.y))
QtGui.QWidget.mousePressEvent(self, eventQMouseEvent)
def setTextLabelPosition (self, x, y):
self.x, self.y = x, y
self.setText('Please click on screen ( %d : %d )' % (self.x, self.y))
class QCustomWidget (QtGui.QWidget):
def __init__ (self, parent = None):
super(QCustomWidget, self).__init__(parent)
self.setWindowOpacity(0.7)
# Init QLabel
self.positionQLabel = QCustomLabel(self)
# Init QLayout
layoutQHBoxLayout = QtGui.QHBoxLayout()
layoutQHBoxLayout.addWidget(self.positionQLabel)
layoutQHBoxLayout.setMargin(0)
layoutQHBoxLayout.setSpacing(0)
self.setLayout(layoutQHBoxLayout)
self.showFullScreen()
myQApplication = QtGui.QApplication(sys.argv)
myQTestWidget = QCustomWidget()
myQTestWidget.show()
myQApplication.exec_()

Is there a way to overlay multiple items on a parent widget (PySide/Qt)

I have a main parent widget, and I want several layouts on top of the parent widget.
Initializing a layout with a parent widget will place the layout on top of the parent widget. I like this and would like to do it multiple times (left, top, bottom, and right sides) for the same parent widget.
I used a QGridLayout with different sub layouts, but this caused the layouts to resize and forced them to be small. Whatever Overlay is added last should be on top of the other items.
Below is a very simple example of what I want.
import sys
from PySide import QtGui, QtCore
class Overlay(QtGui.QBoxLayout):
"""Overlay widgets on a parent widget."""
def __init__(self, parent=None, location="left"):
super().__init__(QtGui.QBoxLayout.TopToBottom, parent)
if location == "left" or location == "right":
self.setDirection(QtGui.QBoxLayout.TopToBottom)
if location == "right":
self.setAlignment(QtCore.Qt.AlignRight)
elif location == "top" or location == "bottom":
self.setDirection(QtGui.QBoxLayout.LeftToRight)
if location == "bottom":
self.setAlignment(QtCore.Qt.AlignBottom)
self.css = "QWidget {background-color: lightskyblue; color: white}"
# end Constructor
def addWidget(self, widget):
super().addWidget(widget)
widget.setStyleSheet(self.css)
# end addWidget
# end class Overlay
def main():
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
window.show()
widg = QtGui.QTreeView()
window.setCentralWidget(widg)
left = Overlay(widg, "left")
left.addWidget(QtGui.QLabel("HELLO"))
left.addWidget(QtGui.QLabel("WORLD!"))
top = Overlay(widg, "top")
top.addWidget(QtGui.QLabel("Hello"))
top.addWidget(QtGui.QLabel("World!"))
right = Overlay(location="right")
right.setParent(widg)
right.addWidget(QtGui.QLabel("hello"))
right.addWidget(QtGui.QLabel("world!"))
return app.exec_()
# end main
if __name__ == '__main__':
sys.exit(main())
Is there anyway to have multiple layouts with the same parent? If not is there some way to create a dummy widget that will move with the parent widget and have the Overlays use multiple dummy widgets as their parent?
also
layout = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom, parent_widget)
does not do the same thing as
layout = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom)
layout.setParent(parent_widget)
What does the Initialization do with the parent that is different?
I solved this by creating my own master custom layout. OverlayCenter has the main widget as it's parent and you just add the other layouts to this layout.
import sys
from PySide import QtGui, QtCore
class OverlayCenter(QtGui.QLayout):
"""Layout for managing overlays."""
def __init__(self, parent):
super().__init__(parent)
# Properties
self.setContentsMargins(0, 0, 0, 0)
self.items = []
# end Constructor
def addLayout(self, layout):
"""Add a new layout to overlay on top of the other layouts and widgets."""
self.addChildLayout(layout)
self.addItem(layout)
# end addLayout
def __del__(self):
"""Destructor for garbage collection."""
item = self.takeAt(0)
while item:
item = self.takeAt(0)
# end Destructor
def addItem(self, item):
"""Add an item (widget/layout) to the list."""
self.items.append(item)
# end addItem
def count(self):
"""Return the number of items."""
return len(self.items)
# end Count
def itemAt(self, index):
"""Return the item at the given index."""
if index >= 0 and index < len(self.items):
return self.items[index]
return None
# end itemAt
def takeAt(self, index):
"""Remove and return the item at the given index."""
if index >= 0 and index < len(self.items):
return self.items.pop(index)
return None
# end takeAt
def setGeometry(self, rect):
"""Set the main geometry and the item geometry."""
super().setGeometry(rect)
for item in self.items:
item.setGeometry(rect)
# end setGeometry
# end class OverlayCenter
class Overlay(QtGui.QBoxLayout):
"""Overlay widgets on a parent widget."""
def __init__(self, location="left", parent=None):
super().__init__(QtGui.QBoxLayout.TopToBottom, parent)
if location == "left":
self.setDirection(QtGui.QBoxLayout.TopToBottom)
self.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
elif location == "right":
self.setDirection(QtGui.QBoxLayout.TopToBottom)
self.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
elif location == "top":
self.setDirection(QtGui.QBoxLayout.LeftToRight)
self.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter)
elif location == "bottom":
self.setDirection(QtGui.QBoxLayout.LeftToRight)
self.setAlignment(QtCore.Qt.AlignBottom | QtCore.Qt.AlignHCenter)
self.css = "QWidget {background-color: lightskyblue; color: white}"
# end Constructor
def addWidget(self, widget):
super().addWidget(widget)
widget.setStyleSheet(self.css)
# end addWidget
# end class Overlay
def main():
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
window.show()
widg = QtGui.QTreeView()
window.setCentralWidget(widg)
left = Overlay("left")
lhlbl = QtGui.QLabel("Hello")
lwlbl = QtGui.QLabel("World!")
lhlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
lwlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
left.addWidget(lhlbl)
left.addWidget(lwlbl)
top = Overlay("top")
lhlbl = QtGui.QLabel("HELLO")
lwlbl = QtGui.QLabel("WORLD!")
lhlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
lwlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
top.addWidget(lhlbl)
top.addWidget(lwlbl)
right = Overlay("right")
lhlbl = QtGui.QLabel("hellO")
lwlbl = QtGui.QLabel("worlD!")
lhlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
lwlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
right.addWidget(lhlbl)
right.addWidget(lwlbl)
bottom = Overlay("bottom")
lhlbl = QtGui.QLabel("hello")
lwlbl = QtGui.QLabel("world!")
lhlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
lwlbl.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
bottom.addWidget(lhlbl)
bottom.addWidget(lwlbl)
center = OverlayCenter(widg)
center.addLayout(left)
center.addLayout(top)
center.addLayout(right)
center.addLayout(bottom)
return app.exec_()
# end main
if __name__ == '__main__':
sys.exit(main())

Resources