widget class in class

::iwidgets::panedwindow .pw

class TimeWidget {
    inherit ::itk::Widget
    private common midhighlight #e0e0f0
    private common smallFont *-helvetica-bold-r-normal--34-*-*-*-*-*-*-*
    public method updateTime
    constructor {args} { 
       # the time widget
       itk_component add time {
       iwidgets::timefield $itk_interior.t \
        -relief flat -textbackground $midhighlight  \
               -textfont $smallFont
       } {}
       eval itk_initialize $args
       bind $itk_interior <FocusIn> {focus . }
       pack $itk_component(time) -side right
       updateTime
    }
}

body TimeWidget::updateTime {} {
 #$itk_component(time) configure -state normal
 $itk_component(time) show
 #$itk_component(time) configure -state disabled
 after 950 [list $this updateTime]
}

class StatusBar {
 inherit ::itk::Widget

    private common midhighlight #e0e0f0
    private common smallFont *-helvetica-bold-r-normal--14-*-*-*-*-*-*-*

       constructor { args } {  
       itk_component add time {
       TimeWidget $itk_interior.t  
 } {}
  eval itk_initialize $args 
  grid $itk_component(time) -row 2 -column 2 -sticky w 
 }
}

set statusBar [StatusBar .sb]
pack .pw -expand 1 -fill both
pack $statusBar -expand 1 -fill x -side left

===================================================

::iwidgets::panedwindow .pw

class TimeWidget {
    inherit ::itk::Widget
    private common midhighlight #e0e0f0
    private common smallFont *-helvetica-bold-r-normal--34-*-*-*-*-*-*-*
    public method updateTime
    constructor {args} { 
       # the time widget
       itk_component add time {
       iwidgets::timefield $itk_interior.t \
        -relief flat -textbackground $midhighlight  \
               -textfont $smallFont
       } {}
       eval itk_initialize $args
       bind $itk_interior <FocusIn> {focus . }
       pack $itk_component(time) -side right
       updateTime
    }
}

body TimeWidget::updateTime {} {
 #$itk_component(time) configure -state normal
 $itk_component(time) show
 #$itk_component(time) configure -state disabled
 after 950 [list $this updateTime]
}


set timeWidget [TimeWidget .tb]
pack .pw -expand 1 -fill both
pack $timeWidget -expand 1 -fill x -side left

posted @ 2011-05-17 22:52  greencolor  阅读(182)  评论(0编辑  收藏  举报