Posted to tcl by saedelaere at Thu Dec 10 15:52:19 GMT 2009view raw

  1. ttk::style theme use tileqt
  2.  
  3. proc build_pref {} {
  4. set w [toplevel .config_wizard]
  5.  
  6. place [ttk::frame $w.bgcolor] -x 0 -y 0 -relwidth 1 -relheight 1
  7.  
  8. set wfbox [ttk::frame $w.frame_configbox]
  9.  
  10. set wfcopt [ttk::frame $w.frame_configoptions]
  11. set wfbtn [ttk::frame $w.frame_buttons -style TLabelframe]
  12.  
  13. listbox $wfbox.listbox_clist \
  14. -font -*-*-Bold-R-Normal-*-*-100-*-*-*-*-*-* \
  15. -width 0 \
  16. -height 0
  17.  
  18. ttk::button $wfbtn.button_save \
  19. -text "Apply"
  20.  
  21. ttk::button $wfbtn.b_default \
  22. -text Default
  23.  
  24. ttk::button $wfbtn.button_quit \
  25. -text Cancel
  26.  
  27. ttk::notebook $wfcopt.nb
  28.  
  29. grid rowconfigure $wfbox 0 -weight 1
  30. grid rowconfigure $wfcopt 0 -weight 1 -minsize 270
  31. grid columnconfigure $wfbox 0 -weight 1
  32. grid columnconfigure $wfcopt 0 -weight 1 -minsize 470
  33.  
  34. grid $wfbox -in $w -row 0 -column 0 \
  35. -sticky nesw \
  36. -padx 5 \
  37. -pady 5
  38. grid $wfcopt -in $w -row 0 -column 1 \
  39. -sticky nesw \
  40. -padx 5 \
  41. -pady 5
  42. grid $wfbtn -in $w -row 1 -column 0 \
  43. -sticky ew \
  44. -columnspan 2 \
  45. -padx 3\
  46. -pady 3
  47.  
  48. grid anchor $wfbtn e
  49. grid $wfbox.listbox_clist -in $wfbox -row 0 -column 0 \
  50. -sticky nesw
  51. grid $wfbtn.button_save -in $wfbtn -row 0 -column 0 \
  52. -padx "0 3" \
  53. -pady 7
  54. grid $wfbtn.b_default -in $wfbtn -row 0 -column 1 \
  55. -sticky ns \
  56. -pady 7
  57. grid $wfbtn.button_quit -in $wfbtn -row 0 -column 2 \
  58. -padx 3 \
  59. -pady 7
  60. grid $wfcopt.nb -in $wfcopt -row 0 -column 0 \
  61. -sticky nesw
  62.  
  63. # Additional Code
  64.  
  65. set conf_opts [list "General" "Analog"]
  66.  
  67. foreach config_option [split $conf_opts] {
  68. $wfbox.listbox_clist insert end " $config_option"
  69. }
  70. bind $wfbox.listbox_clist <<ListboxSelect>> [list listbox_sel $wfbox.listbox_clist $wfcopt.nb]
  71.  
  72. $wfbox.listbox_clist selection set 0
  73. $wfbox.listbox_clist activate 0
  74.  
  75. wm resizable $w 0 0
  76. wm title $w Preferences
  77. wm transient $w .
  78.  
  79. tkwait visibility $w
  80. grab $w
  81. }
  82.  
  83. proc add_tabs {} {
  84.  
  85. set nb .config_wizard.frame_configoptions.nb
  86.  
  87. set tab1 [ttk::frame $nb.tab1]
  88. set tab2 [ttk::frame $nb.tab2]
  89. set tab3 [ttk::frame $nb.tab3]
  90.  
  91. $nb add $tab1 -text "This is the first tab" -padding 2
  92. $nb add $tab2 -text "This is the second tab" -padding 2
  93. $nb add $tab3 -text "This is the third tab" -padding 2
  94.  
  95. ttk::labelframe $tab1.lf
  96. text $tab1.lf.t
  97. ttk::labelframe $tab2.lf
  98. text $tab2.lf.t
  99. ttk::labelframe $tab3.lf
  100. text $tab3.lf.t
  101.  
  102. grid $tab1.lf -padx 10 -pady 10
  103. grid $tab1.lf.t
  104. grid $tab2.lf
  105. grid $tab2.lf.t
  106. grid $tab3.lf
  107. grid $tab3.lf.t
  108. }
  109.  
  110. proc listbox_sel {lb nb} {
  111. set lb_index [$lb curselection]
  112. opt$lb_index $nb
  113. }
  114.  
  115. proc opt0 {nb} {
  116. foreach tab [$nb tabs] {
  117. $nb hide $tab
  118. }
  119. if {[winfo exists $nb.tab1]} {
  120. $nb add $nb.tab1
  121. $nb add $nb.tab2
  122. $nb add $nb.tab3
  123. $nb select $nb.tab2
  124. } else {
  125. set tab1 [ttk::frame $nb.tab1]
  126. set tab2 [ttk::frame $nb.tab2]
  127. set tab3 [ttk::frame $nb.tab3]
  128.  
  129. $nb add $tab1 -text "This is the first tab" -padding 2
  130. $nb add $tab2 -text "This is the second tab" -padding 2
  131. $nb add $tab3 -text "This is the third tab" -padding 2
  132.  
  133. ttk::labelframe $tab1.lf
  134. text $tab1.lf.t
  135. ttk::labelframe $tab2.lf
  136. text $tab2.lf.t
  137. ttk::labelframe $tab3.lf
  138. text $tab3.lf.t
  139.  
  140. grid $tab1.lf -padx 10 -pady 10
  141. grid $tab1.lf.t
  142. grid $tab2.lf
  143. grid $tab2.lf.t
  144. grid $tab3.lf
  145. grid $tab3.lf.t
  146. }
  147. }
  148.  
  149. proc opt1 {nb} {
  150. foreach tab [$nb tabs] {
  151. $nb hide $tab
  152. }
  153. if {[winfo exists $nb.tab4]} {
  154. $nb add $nb.tab4
  155. $nb add $nb.tab5
  156. $nb add $nb.tab6
  157. $nb select $nb.tab5
  158. } else {
  159. set tab1 [ttk::frame $nb.tab4]
  160. set tab2 [ttk::frame $nb.tab5]
  161. set tab3 [ttk::frame $nb.tab6]
  162.  
  163. $nb add $tab1 -text "Another tab" -padding 2
  164. $nb add $tab2 -text "Fun tab" -padding 2
  165. $nb add $tab3 -text "Boring tab" -padding 2
  166.  
  167. ttk::labelframe $tab1.lf
  168. text $tab1.lf.t
  169. ttk::labelframe $tab2.lf
  170. text $tab2.lf.t
  171. ttk::labelframe $tab3.lf
  172. text $tab3.lf.t
  173.  
  174. grid $tab1.lf -padx 10 -pady 10
  175. grid $tab1.lf.t
  176. grid $tab2.lf
  177. grid $tab2.lf.t
  178. grid $tab3.lf
  179. grid $tab3.lf.t
  180. }
  181. }
  182.  
  183. build_pref