2012-02-12 84 views
0

所以,我刚刚开始使用PythonCard,并且无法获得最基本的应用程序:S我试图将TextField中的值分配给变量点击一个按钮;请看看你是否能明白是什么问题:d我刚刚开始使用PythonCard ...

我的Python主文件:

from PythonCard import model 

class register(model.Background): 
    def on_register_mouseClick(self, event): 
     title = self.components.title.text 
     artist = self.components.artist.text 


if __name__ == '__main__': 
    app = model.Application(register) 
    app.MainLoop() 

我的资源文件:

{'type':'CustomDialog', 
    'name':'Template', 
    'title':'Dialog Template', 
    'position':(125, 125), 
    'size':(300, 181), 
    'components': [ 

{'type':'TextField', 
    'name':'artist', 
    'position':(115, 48), 
    'text':'artist', 
}, 

{'type':'TextField', 
    'name':'title', 
    'position':(116, 15), 
    'text':'title', 
    }, 

{'type':'Button', 
    'id':5100, 
    'name':'register', 
    'position':(10, 35), 
    'default':1, 
    'label':'OK', 
}, 

] # end components 
} # end CustomDialog 

提前感谢! :D

回答

3

你错误地做了一个CustomDialog而不是Application。要解决您的问题,请使用此代码替换您的rsrc文件:

{'application':{'type':'Application', 
      'name':'Template', 
    'backgrounds': [ 
    {'type':'Background', 
      'name':'Application', 
      'title':u'Application', 
      'size':(300, 181), 

     'components': [ 

{'type':'Button', 
    'name':'register', 
    'position':(10, 35), 
    'default':True, 
    'label':u'OK', 
    }, 

{'type':'TextField', 
    'name':'title', 
    'position':(116, 15), 
    'text':u'title', 
    }, 

{'type':'TextField', 
    'name':'artist', 
    'position':(115, 48), 
    'text':u'artist', 
    }, 

] # end components 
} # end background 
] # end backgrounds 
} } 
相关问题