I am still working on my text editor, and now I want to make it run faster. So I thought I may somehow get currently visible text, and parse it as I want. So is there a way to get currently visible lines?
P.S. Or maybe there is another way to increase StyledTextCtrl's performance? Thanks.
Use GetFirstVisibleLine() to determine the first visible line. Lines are numbered starting at zero.
Use LinesOnScreen() to determine how many lines are visible on the screen.
You can use GetLine(line) to get a string of an individual line.
Related
I plan to use colab notebooks to teach my pupils (12-13 year olds) Python. We will start with using input() and display with print() to ask simple questions and display the answer.
One problem I have come across is when I use input() in a code cell with an input string a really long input box is produced (in the output area) to get the input value. It is so long that the window scrolls to the end of this empty input box, and you have to scroll back to read the question, even when the window is at full screen width . This is really strange as the input box is completely empty does not need to to be bigger than the window or frame.
Are there settings I can change to prevent this or can I do something with the css to reduce the size of this input box?
This may seem a trivial problem, but little things like this can be distracting and add to the frustration of learning the language so I would like to prevent it if I can.
I have attached a picture that shows the problem.
picture that shows the problem.
I looked at the problem you are trying to solve. Colab fits inside my window perfectly when I size the window to full screen. I think this might be a problem with your browser. Are you using the latest version of Firefox or Chrome?
I just encountered the same problem. For me, it was because I was plotting a graph using the matplotlib.pyplot library before prompting for the input. After I removed that, it worked just fine.
Let's say I'm on line 500 in spyder, and I want to run everything from that line and above (lines 1-500), is there a shortcut to select the lines quickly. Right not I'm highlighting the lines and scrolling up and using shift and up arrow but both of them take some time to scroll. Is there a faster way to select, similar to select all but only for the specific lines 1-500?
(Spyder maintainer here) The easiest way to do what you want is by creating code cells. These are sections in your file separated by comments of the form # %%, which can be run independently by placing the cursor inside them and pressing the shortcuts Ctrl+Enter (run cell) and Shift+Enter (run cell and and advance to the next one).
Please refer to our documentation for more details.
This post is old I know, but I found out that CTRL-Shift-Home doesn't work for me.
I have to use CTRL-Alt-Shift-Home to select everything above the line or -End for everything below.
This is for Windows 7 and Spider 3.3.6
Just in case someone is interested in deleting all the lines, and only find this question after searching, the easy way would be using
'''
for all the codes between the two lines, and then use the triangle on the left to suppress, so you could delete in one go.
This is a simple problem with a potentially simple solution (maybe there is a plugin that will help or a better way of working with the tool).
I have a large Python file with many function definitions that look very similar. Each definition is a few hundred lines long. When I'm trying to make sense of a few lines of code I often want to know which function definition those lines of code belong to. My current method for doing this is scrolling back up the file (I'm using PyCharm) until I reach the start of the function definition. This is tedious and time consuming. Is there a better way of determining which function I am currently viewing?
There is a method called Context info (found under View menu) and bind to CTRL + SHIFT + Q on OSX and ALT + Q on Linux. It will flash you the current class, function, etc, parents of the current cursor position at at the top of code editor.
(Basically it shows the same line if you would scroll up manually).
Press Ctrl-Shift-(Numpad Minus). It will collapse all the functions, putting your cursor back to the start of the current function. Then press Ctrl-Shift-(Numpad Plus) and you will get back where you were before. Or you can use Ctrl-(Numpad Minus) and collapse only the function you are in now.
Taking the following code: http://eli.thegreenplace.net/files/prog_code/wx_mpl_dynamic_graph.py.txt which is actually the second code example that we can find on
http://eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis
I want to add some text on the user interface to show the current iteration at each step. Something like the following example. How can I do that ?
What you probably want to do is add that to the on_redraw_timer method. It appears to fire every time the plot is updated, so I would think that that would be where you'd want to write to your text control as well.
Just make sure you stop writing if it is paused.
For a Python3/PyQt4 project, I'm looking for the fastest way to change the text appearance of several words in a QTextEdit object. The text is not written in HTML (it's a pure text string), is read-only and is made of several words. Each word has a special 'attribute' defined in my code, defining its appearance when this word is hovered over.
The appearance of all words sharing the same attribute must change when one of these words is hovered over.
I need speed since :
I did more or less the same program but the the words' appearance changed when the user clicked on them and I guess my code is too slow to be used with hover events. (see details below)
It's a Python project based on PyQt4, not a C++ one based on Qt.
Any help would be appreciated !
MORE DETAILS :
I can see two ways to achieve my goal :
(1) Write my text in the editor, detect which word the mouse "flies over", get the other words to be highlighted and painfully select them, one by one, inserting some HTML code to modify their appearance. It's the painfully part that I find too complex and too slow : is there a fastest way to do this ?
(2) Writing my text as an HTML one and work with the CSS since a QTextEditor can use them. Alas, the easy way can't work. But perhaps is it possible to "re-load" the CSS of the text and use a more clever trick ?
I'm wondering is it even possible to get the word under mouse cursor from the QTextEdit.
You said the text cannot be edited, so I maybe the QTextEdit is not the best possible widget for this job. Create your own widget and draw the text by yourself. Then you know the word positions so finding the word under the mouse is easy. And when some attribute is activated or deactivated, you can redraw only the affected words.