[PyQt] (no subject)
Erik Janssens
Erik.Janssens at conceptive.be
Mon May 21 23:15:35 BST 2012
you could give Camelot a try ...
http://www.python-camelot.com/
On Sat, May 19, 2012 at 4:16 AM, Wes Goodenough <mobile at wrgoodenough.com> wrote:
> Hello. I'm learning PyQt for use with Designer for database applications.
> I've been reading all the resources and tutorials, and I have a good amount
> of
> experience with GUI and Database programming in MS ACCESS. I have finally
> decided to put in the effort to lear python and QT but i'm stuck and
> need help seeing what I'm doing wrong.
>
> I have Ui_Clients.py generated by Eric from "clients.ui" created by
> Designer.
>
> class Ui_MainWindowClients(object):
> def setupUi(self, MainWindowClients):
> MainWindowClients.setObjectName(_fromUtf8("MainWindowClients"))
> MainWindowClients.resize(640, 480)
>
> ... etc
> Among the widgets is QtGui.QTreeView "ClientTreeView" as follows:
>
> self.ClientTreeView = QtGui.QTreeView(self.centralwidget)
> self.ClientTreeView.setGeometry(QtCore.QRect(30, 290, 401, 111))
>
> ... etc ending with
>
> self.ClientTreeView.setObjectName(_fromUtf8("ClientTreeView"))
>
> I also have Clients.py as generated by Eric from "clients.ui"
>
> class MainWindowClients(QMainWindow, Ui_MainWindowClients):
> SSN, FNAME, LNAME, SEX, RACE, DOB = range(6)
> ASC = 0
> DESC = 1
>
> def __init__(self, parent = None):
> QMainWindow.__init__(self, parent)
> self.setupUi(self)
>
> dbType = "QMYSQL"
> dbConnect = "clientsdb"
> dbName = "clients"
> dbTable = "Clients"
> dbUname = "root" #because db has been created with user name
> dbPW = "" #because db password is not set
> db = QSqlDatabase.addDatabase(dbType, dbConnect)
> db.setDatabaseName(dbName)
> db.setUserName(dbUname)
>
> if not db.open():
> QMessageBox.warning(None, "ClientTracking:".join(dbName),
> QString("Database Open Error:
> %1").arg(db.lastError().text()))
> sys.exit(1)
>
> self.clientModel = QSqlTableModel(None, db)
> self.clientModel.setTable("Clients")
> self.clientModel.setSort(SSN, ASC)
> self.clientModel.select()
>
> self.ClientTreeView = QTreeView(self)
> self.ClientTreeView.setModel(self.clientModel)
> self.ClientTreeView.setGeometry(QtCore.QRect(30, 290, 401, 111))
> self.ClientTreeView.show()
>
> @pyqtSignature("QString")
> def on_cmbBoxUniqueID_editTextChanged(self, p0):
> # TODO: not implemented yet
> ... etc
>
> My problem is in connecting self.clientModel to self.ClientTreeView.
> When i run this code MainWindowClients is painted including ClientTreeView
> from Designer (blank), but instead of having the model attached to
> Designer's
> widget ClientTreeView, a second QTreeview widget is created at default
> Geometry.
>
>
> On a related item, also note... the code snippet in the PyQt documentation
> explaining how to use QT Designer with PyQt contains the following for
> multiple
> inheritance instancing:
> The reference to "self.ui.okButton.clicked.connect(self.accept)" is
> confusing.
> It makes sense for the simple sub-classing of QDialog presented just before,
> but
> it does not help trying to figure out what my problem is...
>
> from PyQt4.QtGui import QDialog
> from ui_imagedialog import Ui_ImageDialog
>
> class ImageDialog(QDialog, Ui_ImageDialog):
> def __init__(self):
> QDialog.__init__(self)
>
> # Set up the user interface from Designer.
> self.setupUi(self)
>
> # Make some local modifications.
> self.colorDepthCombo.addItem("2 colors (1 bit per pixel)")
>
> # Connect up the buttons.
> self.ui.okButton.clicked.connect(self.accept)
> self.ui.cancelButton.clicked.connect(self.reject)
>
> Any help will be appreciated... Thanks. I'm looking forward to using the
> power
> of PyQt with MySql etc for non-MS bound projects.
>
> Wes
>
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
More information about the PyQt
mailing list