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.
Related
I am trying to develop a script in Python 3.7 using Appium in which I want to enter any text in the text fields using the keyboard opened by the app. Is there any way to type the text using keyboard without using send_keys method in appium.
I am also not sure how send_keys works internally, whether it only works when the app keyboard is opened or its just simply enters the text without keyboard opened.
I would prefer to type the text, character by character, using the keyboard of the smartphone.
Actually, this is not a good idea because there is no way to touching keyboard keys as an element. I mean the appium cannot see the keyboard as elements. Also, you will need this if you only want to test the functionality of the keyboard itself. Otherwise technically element.send_keys() acts the same with no difference on std-out. Also, element.set_text() act the paste if you want.
Anyway, to reach this you should:
1- Open the keyboard by clicking on the input field
2- Find the coordinates of the keys and store them in a variable.
3- Touch the coordinates directly.
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
Is it possible to use tkinter to stop a user from clicking off my application. In other words making my program the top level program at all times?
The concept you are looking for is called a "grab". Tkinter supports grabs with several methods.
To do what you want requires a global grab, which effectively freezes your entire display except for your specific window. This is very dangerous since you can easily lock yourself out of your own computer if you have a bug in your code.
For more information, read about grab_set and other grab commands here: http://effbot.org/tkinterbook/widget.htm#Tkinter.Widget.grab_set-method
So I have this script for controlling an LCD plate where I want the backlight to change every time you press a button, but also want to do other things as well. Currently this doesn't work and it doesn't display the messages I want it to.
This is the change backlight bit of code:
while True:
for b in btn:
if lcd.buttonPressed(b):
lcd.backlight(col[randint(0,5)])
And then I want to go on and run a bit of code that prints a string to the lcd and stuff, in this way:
lcd.message("This is a string")
but the script doesn't ever print the string, it just stays on the backlight change-y bit.
Basically I'm creating an index of letters that you can move through using the LCD buttons, and want the backlight to change each time you press a button.
The standard way is to have a single loop containing both. In the loop you first handles any input or state changes. Then at the end of your loop you update display. This is a fairly common paradigm in game programming see pygame for tons of examples. You would then only break once your program is terminating. One thing worth pointing out is that you would not want to block on checking for key press (or any input), otherwise you would hold up your display waiting for input.
sudo code would be something like:
while True:
for event in key_presses():
handle_event(event) # stuff that happens as a result of input
update_state() # stuff that happens regardless of input
update_display() # everything that changes the display (backlight, text, anything)
I have a application running in python, i want to send the input taken from the text box of the webpage and send it as input to the application and once again the output of the application which is in text format back to the result page on web.
thanks a lot for your time :) :)
Here's my suggestion: modify your program to include a button for doing the transformation. When you click it, it should take the contents of the clipboard, do whatever transformation you want, and put the result back on the clipboard.
Once you do that, to use it you select the text from the widget, use the keyboard to copy it to the clipboard, press the button on the GUI, then click back in the widget and use the keyboard to paste.
Alternately, your program can just poll the clipboard every couple of seconds, do the transformation and put the results back (make sure your automatic polling ignores any changes caused by itself). With that you can do a select-all, copy, wait a couple seconds, then paste.
This is pretty trivial to do in both Tkinter and wxPython, and I would guess it is equally trivial with most other GUI toolkits.
Have you tried PyQt4 which has this ability built-in? You can do what you're asking in about ten LOC.