1. Tutorial 2
Here is a simple mockup of the KDE3 control panel.
Here is the implement code (run with 'wize kcont.gui'):
#!/usr/bin/env wize
# "File kcont.gui"
{script} {
# Partial mockup of KDE3 control panel.
array set _ {
v,dtm_menu 1
v,dtm_icon 1
v,dtm_mbut "Window List Menu"
}
set _(def:confs) {
"File Browsing" Information "Look & Feel" Network Peripherals
Personalization "Power Control" Sound System "Web Browsing"
}
set _(def:desktop) {
Background Colors Desktop Fonts Icons "Launch Feedback"
Panel Screensaver Shortcuts Style Taskbar "Theme Manager"
"Window Behavior" "Window Decoration"
}
set _(def:prevs) { "HTML Files" 1 "Images" 0 "Message Catalogs" 0 }
set _(dtclicks) { "No Action" "Window List Menu" "Desktop Menu" "Application Menu" "Custom Menu 1" "Custom Menu 2" }
proc Main {_} {
# Startup code.
upvar $_ {}
set t $(w,previews)
set c $(w,confs)
TreeView conf $c -separator /
TreeView column conf $t Col0 -hide 1
foreach {col title} {
i #
n "Show Previews for:"
} {
TreeView column insert $t end $col -title $title
styles item $t column $col
}
foreach {n i} $(def:prevs) {
TreeView insert $t end #auto -data [list i $i n $n]
}
foreach i $(def:confs) {
TreeView insert $c end $i -forcetree 1
}
foreach i $(def:desktop) {
TreeView insert $c end "Look & Feel/$i"
}
TreeView open $c [TreeView find $c -name "Look & Feel"]
TreeView entry select $c [TreeView find $c -name Desktop]
}
}
# "Toplevel menu"
{Menu +} {
{Menu + -label File} {
}
{Menu + -label View} {
}
{Menu + -label Help} {
}
}
# "Menu for menubutton"
{Menu + -id foo } {
x Enable
x Disable
}
# "Application Style"
{style} {
Toplevel {
@deficons {
desktop kcontrol_2
}
@eval {
font conf TkDefaultFont -weight normal
}
}
TreeView {
-bg White -bd 2
-selectbackground #085d8c -selectforeground White
-nofocusselectbackground #085d8c -nofocusselectforeground White
-font TkDefaultFont
-selectborderwidth 0
@eval {
TreeView button conf %W -bg White
}
}
TreeView::column::i.previews {
-style cb -edit 1 -width 15
}
Labelframe { -padx 3 -pady 3 }
Menubutton { -indicator 0 -anchor w }
Tabset { -gap 1 }
Tabset::tab { -bg darkgray -ipady "2 2" -underline 0 }
Panedwindow { -showhandle 0 }
.confs {
-leaficons ^desktop
}
.previews {
-height 100 -font {Courier -12}
@eval {
TreeView style create checkbox %W cb
TreeView style conf %W cb -showvalue 0 -boxsize 10
}
}
}
# "Main Window"
{Toplevel +} {
{title} "Desktop - Control Center"
{Panedwindow + -pos *} {
{pane +} {
{Tabset + -pos *} {
{tab + -label Index} {
{Frame + -pad 4,0 -pos *} {
{TreeView - -id confs -scroll * -pos *} { }
}
}
{tab + -label Search} {
}
{tab + -label Help} {
}
}
}
{pane +} {
{Tabset + -pos *} {
{tab + -label Desktop} {
{Frame + -pos *} {
{Labelframe + -label "Misc Options" -subpos w -pos *l} {
{Checkbutton - -id dtm_menu -label {Enable Desktop Menu} } {}
{Checkbutton - -id dtm_icon -label {Enable Icons on Desktop} } {}
{Checkbutton - -label {Align Icons Vertically on Desktop} } {}
{Checkbutton - -label {Show Hidden Files on Desktop} } {}
{Checkbutton - -label {Programs in Desktop Window} } {}
}
{Frame + -pad 4,0 -pos *} {
{TreeView - -id previews -scroll * -pos *} { }
}
}
{Labelframe + -label "Clicks on the Desktop" -pos w} {
{grid + -pos * -colattr {{-pos w} {-pos w*}}} {
{row +} { Label {Left Button:} {Menubutton - -listvar (dtclicks)} {} }
{row +} { Label {Middle Button:} {Menubutton - -id dtm_mbut -listvar (dtclicks)} {} }
{row +} { Label {Right Button:} {Menubutton - -menuid foo -indicator 0} {Desktop Menu} }
}
}
{Frame + -pos *} {
}
}
{tab + -label Appearance} {
}
{tab + -label "Number of Desktops"} {
}
{tab + -label Paths} {
}
}
{Frame + -pos _} {
{Button - -pos l} Help
{Button - -pos l} Defaults
{Button - -pos r} Apply
{Button - -pos r} Reset
}
}
}
}
© 2008 Peter MacDonald