wxpython DataViewIndexListModel Text Wrap - dataview

Is it possible to wrap the text in the cells of the wxpython dataviewctrl? I have some long strings which are making the grid cells very large.

OK I was able to get the cells to wrap by using textwrap in a function called from GetValueByRow(). It seems to work; but, does gives a somewhat strange string of text when editing the cell.

Related

Hiding scale x value in graph editor

Im trying to do a simple animation and the scales x value is constant and i dont need to edit at all. however it still show on the graph editor which would be fine if the handles on the keyframes didnt overlap. its not preventing me from getting the work done but its making it take a lot longer having to fiddle with finding just the right spot to grab the proper handle
Have you tried the "Separate Dimensions" button?
Separate Dimensions
If that doesn't work, you could try tying the property you want to edit (the y-value) to a slider value via an expression, and just editing in the expression.

How to store syntax-highlighted text?

I am creating a simple text editor with syntax highlighting from scratch as a school project. Right now, I use QStringList for storing the text data but later I'll be adding the syntax highlighting functionality and I don't know how should I store the data.
One option would be not to save the color information at all and continuously getting it from the code parser. But this would be probably very inefficient.
Maybe better idea is that there would be some list of structs (containing the color and the string) for every line which would store the color for every word in the text. But I'm not so sure how fast will this be either.
What is the best way to store these data?
Thank you
I'll suggest two methods.
Method 1: Store text with attributes
Change your data structure to a container of structures. The structure would contain a text string and a style variable:
struct Text_With_Properties
{
std::string text;
Properties text_properties;
};
This may take up a lot more space and may not be the most efficient method.
Method 2: Parse for Style Changes
Many editors will display the text in normal font, then make another pass parsing for style changes. For example, when a C++ keyword is found during the 2nd pass, the editor would change its style.
This method does not require any more space for the data, but does require more processing time.
This question is probably too broad. But you could probably use HTML markup. It would give you an easy way to test, as well, as you could open up the output in a browser.

Is there a window setting for keeping a selected passage of text even after the text has been changed/refreshed?

I have a CEdit-Box containing some text, which is being refreshed by a thread every ~0.25 seconds. The problem is that everytime the text is being refreshed, a possible selection of text is being erased.
I found 2 ways to avoid this so far:
My implementation right now (1) :
Use quite a passage of logic in order to assure that the text is actually really changing, and not just refreshing itself with the exact same string. This is kind of avoiding the problem, but it feels very clunky to be honest.
Another idea (2) :
Every cycle, before the text is being refreshed, we need to grab the selection we currently have, store it, and try to reconstruct it after our text has been refreshed. However, I don't know how this would turn out if the new text doesn't contain our old string at all. I guess the functionality is implemented in WTL, but I don't think this is a very good approach.
Is there any other way? Something like a control setting which would do something like this?

Using different fonts/attributes in QTextEdit

I have a problem with displaying a text to area with different attributes.
My project has a multi-threading build. I reach to GUI text area by using signal-slot mechanism. I put my texts to the text area like this;
addrMW->ui->printerArea->appendPlainText(command.Data);
I want to append my text to this area with different font, size, etc..
I'm using Qt Creator 2.7.2 / Qt 5.1. Could someone explain this to me with an example?
What you want is a rich text edit. Luckily QTextEdit is able to handle that. Check the acceptRichText property (which should be true by default).
Then the methods you're looking for are:
setCurrentCharFormat
setCurrentFont
setFontFamily
setFontPointSize
etc...
Then, instead of appendPlainText() you should use append() to add text to the QTextEdit. Also see this Q/A. As proposed in the accepted answer, you can also use html formatted text instead.

Display tooltip for a selected word

I'm writing a simple text editor using Python 2.7, pyqt library. I basically want to display the meaning of a word when the user selects the word in the text editor.
So far I can detect the word under the cursor, look it up in my dictionary and return the meaning (using a print statement) so I know I can get the guts to work.
My trouble is displaying the meaning of the word in a tooltip that doesn't dissapear in less than 2 miliseconds. So far I have been using this:
QtGui.QToolTip.showText(QtGui.QCursor.pos(), tool_tip_text)
Ideally want to show the meaning just over where the selection was made, so far this displays the tooltip so quickly that I can't even read the meaning of the word under the cursor. It just pops up and dissapears almost immediately. Can anyone share how to make the tooltip remain visible for at least 5 seconds, or until the user de-selects the word.
I am not using the QHELPEVENT (not even quite sure how the helpevent is triggered) I am just calling my lookup_word_in_dictionary() function when a word has been selected.
Any samples are much appreciated.
Thanks, I found a solution, creating my own popup class, subclassed from QWidget
and used a simple timer to hide the tooltip
QTimer.singleShot(5000, self.hide_tooltip) #check to see if the tooltip shold be hidden after 5 secs
you can replace QToolTip by QSplashScreen,if you are Chinese ,please look at this post .
BTW , can you share the method that you detect the word under the cursor with me ?