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.

65 lines
1.9KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: CmpImg.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 compound images: it uses compound
  13. # images to display a text string together with a pixmap inside
  14. # buttons
  15. #
  16. proc RunSample {w} {
  17. set img0 [tix getimage network]
  18. set img1 [tix getimage harddisk]
  19. button $w.hdd -padx 4 -pady 1 -width 120
  20. button $w.net -padx 4 -pady 1 -width 120
  21. # Create the first image: we create a line, then put a string,
  22. # a space and a image into this line, from left to right.
  23. # The result: we have a one-line image that consists of three
  24. # individual items
  25. #
  26. set hdd_img [image create compound -window $w.hdd]
  27. $hdd_img add line
  28. $hdd_img add text -text "Hard Disk" -underline 0
  29. $hdd_img add space -width 7
  30. $hdd_img add image -image $img1
  31. # Put this image into the first button
  32. #
  33. $w.hdd config -image $hdd_img
  34. # Create the second compound image. Very similar to what we did above
  35. #
  36. set net_img [image create compound -window $w.net]
  37. $net_img add line
  38. $net_img add text -text "Network" -underline 0
  39. $net_img add space -width 7
  40. $net_img add image -image $img0
  41. $w.net config -image $net_img
  42. # The button to close the window
  43. #
  44. button $w.clo -pady 1 -text Close -command "destroy $w"
  45. pack $w.hdd $w.net $w.clo -side left -padx 10 -pady 10 -fill y -expand yes
  46. }
  47. if {![info exists tix_demo_running]} {
  48. wm withdraw .
  49. set w .demo
  50. toplevel $w; wm transient $w ""
  51. RunSample $w
  52. bind $w <Destroy> exit
  53. }
上海开阖软件有限公司 沪ICP备12045867号-1