I want the user to enter something in the TextBox, and if he exits the program and returns to open the program again at any time, he finds that the words he entered are still there.
(Python programmers - Save Dialog- tkinter )
If you want to save the state of the program, you could save it in file, in a database, or put your data in one place and use pickle. And at least reload the state on program start.
Related
I have a translation application for a niche language.
If the user selects/highlights text (typically in the browser) I want the translation func to get triggered. It manually checks and if the language is detected it translates.
I do have my onMouseUp Listener that triggers. However I don’t know how to get the selected text, how to put it into a variable (without triggering ctrl+c and possibly overwriting the users clipboard)
Iam not sure what I am trying to do is possible.
Is it possible to get the users selected/highlighted text in an other app (browser), without triggering ctrl+c and clipboard?
Used pyperclip package however since it uses clipboard it overrides the users current clipboard text which might be important to the user.
So it is not a problem for you to use the clipboard, provided you can keep the old clipboard -- right? So would it be possible for you to save the old clipboard first. Do whatever you want to do and then later restore the clipboard?
Some ideas when using Windows: How do I read text from the clipboard? From there specifically this one could help gross-platform.
When I was programming in Mindstorms Robot Inventor, and decided to put an input in my code, I bumped into this NameErrorThis is the Error
Is it Even possible to put an input in Mindstorms??
The Python available isn’t the complete Python standard library. The terminal view in the code editor doesn’t provide for a way to put in input either, so unfortunately no.
What you can do instead is use the buttons on the hub as a type of input. This wouldn’t be free-form text, but if you’re using input() as a user-controlled wait before progressing, you can do that.
_ = hub.right_button.was_pressed() # clear out any button press
while not hub.right_button.was_pressed():
# do something
# do something after the button was pressed
You can string multiple of the above in a row if you want to do multiple actions separated by waiting for you to let it continue, or even take different actions based on which button was pressed.
Finally, you could do a very slow text input using the buttons and the display screen to scroll through the alphabet, confirm the letter, and finish the input.
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.
Hi,
I am working on a project and I am monitoring the keyboard with the keyboard module.
My application works in real-time (on-the-fly) and read strings entered from user (with the keyboard module as mentioned)
What I want to do is hide user input when some specific conditions are True.
I have searched all the web and didn't manage to find something that does what I want.
To give it a more detailed explanation lets say that the user enters some text and this text string-by-string is being checked for some condition from my program.
If everything is OK, then nothing happens but if not, then I want the next user input not to be shown in the position he is writing.
I found solutions that do exactly this in the terminal like the msvcrt module (How to temporarily disable keyboard input using Python ) or do the above functionality with the input() function.
Is there something that prevent the text ,entered from the keyboard, from showing to the screen, but send it to a buffer for editing first.
Thanks in advance.
! I am on windows
I am working on a Reset button. The button is supposed to clear the text that is generated in a Text Widget and delete the file that the data was being written to. Clearing the Text Widget works, but I am having problems deleting the file.
When I try to delete it from windows, it says that it is still open in Python. So, I closed it from my code first, and then tried to delete it but didn't work.
I have programmed the other button so that it doesn't override files. So, I can't just delete the data that is already written in the file.
Is there any way that I can force the deletion of that file??
I am using Python 2.6.6.
This is my code on the reset button:
def reset_it(self):
self.run.update() # run is the other button, I have to stop it's processing!
self.Outputlines.update() # Forcing the TextWidget to update.
self.Outputlines.config(state=NORMAL)
self.Outputlines.delete(1.0, END) # Clearing everything from the TextWidget.
self.Outputlines.config(state=DISABLED)
self.run.wait_variable() # Stopping the run button.
self.infile.close() # Closing the file.
os.remove(self.filename.get()) # Code to delete the file.