Writing a text on the user interface using wxPython - python

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.

Related

Code to listen for changes in a pywinauto Listbox

I'm using pywinauto to interact with the window of an old game - specifically the dedicated server GUI. I've been able to connect to it with:
app = Application(backend="uia").connect(path=r"C:\Program Files (x86)\___.exe")
Using a loop, I'm able to read each line in a Listbox in a specific window using:
for i in dlg.ListBox.descendants():
print (i.window_text())
The Listbox behaves as like a console output area and I've also been able to write commands to the Edit (input) field which appear in the Listbox.
All of this is great considering I didn't think it would be easy at all!
However, the last part of what I'd like to do is proving more difficult...
I want to listen for changes in the list box so I can react to them and write different responses back into the Listbox. So for example, when a player joins the server, I want my code to know that a new line has appeared in the Listbox (so I can write a custom welcome message to the Edit field).
I have tried to look at listener scripts but I feel a bit out of my depth and can't seem to find a simple code example that could help me accomplish this. Does anyone have any ideas where I could look or what I could use?
Even better... would anyone be able to provide some sample code for me to re-work?

Block Windows clipboard from user with Python while Program running

I want to make it impossible for a user to copy data to the clipboard as long as my program is running. How would I go about to do that in Python ?
You could simply render the text as a graphic.
This way selecting text would not be possible.
I have to point out, that stuff like this is always a bad idea, and if the user wants to get the text, he will.
In the past I used screenshots with OCR to get texts.
It's not worth the effort, and in most cases doing stuff like this will just result in the user not wanting to use your program.

Opening up a Drop-Down-Menu Tkinter

I have been implementing in a drop down menu (offically called a "Tkinter.OptionMenu") inside my application, that once clicked open will allow users to skip to certain parts of the form (like skipping to a certain chapter of a book/play). I want to be able to OPEN that drop down menu on an event i.e with code however as much as i have searched, it seems the very best i can do i to do a .focus_set() which is better than nothing, but all it does it place a faint outline around the widget. I would like it to fully open it up, just as if the user had clicked on it.
I'm pretty sure that i'm missing something simple, but help would be appreciated :)
Edit: Yes, i do have good reason to programatically open it, and even if i didn't it would still be nice to find out. I do not need access to the functions the list gives, but rather, i need the user to pick something from that drop down, and so i would like to open it for them

How do I automatically find out the name of the function I am currently viewing in PyCharm?

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.

wxPython - StyledTextCtrl get currently visible lines

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.

Categories

Resources