示例#1
0
from taurus.qt.qtgui.container import TaurusWidget
from taurus.qt.qtgui.display import TaurusLabel
from taurus.qt.qtgui.input import TaurusValueSpinBox

app = Qt.QApplication(sys.argv)

panel = TaurusWidget()
layout = Qt.QHBoxLayout()
panel.setLayout(layout)

w1 = TaurusLabel()
w2 = TaurusLabel()
w3 = TaurusValueSpinBox()
w4 = TaurusLabel()
layout.addWidget(w1)
layout.addWidget(w2)
layout.addWidget(w3)
layout.addWidget(w4)
w1.setUseParentModel(True)
w2.setUseParentModel(True)
w3.setUseParentModel(True)
w4.setUseParentModel(True)
panel.setModel('sys/taurustest/1')
w1.setModel('/position#label')
w2.setModel('/position')
w3.setModel('/position')
w4.setModel('/position#unit')

panel.show()
sys.exit(app.exec_())
示例#2
0
app = TaurusApplication(sys.argv)

# The problem arises in some situations when the Taurus parenting is not the same
# as the Qt parenting. For demonstration we use 3 widgets:
# p <-- m <--c (the arrows indicate the *Qt* parent)
# note that "m" not being a Taurus widget, implies that the *Taurus* parent of c is p
# also note that we are not giving the parent in the constructor, but we rely on
# doing it later on when adding to layout

p = TaurusWidget()  # Taurus parent
m = Qt.QWidget()  # midle widget (non Taurus)
c = TaurusLabel()  # Taurus child

# here we call setUseParentModel before the parent is known!

c.setUseParentModel(True)

# we prepare the layouts

m.setLayout(Qt.QVBoxLayout())
p.setLayout(Qt.QVBoxLayout())

# Now, by adding the widgets to the layout we are actually reparenting them.
# The order in which we reparent determines success/failure:
# if we do m-->p and then c-->m, it works, but if we do it in the opposite
# order, we trigger the error.
# (i.e., if we had called "p.layout().addWidget(m)" it would work work)
m.layout().addWidget(c)
p.layout().addWidget(m)

# the problem arises because the Taurus ancestry of c is only checked when:
示例#3
0
app = Qt.QApplication(sys.argv)

# The problem arises in some situations when the Taurus parenting is not the same
# as the Qt parenting. For demonstration we use 3 widgets:
# p <-- m <--c (the arrows indicate the *Qt* parent)
# note that "m" not being a Taurus widget, implies that the *Taurus* parent of c is p
# also note that we are not giving the parent in the constructor, but we rely on
# doing it later on when adding to layout

p = TaurusWidget()  # Taurus parent
m = Qt.QWidget()  # midle widget (non Taurus)
c = TaurusLabel()  # Taurus child

# here we call setUseParentModel before the parent is known!

c.setUseParentModel(True)

# we prepare the layouts

m.setLayout(Qt.QVBoxLayout())
p.setLayout(Qt.QVBoxLayout())

# Now, by adding the widgets to the layout we are actually reparenting them.
# The order in which we reparent determines success/failure:
# if we do m-->p and then c-->m, it works, but if we do it in the opposite
# order, we trigger the error.
# (i.e., if we had called "p.layout().addWidget(m)" it would work work)
m.layout().addWidget(c)
p.layout().addWidget(m)

# the problem arises because the Taurus ancestry of c is only checked when: