Defining and referring to GUI controls
Posted: Tue Apr 29, 2014 7:26 pm
I have the feeling I'm not doing this right, although it might be only an unfamiliar itch where I'm used to Python not defining it out on its own like that.
What's the correct way to define a control e.g. chkTest below, in order to refer to it later e.g. .chkTest.checked - do I define it as a class variable as below, or is there a better way?
What's the correct way to define a control e.g. chkTest below, in order to refer to it later e.g. .chkTest.checked - do I define it as a class variable as below, or is there a better way?
- Code: Select all
use System.Windows.Forms
class MyForm inherits Form
var chkTest as CheckBox
cue init
base.init
.text = 'Simple sample'
.width=180
.height=70
pnl = FlowLayoutPanel(parent=this, dock=DockStyle.Fill, flowDirection=FlowDirection.LeftToRight, autoSize=true)
.chkTest = CheckBox(parent = pnl, autoSize=true, text='check me')
btnTest = Button(autoSize=true, text='test')
pnl.controls.add(btnTest)
listen btnTest.click, ref .handleTestClick
def handleTestClick(sender, args as EventArgs)
MessageBox.show(this, 'Checkbox is checked: [.chkTest.checked]', 'Check the Checkbox')
class Program
def main has STAThread
Application.run(MyForm())