Posted to tcl by patthoyts at Thu Dec 25 22:56:22 GMT 2008view raw

  1. # Vista theme checking.
  2. #
  3. # Also tester for a frame with ttk::entry border style for wrapping around text+scrollbar
  4. #
  5.  
  6. ttk::style theme settings default {
  7. ttk::style layout EntryFrame {
  8. EntryFrame.field -sticky nswe -border 0 -children {
  9. EntryFrame.fill -sticky nswe -children {
  10. EntryFrame.padding -sticky nswe
  11. }
  12. }
  13. }
  14. ttk::style configure EntryFrame -padding 1 -relief sunken
  15. ttk::style map EntryFrame -background {}
  16. }
  17. ttk::style theme settings classic {
  18. ttk::style configure EntryFrame -padding 2 -relief sunken
  19. ttk::style map EntryFrame -background {}
  20. }
  21. ttk::style theme settings alt {
  22. ttk::style configure EntryFrame -padding 2
  23. ttk::style map EntryFrame -background {}
  24. }
  25. ttk::style theme settings clam {
  26. ttk::style configure EntryFrame -padding 2
  27. ttk::style map EntryFrame -background {}
  28. }
  29. ttk::style theme settings winnative {
  30. ttk::style configure EntryFrame -padding 2
  31. }
  32. ttk::style theme settings xpnative {
  33. ttk::style configure EntryFrame -padding 1
  34. ttk::style element create EntryFrame.field vsapi \
  35. EDIT 1 {disabled 4 focus 3 active 2 {} 1} -padding 1
  36. }
  37. ttk::style theme settings vista {
  38. ttk::style configure EntryFrame -padding 2
  39. ttk::style element create EntryFrame.field vsapi \
  40. EDIT 6 {disabled 4 focus 3 active 2 {} 1} -padding 2
  41. }
  42.  
  43. bind EntryFrame <Enter> {%W instate !disabled {%W state active}}
  44. bind EntryFrame <Leave> {%W state !active}
  45. bind EntryFrame <<ThemeChanged>> {
  46. set pad [ttk::style lookup EntryFrame -padding]
  47. %W configure -padding [expr {$pad eq {} ? 1 : $pad}]
  48. }
  49.  
  50. proc Once {} {
  51. rename Once {} ;# Only call this once per interp.
  52.  
  53. #bind [winfo class .] <<ThemeChanged>> \
  54. # [list +ttk::style layout EditFrame [ttk::style layout EditFrame]]
  55. bind . <Control-F2> {console show}
  56. }
  57. Once
  58.  
  59. # -------------------------------------------------------------------------
  60.  
  61. ttk::frame .main
  62.  
  63. ttk::frame .ef
  64. ttk::entry .e0
  65. ttk::entry .e1
  66. ttk::entry .e2
  67.  
  68. grid .e0 .e1 .e2 -in .ef -padx 1 -pady 1
  69.  
  70. ttk::frame .sf
  71. ttk::spinbox .s0 -from 0 -to 100 ; .s0 set 0
  72. ttk::spinbox .s1 -values [info vars] ; .s1 set [lindex [.s1 cget -values] 0]
  73. ttk::spinbox .s2 -from 0 -to 100 ; .s2 set 0
  74.  
  75. grid .s0 .s1 .s2 -in .sf -padx 1 -pady 1
  76.  
  77. ttk::combobox .a -values {disabled reallydisabled}
  78. ttk::combobox .b -values [info vars]
  79. ttk::combobox .c -values [list oneoneoneoneoneoneoneoneone \
  80. twotwotwotwotwotwotwotwotwotwotwotwotwo \
  81. threethreethreethreethreethreethreethreethree]
  82. ttk::combobox .d -values [lsort [ttk::style theme names]]
  83. ttk::button .apply -text Apply -command {ttk::style theme use [.d get]}
  84. ttk::frame .f -relief solid -borderwidth 1 -height 20 -width 40
  85. ttk::frame .f2 -height 20 -width 40 -style EntryFrame -class EntryFrame
  86.  
  87. ttk::frame .tf -style EntryFrame -class EntryFrame
  88. text .tf.t -width 40 -height 8 -wrap none -borderwidth 0 -relief flat \
  89. -yscrollcommand {.tf.vs set} -xscrollcommand {.tf.hs set}
  90. ttk::scrollbar .tf.vs -orient vertical -command {.tf.t yview}
  91. ttk::scrollbar .tf.hs -orient horizontal -command {.tf.t xview}
  92. ttk::sizegrip .tf.sg
  93. .tf.t insert end [info body tcl::HistIndex]
  94.  
  95. grid .tf.t .tf.vs -sticky news
  96. grid .tf.hs x -sticky ew
  97. grid rowconfigure .tf 0 -weight 1
  98. grid columnconfigure .tf 0 -weight 1
  99.  
  100. .a current 0
  101. .a state disabled
  102. .b current 0
  103. .c current 0
  104. .d current [lsearch [.d cget -values] [ttk::style theme use]]
  105. .d state readonly
  106.  
  107. .e0 insert end Normal
  108. .e1 insert end Readonly ; .e1 state readonly
  109. .e2 insert end Disabled ; .e2 state disabled
  110.  
  111. .s1 state readonly
  112. .s2 state disabled
  113.  
  114. ttk::progressbar .pb -mode indeterminate ; .pb start
  115. ttk::scale .sc
  116.  
  117. ttk::frame .vf
  118. ttk::progressbar .vpb -orient vertical -mode indeterminate ;.vpb start
  119. ttk::scale .vsc -orient vertical
  120. grid .vpb .vsc -in .vf -sticky ns -padx 1 -pady 1
  121.  
  122. grid .ef - -in .main -sticky ew -padx 5 -pady 5
  123. grid .sf - -in .main -sticky ew -padx 5 -pady 5
  124. grid .a .vf -in .main -sticky w -padx 5 -pady 5
  125. grid .b ^ -in .main -sticky w -padx 5 -pady 5
  126. grid .c ^ -in .main -sticky w -padx 5 -pady 5
  127. grid .d .apply -in .main -sticky w -padx 5 -pady 5
  128. grid .f .f2 -in .main -sticky w -padx 5 -pady 5
  129. grid .pb .sc -in .main -sticky w -padx 5 -pady 5
  130. grid .tf - -in .main -sticky news -padx 5 -pady 5
  131.  
  132. grid columnconfigure .main 0 -weight 1
  133. grid rowconfigure .main 8 -weight 1
  134.  
  135. grid .main -sticky news
  136. grid rowconfigure . 0 -weight 1
  137. grid columnconfigure . 0 -weight 1