2010-11-04 50 views
0

我是IronPython的新手,目前使用的是Ironpython工作室,通常我喜欢用Visual Basic或Delphi编程。在VB在Ironpython工作室上的表单之间切换

procedure TMain.buttonClick(Sender: TObject); 
begin 
    form2.show; 
end; 

你平时写几乎同样的事情:我的问题是,我不知道如何通过点击一个按钮形式之间切换,德尔福你normaly写上“form1的”从按钮的代码,我想知道如何在Ironpython工作室做到这一点,如果有人能帮助我,我会很感激,谢谢!

回答

1

你必须添加一个处理程序到按钮的点击事件(就像你在C#中,而不是像在VB中)并显示其他形式。参考C#教程以供参考,它在IronPython中会非常相似。或者更好的是,尝试了解C#,IronPython,VB和Delphi之间的差异。

按钮的Click事件有两个参数。只要该函数需要两个参数(不包括隐含的self),就已设置。

例如,

class MyForm(Form): 
    def __init__(self): 
     # create a form with a button 
     button = Button() 
     button.Text = 'Click Me' 
     self.Controls.Add(button) 

     # register the _button_click() method to the button's Click event 
     button.Click += self._button_Click 

    def _button_Click(self, sender, e): 
     # do what you want to do 
     Form2().Show() # create an instance of `Form2` and show it