views:

122

answers:

1

Hi Everybody,

I have calendar that is working fine.

Here is the function that display the full date:

def selectDate(self,date):
    self.fullDate = str(date.day()) + " / " + str(date.month()) + " / " + str(date.year())
    print "full date: %s" % self.fullDate

And here the code with the calendar:

def TabCalendar(self):
    self.calendar = QtGui.QCalendarWidget(self.tab)
    self.calendar.setGeometry(QtCore.QRect(self.x1, self.y1, self.x2, self.y2)) 

    QtCore.QObject.connect(self.calendar, QtCore.SIGNAL("selectionChanged()"), self.selectDate)
    QtCore.QObject.connect(self.calendar, QtCore.SIGNAL("clicked(QDate)"), self.selectDate)

To have direct access to selected day, I am calling the function selectDate based on connect event, and then using the 'date' to obtain the precise date.day and so on -- which is working fine.

The only awkward thing that is annoying me is that it gives the following warning..

TypeError: turbSchedule_selectDate() takes exactly 2 arguments (1 given)

Any suggestion to stop this TypeError warning?

All comments and suggestions are highly appreciated.

+2  A: 

I guess that the slot called by the selectdate signal shouldn't have any argument. You can access the selectedDate by the corresponding calendar method.

See the c++ docs: http://doc.trolltech.com/4.3/widgets-calendarwidget.html

So your code should be something like:

def selectDate(self):
    date = self.calendar.selectedDate()
    self.fullDate = str(date.day()) + " / " + str(date.month()) + " / " + str(date.year())
    print "full date: %s" % self.fullDate
luc
Thanks Luc... it did the trick!
ThreaderSlash