Reputation: 7513
I am quite confused about the stdin and the key_events of GUI widget.
Usually in my mind, I thought stdin is the ordinary way to get the keyboard input for a process. E.g., If I have a process, then I could use stdin to have the keyboard inputs. And this is usually used to make I/O direction for the subprocess to get keyboard inputs. E.g., I could make subprocess.Popen(stdin=PIPE)
On the other hand for GUI, I am using wx.TexCtrl or py.Shell.shell, to catch the key events, like inputs.
So I am quite confused here, if I have a GUI or pyShell running, when I am typing via the keyboard, is it via the stdin or via the GUI key event catching system? If via the GUI key events system, how can I get the keyboard stdin? Can I still simply redirect the keyboard inputs to my child process (inside the GUI) as the ordinary non-GUI programming?
Thanks a lot for any comments.
Upvotes: 0
Views: 420
Reputation: 385970
When you type, the input comes from the GUI event mechanism, not from stdin. You asked how to get the "keyboard stdin", and the answer to that is the same as for any other type of program: you read it (but it will almost certainly be empty). It's important to realize that the GUI probably doesn't have a stdin if it was started by double-clicking on an icon on the desktop.
And no, you can't "redirect keyboard inputs to [your] child process", if I understand your question. Stdin really has absolutely nothing to do with GUIs at all. How keyboard input is read via a GUI is completely disconnected from stdin.
Upvotes: 2