使用pyins构建tkinter时,BlockingScheduler不工作

2024-04-26 13:15:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个tkinter python脚本,它会在指定的时间提醒我。一切正常。现在我想让这个应用程序通过pyinstaller执行。当我运行pyinstaller时文件名.py,它还创建所有依赖项文件。但单击.exe文件无法工作/打开我的应用程序。告诉你我在用ubuntu16.1。下面是我的代码。你知道吗

import time
from apscheduler.schedulers.blocking import BlockingScheduler
import logging
import urlparse
import urllib
import urllib2
import simplejson
from Tkinter import *



logging.basicConfig()

def auto_timer():
    global time, urllib2, simplejson
    today_date = time.strftime("%Y-%m-%d")

    response = urllib2.urlopen("http://localhost/tk_dev/index.php/json/python_tkinter_effort_notice/118")
    data = simplejson.load(response)
    data_status = data["ma_effort_date"]  # 2017-02-19


    global root100
    root100 = Tk()


    if data_status != today_date:
        root100.attributes('-zoomed', True)
        root100.title("Notification")
        label = Label(root100, width="100",  text="Your didn't effort today. \nTime to do this job now. . . \nHurry up!!!")
        label.pack(side="top", fill="both", expand=True, padx=20, pady=20)

        button = Button(text = 'Close')
        button.pack(side="bottom", fill="none", expand=True)

        root100.mainloop()




not_executed = 1

while(not_executed):
    dt = list(time.localtime())
    hour = dt[3]
    minute = dt[4]


    if hour == 20 and minute == 40:
        scheduler = BlockingScheduler()
        scheduler.add_job(auto_timer, 'interval', hours=0.002)
        scheduler.start()
        not_executed = 0

Tags: importtruedatatodaydatetimetkinterdt