In itorch notebook, Is there a way to clear the output of a cell with code?
What I would like to do is to dynamically display the progress, like a loading bar.
The reason for this is when a lot of computation is involved, I would like to track how far the progress has gotten, and whether it froze or not.
So basically I would like to print the number of iteration I'm in in percentage form and overwrite it in the next iteration.
Any ideas?
You can use the carriage return character (\r) to overwrite the same line in a cell.
For example:
io.write("Hello") -- No newline
io.write("\rWorld")
just displays
World
You can use this to write several times the progress of your process, without adding multiple lines.
Related
So, it's kind of a simple styling.
Text(
text = "some text which can extends to many lines"
)
how would someone build an annotated string to style only specif lines of the text? And by line I mean what it's actually rendering as a line - and not something predefined as a list of sub strings.
I've imagine to make a use of combined textLayoutResult with the annotated capability, but by reading the documentation I don't have much clue how to do so.
The plan was to the TextLayoutResult to retrieve the number of lines rendered on text. Then, it should be theoretically possible to retrieve the sub string on each of the lines rendered. And by pushing them on the annotated processor, the desired results would be achieved.
What am I missing?
I've managed to achieve the desired effect.
For those who want to do, you will need at least:
Two Text components;
A mutable state to keep track of offset on the text;
You limit the first Text by the number of maxLines - 1 and uses TextLayoutResult to retrieve the last offset of the last line. Then, you just update the state on the composable and create another Text component with the substring which starts from the last one. Then, you can apply the filters that you wish on this one.
Repeate the process for as many lines as you wish.
Looking for some help or to be pointed in the right direction. Been stuck on this for a while and the main issue is I don't even know where to start. I am sure there is a solution but my brain will not see it.
To use as an example I have a table that shows monthly results for multiple different areas:
What I want to do is in the gap along side each number is show an increase, decrease or no change, using up arrow down arrow and square. That I can do using conditional formatting my issue comes with the fact that I also want it to be multiple Colours. So it will take into account increase and decrease and whether they are in target.See below:
Atm I am copying and pasting each month. But having it automated would be amazing. The outcome would hopefully look like this:
I am hoping there is a way that I can do two things compare to the previous month and then check it against my table to see where it sits then display the appropriate symbol.
Thank you in advance for any help or a place to start.
So extremely easy to figure out once I looked at it in a simplistic way.
Firstly, I used: =IF(-SIGN(E26-G26)= 0, "n", IF(-SIGN(E26-G26)=1, "é", IF(-SIGN(E26-G26)=-1, "ê","")))
To compare the current number to the previous number and get a 1, 0 or -1 depending on if it had gone up down or stayed the same, using this it either displays é, n or ê. I then set the font on these cells to Wingdings. so they become up arrow, down arrow and a square.
Then I use conditional formatting to colour it based on the adjacent cells value.
No need for a long, complex formula
=IF(A2>A1,"t",IF(A2<A1,"u","v")) - set the font to Marlett
When typing "? something" (or "describe(something)") in Maxima the output scrolls off the screen and one has to manually page up and down to read it. But, for example, in Sage it is paged through "less". Can I somehow configure Maxima to do the same, i.e. page the help text through "less" (or "more")?
I'm dynamically loading a file that will indicate when to show certain words at certain frames. However, I'm having trouble with the concept of timeline control from ActionScript (I'm building everything programmatically in Flash Builder). Let's say my tuples has frame and word:
5, "duck"
13, "cow"
22, "pig"
There is a sprite associated with each. What I would like to do is something like the following:
for (frame in timeline) { //should iterate from frame 0-22 (last frame in list)
if (frame in list) {
list[frame].alpha = 0;
}
}
I already know that my display of sprites works and whatnot, I'm just confused on how to play through the timeline in this kind of way, or if it's possible to dynamically do this.
EDIT: Related, can I control how fast the timeline plays?
EDIT: To give a more thorough explanation, I'm looking to visualize word appearances over time in a text. So "duck" may appear as the 5th word in a corpus, "cow" as the 13th word, etc. My list contains tuples of word positions (unique) and the word that appears at that position. I have a small selection of words that I'm interested in from the corpus, so not every position is represented. I would like to be able to have a SWF movies that essentially starts at the beginning of the corpus, go through my word list in order of appearance in the corpus, and then display the word (and have it fade out). So, if there's a word at position 5 and 10, then should appear in much more rapid succession than if there's a word at position 15, and the next one doesn't appear until 50. Basically, I would like to keep that temporal component.
I'm having a little trouble understanding exactly what you're asking about, but in general for controlling the timeline use the commands play() stop() gotoAndPlay() gotoAndStop()
Beyond that I'm gonna need you to explain more clearly what exactly you are trying to do.
ADDITION: From your edits it sounds like you simply want to trigger an animation when the user clicks a button or something. So make the animation in Flash and then use the commands I listed to play it.
ADDITION2: If however you definitely want to do this in code then that has nothing to do with the timeline; program the fading in and out using a tweening library like http://www.greensock.com/tweenlite/
Is there a way to draw a long text on the screen using SpriteBatch.DrawString? I mean inserts new lines when comes to the end of the screen.
I'd suggest looking at XNAwiki - TextRendering.
Inserting new lines is something you'd have to calculate yourself it's not something you an do automatically with the XNA framework, but yes it's possible to write code to do that.
One way to do it would be to take the string want to write and to move through it a word at a time an measure it until you get enough words to fill the width of whatever area it is you want to fill. Once you've found that width, you'd either change the Y Position of the string you want to draw and move onto the next line or insert a new line character into the string at that point and start calculating the amount of words that should be on the next line.
A thing to pay attention to is that string manipulation is expensive and generates a lot of garbage so you should try and minimize the amount of times you do something like that. If the text is static and never changes it would be ideal to do this one and never again while the game is running.