Tablacus Explorer 定制菜单项:长时间任务

Tablacus Explorer菜单运行的任务会阻塞UI。为了改掉这个问题,我写了一个Python脚本——long_run.py:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import subprocess
import threading
import os.path
import tkinter as tk
from tkinter import messagebox


class MainUI(tk.Tk):
    def __init__(self, cmd):
        tk.Tk.__init__(self)
        self._output = tk.StringVar(value='Please wait...')
        tk.Label(self, textvariable=self._output).pack(expand=True, fill=tk.BOTH, padx=5, pady=5)
        self._is_stop = False
        self.protocol("WM_DELETE_WINDOW", self.on_closing)
        self._proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
        threading.Thread(target=self.wait_result).start()

    def on_closing(self):
        if self._is_stop or messagebox.askokcancel('Quiz', 'Are you sure to exit?'):
            self._is_sto
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值