可以使用tkinter制作一个cron python脚本

发布于 2025-02-08 07:24:36 字数 680 浏览 0 评论 0原文

我在Python中制作一个简单的脚本(仅用于测试),

import tkinter as tk

root = tk.Tk()
root.mainloop()

如果我在我的终端中编写python3 kinter.py,它只能在我的终端上写下一个void tkinter窗口。

问题随之而来的是我将同一文件放在我的crontab -e中:

* * * * * /usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py

这并非没有显示。如果我读了cron log:

Jun 15 16:44:01 mypc_fcoterroba CRON[125245]: (fcoterroba) CMD (/usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py)

你知道我该怎么办吗?

btw :我正在使用Ubuntu 20.04 LTS

I make a simple script (just to test) in Python which just make a void tkinter window

import tkinter as tk

root = tk.Tk()
root.mainloop()

If I write python3 kinter.py in my terminal that's works okey, without problems.

The problem came with I put this same file in my crontab -e like this:

* * * * * /usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py

This don't show nothing. If I read cron log:

Jun 15 16:44:01 mypc_fcoterroba CRON[125245]: (fcoterroba) CMD (/usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py)

Do you know what can I do?

BTW: I'm using Ubuntu 20.04 LTS

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅沫记忆 2025-02-15 07:24:36

自动答案

如果您想使用TKINTER或任何其他GUI Python库,则应指定要显示的显示(通常为0.0)。
So, In mi case, I should have put this in the cronjob:

env DISPLAY=:0.0 /usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py

Auto-answer

If you want use TKinter or any other GUI Python's libraries, you should specify the display where you want to show it (which will usually be 0.0).
So, In mi case, I should have put this in the cronjob:

env DISPLAY=:0.0 /usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文