gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: StdBBox.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
  4. #
  5. # Tix Demostration Program
  6. #
  7. # This sample program is structured in such a way so that it can be
  8. # executed from the Tix demo program "widget": it must have a
  9. # procedure called "RunSample". It should also have the "if" statment
  10. # at the end of this file so that it can be run as a standalone
  11. # program using tixwish.
  12. # This file demonstrates the use of the tixStdButtonBox widget, which is a
  13. # group of "Standard" buttons for Motif-like dialog boxes.
  14. #
  15. proc RunSample {w} {
  16. # Create the label on the top of the dialog box
  17. #
  18. label $w.top -padx 20 -pady 10 -border 1 -relief raised -text \
  19. "This dialog box is\n a demostration of the\n tixStdButtonBox widget" \
  20. -justify center -anchor c
  21. # Create the button box. We also do some manipulation of the
  22. # button widgets inside: we disable the help button and change
  23. # the label string of the "apply" button to "Filter"
  24. #
  25. # Note that the -text, -underline, -command and -width options are all
  26. # standard options of the button widgets.
  27. #
  28. tixStdButtonBox $w.box
  29. $w.box subwidget ok config \
  30. -command "tixDemo:Status {OK pressed}; destroy $w"
  31. $w.box subwidget apply config -text "Filter" -underline 0 \
  32. -command "tixDemo:Status {Filter pressed}"
  33. $w.box subwidget cancel config \
  34. -command "tixDemo:Status {Cancel pressed}; destroy $w"
  35. $w.box subwidget help config -state disabled
  36. pack $w.box -side bottom -fill x
  37. pack $w.top -side top -fill both -expand yes -anchor c
  38. # "after 0" is used so that the key bindings won't interfere with
  39. # tkTraverseMenu
  40. #
  41. bind [winfo toplevel $w] <Alt-o> \
  42. "after 0 tkButtonInvoke [$w.box subwidget ok]"
  43. bind [winfo toplevel $w] <Alt-f> \
  44. "after 0 tkButtonInvoke [$w.box subwidget apply]"
  45. bind [winfo toplevel $w] <Alt-c> \
  46. "after 0 tkButtonInvoke [$w.box subwidget cancel]"
  47. bind [winfo toplevel $w] <Escape> \
  48. "after 0 tkButtonInvoke [$w.box subwidget cancel]"
  49. focus [$w.box subwidget apply]
  50. }
  51. if {![info exists tix_demo_running]} {
  52. wm withdraw .
  53. set w .demo
  54. toplevel $w; wm transient $w ""
  55. RunSample $w
  56. bind $w <Destroy> exit
  57. }
上海开阖软件有限公司 沪ICP备12045867号-1