Posted to tcl by saedelaere at Thu Dec 10 15:52:19 GMT 2009view raw
- ttk::style theme use tileqt
- proc build_pref {} {
- set w [toplevel .config_wizard]
- place [ttk::frame $w.bgcolor] -x 0 -y 0 -relwidth 1 -relheight 1
- set wfbox [ttk::frame $w.frame_configbox]
- set wfcopt [ttk::frame $w.frame_configoptions]
- set wfbtn [ttk::frame $w.frame_buttons -style TLabelframe]
- listbox $wfbox.listbox_clist \
- -font -*-*-Bold-R-Normal-*-*-100-*-*-*-*-*-* \
- -width 0 \
- -height 0
- ttk::button $wfbtn.button_save \
- -text "Apply"
- ttk::button $wfbtn.b_default \
- -text Default
- ttk::button $wfbtn.button_quit \
- -text Cancel
- ttk::notebook $wfcopt.nb
- grid rowconfigure $wfbox 0 -weight 1
- grid rowconfigure $wfcopt 0 -weight 1 -minsize 270
- grid columnconfigure $wfbox 0 -weight 1
- grid columnconfigure $wfcopt 0 -weight 1 -minsize 470
- grid $wfbox -in $w -row 0 -column 0 \
- -sticky nesw \
- -padx 5 \
- -pady 5
- grid $wfcopt -in $w -row 0 -column 1 \
- -sticky nesw \
- -padx 5 \
- -pady 5
- grid $wfbtn -in $w -row 1 -column 0 \
- -sticky ew \
- -columnspan 2 \
- -padx 3\
- -pady 3
- grid anchor $wfbtn e
- grid $wfbox.listbox_clist -in $wfbox -row 0 -column 0 \
- -sticky nesw
- grid $wfbtn.button_save -in $wfbtn -row 0 -column 0 \
- -padx "0 3" \
- -pady 7
- grid $wfbtn.b_default -in $wfbtn -row 0 -column 1 \
- -sticky ns \
- -pady 7
- grid $wfbtn.button_quit -in $wfbtn -row 0 -column 2 \
- -padx 3 \
- -pady 7
- grid $wfcopt.nb -in $wfcopt -row 0 -column 0 \
- -sticky nesw
- # Additional Code
- set conf_opts [list "General" "Analog"]
- foreach config_option [split $conf_opts] {
- $wfbox.listbox_clist insert end " $config_option"
- }
- bind $wfbox.listbox_clist <<ListboxSelect>> [list listbox_sel $wfbox.listbox_clist $wfcopt.nb]
- $wfbox.listbox_clist selection set 0
- $wfbox.listbox_clist activate 0
- wm resizable $w 0 0
- wm title $w Preferences
- wm transient $w .
- tkwait visibility $w
- grab $w
- }
- proc add_tabs {} {
- set nb .config_wizard.frame_configoptions.nb
- set tab1 [ttk::frame $nb.tab1]
- set tab2 [ttk::frame $nb.tab2]
- set tab3 [ttk::frame $nb.tab3]
- $nb add $tab1 -text "This is the first tab" -padding 2
- $nb add $tab2 -text "This is the second tab" -padding 2
- $nb add $tab3 -text "This is the third tab" -padding 2
- ttk::labelframe $tab1.lf
- text $tab1.lf.t
- ttk::labelframe $tab2.lf
- text $tab2.lf.t
- ttk::labelframe $tab3.lf
- text $tab3.lf.t
- grid $tab1.lf -padx 10 -pady 10
- grid $tab1.lf.t
- grid $tab2.lf
- grid $tab2.lf.t
- grid $tab3.lf
- grid $tab3.lf.t
- }
- proc listbox_sel {lb nb} {
- set lb_index [$lb curselection]
- opt$lb_index $nb
- }
- proc opt0 {nb} {
- foreach tab [$nb tabs] {
- $nb hide $tab
- }
- if {[winfo exists $nb.tab1]} {
- $nb add $nb.tab1
- $nb add $nb.tab2
- $nb add $nb.tab3
- $nb select $nb.tab2
- } else {
- set tab1 [ttk::frame $nb.tab1]
- set tab2 [ttk::frame $nb.tab2]
- set tab3 [ttk::frame $nb.tab3]
- $nb add $tab1 -text "This is the first tab" -padding 2
- $nb add $tab2 -text "This is the second tab" -padding 2
- $nb add $tab3 -text "This is the third tab" -padding 2
- ttk::labelframe $tab1.lf
- text $tab1.lf.t
- ttk::labelframe $tab2.lf
- text $tab2.lf.t
- ttk::labelframe $tab3.lf
- text $tab3.lf.t
- grid $tab1.lf -padx 10 -pady 10
- grid $tab1.lf.t
- grid $tab2.lf
- grid $tab2.lf.t
- grid $tab3.lf
- grid $tab3.lf.t
- }
- }
- proc opt1 {nb} {
- foreach tab [$nb tabs] {
- $nb hide $tab
- }
- if {[winfo exists $nb.tab4]} {
- $nb add $nb.tab4
- $nb add $nb.tab5
- $nb add $nb.tab6
- $nb select $nb.tab5
- } else {
- set tab1 [ttk::frame $nb.tab4]
- set tab2 [ttk::frame $nb.tab5]
- set tab3 [ttk::frame $nb.tab6]
- $nb add $tab1 -text "Another tab" -padding 2
- $nb add $tab2 -text "Fun tab" -padding 2
- $nb add $tab3 -text "Boring tab" -padding 2
- ttk::labelframe $tab1.lf
- text $tab1.lf.t
- ttk::labelframe $tab2.lf
- text $tab2.lf.t
- ttk::labelframe $tab3.lf
- text $tab3.lf.t
- grid $tab1.lf -padx 10 -pady 10
- grid $tab1.lf.t
- grid $tab2.lf
- grid $tab2.lf.t
- grid $tab3.lf
- grid $tab3.lf.t
- }
- }
- build_pref