By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,264 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,264 IT Pros & Developers. It's quick & easy.

PyQt database example

P: n/a
Can somebody point me to a quick example on how to display the result of
an SQL query in a PyQt QListBox? I've googled in vain for this.

regards,
--
Leif Biberg Kristensen
http://solumslekt.org/
Validare necesse est
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mon, 22 Mar 2004 08:30:18 +0100, "Leif B. Kristensen"
<ju******@solumslekt.org> wrote:
Can somebody point me to a quick example on how to display the result of
an SQL query in a PyQt QListBox? I've googled in vain for this.


Assuming you can get the results of your SQL query into string form,
it should be just a matter of inserting those strings into your
widget.

I don't know if this will help you, but here is a snip from one of my
classes where I am processing a list of text lines and displaying
those lines in a QTextEdit widget. The fields in each line are padded
to make everything come out in nice columns.

The snag that hung me up when I first started using PyQt was not
realizing that the "QStrings" that come out of a Qt widget (a C++
thingy) have to be converted to Python strings ( with the str function
). It's OK going the other way, however. You can insert a Python
string ( p below ) into a PyQt widget.

def slotParse(self):
self.outputTextLabel.setText(self.simComboBox.curr entText())
pystring = str(self.textEdit1.text()) # Convert QString to
pystring
modlist = pystring.splitlines()
plist = parseMods(modlist)
for p in plist:
self.textEdit2.insert(p + '\n')

-- Dave

Jul 18 '05 #2

P: n/a
David MacQuigg wrote:
I don't know if this will help you, but here is a snip from one of my
classes where I am processing a list of text lines and displaying
those lines in a QTextEdit widget. The fields in each line are padded
to make everything come out in nice columns.


David,
thanks for your suggestion, but I've been completely stalled in my
efforts to learn PyQt due to the arcane documentation. For now I'm
doing some progress with Tkinter, as there are so many docs, resources
and tutorials on the web that even a clod like me can make some sense
of it.

I found a great multi-column listbox in Tkinter here:

<url:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266>

regards,
--
Leif Biberg Kristensen
http://solumslekt.org/
Validare necesse est
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.