mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Nicer test widget for FlowLayout
This commit is contained in:
parent
f737f515ba
commit
f81ac1ad00
@ -37,6 +37,7 @@ from qt.core import (
|
|||||||
QScrollArea,
|
QScrollArea,
|
||||||
QSize,
|
QSize,
|
||||||
QSizePolicy,
|
QSizePolicy,
|
||||||
|
QSplitter,
|
||||||
QStyle,
|
QStyle,
|
||||||
QStyledItemDelegate,
|
QStyledItemDelegate,
|
||||||
QStyleOptionToolButton,
|
QStyleOptionToolButton,
|
||||||
@ -51,6 +52,7 @@ from qt.core import (
|
|||||||
QUndoCommand,
|
QUndoCommand,
|
||||||
QUndoStack,
|
QUndoStack,
|
||||||
QUrl,
|
QUrl,
|
||||||
|
QVBoxLayout,
|
||||||
QWidget,
|
QWidget,
|
||||||
pyqtSignal,
|
pyqtSignal,
|
||||||
)
|
)
|
||||||
@ -524,7 +526,18 @@ class FlowLayout(QLayout): # {{{
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test():
|
def test():
|
||||||
|
s = QSplitter()
|
||||||
|
h = QSplitter()
|
||||||
|
h.setOrientation(Qt.Orientation.Vertical)
|
||||||
|
def filler():
|
||||||
|
la = QLabel(' filler')
|
||||||
|
la.sizeHint = lambda *a: QSize(10000, 10000)
|
||||||
|
la.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||||
|
return la
|
||||||
w = QWidget()
|
w = QWidget()
|
||||||
|
h.addWidget(w), h.addWidget(filler())
|
||||||
|
s.addWidget(h)
|
||||||
|
s.addWidget(filler())
|
||||||
l = FlowLayout(w)
|
l = FlowLayout(w)
|
||||||
la = QLabel('Some text in a label')
|
la = QLabel('Some text in a label')
|
||||||
l.addWidget(la)
|
l.addWidget(la)
|
||||||
@ -533,7 +546,7 @@ class FlowLayout(QLayout): # {{{
|
|||||||
cb = QComboBox()
|
cb = QComboBox()
|
||||||
cb.addItems(['Item one'])
|
cb.addItems(['Item one'])
|
||||||
l.addWidget(cb)
|
l.addWidget(cb)
|
||||||
return w
|
return s
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
@ -897,6 +910,8 @@ if __name__ == '__main__':
|
|||||||
from calibre.gui2 import Application
|
from calibre.gui2 import Application
|
||||||
app = Application([])
|
app = Application([])
|
||||||
app.load_builtin_fonts()
|
app.load_builtin_fonts()
|
||||||
w = RatingEditor.test()
|
d = QDialog()
|
||||||
w.show()
|
l = QVBoxLayout(d)
|
||||||
app.exec()
|
w = FlowLayout.test()
|
||||||
|
l.addWidget(w)
|
||||||
|
d.exec()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user