1
self.date = QtCore.QDate.currentDate() 
self.time = QtCore.QTime.currentTime()
self.updateTime = QtCore.QString(self.time.toString("hh:mm:ss AP"))
if ((self.time.second() % 2) == 0):
    self.updateTime[2]= ' '

self.label.setText(self.updateTime)

Error: TypeError: file line 54: 'QString' object does not support item assignment

iam getting this error in if loop, is there any solution? iam new to python any help appreciated....

thank you

iruvar
  • 22,736
  • 7
  • 53
  • 82
Anvesh Chary
  • 65
  • 1
  • 11
  • 1
    Your question would have been much better if you'd asked: in my clock widget, how do I make the ":" blink on and off every other second? Instead, your question currently amounts to little more than a trivial bit of debugging that can be easily solved by consulting the relevant documentation. – ekhumoro Apr 25 '14 at 19:32

1 Answers1

1

Your problem is that you cannot change the the QString by item assignment (a[2] = ' '); you get a TypeError whenever you try to do something to an object that isn't allowed. You have to create a new string and assign it to the variable. So, replace the line

self.updateTime[2]= ' '

with the following

self.updateTime = self.updateTime[:2] + ' ' +self.updateTime[3:]
SethMMorton
  • 45,752
  • 12
  • 65
  • 86