zoukankan      html  css  js  c++  java
  • Iwidgets class tcl tk

    package require Iwidgets
    namespace import itcl::*
    namespace import itk::*

    option add *TextDisplay.wrap none widgetDefault
    option add *TextDisplay.textBackground ivory widgetDefault
    option add *TextDisplay.width 40 widgetDefault
    option add *TextDisplay.height 10 widgetDefault

    class TextDisplay {
        inherit itk::Widget

        constructor {args} {
     itk_component add text {
         text $itk_interior.info -state  disabled -yscrollcommand [code $itk_interior.sbar set]
     } {
         usual
         keep -tabs -wrap -width -height
         rename -background -textbackground textBackground Background
     }
     pack $itk_component(text) -side left -expand yes -fill both

     itk_component add scrollbar {
         scrollbar $itk_interior.sbar -command [code $itk_interior.info yview]
     }
     pack $itk_component(scrollbar) -side right -fill y

     eval itk_initialize $args
        }

        public method display {info}
        public method append {info}
    }

    body TextDisplay::display {info} {
        $itk_component(text) configure -state normal
        $itk_component(text) delete 1.0 end
        $itk_component(text) insert 1.0 $info
        $itk_component(text) configure -state disabled
    }

    body TextDisplay::append {info} {
        $itk_component(text) configure -state normal
        $itk_component(text) insert end $info
        $itk_component(text) configure -state disabled
    }

    usual TextDisplay {
        keep -background -cursor -foreground -font
        keep -activebackground -activerelief
        keep -highlightcolor -highlightthickness
        keep -insertbackground -insertborderwidth -insertwidth
        keep -insertontime -insertofftime
        keep -selectbackground -selectborderwidth -selectforeground
        keep -textbackground -troughcolor
    }

    #
    # EXAMPLE:  Display the /etc/passwd file
    #
    TextDisplay .file -background red

    # new a widigets class as .file, and with the args as -background red.
    pack .file

    .file display [exec cat /etc/passwd]

    # .file has following methods:

    #  .file append info
    # .file cget option
    #  .file component ?name? ?arg arg ...?
    #  .file config ?option? ?arg arg ...?
    #  .file configure ?option? ?arg arg ...?
    #  .file display info
    #  .file isa className
    #    while executing

  • 相关阅读:
    读书笔记:你就是极客软件开发人员生存指南
    读书笔记:重来 Rework
    敏捷个人2012.1月份线下活动报道:谈谈职业
    敏捷个人2011.12月份线下活动报道:认识自我
    敏友的【敏捷个人】有感(12): 敏友们自发组织的线上思想的碰撞
    敏捷团队:我尽力先做好本职工作是否正确?
    OpenExpressApp:精通 WPF UI Virtualization
    MDSF:发布图形编辑器源码OpenGraphicEditor
    产品管理:用户访谈之道
    敏捷个人架构图
  • 原文地址:https://www.cnblogs.com/greencolor/p/2036479.html
Copyright © 2011-2022 走看看