diff options
author | culler <culler> | 2023-01-30 15:21:54 (GMT) |
---|---|---|
committer | culler <culler> | 2023-01-30 15:21:54 (GMT) |
commit | ba084026be93362126c6ae4e8bf1145a374d66b3 (patch) | |
tree | a951d643ea762fd3750b9412a263a331bcb1161c /library/demos/mac_wm.tcl | |
parent | e65a61d84a484846c04835b4554655247b9e853e (diff) | |
download | tk-ba084026be93362126c6ae4e8bf1145a374d66b3.zip tk-ba084026be93362126c6ae4e8bf1145a374d66b3.tar.gz tk-ba084026be93362126c6ae4e8bf1145a374d66b3.tar.bz2 |
demo details
Diffstat (limited to 'library/demos/mac_wm.tcl')
-rw-r--r-- | library/demos/mac_wm.tcl | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/library/demos/mac_wm.tcl b/library/demos/mac_wm.tcl index 0f91f0b..2f1c198 100644 --- a/library/demos/mac_wm.tcl +++ b/library/demos/mac_wm.tcl @@ -25,6 +25,11 @@ set winlist {} pack [addSeeDismiss $w.buttons $w] -side bottom -fill x proc launch {name windowInfo type} { + if {[winfo exists $name]} { + wm deiconify $name + focus -force $name + return + } wm attributes $name -type $type; toplevel $name wm title $name $type set f $name.f @@ -52,7 +57,8 @@ proc launch {name windowInfo type} { $f.stylemask.closable state selected grid $f.stylemask.closable -row 1 -column 0 -sticky w # miniaturizableable - ttk::checkbutton $f.stylemask.miniaturizable -text miniaturizable -variable $name.miniaturizable \ + ttk::checkbutton $f.stylemask.miniaturizable -text miniaturizable \ + -variable $name.miniaturizable \ -command [list setbit $name $f.stylemask.miniaturizable miniaturizable] if {$type == "nswindow"} { $f.stylemask.miniaturizable state selected @@ -107,9 +113,9 @@ grid $t -row 0 -column 0 -columnspan 2 -sticky NSEW ttk::labelframe $f.stylemask -text "styleMask" grid $f.stylemask -row 1 -column 0 grid [ttk::button $f.wbw -text "Open an NSWindow" -width 20 \ - -command [list launch $w.window $windowInfo nswindow]] -row 2 -column 0 + -command [list launch .nswindow $windowInfo nswindow]] -row 2 -column 0 grid [ttk::button $f.wbp -text "Open an NSPanel" -width 20 \ - -command [list launch $w.panel $panelInfo nspanel]] -row 3 -column 0 + -command [list launch .nspanel $panelInfo nspanel]] -row 3 -column 0 grid [ttk::button $f.wbm -text "Open a modern window" -width 20 \ -command launchModernWindow] -row 4 -column 0 pack $w.f -side bottom -fill both -expand 1 -padx 16 -pady 16 @@ -127,26 +133,6 @@ proc setbit {win cb bitname} { wm attributes $win -stylemask $bits } -proc createPanel {basename} { - global suffix - global winlist - set name "$basename$suffix" - wm attributes $name -type nspanel; toplevel $name - lappend winlist $name - wm title $name TKPanel - incr suffix -} - -proc createWindow {basename} { - global suffix - global winlist - set name "$basename$suffix" - toplevel $name - lappend winlist $name - wm title $name TKWindow - incr suffix -} - set aboutText \ "Most of the apps which ship with a contemporary version of macOS \ feature a window similar to this one, with a left sidebar that \ @@ -191,27 +177,37 @@ proc launchModernWindow {} { global aboutText global aboutCode global detailsText + if {[winfo exists .mod]} { + wm deiconify .mod + focus -force .mod + return + } toplevel .mod wm title .mod {} - wm attributes .mod -stylemask {titled fullsizecontent closable miniaturizable resizable} + wm attributes .mod -stylemask {titled fullsizecontent closable \ + miniaturizable resizable} .mod configure -background white grid columnconfigure .mod 0 -weight 0 grid columnconfigure .mod 1 -weight 1 grid rowconfigure .mod 0 -weight 1 frame .mod.left -width 220 -height 400 -background systemWindowBackgroundColor - font create leftFont -family .AppleSystemUIFont -size 11 - font create rightFont -family .AppleSystemUIFont -size 16 - font create codeFont -family Courier -size 16 + catch { + font create leftFont -family .AppleSystemUIFont -size 11 + font create rightFont -family .AppleSystemUIFont -size 16 + font create codeFont -family Courier -size 16 + } grid [ttk::label .mod.left.spacer -padding {220 30 0 0}] -row 0 -column 0 - grid [ttk::radiobutton .mod.left.about -text About -style SidebarButton -variable whichPage -value 1] \ + grid [ttk::radiobutton .mod.left.about -text About -style SidebarButton \ + -variable whichPage -value 1] \ -row 1 -column 0 -sticky nsew -padx 14 - grid [ttk::radiobutton .mod.left.details -text Details -style SidebarButton -variable whichPage -value 2] \ + grid [ttk::radiobutton .mod.left.details -text Details -style SidebarButton \ + -variable whichPage -value 2] \ -row 2 -column 0 -sticky nsew -padx 14 grid .mod.left -row 0 -column 0 -sticky nsew frame .mod.right -width 500 -background systemTextBackgroundColor grid rowconfigure .mod.right 0 -weight 0 text .mod.right.about -highlightcolor systemTextBackgroundColor \ - -background systemTextBackgroundColor -font rightFont\ + -background systemTextBackgroundColor -font rightFont \ -highlightthickness 0 -wrap word -width 40 .mod.right.about tag configure code -font codeFont .mod.right.about insert end $aboutText |