mirror of
https://github.com/thestk/stk
synced 2026-01-14 21:41:53 +00:00
Version 4.4.4
This commit is contained in:
committed by
Stephen Sinclair
parent
0aec39260a
commit
fc877b87bf
@@ -3,7 +3,6 @@
|
||||
# Set initial control values
|
||||
set pitch 64.0
|
||||
set press 64.0
|
||||
set outID "stdout"
|
||||
|
||||
# Configure main window
|
||||
wm title . "A Simple GUI"
|
||||
@@ -33,22 +32,50 @@ bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "NoteOff 0.0 1 %f 127" $pitch ]
|
||||
flush $outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
puts [format "NoteOff 0.0 1 %f 127" $pitch ]
|
||||
flush stdout
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush $outID
|
||||
puts [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
bind . <Configure> {+ center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user