Updating a GUI - Embedding post window in a GUI

Hi, I am trying to update this GUI:
https://listarc.cal.bham.ac.uk/lists/sc-users-2011/msg09522.html

However it can’t compile, possibly due to GUI changes throughout all these years.

What would be a replacement for this line?

active.background = "" style="color: #032ec3">Color.black;

active is a QStaticText. In a brief, it is this part of the code:

({
	var active, gui;
	gui = GUI.current;
	active = gui.staticText.new(w, Rect(1*5+(10*3),10, 1*5, 1));
	active.class.postln;
	active.string = this.name.asString;
	active.align = \center;
	active.font = gui.font.new( gui.font.defaultSansFace, 16 ).boldVariant;
	active.background = "" style="color: #032ec3">Color.black;
})

If you have any other newer solution about how to embed a independent instance of post window in a GUI, please share it.

1 Like

It looks like some html got embedded in the code.

"" style="color: #032ec3"> is the bad part.

active.background = Color.black;

^^ That should be valid syntax.

hjh

Thanks! Now I understand that some other strange parts of the code like ""> are also spurious html…

I’ll finish debugging and post it here later.

1 Like

I’ve realized that the code is not doing what I was expecting from the title… However I found out that the way to implement something similar to post window behavior is to use the LogWindow from the Log Quark.

In case this is helpful for someone, here is the modified version of the code. There are still some stuff not working because I could not find some of the functions used:

//https://listarc.cal.bham.ac.uk/lists/sc-users-2011/msg11413.html

(
~makeMyWindow = { arg step = 25, left = 10, top = 10, width, height, bound = 4, label = "localhost server" ;
	var active, booter, killer, makeDefault, running, booting, stopped, bundling;
	var recorder, scoper;
	var countsViews, ctlr;
	var dumping=false, gui;


	var otherStep = ((step*16-(7*bound))/6).asInteger ;

	var w ;


	if (width.isNil, { width = 16*step+(bound*6) }) ;
	if (height.isNil, { height = step+(bound*4)+(step*0.6*2) }) ;


	gui = GUI.current;



	w  = gui.window.new( label,
		Rect(left, top, width, height),
		resizable: true );


	// This messes all up...so keep out
	//	w.view.decorator = FlowLayout(w.view.bounds);


	// We use local (also: no internal in swing)
	if(s.isLocal,{
		booter = gui.button.new(w, Rect(bound, bound, step*3, step));
		booter.states = [["Boot", Color.black, Color.clear],
			["Quit", Color.black, Color.clear]];


		booter.action = { arg view;
			if(view.value == 1, {
				booting.value;
				s.boot;
			});
			if(view.value == 0,{
				s.quit;
			});
		};
		booter.setProperty(\value,s.serverRunning.binaryValue);


		// hard-coded positions: but using a  module (here: 25)
		killer = gui.button.new(w, Rect(step*3+(bound*2), bound, step*2, step));
		killer.states = [["K", Color.black, Color.clear]];


		killer.action = { Server.killAll };
	});

	active = gui.staticText.new(w, Rect(step*5+(bound*3),bound, step*5, step));
	active.string = s.name.asString;
	active.align = \center;
	active.font = gui.font.new( gui.font.defaultSansFace, 16 ).boldVariant;
	active.background = Color.black;
	//if(serverRunning,running,stopped);

	makeDefault = gui.button.new(w, Rect(step*10+(bound*4),bound, step*3, step));
	makeDefault.states = [["default", Color.black, Color.clear]];
	makeDefault.action = {
	thisProcess.interpreter.s = s;
	Server.default = s;
};

	//w.view.decorator.nextLine;


	recorder = gui.button.new(w, Rect(step*13+(bound*5), bound, step*3, step));
	recorder.states = [
		["prepare rec", Color.black, Color.clear],
		["record >", Color.red, Color.gray(0.1)],
		["stop []", Color.black, Color.red]
	];
	recorder.action = {
	if (recorder.value == 1) {
		s.prepareForRecord;
	}{
		if (recorder.value == 2) { s.record } { s.stopRecording };
	};
};
recorder.enabled = true;

if (s.isLocal, {


	running = {
		active.stringColor_(Color.red);
		booter.setProperty(\value,1);
		recorder.enabled = true;
	};
	stopped = {
		active.stringColor_(Color.grey(0.3));
		booter.setProperty(\value,0);
		recorder.setProperty(\value,0);
		recorder.enabled = false;

	};
	booting = {
		active.stringColor_(Color.yellow(0.9));
		//booter.setProperty(\value,0);
	};
	bundling = {
		active.stringColor_(Color.new255(237, 157, 196));
		booter.setProperty(\value,1);
		recorder.enabled = false;
	};


	//w.window = nil;
	ctlr.remove;

},{
	running = {
		active.stringColor = Color.red;
		active.background = Color.red;
		recorder.enabled = true;
	};
	stopped = {
		active.stringColor = Color.red;
		active.background = Color.black;
		recorder.setProperty(\value,0);
		recorder.enabled = false;

	};
	booting = {
		active.stringColor = Color.red;
		active.background = Color.yellow;
	};


	bundling = {
		active.stringColor = Color.new255(237, 157, 196);
		active.background = Color.red(0.5);
		booter.setProperty(\value,1);
		recorder.enabled = false;
	};


	//w.{
	// but do not remove other responders
	s.stopAliveThread;
	ctlr.remove;
};

);

//if(serverRunning,running,stopped);

//toda essa parte até aqui foi para deixar fazer o boot e mostrar isso numa GUI

w.front;


//w.view.decorator.nextLine;


countsViews =
#[
	"Avg CPU :", "Peak CPU :",
	"UGens :", "Synths :", "Groups :", "SynthDefs :"
].collect({ arg name, i;
	var label,numView, pctView;
	// skip % signs and use a horizontal layout
	label = gui.staticText.new(w, Rect(i*(otherStep+bound), bound*2+step, otherStep, step*0.6));
	label.string = name;
	label.align = \right;


	numView = gui.staticText.new(w,  Rect(i*(otherStep+bound), bound*3+step+(step*0.6), otherStep, step*0.6));
	numView.string = "?";
	numView.align = \right;

	numView
});

/*ctlr = SimpleController(s)
.put(\serverRunning, {	if(serverRunning,running,stopped) })
.put(\counts,{
	countsViews.at(0).string = avgCPU.round(0.1);
	countsViews.at(1).string = peakCPU.round(0.1);
	countsViews.at(2).string = numUGens;
	countsViews.at(3).string = numSynths;
	countsViews.at(4).string = numGroups;
	countsViews.at(5).string = numSynthDefs;
})
.put(\cmdPeriod,{
	recorder.setProperty(\value,0);
})
.put(\bundling, bundling);*/


s.startAliveThread;

}
)
~makeMyWindow.()
1 Like