当在 Python Gtk 中放置模式对话框时,如何从主窗口接收事件
我有客户端服务器程序。我的python总是监听套接字中传递的数据。如果我从服务器获取某些预定义的字符串,我会显示一个模式对话框。可以通过两种方式关闭该对话框。第一种方法是用户应对对话框按钮做出反应。第二种方法是,从套接字我必须再接收一个命令才能关闭。现在我面临的问题是当对话框可见时套接字不接收任何字符串。仅当我关闭对话框时,才会从套接字接收对话框存在时客户端发送的字符串。当对话框存在时,如何从客户端异步接收消息。如果可能的话,我如何以编程方式关闭对话框。
I have client server program. My python always listens to the data passed in the socket. If I get certain predefined strings from the server i display a modal dialog.The dialog can be closed in 2 ways. First way is user should react to the dialog buttons. Second way is, From socket i have to receive one more command to close. Now problem i am facing is when the dialog is visible the socket doesn't receive any string. Only if I close the dialog the string sent by the client when dialog was there is received from the socket. How can i receive messages asyncronously from the client when dialog is there. If this is possible how do i close the dialog programatically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的两个问题都与模式对话框的使用有关。您最好创建一个仅设置“stay-on-top”属性的常规对话框(非模式)。在该窗口上,您将能够修改消息,甚至可以从其他进程中关闭它。
您必须将“响应”(或其他方法名称,如果您愿意)添加到按钮:
并在“接受”例程(所有按钮一个)中添加类似的内容:
我没有测试这个,但它应该可以工作。
Both your problems are linked to the usage of the modal dialog. You 'd better create a regular dialog (not modal) with only the "stay-on-top" attribute set. On that window you will be able to modify messages and even to close it from your other process.
You will have to add the "response" (or another method name if you want) to the buttons :
and in the "accepted" routine (one for all the buttons) something like that:
I did not test this, but it should work.