防止打开第二个实例 [英] Prevent opening a second instance

查看:39
本文介绍了防止打开第二个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查我的程序是否已经在 Windows 下使用 WxPython 运行的最简单方法是什么?理想情况下,如果用户尝试第二次启动程序,焦点应返回到第一个实例(即使窗口已最小化).

What's the easiest way to check if my program is already running with WxPython under Windows? Ideally, if the user tries to launch the program a second time, the focus should return to the first instance (even if the window is minimized).

这个问题 类似,但答案适用于 VB.NET.

This question is similar but the answer is for VB.NET.

推荐答案

你应该使用 wx.SingleInstanceChecker.请参阅此处了解有关如何使用它的更多信息,以及这篇文章 讲述了如何找到正在运行的实例(为此您必须使用 pywin32 函数,没有内置任何内容)wxPython AFAIK).

You should use wx.SingleInstanceChecker. See here for more information on how to use it, and this post tells about finding the running instance (you have to use pywin32 functions for this, there's nothing built into wxPython AFAIK).

这篇关于防止打开第二个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆