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.

74 lines
2.3KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: PopMenu.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 tixPopupMenu widget.
  13. #
  14. proc RunSample {w} {
  15. # We create the frame and the button, then we'll bind the PopupMenu
  16. # to both widgets. The result is, when you press the right mouse
  17. # button over $w.top or $w.top.but, the PopupMenu will come up.
  18. #
  19. frame $w.top -relief raised -bd 1
  20. button $w.top.but -text {Press the right mouse button over
  21. this button or its surrounding area}
  22. pack $w.top.but -expand yes -fill both -padx 50 -pady 50
  23. tixPopupMenu $w.top.p -title "Popup Test"
  24. $w.top.p bind $w.top
  25. $w.top.p bind $w.top.but
  26. # Set the entries inside the PopupMenu widget.
  27. # [Hint] You have to manipulate the "menu" subwidget.
  28. # $w.top.p itself is NOT a menu widget.
  29. # [Hint] Watch carefully how the sub-menu is created
  30. #
  31. set menu [$w.top.p subwidget menu]
  32. $menu add command -label Desktop -under 0
  33. $menu add command -label Select -under 0
  34. $menu add command -label Find -under 0
  35. $menu add command -label System -under 1
  36. $menu add command -label Help -under 0
  37. $menu add cascade -label More -menu $menu.m1
  38. menu $menu.m1
  39. $menu.m1 add command -label Hello
  40. pack $w.top.but -side top -padx 40 -pady 50
  41. # Use a ButtonBox to hold the buttons.
  42. #
  43. tixButtonBox $w.box -orientation horizontal
  44. $w.box add ok -text Ok -underline 0 -command "destroy $w" \
  45. -width 6
  46. $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
  47. -width 6
  48. pack $w.box -side bottom -fill x
  49. pack $w.top -side top -fill both -expand yes
  50. }
  51. # This "if" statement makes it possible to run this script file inside or
  52. # outside of the main demo program "widget".
  53. #
  54. if {![info exists tix_demo_running]} {
  55. wm withdraw .
  56. set w .demo
  57. toplevel $w; wm transient $w ""
  58. RunSample $w
  59. bind $w <Destroy> {if {"%W" == ".demo"} exit}
  60. }
上海开阖软件有限公司 沪ICP备12045867号-1