2024年3月5日 星期二

Python Tkinter First Example

import tkinter as tk


def on_closing():

    root.destroy()


class MainWindow(tk.Tk):

    def __init__(self, *args, **kwargs):

        tk.Tk.__init__(self, *args, **kwargs)


root = MainWindow()

root.title('Main Window')

root.protocol("WM_DELETE_WINDOW", on_closing)

root.geometry('640x480')

root.mainloop()

 

2024年3月4日 星期一

在Ubuntu桌面載入後自動執行程式

在 <home>/.config 新增 autostart 目錄

touch <home>/.config/autostart/<program name>.desktop

在<program name>.desktop加入以下內容

[Desktop Entry]

Name=<program name>

Exec=<path to>/<your program execuable>

Type=application

 就可以了

RaspberryPi也一樣可以這樣處理

Python Tkinter First Example

import tkinter as tk def on_closing():     root.destroy() class MainWindow(tk.Tk):     def __init__(self, *args, **kwargs):         tk.Tk.__...