python太多語法,放這邊練習
filedialog 對話框函數測試
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog as fd
def do_askopenfilename():
file=fd.askopenfilename()
print(type(file))
print(file)
def do_askopenfilenames():
files=fd.askopenfilenames()
print(type(files))
print(files)
def do_asksaveasfilename():
file=fd.asksaveasfilename()
print(type(file))
print(file)
def do_askdirectory():
dir=fd.askdirectory()
print(type(dir))
print(dir)
def do_askopenfile():
file=fd.askopenfile()
print(type(file))
print(file)
def do_askopenfiles():
files=fd.askopenfiles()
print(type(files))
print(files)
def do_asksaveasfile():
file=fd.asksaveasfile()
print(type(file))
print(file)
root=tk.Tk()
root.title("檔案開啟儲存")
ttk.Button(root, text="askopenfilename", command=do_askopenfilename).pack()
ttk.Button(root, text="askopenfilenames", command=do_askopenfilenames).pack()
ttk.Button(root, text="asksaveasfilename", command=do_asksaveasfilename).pack()
ttk.Button(root, text="askdirectory", command=do_askdirectory).pack()
ttk.Button(root, text="askopenfile", command=do_askopenfile).pack()
ttk.Button(root, text="askopenfiles", command=do_askopenfiles).pack()
ttk.Button(root, text="asksaveasfile", command=do_asksaveasfile).pack()
root.mainloop()
http://yhhuang1966.blogspot.com/2018/10/python-gui-tkinter.html
背景顏色
entry類
Frame2_R1_Label_2 = tk.Label(Frame_Button, text=txtcount, width=10)
Frame2_R1_Label_2.grid(column=1, row=1, sticky="W", padx=8, pady=4)
Frame2_R1_Label_2["text"] = "123"
auto-py-to-exe:pyhton打包程式UI介面
安裝
python -m pip install auto-py-to-exe
執行
auto-py-to-exe
參考網址
https://nitratine.net/blog/post/issues-when-using-auto-py-to-exe/
pyinstaller pyhton打包程式
安裝
python -m pip install pyinstaller
執行
pyinstaller -F 你的檔名.py
留言列表