使用ArcGIS Python Addin我需要在類之間更新一個名爲phase
的全局變量。這裏我想要做的是更新phase
變量,方法是更改ComboBoxClass1
並單擊ButtonClass3
訪問它。更新Python中類之間的全局變量問題
正如你可以看到我試圖通過global phase = selection
上
def onSelChange(self, selection):
global phase = selection
不過貌似這是不工作!
import arcpy
import pythonaddins
import os
phase = ""
class ButtonClass3(object):
"""Implementation for Trace_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
print global phase
class ComboBoxClass1(object):
"""Implementation for Trace_addin.combobox (ComboBox)"""
def __init__(self):
self.items = ["Phase A", "Phase B", "Phase C"]
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWWW'
self.width = 'WWWWWWWWWWWWWWWWW'
def onSelChange(self, selection):
global phase = selection
def onEditChange(self, text):
pass
def onFocus(self, focused):
pass
def onEnter(self):
pass
def refresh(self):
pass
我能問你爲什麼反對投票這個問題? ! – Suffii
'全球階段'是一個完整的陳述。您無法將此與讀取或寫入變量的值結合使用。 – jasonharper
你的_exact和specific_問題是什麼? – csmckelvey