Subclassing Widgets
To create your own widget subclass, use the oo::class create with superclass of the widget you want to subclass. For example, to create your own button class, MyButton, you could do:
oo::class create ::MyButton {
superclass ::ptk::Button
self method init {} {
variable OptionDef
set OptionDef {
-mynewoption {-default rounded}
}
}
constructor {wName args} {
classvariable OptionDef
variable widgetInfo
set widgetInfo {}
set remainderArgs [my ProcessArgs $args $OptionDef]
next $wName {*}$remainderArgs
}
}
::MyButton init
#::oo::define ::MyButton deletemethod init