[PyKDE] Listbox item value

Derek Fountain derekfountain at yahoo.co.uk
Wed May 28 14:33:01 BST 2003


Given this bit of (total newbie) code:

---
#!/usr/bin/python

import sys
from qt import *

app=QApplication(sys.argv)

list=QListBox()
list.insertItem("Item 1")

list.setCurrentItem(0)
list.clearSelection()
print "Currently selected: " + str(list.currentItem())

list.setCurrentItem(-1)
print "Currently selected: " + str(list.currentItem())

app.setMainWidget(list)
list.show()
app.exec_loop()
---

what would you expect to be printed? On my SuSE-8.1 box with PyQt-3.3.2 I get 
0 and 0 which puzzles me. If I comment out the "list.setCurrentItem(0)" line, 
I get -1 and -1, which is what I'd expect to receive in all cases. Can't I 
set a list to have no selected item once it's had one selected?

Can someone give me a clue what's going on?

-- 
"...our desktop is falling behind stability-wise and feature wise to KDE 
...when I went to Mexico in December to the facility where we launched gnome, 
they had all switched to KDE3." - Miguel de Icaza, March 2003




More information about the PyQt mailing list