,當我按照教程「編寫使用TraitsUI http://code.enthought.com/projects/traits/docs/html/tutorials/traits_ui_scientific_app.html 科學編程圖形應用程序和測試下面的代碼片段:問題與configure_traits使用Enthought雨棚
from enthought.traits.api import *
from enthought.traits.ui.api import *
class Camera(HasTraits):
""" Camera object """
gain = Enum(1, 2, 3,
desc="the gain index of the camera",
label="gain",)
exposure = CInt(10,
desc="the exposure time, in ms",
label="Exposure",)
def capture(self):
""" Captures an image on the camera and returns it """
print "capturing an image at %i ms exposure, gain: %i" % (
self.exposure, self.gain)
if __name__ == "__main__":
camera = Camera()
camera.configure_traits()
camera.capture()
如果我運行這個在命令行它會像廣告一樣工作,彈出一個GUI,你調整參數,當你點擊「確定」時,它會返回修改後的值,但是當我通過點擊運行按鈕運行Canopy編輯器中的相同代碼時,默認參數立即打印;然後彈出窗口,然後在GUI中調整參數並單擊「確定」時,GUI將退出,但新參數eter值不打印。
就好像某種方式camera.capture()在camera.configure_traits之前運行。 http://docs.enthought.com/traitsui/tutorials/traits_ui_scientific_app.html
你鏈接到引用材料TraitsUI 3版本之一,而上面的一個是版本你有可能使用(第4版: