I am developing an application in R Shiny. One of my modules in the application, displays dynamic text depending on user inputs. I would like to display the text as bullet points and additionally would like the text in "strong" or "heading" format. I can do this individually but somehow I am not able to figure out how to combine the 2. So assuming that my function returns a character vector a, with 2 components that I need to display, I can do the following:
HTML("<ul><li>",a[1],"</li><li>",a[2]) #To generate bullet points
HTML(paste(h4(a[1],a[2],sep=''))) #To concatenate and change format to heading
Now my question is - How can I do both (display as bullets with heading format)? I tried different combinations but it's not working.
Secondly, how do I change the colour of my text?
Any help will be greatly appreciated.
Thanks!
To get a bullet list with heading format, you can just add an <h4> tag to the paste. Also, make sure you close all the tags you open, for ex:
HTML("<ul'><li><h4>",a[1],"</h4></li><li><h4>",a[2],"</h4></li></ul>")
You can use inline CSS to change the color, for ex:
HTML("<ul style='color:red'><li><h4>",a[1],"</h4></li><li><h4>",a[2],"</h4></li></ul>")
More info here.
Related
I'm currently working on a non profit project where I need to reformat the way the data in the rows displays.
At the moment, this is how the row data looks:
Save The Children (Donation)|10.00{0}{2}
And I need it to output like this instead:
donation_id:save_children|quantity:1|total:10.00
The first problem is sometimes there's multiple items within the row:
Save The Children (Donation)|10.00{0}{2} / Save The Forrest|15.50{0}{2}
In which case it would need to be separated by a semicolon:
donation_id:save_children|quantity:1|total:10.00;donation_id:save_forrest|quantity:1|total:15.50
The second problem is, we have 9 donation variables/causes, each needing to convert the output to a different "donation_id".
So every time it finds:
Save the Children, it needs to convert to: donation_id:save_children
Save the Forrest, to, donation_id:save_forrest
Save the Animals, to, donation_id:save_animals
And so forth.
And the third problem is that the donation amounts are variable (as people donate whatever they wish), so the "total:" dollar value that we ouput will often be different.
How would I go about doing this with the regex?
Thank you
You can use below regex
(Save) The (Children|Forrest|Animals).*?\|([0-9]+\.[0-9]+)\{0\}\{2\}([\s\/]+)?
substitution/replace with
donation_id:$1_$2|quantity:1|total:$3;
When I test for
Save The Children (Donation)|10.00{0}{2} / Save The Forrest|15.50{0}{2}
Output is
donation_id:Save_Children|quantity:1|total:10.00;donation_id:Save_Forrest|quantity:1|total:15.50;
Test it online!
I'd like to write some text on a world map pointing to several locations. The text to be written for each location is short, a few lines, with one or two words/numbers (i.e earthquake magnitude, location, date). Is there a pythonic way to perform this?
Since matplotlib-basemap is based on matplotlib, you can simply use
plt.text(x,y,'yourtext')
to write text onto your map. If you want to have it boxed, add something like:
plt.text(x,y,'yourtext',bbox={'pad':10})
See also http://matplotlib.org/users/text_intro.html.
I have a dataset in which 1 column has the tweets and other column has labels for the tweets. My problem is I want the html links present in the tweets to be removed for example
RT #AmDiabetesAssn: Know what’s scary? These #diabetes statistics. Spread awareness this November for #DiabetesMonth! http://t.co/qIiiSc4ozZ
I have a tweet as given above i want to remove(http://t.co/qIiiSc4ozZ) and want the output in this way, for all the strings.
RT #AmDiabetesAssn: Know what’s scary? These #diabetes statistics. Spread awareness this November for #DiabetesMonth!
I have seen many examples and tried those but couldn't get the desired result. Please help. Thanks in advance.
I tried this, which should work for any links that don't have spaces in them:
for tweet in tweets:
print re.sub(r'http://\S+\s?','',tweet)
I assume here that you've got a bunch of strings in the tweets array that represent the first column that you described above (also that you want them printed). You should be able to modify to suit the iteration pattern you're using.
I've got a GtkHBox with 2 items. Inside that, on the left, I have a GtkHBox with 4 items. The first two are GtkEventBox's, followed by a GtkHScale and finally a GtkLabel.
The two GtkEventBox's each contain a GtkVBox with two items, an image and a label (using the GtkEventBox so that I can catch click events on the image). Unfortunately, I can't seem to figure out how to set the width for them. Currently, it looks like this:
But I want the Select and Pan sections to be much narrower. Any suggestions?
Make sure to pack the event boxes into your GtkHBox with the expand and fill parameters set to false.
I am trying to simulate a piece of hardware, and this hardware has a static ribbon display.
to do this, I'd like to use a TextView. My display has 10 rows, with 25 columns. So I figured that a TextView should be easy enough.
basically, I would like to be able to say "insert/replace string S at row X, starting at column Y". i may need to only update a specific row, or even a single column within a row.
I have not been successful at getting this to work though. the best I have been able to do is to fill the TextView with 10 lines of 25 spaces when i create it, and then use the get_iter_at_line_offset to get the iterator of a line, and then push the new text onto that line.
but this will start appending text to the line, rather than replacing the existing one.
I need both row and column control (i.e. need to be able to set text at a specific (X,Y) coordinate).
I'm assuming this is somehow possible using marks.
Can anyone give me a quick example of how i can do this? Unfortunately, there isn't a whole lot of documentation on this sort of thing.
You'll have to get an iter at a specific line, row X, and then use the iterator's forward_chars() method to move forward Y characters. Then delete the number of characters you are replacing, and finally insert the text you want to insert. You can do it all with iterators, I think - iterators are invalidated when you change the buffer, but when you delete text, one of your iterators is revalidated to point to the place where the text was.
If you're targetting GTK+ 3.x, you should really look into using Cairo. Since you don't actually need a text buffer, it seems like overkill and a bit of a mis-alignment to use the GtkTextView.
Look at the very basic introduction on how to draw with Cairo in GTK+. Then look at the text-rendering Cairo APIs, that should be enough to get you started.