[PyQt] dip: how to connect the model with ui-view
Achim Kisseler
ak7 at jupiter.uni-freiburg.de
Tue Feb 8 21:50:48 GMT 2011
Hi everyone,
I managed (thank Phil) to integrate the file I created with ui-designer
correct.
Now I trying to set up the connection with the model and a controller.
But the vars I define in the model do not init the desired attributes:
--%<--
import sys
from PyQt4.QtGui import QApplication
from dip.model import *
from dip.ui import Designer, VBox
from dip.ui.toolkits.qt import QtToolkit
app = QApplication(sys.argv)
# Define the model.
class test_model(Model):
MU = Str("testtext")
lineEdit= Str("testtext")
spinBox_MU=Int(8 , minimum=8 , maximum=14)
# comboBox=List("M" , "E" , "Z")
# Create the model.
model = test_model()
# Define the view.
view = VBox(Designer('dip-test.ui'))
# Create and display the GUI.
ui = view(model, QtToolkit(), widget=True)
ui.show()
app.exec_()
--%<--
My idea to set up the controller comes from the example in "Controllers
and Validation", which does not work:
first:
#define the controller:
class basis_controller(Controller):
def update_model(self):
# invalid_reason = super(basis, self).validate_view()
sum = int(self.MU_editor.value)+1
self.SUM=Int(sum)
second:
# Create the controller.
controller = PersonController(auto_update_model=False)
# Create an instance of the view for the model.
ui = view(model, QtToolkit(), controller=controller)
I am looking fir : hints, tutorials, examples!
Thanks,
Achim
More information about the PyQt
mailing list