question on Trigger and updating of Manipulate expression - wolfram-mathematica

Experts,
I can't figure out why the Manipulate expression is being evaluated 2 times each time I click on the 'StepRightButton' which is part of a Trigger control.
When I click on the '+' button, I see the counter going up once as expected, but the expression is being evaluated 2 times, not one time as expected. Here is a small example
Manipulate[
Show[
Graphics#Text#Row[{currentTime," ",Date[]}],
Plot[Sin[x],{x,-Pi,Pi}]
],
Control[{{currentTime,0,Style["run",10]},0,100,0.1,
ControlType->Trigger,DisplayAllSteps->True,ImageSize->Tiny,
AnimationRate->Automatic,AnimationRepetitions->0,
AppearanceElements->{"PlayButton","PauseButton","StepRightButton","ResetButton"}}
],
ContinuousAction->False,
SynchronousUpdating->False
]
again, clicking on '+' shows the 'currentTime' variable is being increased by the correct amount (0.1 in this example). But my question is, why is the expression being evaluated twice by the evidence that the Date[] printed can be seen to increment 2 times per each click on '+' button.
This causes me problem, as I was assuming the expression will evaluate once per 'tick'.
Is this a way to make sure the expression is evaluated once each time I click on '+' once?
thanks,

This can be solved by adding the option PerformanceGoal -> "Quality" to the Plot function.
During the display of manipulated items a lower fidelity sample of the object can be shown depending on the PerformanceGoal setting. A higher fidelity version is drawn at the end of the manipulation, if necessary. It is this later redrawing which seems to be causing the problem here.

Related

Nightwatch - Meaning of WaitForElementVisible and WaitForElementPresent

Im using Nightwatch for e2e and Im finding these two command a little bit confusing given the name and explanation that comes with them.
.waitForElementVisible:
Waits a given time in milliseconds for an element to be visible in the page before performing any other commands or assertions.
What is the meaning of visible?
An element position in the footer, you need to scroll to see it, is it considered visible?
Does it mean visible in the DOM even if it is display:hidden, position:relative; left:20000px;, ...? Not actually visible for a user but dom is existing basically.
What is a modal view in on top of some content? Is it visible?
.waitForElementPresent:
Waits a given time in milliseconds for an element to be present in the page before performing any other commands or assertions.
What is the meaning of present?
Existing in the DOM without taking into account if it's visible or not?
Is there any relation/implication between these two command?
If an element return truth for .waitForElementVisible does it imply that .waitForElementPresent will return true?
A lot of questions but maybe an explanation about how they work would solve all of these small questions...
Sometimes Im just getting errors and Im thinking that it might be my bad understanding of these two commands.
What is problem with definition ? You already answer your question.
An element position in the footer, you need to scroll to see it, is it considered visible?
No,you dont need to scroll to check it visible or not.May be you do need with some command but not with these visible/present commands.
Does it mean visible in the DOM even if it is display:hidden, position:relative; left:20000px;, ...? Not actually visible for a user but dom is existing basically.
Yes,it exists(means present) in the DOM but for some reason it is not visible yet
(bad connection,attribute value,...).
If an element return truth for .waitForElementVisible does it imply
that .waitForElementPresent will return true?
yes it will, if an element is visible = > it is present.
For usage , you can check out my an example answer here,it might help .
Login timeout
Basically an element might be present (as in loaded in DOM) but not visible (e.g. out of view so you might need to scroll to see it, or it might be hidden).
If you want to perform an action like a click on an element then you want to be using 'visible'.

parentheses around a formula result

How do I display the results of a formula -- e.g. "=(a1/b1)" which might return "45%" -- so that the result is surrounded by parens and appears as "(45%)"? Putting parens around the formula -- e.g. "(=(a1/b1))" -- doesn't work.
Do you mean in Excel? you can just set the format of the cell. how it should show the result.
Just right click on the Cell then format cells and then chose percentage on the left hand side. then change it to custome and put some parentheses arround the result. thats it ;)
Depends on the language you're using.
If =(a1/b1) works to give you "45%" then I would trying this: "(" + =(a1/b1) + ")"
I know this is an old thread but I thought it might be of interest for others as well.
To clarify the answer since it did not work for me when I tried it. In order to put the result from a function/formula within two parentheses in the same cell you need to use this function:
="("&(Cellfunction)&")".
In your case that would look like this:
="("&(A1/B1)&")".
If you have the same problem as the one asking the question, try copy/paste this funtion into a blank cell in a new sheet in Excel and type 1 into cell A1 and 2 into cell B1.
When using the funcion in the blank cell (for example C1) the result should be 0,5. This function also works for displaying parentheses around a returned answer. For example: Cell D252 displays the result from Cell C7 (C7 could have its own function/formula). That's how I used the function which looked like this:
="("&(C7)&")"
Hope this helps,
Best,
Felix, Business administration student in Sweden
I'm using Mac and Excel for Mac Home and Student 2011.

Complex ajax search / comparison form

Firstly this is more of a design / interface type question, so has no right / wrong answer, but I would appreciate peoples opinions on this.
I am creating a comparison site, and I am unsure how to proceed with the search interface. There are going to be lots of fields, and each field will potentially have many values. Some of these fields will condense the values by using a slider, but others will need a checkbox for each value available (as multiple values may be needed).
When you change any field, it will automatically update the results below, and each fields options to show whats left to filter / search.
Now I had originally intended to have the top 5 search fields visible at the top of the page in columns, and limit those fields to the top 5 most frequently occurring values. Each field would have a show more to expand the options, and there would also be a show more fields button to expand the search even more.
When fully expanded, this definitely has the capability to fill a good size screen resolution. Obviously it has the option to minimise the form again, and the results will be shown underneath, but has anyone got any ideas how this can be layed out?
We have toyed with having all the search options in a side bar, but there are so many you would probably have to scroll down a full page height 2 or 3 times to see everything which would get annoying. Clicking the max / minimise button would definitely be easier in my opinion.
A few examples but in reality are not as complicated as what we need are:
http://www.autotrader.co.uk/
http://www.holidaylettings.co.uk/homesearch.asp
Any good examples / ideas?
Ended up just having it have the 5 most important fields, with the less important options hidden, then you can show more options, and show more fields.
Simples :)

Reset ItemNumbered

I know there must be a simple answer to this but I've looked and looked. Suppose I form an ItemNumbered list at some point in the notebook. Then at some other point I want a new ItemNumbered list starting with number 1, but without resetting the original list. At present when I try to form the second list it always starts with n + 1, where n is the total number of items in the prior lists.
I've tried the Insert without luck. Help, please.
This behavior is subject to change in future versions of Mathematica, but for now you can use the CounterAssignments option to Cell to reset it for a particular cell, and then it applies to that cell and subsequent cells in the notebook.
Use the Option Inspector or directly edit the Cell expression ( Cell > Show Expression in the menu) and add the option, e.g.:
CounterAssignments -> {{"ItemNumbered", 1234}}
Note that the counter will be incremented if it is displayed in that same cell, so if you want to start numbering at 1, start your counter at 0.
Hope that helps!

Idioms for a three-state toggle?

I have a table column where each row has one of three states, and the purpose of the row is to offer manipulation AND display of this property with three states.
My current development view is to have three tightly packed radio buttons with labels at the head of the columns (and every 50 rows or so) and onClick they send an AJAX request and thar she blows.
This is fugly.
Is there a standard idiom for a control like this? I'm currently mocking up something similar to the iPhone on/off toggle, but with a "middle" state.
Any input would be welcome.
EDIT
A bit more clarification: I have a tool for confirming events. Each event is either "proposed", "cancelled", or "confirmed". They all default to "proposed" until someone explicitly confirms or cancels them. This is a thin front-end for a SQL table.
I've seen this handled with image buttons that remain "depressed" when you click while popping the other two out. They act like radio buttons except that the label and the state are merged. If your names are too lengthy to fit in a button, you can abbreviate them and provide a key. I'd also give each one a distinct color. For implementation just pop the value in a hidden form field on click.
These are called "Toggle Buttons" in some other UI's:
http://java.sun.com/products/jlf/ed2/book/HIG.Controls2.html
http://msdn.microsoft.com/en-us/library/dd940509%28VS.85%29.aspx
http://developer.gnome.org/projects/gup/hig/2.0/controls-toggle-buttons.html
The standard mechanization for things like this in military avionics, where screen space is always at a premium,and so are buttons, is a "rotary". Each time you click it, it steps to the next value in sequence, wrapping around.
As an example, a device with a cryogenic cooler might have three states: OFF, WARM, and COOL. Initially, the device is OFF: no power applied. Click it, and it switches to WARM, meaning power is applied, but no cooling. Click it again, and it starts the cooler. (Since cooling in this kind of thing is usually supplied by a gas bottle with a strictly limited capacity, you don't want to cool the device until you are getting ready to party.) Click it again, and it shuts the device OFF.
You could also do this with buttons or hyperlinks. In a big table, hyperlinks will probably look best.
In the Proposed state, your cell could look something like this (with underlined links, but the editor won't let me):
Proposed Confirm Cancel
In the Confirmed state:
Confirmed Undo
In the Cancelled state:
Cancelled Undo
This will take two clicks to get from Confirmed to Cancelled and vice versa, but I assume that this operation is rarer than switching between Proposed and one of the other two.
Perhaps display arrows on either side to change the state:
(Cancelled) <| Proposed |> (Confirmed)
These may or may not 'wrap' depending on how well that suits the values and how important it is to saving a click when transitioning from value 1 to value 3 (or vice-versa).
As an alternative to you radio buttons, you could consider a drop-down list with three options. The disadvantage is, of course, that two clicks are needed to change the value.
Maybe use a slider with three states? (It really depends on the exact situation!)
Consider a fixed-position slider with three positions, such as offered by jQueryUI: http://jqueryui.com/demos/slider/#steps
I am reminded of the permissions button in SQL - it has multiple states; green check, red x, no setting, and clicking on them cycles through the three states. Its ok but annoying if you want to change a bunch to the state reached second, and if you click too many times you have to go through it all again. Left click - cycle forward; right click - cycle backward might work but certainly has no basis in UI expectations.
Idiomatically, I would say a Stop Light (red/yellow/green). They could behave like radio buttons; darker toned for 'off' and lighter tones for 'on', and since the color gives a cue you can move the description to a mouseover label. Of course, it isn't RG Colorblind kosher, so depending on your application that may be a deal breaker. (also, it may be confusing on Mac where the minimize/close etc buttons are the same color scheme).
Why not use three boxes that look like the "Questions", "Tags", "Users", ... boxes on this page (could be implemented as links, buttons or whatever)?

Resources