Justin,
find the attached file which i used to time update.
After commenting the Print statement in "Sec2TC" function. maya is
responding.
But i used your Qtimer as you suggested.
On Tuesday, September 11, 2012 8:45:30 PM UTC+5:30, Justin Israel wrote:
>
> I would need to see a snippet of your code to know why it isn't updating
> the label from a single manual operation. But once you get that working
> properly, you can start a QTimer to do the updates:
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtimer.html
>
> It uses the event loop. You would connect the timeout signal to your
> update slot.
>
> self.timer = QtCore.QTimer(self)
> self.timer.timeout.connect(self.updateLabel)
> self.timer.start(1000)
>
>
>
>
> On Sep 11, 2012, at 5:28 AM, PBLN RAO <[email protected] <javascript:>>
> wrote:
>
> Hi,
>
> I just wanted to create a timer display in Maya.
>
> I have a tool which i have docked to "right"
>
> I added a label to the window and tried to display the counter. i am
> echoing the result.
>
> i could able to see the result in the script editor but the label never
> gets updated and also maya doesn't respond to any of the task.
>
> how can i make it to run separately so that i can work in maya and the
> timer gets updated as well (like we see time in some webpages).
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 11 15:30:00 2012
@author: narasimhapbl.1863
"""
import time
global Counter
Counter=True
def StartTimer(Control): #Control is a QLabel object
global Counter
print "Starting counter"
if Counter==True:
StopTimer()
print "Start timer"
Counter=True
Count=TC2Sec(Control.text())
while True:
if Counter==False:
break
Control.setText(Sec2TC(Count))
time.sleep(1)
Count += 1
def StopTimer():
global Counter
print "Stop timer"
Counter=False
def Sec2TC(secs):
#converts 3601 seconds to 01:00:01 TC (TimeCode)
# print "Get time code"
#AFTER COMMENTING ABOVE LINE MAYA IS RESPONDING.
Min,Sec = divmod(secs,60)
Hr,Min = divmod(Min,60)
return str(("%02d:%02d:%02d" % (Hr,Min,Sec)))
def TC2Sec(tc):
#converts TC (TimeCode) 01:00:01 to 3601 seconds
TimeSplit = tc.split(":")
Sec = int(TimeSplit[0]) * 60 #Hours -> Mins
Sec += int(TimeSplit[1]) #Adding Remaing Mins
Sec = (Sec * 60) + int(TimeSplit[2]) #converting Mins to Sec and Adding Remaing Secs
return Sec