469,327 Members | 1,226 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

PyQt database example

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
2 7738
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
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.

Similar topics

5 posts views Thread by mghale | last post: by
2 posts views Thread by Karen | last post: by
6 posts views Thread by GGerard | last post: by
2 posts views Thread by Marcel Balcarek | last post: by
2 posts views Thread by Sacha Vieux-Roy | last post: by
9 posts views Thread by anders | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.