参考链接:
https://bbs.csdn.net/topics/392278929?page=1
https://blog.csdn.net/Teddycxr/article/details/80804383
思路一:用一个文件存放改程序pid号,启动时去该文件读取pid号,判断程序是否在执行
我的代码
def close_window(window):
"""关闭友好提示"""
if QMessageBox().information(None, "标题", "不能重复开启",
QMessageBox.Ok) == QMessageBox.Ok:
window.close()
if __name__ == '__main__':
cf = configparser.ConfigParser()
status_path = os.path.join(os.getcwd(), 'config', 'status.conf')
# 判断是否有开启权限,限制多开
tool_pid = conf_get(cf, status_path, 'tool_pid', 'pid')
permission = True
pids = psutil.pids()
# tool_pid 不为空