What's wrong with this code?

What's wrong with this code?

Anonymous
Not applicable
326 Views
0 Replies
Message 1 of 1

What's wrong with this code?

Anonymous
Not applicable

this is my code time does not update....what's wrong in run_time method?
please help....

from PyQt4 import QtGui, QtCore
import maya.OpenMayaUI as mui
import sip

def maya_main_window():
ptr = mui.MQtUtil.mainWindow()
return sip.wrapinstance(long(ptr), QtCore.QObject)

class RenamingDialog(QtGui.QDialog):
def __init__(self, parent= maya_main_window()):
QtGui.QDialog.__init__(self,parent)

self.setWindowTitle("Clock")
self.setFixedSize(250, 200)

self.createLayout()
self.button_update()

self.run_time() 

def run_time(self):
self.timer = QtCore.QTimer(self)
self.connect(self.timer, QtCore.SIGNAL("timeout()"), self, QtCore.SLOT("update_time()"))
self.timer.start()

def createLayout(self):
self.button1 = QtGui.QPushButton("Ok")
self.label = QtGui.QLabel("time")

buttonLayout = QtGui.QHBoxLayout()
buttonLayout.addWidget(self.button1)
buttonLayout.addWidget(self.label)

mainLayout = QtGui.QVBoxLayout()
mainLayout.addLayout(buttonLayout)
self.setLayout(mainLayout)

def update_time(self): 
self.time = QtCore.QTime.currentTime()
self.updater = QtCore.QString(self.time.toString("hh:mm:ss"))
self.label.setText(self.updater)

def button_update(self):
self.connect(self.button1, QtCore.SIGNAL("clicked()"), self.printer)

def printer(self):
print "hai",

if __name__ == "__main__":
dialog = RenamingDialog()
dialog.show()

thank you.

0 Likes
327 Views
0 Replies
Replies (0)