I think the directions might be mixed up, right?
(full example: http://pastebin.com/KrTKiscj)
You should probably also do a setCurrentItem right after you insert it so
it keeps the effect like it is moving and staying selected:
def changePriority(self, direction):
crntRow = newrow = self.listWidget.currentRow()
total=self.listWidget.count()
print "Total no. of items %s, and selected item number is
%s"%(total,crntRow)
if direction=='up':
if crntRow > 0 :
newrow -= 1
else:
print "This is the first item cannot move up further."
elif direction=='down':
if crntRow + 1 < total:
newrow += 1
else:
print "This is the last item cannot move down further."
if crntRow != newrow:
crntItem = self.listWidget.takeItem(crntRow)
self.listWidget.insertItem(newrow, crntItem)
self.listWidget.setCurrentItem(crntItem)
On Tue, Dec 11, 2012 at 11:50 AM, san <[email protected]> wrote:
> crntRow = self.listWidget.currentRow()
> total=self.listWidget.count()
> print "Total no. of items %s, and selected item number is
> %s"%(total,crntRow)
> if args[0]=='up':
> if crntRow > 0 :
> crntItem= self.listWidget.takeItem(crntRow)
> self.listWidget.insertItem(crntRow+1,crntItem)
> if args[0]=='down':
> if crntRow + 1 < total:
> crntItem=self.listWidget.takeItem(crntRow)
> sel.listWidget.insertItem(crntRow-1,crntItem)
> else: print "This is the last item cannot move down further."
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].