Attached required files for your reference.
When maya loads its opening the window.
So if i use below command to update a label on that window i get the error
MainUi.lbl_Login_ID.setText(UserLogin)
# Error: NameError: name 'MainUi' is not defined #
Where this MainUi i used in ShowTimePro main() function. this is a variable
that has the GUI (Interface()) Instance.
On Thursday, October 4, 2012 7:23:35 PM UTC+5:30, Justin Israel wrote:
>
> Can you show the code snippet you are using to start the window in your
> userSetup? You are probably just creating a local variable whose reference
> gets lost after the window is created.
>
> On Oct 4, 2012, at 6:07 AM, PBLN RAO <[email protected] <javascript:>>
> wrote:
>
> Hi,
>
> I created a application which loads when maya starts up. For this we added
> a line in userSetup.py
>
> Now if i want to update a label in that window i get an error label not
> found.
>
> In main function we created an instance of the Ui say (testUI).
>
> if i use testUi.label.setText('Test Update') i variable not found/defined
> error.
>
> but if the same python script is copied and executed in script editor and
> run i can able to update the label. its not happening when loaded at maya
> startup from userSetup.
>
> any suggestions....?
>
> --
> 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
"""
Created on Thu Aug 16 15:33:07 2012
@author: NARASIMHAPBL.1863
"""
#Importing required Modules
import sip
import os
import mysql.connector as MySqlconn
import maya.cmds as mc
from PyQt4 import QtGui, QtCore, uic
#Importing custom Modules
from GUI_Module import Interface
from DB_Module import ST_DataBase
from ShowTime_ui import Ui_MainWindow
#from SceneManagment import SceneHandling
from Shot_Module import Shot
import MayaMod
#class ShotDisplay(QtGui.QMainWindow,Ui_MainWindow):
# def __init__(self,parent=None):
# super(ShotDisplay, self).__init__()
def MaxMini():
versize = MainUi.lbl_maxmin.text()
if versize == 'maxi':
MainUi.setGeometry(300,300,320,700)
mc.dockControl('ui_dock', e=1, width=320)
mc.paneLayout('ShowTimePane',e=1,width=320)
MainUi.lbl_maxmin.setText('mini')
else:
MainUi.setGeometry(300,300,800,700)
mc.dockControl('ui_dock', e=1, width=800)
mc.paneLayout('ShowTimePane',e=1,width=800)
MainUi.lbl_maxmin.setText('maxi')
def AddShotRow():
MainUi.AddShotDetails(MainUi)
def OpenScene():
if len(MainUi.SelectedShots)==0:
QtGui.QMessageBox.information(MainUi,'Error Selection','No Shot is selected')
elif len(MainUi.SelectedShots)==1:
SelShot = MainUi.SelectedShots[0]
MainUi.ShotObjects["Shot_%s" % SelShot].Open(MainUi)
else:
# mc.confirmDialog(title='Error Selection', message='Cannot open multiple Shots', button=['Ok'], defaultButton='Ok', dismissString='Ok' )
QtGui.QMessageBox.information(MainUi,'Error Selection','Cannot open multiple Shots')
# Scene.Open(MainUi,MainUi.SelectedProject,MainUi.SelectedEpisode,MainUi.SelectedShots)
# MainUi.ShotObjects[]Open(MainUi,MainUi.SelectedProject,MainUi.SelectedEpisode,MainUi.SelectedShots)
def SaveScene():
if len(MainUi.SelectedShots)==0:
QtGui.QMessageBox.information(MainUi,'Error Selection','No Shot is selected')
elif len(MainUi.SelectedShots)==1:
SelShot = MainUi.SelectedShots[0]
MainUi.ShotObjects["Shot_%s" % SelShot].Save(MainUi)
else:
# mc.confirmDialog(title='Error Selection', message='Cannot open multiple Shots', button=['Ok'], defaultButton='Ok', dismissString='Ok' )
QtGui.QMessageBox.information(MainUi,'Error Selection','Cannot save multiple Shots')
# Scene.Save(MainUi,MainUi.SelectedProject,MainUi.SelectedEpisode,MainUi.SelectedShots)
def SaveVersion():
if len(MainUi.SelectedShots)==0:
QtGui.QMessageBox.information(MainUi,'Error Selection','No Shot is selected')
elif len(MainUi.SelectedShots)==1:
SelShot = MainUi.SelectedShots[0]
MainUi.ShotObjects["Shot_%s" % SelShot].SaveVersion(MainUi)
else:
# mc.confirmDialog(title='Error Selection', message='Cannot open multiple Shots', button=['Ok'], defaultButton='Ok', dismissString='Ok' )
QtGui.QMessageBox.information(MainUi,'Error Selection','Cannot Save multiple Shots')
# Scene.SaveVersion(MainUi,MainUi.SelectedProject,MainUi.SelectedEpisode,MainUi.SelectedShots)
def OpenMovie():
QtGui.QMessageBox.information(MainUi,'Open Movie','Coding under development')
def MakeMovie():
QtGui.QMessageBox.information(MainUi,'Make Movie','Coding under development')
def LoadData():
print "Loading data..."
SQL = "SELECT * FROM employee WHERE Login_ID = '" + UserLogin + "'"
Final_Result=DB.QueryDatabase('artists_core',SQL)
MainUi.lbl_Designation.setText(Final_Result[0]['Designation'])
MainUi.lbl_Grade.setText(Final_Result[0]['Grade'])
ArtistPhoto = QtGui.QPixmap()
ArtistPhoto.loadFromData(Final_Result[0]['Photo'])
#Displaying Artist Photo
MainUi.lbl_ArtistPhoto.setPixmap(ArtistPhoto)
def SetButtonConnections():
MainUi.btn_sizer.clicked.connect(MaxMini)
# MainUi.btn_Something.clicked.connect(AddShotRow)
# MainUi.btn_OpenScene.clicked.connect(OpenShot)
MainUi.btn_OpenScene.clicked.connect(OpenScene)
MainUi.btn_SaveScene.clicked.connect(SaveScene)
MainUi.btn_SaveVersion.clicked.connect(SaveVersion)
MainUi.btn_OpenPB.clicked.connect(OpenMovie)
MainUi.btn_MakePB.clicked.connect(MakeMovie)
def main():
global MainUi # Used for GUI Module
global DB # Used for Database Module
global Scene # Used for SceneHandling Module
global UserLogin # Used to store associate login
global ProjCode # Used in naming convenction projCode_Epi_
global Episode # Used for working episode
UserLogin = os.environ.get('USERNAME').lower()
print 'disabling menu items'
MayaMod.EnableDisableItems()
print "Initilizing modules..."
MainUi = Interface()
DB = ST_DataBase()
# Shot=SceneHandling()
Scene=Shot()
# mMaya = ModMaya()
print "Initilizing modules completed..."
# MainUi.lbl_ArtistPhoto.setPixmap(QtGui.QPixmap('D:/PBL Data/Development/ShowTime Maya/media/pbl.jpg'))
MainUi.lbl_Login_ID.setText(UserLogin)
# MainUi.sizer.connect(MainUi.sizer, QtCore.SIGNAL("clicked()"), MaxMini)
print "connecting buttons..."
SetButtonConnections()
print "connecting buttons completed..."
if mc.dockControl('ui_dock', q=1, ex=1):
mc.deleteUI('ui_dock')
floatingLayout = mc.paneLayout('ShowTimePane',configuration = 'single', width = 800)
docControl = mc.dockControl('ui_dock', area='right', content=floatingLayout, label='ShowTimePro')
mc.control('ShowTime', e = True, p = floatingLayout)
LoadData()
# ModFileCommands()
MainUi.show()# -*- coding: utf-8 -*-
"""
Created on Tue Aug 21 16:46:00 2012
@author: srinivas.p4557
"""
import maya.utils as mut
import ShowTimePro
mut.executeDeferred(ShowTimePro.main)
print 'UserSetup Executed'