如何将粘贴在html网页文本框中的文本发送到硬盘中用python编写的应用程序?
我有一个在 python 中运行的应用程序,我想发送从网页文本框中获取的输入,并将其作为输入发送到应用程序,并再次将文本格式的应用程序输出发送回网络上的结果页面。
非常感谢您的宝贵时间:) :)
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 :) :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我的建议:修改您的程序以包含用于进行转换的按钮。当您单击它时,它应该获取剪贴板的内容,执行您想要的任何转换,然后将结果放回剪贴板。
完成此操作后,要使用它,您可以从小部件中选择文本,使用键盘将其复制到剪贴板,按 GUI 上的按钮,然后在小部件中单击返回并使用键盘进行粘贴。
或者,您的程序可以每隔几秒钟轮询一次剪贴板,进行转换并将结果放回(确保您的自动轮询忽略由其自身引起的任何更改)。这样您就可以进行全选、复制、等待几秒钟,然后粘贴。
这在 Tkinter 和 wxPython 中都是非常简单的事情,我猜想这对于大多数其他 GUI 工具包来说同样是微不足道的。
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.
您是否尝试过内置此功能的 PyQt4?您可以在大约十个 LOC 内完成您所要求的操作。
Have you tried PyQt4 which has this ability built-in? You can do what you're asking in about ten LOC.