471,310 Members | 1,156 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

I am facing a problem related to global variable...can anybody please help me

The problem is coming " File "D:\Atelier 11th jan\trunk\Strings.py", line 777, in _Gen
if stUnicode.IsChecked() == True:
NameError: global name 'stUnicode' is not defined
"this message is coming at the terminal.
Jan 11 '08 #1
2 1042
rhitam30111985
112 100+
post your code ... only then can someone help you...
Jan 11 '08 #2
post your code ... only then can someone help you...

In this function i am making two radio button and i want to access its status in other file




def _OnProjectProperties(self, evt):
if self.project is None:
return
xmlTree = ET.parse(self.projectFile)
prjRoot = xmlTree.getroot()
if prjRoot:
tag = prjRoot.find("outdir")
if not tag is None:
outDirPath = tag.attrib["path"]

#projDir = os.path.dirname(os.path.abspath(self.projectFile)) + '\\'
#outDirPath = self.project.outDir.replace(projDir, '.\\')
#print self.project.outDir, projDir, outDirPath

self.dlgProjectProperties = wx.Dialog(self, -1, 'Project properties',
size=(450,450), style=wx.DEFAULT_DIALOG_STYLE)#|wx.STAY_ON_TOP)
self.stWidth = wx.StaticText(self.dlgProjectProperties, -1, "Screen width")
self.stHeight = wx.StaticText(self.dlgProjectProperties, -1, "Screen height")
self.stBitsperpixel = wx.StaticText(self.dlgProjectProperties, -1, "Bits per pixel")
self.stDialogsFile = wx.StaticText(self.dlgProjectProperties, -1, "Dialogs file")
self.stStringsFile = wx.StaticText(self.dlgProjectProperties, -1, "Strings file")
self.stImagesFile = wx.StaticText(self.dlgProjectProperties, -1, "Images file")
self.stThemesFile = wx.StaticText(self.dlgProjectProperties, -1, "Themes file")
self.stOutdirPath = wx.StaticText(self.dlgProjectProperties, -1, "Outdir path")
self.stIncludeFiles = wx.StaticText(self.dlgProjectProperties, -1, "Include files")
stStorageSettings = wx.StaticText(self.dlgProjectProperties,-1,"Settings")
stUnicode = wx.RadioButton(self.dlgProjectProperties, -1,"Unicode")
stAscii = wx.RadioButton(self.dlgProjectProperties, -1,"Ascii")
self.stLocales = wx.StaticText(self.dlgProjectProperties, -1, "Locales")
self.stNotGenerated = wx.StaticText(self.dlgProjectProperties, -1, "Not Generated")
self.stGenerated = wx.StaticText(self.dlgProjectProperties, -1, "Generated")
self.intWidth = wx.lib.intctrl.IntCtrl(self.dlgProjectProperties,-1,size=(350,-1),value=self.project.screenW,min=1,max=700,limite d=True)
self.intHeight = wx.lib.intctrl.IntCtrl(self.dlgProjectProperties,-1,size=(350,-1),value=self.project.screenH,min=1,max=700,limite d=True)
self.choiceBitsperpixel = wx.Choice(self.dlgProjectProperties,-1, size=(350,-1), choices=[str(self.project.bitsperpixel)])
self.choiceBitsperpixel.SetSelection(0)
self.choiceBitsperpixel.Disable()
self.tcDialogsFile = wx.TextCtrl(self.dlgProjectProperties,-1,value=self.project.dialogsFile, size=(350,-1), style=wx.TE_READONLY)
self.tcDialogsFile.SetBackgroundColour(self.dlgPro jectProperties.GetBackgroundColour())
self.tcStringsFile = wx.TextCtrl(self.dlgProjectProperties,-1,value=self.project.stringsFile,size=(350,-1), style=wx.TE_READONLY)
self.tcStringsFile.SetBackgroundColour(self.dlgPro jectProperties.GetBackgroundColour())
self.tcImagesFile = wx.TextCtrl(self.dlgProjectProperties,-1,value=self.project.imagesFile,size=(350,-1), style=wx.TE_READONLY)
self.tcImagesFile.SetBackgroundColour(self.dlgProj ectProperties.GetBackgroundColour())
self.tcThemesFile = wx.TextCtrl(self.dlgProjectProperties,-1,value=self.project.themesFile,size=(350,-1), style=wx.TE_READONLY)
self.tcThemesFile.SetBackgroundColour(self.dlgProj ectProperties.GetBackgroundColour())
self.tcOutdirPath = wx.TextCtrl(self.dlgProjectProperties,-1,value=outDirPath,size=(350,-1))
self.tcIncludeFiles = wx.TextCtrl(self.dlgProjectProperties,-1,value=self.project.includefiles,size=(350,-1))

list_lb1 = []
list_lb2 = []
dict_lb2 = {}
for localeName, localeObj in sorted(self.stringsWin.xml.localeDict.iteritems()) :
if localeObj.generate == 'yes':
dict_lb2[int(localeObj.order)] = localeName
else:
list_lb1.append(localeName)

for key, val in sorted(dict_lb2.iteritems()):
list_lb2.append(val)

self.lb1 = wx.ListBox(self.dlgProjectProperties, -1, size=(90, 120), choices=list_lb1, style=wx.LB_EXTENDED)
btnAddLocalesToGenerateList = wx.Button(self.dlgProjectProperties, -1, "Add>>")
self.lb2 = wx.ListBox(self.dlgProjectProperties, -1, size=(90, 120), choices=list_lb2, style=wx.LB_EXTENDED)
btnRemoveLocalesFromGenerateList = wx.Button(self.dlgProjectProperties, -1, "<<Remove")
self.btnMoveUpLocale = wx.Button(self.dlgProjectProperties, -1, "Move Up")
self.btnMoveDownLocale = wx.Button(self.dlgProjectProperties, -1, "Move Down")

self.btnNewLocale = wx.Button(self.dlgProjectProperties, -1, "New Locale")
self.Newlocales = []

sizer = wx.lib.rcsizer.RowColSizer()
sizer.Add(self.stWidth,row=0,col=0,flag=wx.ALIGN_R IGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1)
sizer.Add(self.stHeight,row=1,col=0,flag=wx.ALIGN_ RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1)
sizer.Add(self.stBitsperpixel,row=2,col=0,flag=wx. ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border =1)
sizer.Add(self.stDialogsFile,row=3,col=0,flag=wx.A LIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border= 1)
sizer.Add(self.stStringsFile,row=4,col=0,flag=wx.A LIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border= 1)
sizer.Add(self.stImagesFile,row=5,col=0,flag=wx.AL IGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1 )
sizer.Add(self.stThemesFile,row=6,col=0,flag=wx.AL IGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1 )
sizer.Add(self.stOutdirPath,row=7,col=0,flag=wx.AL IGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1 )
sizer.Add(self.stIncludeFiles,row=8,col=0,flag=wx. ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border =1)
sizer.Add(stStorageSettings,row=9,col=0,flag=wx.AL IGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1 )
sizer.Add(stUnicode,row=9,col=1,flag=wx.ALIGN_LEFT |wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1)
sizer.Add(stAscii,row=9,col=2,colspan=4,flag=wx.AL IGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border=1)
sizer.Add(self.stLocales,row=10,col=0,flag=wx.ALIG N_RIGHT|wx.ALL,border=1)
sizer.Add(self.stNotGenerated,row=10,col=1,flag=wx .ALIGN_CENTER|wx.ALL,border=1)
sizer.Add(self.stGenerated,row=10,col=3,flag=wx.AL IGN_CENTER|wx.ALL,border=1)
sizer.Add(self.intWidth,row=0,col=1,colspan=4,flag =wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,bor der=1)
sizer.Add(self.intHeight,row=1,col=1,colspan=4,fla g=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,bo rder=1)
sizer.Add(self.choiceBitsperpixel,row=2,col=1,cols pan=4,flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL| wx.ALL,border=1)
sizer.Add(self.tcDialogsFile,row=3,col=1,colspan=4 ,flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.AL L,border=1)
sizer.Add(self.tcStringsFile,row=4,col=1,colspan=4 ,flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.AL L,border=1)
sizer.Add(self.tcImagesFile,row=5,col=1,colspan=4, flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL ,border=1)
sizer.Add(self.tcThemesFile,row=6,col=1,colspan=4, flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL ,border=1)
sizer.Add(self.tcOutdirPath,row=7,col=1,colspan=4, flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL ,border=1)
sizer.Add(self.tcIncludeFiles,row=8,col=1,colspan= 4,flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.A LL,border=1)
sizer.Add(self.lb1,row=10,col=1,rowspan=2,flag=wx. ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border= 1)
sizer.Add(btnAddLocalesToGenerateList,row=10,col=2 ,flag=wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL|w x.ALL,border=1)
sizer.Add(self.lb2,row=10,col=3,rowspan=2,flag=wx. ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL,border =1)
sizer.Add(btnRemoveLocalesFromGenerateList,row=11, col=2,flag=wx.ALIGN_TOP|wx.ALIGN_CENTER_HORIZONTAL |wx.ALL,border=1)
sizer.Add(self.btnMoveUpLocale,row=10,col=4,flag=w x.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,b order=1)
sizer.Add(self.btnMoveDownLocale,row=11,col=4,flag =wx.ALIGN_TOP|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,bo rder=1)
sizer.Add(self.btnNewLocale,row=12,col=1,flag=wx.A LIGN_TOP|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,border= 1)

btnOk = wx.Button(self.dlgProjectProperties, -1, "Ok")
btnCancel = wx.Button(self.dlgProjectProperties, wx.ID_CANCEL, "Cancel")
#sizer2 = wx.lib.rcsizer.RowColSizer()
#sizer2.Add(btnOk,row=0,col=0,flag=wx.ALIGN_CENTER _HORIZONTAL|wx.ALL,border=2)
#sizer2.Add(btnCancel,row=0,col=1,flag=wx.ALIGN_CE NTER_HORIZONTAL|wx.ALL,border=2)
sizer.Add(btnOk,row=13,col=3,flag=wx.ALIGN_BOTTOM| wx.ALIGN_CENTER_HORIZONTAL|wx.TOP,border=15)
sizer.Add(btnCancel,row=13,col=4,flag=wx.ALIGN_BOT TOM|wx.ALIGN_CENTER_HORIZONTAL|wx.TOP,border=15)

mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(sizer,flag=wx.ALL,border=3)
#mainSizer.Add(sizer2,flag=wx.ALL,border=3)
self.SetSizer(mainSizer)
self.Layout()

self.dlgProjectProperties.Bind(wx.EVT_BUTTON, self._OnbtnOk_ProjectProperties, btnOk)
self.dlgProjectProperties.Bind(wx.EVT_BUTTON, self._OnbtnCancel_ProjectProperties, btnCancel)
self.dlgProjectProperties.Bind(wx.EVT_BUTTON, self._OnbtnAddLocalesToGenerateList, btnAddLocalesToGenerateList)
self.dlgProjectProperties.Bind(wx.EVT_BUTTON, self._OnbtnRemoveLocalesFromGenerateList, btnRemoveLocalesFromGenerateList)
self.dlgProjectProperties.Bind(wx.EVT_BUTTON, self._OnbtnMoveUpLocale, self.btnMoveUpLocale)
self.dlgProjectProperties.Bind(wx.EVT_BUTTON, self._OnbtnMoveDownLocale, self.btnMoveDownLocale)
self.lb2.Bind(wx.EVT_RIGHT_UP, self._OnListBoxRightClick)
self.lb2.Bind(wx.EVT_LISTBOX, self._OnListBox)
self.dlgProjectProperties.Bind(wx.EVT_BUTTON, self._OnbtnNewLocale, self.btnNewLocale)

self._OnListBox(None)
self.dlgProjectProperties.ShowModal()
Jan 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Stephane Pointu | last post: by
41 posts views Thread by Miguel Dias Moura | last post: by
16 posts views Thread by Roman Ziak | last post: by
reply views Thread by Suresh | last post: by
12 posts views Thread by usa-99 | last post: by
2 posts views Thread by sorobor | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.