Bokeh: how to flush spectrogram - bokeh

I'm using bokeh spectrogram example and I need to clear image. Is there any way to add new function named flush to WaterfallRendererView class that I could call from main.py: waterfall_renderer.flush()?
Thanks!

As of Bokeh 0.12.4 there is not any direct way. The best way to "fake it" would be to add a property to WaterfallRenderer that exists solely for the purpose of triggering events in WaterfallRendererView.
class WaterfallRenderer(Model):
flusher = Int()
def flush(self):
self.flusher += 1
Then on WaterfallRendererView you can set up something like:
#listenTo(#model, 'change:flusher', #flush)
in 0.12.5 there will be a new API for "fire and forget" events that will make it possible to implement things like this in a less kludgy way.

Related

Where did LoaderService go?

Upgrading AngleSharp from 0.9.6 to 0.9.9 I have this line of code no longer compiling:
return configuration.With(LoaderService(new[] { requester }));
It complains that LoaderService does not exist in the current context. So what happened to LoaderService? Is there a replacement? Does it still exist but just somewhere else?
Good question. Sorry for being late to the party, but even though you may have solved your problem someone else is having a hard time figuring it out.
LoaderService was essentially just a helper to create a loader. But having a service for anything creating a little thing would be overkill and not scale much. Also AngleSharp.Core would need to define all these. So, instead a generic mechanism was introduced, which allows registering such "creator services" via Func<IBrowsingContext, TService>.
However, to solve your piece of code I guess the following line would do the trick:
return configuration.WithDefaultLoader(requesters: requester);
This registers the default loader creator services (one for documents, one for resources inside documents) with the default options (options involve some middleware etc.).
Under the hood (besides some other things) the following is happening:
// just one example, config.Filter is created based on the passed in options
return configuration.With<IDocumentLoader>(ctx => new DocumentLoader(ctx, config.Filter));

How do I make one of a stub's method call the real method in ASMock?

In flex I want to do something similar to the following
var audioPlayerMock:AudioPlayer = AudioPlayer(mockRepository.createStub(mockRepository.createStub(AudioPlayer));
SetupResult.forCall(audioPlayerMock.play).(CALL_ACTUAL_PLAY_METHOD(WITH_ARGUMENT));
AudioPlayer has a lot of methods that I want stubbed, (so I use mockRepository.creatStub()). But there is one method, play(), that I want to call the actual actual method (super.play(argument) if my thinking is right). I'm not sure how to do this?
I know I can use createDynamic(AudioPlayer) then stub out every other method, but that is a bit tedious.
Cheers
You can use IMethodOptions.callOriginalMethod() to call the actual implementation on a stubbed class:
SetupResult.forCall(authatoPlayerMock.play(null))
.ignoreArguments()
.callOriginalMethod();

How to edit a property on 'window', 'document'(width,height) from QtWebKit?

I tried to change like that(worked on the 'navigator' object)
page->mainFrame()->evaluateJavaScript(
"var navigator=new Object;"
"navigator.someProperty=...");
In that case, I would use the signal javaScriptWindowObjectCleared
That kicks in just before load, when the window has been cleared.
You probably want to validate the origin before doing anything, though.
That being said - and I am not too sure what you want to achieve - I wouldn't manipulate the javascript scope like that. Maintaining and deploying javascript is easier than doing the same for C++. So, I would instead just expose a simple C++ object to the javascript scope (via addToJavaScriptWindowObject), and then have the javascript code test this object and do what it has to do.
Either way, hope this helps.

passing multiple parameters to resulthandlers in flex

Is there a way to extend the ResultEvent class in flex. i have the following code:
var token:AsyncToken = remoteObject.setQueryAndGetPromptValues('country', queryString);
token.addResponder(new mx.rpc.Responder(resultCountrySearch,faultCountrySearch));
var token:AsyncToken = remoteObject.setQueryAndGetPromptValues('company', queryString);
token.addResponder(new mx.rpc.Responder(resultCompanySearch,faultCompanySearch));
so once the RPC call is executed I get a ResultEvent which is handled by resultCountrySearch or resultCompanySearch, each of which updates the corresponding text field. I have 30 such prompts so I do not want to create 30 different handler functions. Is there a way that I could pass which text field to update to the resultHandler along with the result event.
One way is to add your variables to to the asyncToken as object properties and the use them in the resulthandler
token.myprop = myvar;
There IS a way because the Swiz library does it for you. All you have to do is call executeServiceCall(call, resultHandler, faultHandler, eventArgs), and the evertArgs array is passed through as an argument to whichever handler is called.
I don't know all the implementation details, but it's an open source library, so you can have a poke around at their DynamicResponder class (implements IResponder) to see the Swiz approach. It's probably best to read the relevant documentation first of course (don't worry, it's short!).
Alternatively you could just use the library, though that may not be practical for your requirements.

Flex - Is there a way to specify what direction a ComboBox will open?

Maybe I should further qualify this - Is there a way to specify which direction a ComboBox will open without copying and pasting the entire ComboBox class and ripping out the code where it determines which direction it will open in...
I'm my specific case - I need it to open upwards - always.
UPDATE: You can't fix this by subclassing it because the function that handles the direction of the opening is:
private function displayDropdown(show:Boolean, trigger:Event = null):void
And that bad boy uses a fair amount of private variables which my subclass wouldn't have access to...
If you build up the Menu object yourself, you can place the menu anywhere you want by simply setting the x,y coordinates of the menu object. You'll need to calculate those coordinates, but you might be able to do this easily without subclassing ComboBox.
I am doing something similar with PopUpButton; you might find it easier to work with PopUpButton. This is based on real code from my current project:
private function initMenu(): void {
var m:Menu = new Menu();
m.dataProvider = theMenuData;
m.addEventListener(MenuEvent.ITEM_CLICK, menuClick);
m.showRoot = false;
// m.x = ... <-- probably don't need to tweak this.
// m.y = ... <-- this is really the interesting one :-)
theMenu.popUp = m;
}
<mx:PopUpButton id="theMenu" creationComplete="initMenu()" ... />
BTW, to get the PopUpButton to act more like I wanted it (always popup, no matter where the click), setting openAlways=true in the MXML works like a charm.
I doubt it - you'd need to subclass the control (which isn't that big a deal.)
Maybe you could mess with the real estate so it's placed in such a fashion (e.g. crowded into the lower right corner) that up is naturally coerced?
I would recommend checking out this post. Yes, you do have to grab the ComboBox code and modify it, but at least now you have an idea where the modifications need to go.
You could set the MaxDropDownHeight, if you set it big enough Windows will automatically set the direction upwards.
This irritated me no end. I have uploaded a solution, its a simple Class that extends the PopUpButton and removes the logic of stage bounds detection as it failed 50% of the time anyway. My code just allows you to simply specify whether you want to open the menu up or down:
http://gist.github.com/505255

Resources