python: how to make programm press some buttons after if else - python

I have a programm which makes something when I talk in microphone. So I don't know how to make it press buttons by itself. I made a simple if else request where I say some words and it must press buttons.
If you can say how to loop it, so it won't close after a first answer to request, then you can try to help with that

Related

Can I put input in Mindstorms 51515 while programming in python?

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.

How can I press the fn+f keys with Pynput?

I need to be able to press the Function key along with one of the f-keys with pynput, but it doesn't seem to recognize the function key as a keypress, nor does it recognize anything as a keypress when I hit both the function and one of the f-keys.
I'm trying to make a program that will change my keyboard backlight, and to do that I need to be able to have the program press fn+f3 and fn+f4, but I can't seem to make that work. Can anyone tell me how I can do this?

Want Clarification for Program Loop (Python)

So I was wondering if someone would be able to help shed a little light for me on something I am working on in Python.
I am creating a program with a Tkinter GUI interface that interacts with a Serial device, and an ADC chip to measure voltage. I want to make sure I properly understand how I'm building the main program loop to keep everything running smoothly. I'm going to lay out how I think the program should run, if anyone has any corrections please throw them at me.
Program is run, GUI Interface initializes
User presses a button
send signal of button through serial
measure/display voltage levels
periodically update voltage display
if button is pressed, return to step 3
Now I know to run my Tkinter GUI I set up mainloop() as the last line of code. Now my question is simply, is that all I will need? Will mainloop() continually update while it waits for another button press, or will I essentially have to creatre an update method that cycles through everything until another button is pressed?
Will mainloop() continually update while it waits for another button press, or will I essentially have to creatre an update method that cycles through everything until another button is pressed?
Not all. That's why you are using tk.Tk().mainloop(). tkinter does this for you. All you are expected to do is implement the functionality that should happen when your button is pressed. tkinter will listen for the button press.

I want to make sure that some buttons are pressed in the correct order, how do I do this?

Hey just trying to create a basic logic game using pyqt that requires some buttons to be pressed in the correct order to open a 'safe' how could I do this whilst using an array? I am pretty knew to this stuff so apologies if it is very easy!
Every Time someone presses the button, add which button they pressed to the array ("1" if they pressed the 1st button, "2" if they pressed the 2nd button), once the size of this array is equal to how many numbers are in the code, check to see if all the numbers in the array match all the numbers in the code.

How to freeze/grayish window in pygtk?

I want main window to "gray, freeze, stop working", when some other window is opened. Is there some default way to do it? Pretty much the same as gtk.Dialog is working.
EDIT: Currently I'm just replacing all contents by a text line, but I guess there should be better way.
You really shouldn't try to make a program become unresponsive.
If what you want to do is stop the user from using the window, make the dialog modal: gtk.Dialog.set_modal(True)

Categories

Resources