PyQt database example

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leif B. Kristensen

    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

    Validare necesse est
  • David MacQuigg

    #2
    Re: PyQt database example

    On Mon, 22 Mar 2004 08:30:18 +0100, "Leif B. Kristensen"
    <junkmail@solum slekt.org> wrote:
    [color=blue]
    >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.[/color]

    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.outputText Label.setText(s elf.simComboBox .currentText())
    pystring = str(self.textEd it1.text()) # Convert QString to
    pystring
    modlist = pystring.splitl ines()
    plist = parseMods(modli st)
    for p in plist:
    self.textEdit2. insert(p + '\n')

    -- Dave

    Comment

    • Leif B. Kristensen

      #3
      Re: PyQt database example

      David MacQuigg wrote:
      [color=blue]
      > 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.[/color]

      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.activestat e.com/ASPN/Cookbook/Python/Recipe/52266>

      regards,
      --
      Leif Biberg Kristensen

      Validare necesse est

      Comment

      Working...