I have a case where there is an OK button on two windows. I want to click the OK button on the former window but using Sikuli I am unable to do it. I tried using Python script getting the nearest button using Y co-ordinates. But I guess its not working.
Find something that's in the window you're interested in but not in the other (e.g. part of the title), extend the matched area to contain the button you want but not the other one, then search for the button within that area.
A couple of options come to mind:
Restrict your search to a particular area of the screen either by pre-defining a region, (region.click(okButton1), or
you can try using sorted() to sort the y coordinates (if they appear left-and-right of each other) or x coordinates (if they appear above-and-below each other) of the two OK buttons, and then click on the one of interest like so--
#to find top-most OK Button
def byY(match):
return match.y
okButtons = list([x for x in findAll(OkButtonPic)]) #make a list of the OK Buttons
TopOkButton = sorted(okButtons, key=byY)[0] #sort them according to Y values
click(topOkButton)
#to find left-most OK button
def byX(match):
return match.x
okButtons = list([x for x in findAll(OkButtonPic)])
leftOkButton = sorted(okButtons, key=byX)[0]
click(leftOkButton)
If there is anything distinct that reliably appears near the OK button that you want to click, you can click(uniqueThing).targetOffset(pixelsX,pixelsY).
If the OK button you want to click is in a window that is now covered, there are other issues to deal with, making the window visible first, but that's not what it sounds like your question is really asking...
Related
I am making a data logger for a couple of Arduino sensors in Qt. The problem is that I want to log the data in 3 different graphs, each of one having one specific scale, and then I'll choose what graph I will show (just one of the 3 graphs will be displayed at one time).
I tried something like this:
QCPGraph *sensorXGraph = ui->graph->addGraph();
QCPGraph *sensorYGraph = ui->graph->addGraph();
sensorXGraph->setVisible(false);
sensorYGraph->setVisible(false);
And then, in a slot call from a RadioButton clicked event I did:
sensorXGraph->setVisible(true);
sensorYGraph->setVisible(false);
And the inverse for another RadioButton. But the graph seems to keep the axis of the last graph created. So, if I try to see the sensorXGraph, the data will change accordingly but y axis range will be the one of the sensorYGraph.
I also tried to make a single QCPAxis for each graph, but it started to be a mess because I had to make QCPAxisRect for each graph as well and the result was worse than the first trial.
How do I achieve to change from one graph to another properly?
Thank you in advance.
You can call clearGraphs() on your QCustomPlot and then add whatever graphs you want to display by calling addGraph() and then call replot() on your QCustomPlot. So it would be something like this:
ui->graph->clearGraphs();
ui->graph->addGraph();
// Do whatever you need to do to edit your graph.
ui->graph->replot();
Since you are using a radio button I think that it would be easier to draw one graph and add the necessary data and labels based on whatever radio button has been selected. Hopefully that helps!
I've played with the mouse click event in leaflet using the following code:
mymap=leaflet()
selected_site=eventReactive(input$mymap_marker_click,{
event <- input$mymap_map_marker_click
return(mydt[Long==event$lng & Lat==event$lat,get("sites")])
})
to display a plot from a data.table after a click on a point of the map.
Now, I'd like to select an entire area then display data binding to it.
In other terms, I'd like to select not a couple of (Lat,Long) but a series of (Lat1, Long1)....(Latn,Longn)
Is there a mean to do it in leaflet ?
Thanks in advance,
You just have to instantiate a L.Polygon per area, and attach an event handler to it: http://playground-leaflet.rhcloud.com/zab/edit?html,console,output
Keep in mind that you can make areas transparent (zero opacity but fill option still set to true) and still get mouse events from them.
At the moment when a data point is clicked, all other data points are shaded. Is there a way to prevent this?
fig = fig.circle(x, y)
Ideally, I would like to increase size of the selected circle instead. Is there an easy why to do so?
Update
Seems we cannot change size... according to here:
Only the visual properties of selection_glyph and nonselection_glyph are considered when renderering. Changing
positions, sizes, etc. will have no effect.
However, we can simulate it using line_width property, it becomes more fun if I combine it with line_dish.
As of Bokeh 0.12.15, you can set nonselection_glyph=None when you call a glyph method, for example:
p.circle(x, y, radius=radii, fill_color="navy",
line_color=None, fill_alpha=0.6,
# this is the new part
nonselection_glyph=None)
Concerning the superb iplots package in R:
By default, pressing CTRL and moving the mouse over a point in a scatter plot shows the x and y values of this point. How can I extend this to also show other attributes, which are not part of the plot, as shown here (see Mondrian screenshot) and as asked here, too?
In Mondrian, this works perfectly well by selecting any attributes within the data overview window and then pressing CTRL + SHIFT on a data point in a scatter plot for example. In iPlots, there is no way to select the attributes like this. I thought iplot.setExtendedQuery() is the key. However, there are no examples on how to use the query string.
Selecting a point plus printing the attributes using sth in the veins of mydata[iset.selected(), ] can't be the only way to go...
When making a line chart, Lets say its for business sales for different depts and horizontally is days and vertically is dollars. When you hover over a line it tells a dataTip tells you the sales for that dept. on that day. I want it to show all the depts at the same time, so say you hover over day 3, I want the dataTips for all depts on day 3 to display so you can compare the values for all the sales on the same day. I set the mouseSensitivity for the dataTips to display all the lines at once but I end up getting day 2 for one dept and day 3 for another which is not wanted. This is actually posted as a bug and explained better here: http://bugs.adobe.com/jira/browse/FLEXDMV-1853
I am wondering if anyone can come up with a work-around for this?
Thanks!
I ran into a similar problem to this recently and came up with a solution that also applies to your problem. I had a step LineChart and wanted to display a data tip when the user hovered anywhere on the line instead of just at defined data points.
You can read about the solution I wrote for that problem here: Flex: Customizing data tip location and behavior in a LineChart
You'll have to modify my solution slightly to fit your problem:
On line 47 you can remove the Math.abs(last.y - mouseLoc.y) < 50 check. This constrains the data tips to lines that are within 50 pixels vertically of the mouse.
I'm assuming that you're using the default segment line chart which just draws lines directly between data points. You'll need to modify the code that calculates the line value at a given x-coordinate to work with that chart type. I already find the closest data point to the left of the mouse with lines 33-41 and store it in last. Just get the next data point (which will be the one closest to the right of the mouse) and use something like this to get the value at the mouse:
var slope:Number = (nextPoint.y - last.y) / (nextPoint.x - last.x);
var lineYAtMouse:Number = (slope * (last.x - mouseLoc.x)) + last.y;
var lineValue:Array = line.localToData(new Point(mouseLoc.x, lineYAtMouse));
Then replace lines 69 through 72 with:
hitPoint.x = mouseLoc.x;
hitPoint.y = lineYAtMouse;
hitPoint.xValue = lineValue[0];
hitPoint.yValue = lineValue[1];
I haven't tested these modifications so there could be a bug or 2 but the general idea is there. I hope maybe this is still useful to someone. This question is getting pretty old. :)
Not an answer, but a poor alternative:
You could create your own DataTip renderer that [ahem] mapped the location of every point and drew the tip for each one there.
Basically, you would be duplicating a lot of the code inside the charting classes.
I have the same problem but working on column charts. Was thinking that I could enable the vertical gridLines using backgroundElements and then add a chart event listener for mouse over (which fires when mouse passes over a vertical gridline). Using the localX value, i could compare it to the closest datapoint, maybe.
Brian