display.newText isnt working - text

first time user of Stackoverflow;
Problem: even at the basic level of trying to print out simply Hello world nothing seems to happen.
using this:
local text = display.newText("helloworld", 50, 50, native.systemFont, 24)
print(text)
the varible "text" when printed holds the value of "Table: 010F3E50" which changes on each reload
im new to this language and this is really annoying - Any help would be fantastic
Cheers

Actually, you are trying to print the object. Not the text inside. So try:
print(text.text)
Instead of:
print(text)
Keep coding............ :)

The color of the text might be black by default which might be the same color as the background in the simulator. Meaning it's visible but you just can't see it!
Trying changing the color of the text object by doing this:
text:setFillColor(1,0,0) -- red text

Related

Changing text color on output

I have written a text based game for the class I am taking, but I want to see how I can change certain output text to different colors. Say the villain loses, the text prints out red or something, and vice versa, if he wins, the text prints out in like blue. Do I need to define all the colors first, or is there a way to add it to the string? example:
print('Thank you for playing but unfortunately you lost your life!')
How can I change the output to red text?
is this python?
If so here is a link to a few options python colors
in your case I guess you want to have something like:
text = colored('Thank you for playing but unfortunately you lost your life!', 'red', attrs=['reverse', 'blink'])
print(text)
I'm basing my game off Game of Thrones. Here a sample of the output when the character loses. I'm still working on the story.
else:
print('\nOh dear! You did not collect all of the items!')
print('You were caught by Daenerys and set on fire by Drogon!')
print('Drogon escaped and set the township on fire!')
print('Thank you for playing but unfortunately you lost your life!')
print('You must start over')

ANSI Colors not showing where they are supposed to show

I would like for the entire text that pops up when you use the help() function to be affected by the color code that I used, but instead when I run the script the only part that is affected by said color code is a "None" text below the help() result
print(f'\033[34m {help("for")} \033[m')
This is the single line of code and how it looks in the terminal
The (pretty simple) workaround that I found is to just print the color codes on separate lines
Example:
print('\033[41m')
print(help('for'))
print('\033[m')
That code will make it so the output of the help('for') function has a red background

display.newText wont draw to screen in Lua

Looking through a few questions and answers i still am unable to find out what is wrong...
local myTextObject = display.newText( "Hello World!", 160, 240, "Arial", 60 )
This line of code - directly from the Corona Docs Guide is not displaying any text within my simulator. trying to figure out the problem i created a blank project and copy pasted this code and still nothing happens despite it being the only thing within the file.
Checking through iv used differnt fonts, used differnt methods of handling the string and still nothing will appear within the Corona Simulator - Even updating the SDK still doesnt solve this issue.
What am i doing wrong :S
thanks
local myText = display.newText( "Hello World!", 100, 200, native.systemFont, 16 )
myText:setFillColor( 1, 0, 0 )
Paste this code in the main.lua. Try this out it must work for sure.
Have you tried changing the font color?
text:setFillColor (200/255,0/255,2/255)
You said that you create a blank project so, Im expecting it as a black background, and creating text without changing the font color will make it look that it doesn't show any text

wxpython textctrl change caret colour

I'm using a wxpython textctrl & would like to hide the caret. After a lot of searching it would appear that the best approach would be to simply change it's colour to white. However I can not work out how to do this.
I found the following info:
SetCaretForeground(fore)
Sets the foreground color of the caret. The parameter fore is a wxColour object, a #RRGGBB string, or a color spec like "white". Returns None.
from here: http://www.yellowbrain.com/stc/caret.html#setfg
The code for my current textctrl is below. Any help would be appreciated.
self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL)
Clinton.
You are using a wx.TextCtrl and the link you give is for a wx.StyledTextCtrl. These are completely different animals, and the wx.StyledTextCtrl has a lot more functionality than the simple wx.TextCtrl.
I don't think there's a way to set the caret color in an ordinary wx.TextCtrl.

Is there a way to make a fragment of text within a line bold in nodejs pdfkit?

Node-pdfkit http://pdfkit.org/index.html
I am using nodejs pdfkit to generate a pdf. I want to be able to bold or italic individual words in a line. It looks like pdfkit doesn't support this, so I was wondering if anyone had done something similar?
What would be really useful is to call the doc.text function, but have the document retain it's x position, so that I could do the following.
doc.text('some words then ');
doc.font('Helvetica-Oblique');
doc.text('italic');
doc.font('Helvetica');
doc.text(' then the remaining words');
and see the output:
some words then italic then the remaining words.
Right now it's outputting one line per text function.
Anyone know a good way to do this?
This feature was added by ej4 in this pull request https://github.com/devongovett/pdfkit/pull/60
It hasn't been merged in to the main project yet, so I ended up forking pdfkit myself, and including ej4s changes and a few of my own.
The basic result is that the changes make it possible to add
continued: true
to the options object. Pdfkit then remembers the caret position and returns you to that position for the next line of text.
Please see: Can I mix font weights in the same paragraph when using pdfkit?
pdf.text('Hello ', LEFT, 200, {
//here it is,
lineBreak : false
}).font(bold).text('World!');

Resources