Add text string to window?

Hoping someone can point me in the direction of adding a line descriptive text to this nice little progress bar / window. Im still learning about windows and have tried a few options without success including adding

.


-- Created 2015-12-11 by Takaaki Naganoya
-- 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSWindowController : a reference to current application's NSWindowController
property NSWindow : a reference to current application's NSWindow

property windisp : false
property aPBar : missing value
property aWin : missing value

set aWidth to 400
set aHeight to 40

set aMaxVal to 100
set aButtonMSG to "Abort"
set aTitle to "Progress..."

--set aWin to makeProgressWindow(aMaxVal, aButtonMSG, aTitle, aWidth, aHeight) of me
set paramObj to {myMax:aMaxVal, myMSG:aButtonMSG, myTitle:aTitle, myWidth:aWidth, myHeight:aHeight}
my performSelectorOnMainThread:"makeProgressWindow:" withObject:(paramObj) waitUntilDone:true

repeat with i from 1 to aMaxVal by 1
	if (my windisp) = false then
		exit repeat
	end if
	(aPBar's setDoubleValue:(i as real))
	
	--call main routine here
	
	
	delay 0.1
end repeat

if i is not equal to aMaxVal then
	tell current application
		display notification "Aborted"
	end tell
end if
my closeWin:aWin
set my aPBar to missing value
set aWin to missing value



on makeProgressWindow:paramObj
	set aMaxVal to (myMax of paramObj) as integer
	set aButtonMSG to (myMSG of paramObj) as string
	set aTitle to (myTitle of paramObj) as string
	set aWidth to (myWidth of paramObj) as integer
	set aHeight to (myHeight of paramObj) as integer
	
	set (my windisp) to true
	
	--ProgressIndicatorをつくる
	set aSlider to makeProgressIndicator(aMaxVal, aWidth) of me
	
	--Buttonをつくる
	set bButton to (current application's NSButton's alloc()'s initWithFrame:(current application's NSMakeRect(aWidth / 4, 0, aWidth / 2, 40)))
	bButton's setTitle:aButtonMSG
	bButton's setButtonType:(current application's NSMomentaryLightButton)
	bButton's setBezelStyle:(current application's NSRoundedBezelStyle)
	bButton's setTarget:me
	bButton's setAction:("clicked:")
	
	set aView to current application's NSView's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, aWidth, aHeight))
	aView's addSubview:aSlider
	aView's addSubview:bButton
	aView's setNeedsDisplay:true
	
	set (my aWin) to (my makeDockLevelWinWithView(aView, 400, 70, aTitle))
	
	set wController to NSWindowController's alloc()
	wController's initWithWindow:aWin
	(my aWin)'s makeFirstResponder:aView
	wController's showWindow:me
	
	(my aWin)'s makeKeyAndOrderFront:me
end makeProgressWindow:


on clicked:aSender
	set (my windisp) to false
end clicked:


--make Window for Display
on makeDockLevelWinWithView(aView, aWinWidth, aWinHeight, aTitle)
	set aScreen to current application's NSScreen's mainScreen()
	set aFrame to {{0, 0}, {aWinWidth, aWinHeight}}
	
	set aBacking to current application's NSTitledWindowMask
	
	set aDefer to current application's NSBackingStoreBuffered
	
	-- Window
	set aWin to current application's NSWindow's alloc()
	(aWin's initWithContentRect:aFrame styleMask:aBacking backing:aDefer defer:false screen:aScreen)
	
	aWin's setTitle:aTitle
	aWin's setDelegate:me
	aWin's setDisplaysWhenScreenProfileChanges:true
	aWin's setHasShadow:true
	aWin's setIgnoresMouseEvents:false
	aWin's setLevel:(current application's NSDockWindowLevel)
	aWin's setOpaque:false
	aWin's setReleasedWhenClosed:true
	aWin's |center|()
	aWin's makeKeyAndOrderFront:(me)
	
	aWin's setContentView:aView
	
	return aWin
	
end makeDockLevelWinWithView

--close win
on closeWin:aWindow
	repeat with n from 10 to 1 by -1
		(aWindow's setAlphaValue:n / 10)
		delay 0.02
	end repeat
	aWindow's |close|()
end closeWin:

--make progress indicator
on makeProgressIndicator(aMaxNum, aWidth)
	set aPBar to current application's NSProgressIndicator's alloc()'s initWithFrame:(current application's NSMakeRect(0, 40, aWidth, 40))
	aPBar's setMaxValue:aMaxNum
	aPBar's setMinValue:1
	aPBar's setIndeterminate:false
	aPBar's setControlSize:(current application's NSProgressIndicatorPreferredLargeThickness)
	aPBar's setDoubleValue:(1.0 as real)
	return aPBar
end makeProgressIndicator

This should give you some direction to dig for


set aTextField to current application's NSTextField's alloc's initWithFrame:(current application's NSMakeRect(100, 0, 200, 40)) --> you need to fix frame dimensions here
aTextField's setStringValue:"somestring"
aView's addSubview:aTextField

Thank you! I’m headed in a very positive direction. Rather then using

is there a way to auto center if the contents are dynamic? Im having trouble centering the button and text description.

Here is where I am at


on makeProgressWindow:paramObj
	set aMaxVal to (myMax of paramObj) as integer
	set aButtonMSG to (myMSG of paramObj) as string
	set aTitle to (myTitle of paramObj) as string
	set aWidth to (myWidth of paramObj) as integer
	set aHeight to (myHeight of paramObj) as integer
	set (my windisp) to true
	
	--ProgressIndicatorをつくる
	set aSlider to makeProgressIndicator(aMaxVal, aWidth) of me
	
	---Text Field to reflect status description
	set aTextField to current application's NSTextField's alloc's initWithFrame:(current application's NSMakeRect(50, 35, 400, 20)) --> you need to fix frame dimensions here
	set descriptionString to "What the heck is going On?!!!"
	aTextField's setEditable:false
	aTextField's setStringValue:(descriptionString)
	aTextField's setDrawsBackground:false
	aTextField's setBordered:false
	
	--Buttonをつくる
	set bButton to (current application's NSButton's alloc()'s initWithFrame:(current application's NSMakeRect((aWidth / 4), 0, 100, 50)))
	bButton's setTitle:aButtonMSG
	bButton's setButtonType:(current application's NSMomentaryLightButton)
	bButton's setBezelStyle:(current application's NSRoundedBezelStyle)
	bButton's setTarget:me
	bButton's setAction:("clicked:")
	
	set aView to current application's NSView's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, aWidth, aHeight))
	aView's addSubview:aSlider
	aView's addSubview:bButton
	aView's setNeedsDisplay:true
	aView's addSubview:aTextField
	
	set (my aWin) to (my makeDockLevelWinWithView(aView, 400, 70, aTitle))
	
	set wController to NSWindowController's alloc()
	wController's initWithWindow:aWin
	(my aWin)'s makeFirstResponder:aView
	wController's showWindow:me
	
	
	
	(my aWin)'s makeKeyAndOrderFront:me
end makeProgressWindow:

This I can’t really tell you, this is something I didn’t investigate. There’s probably a way to make the frame full width and then get the text centered in it.