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


背景顏色

root.configure(background='SystemButtonFace') #透明

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介面

自動py-to-exe空界面

安裝

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


 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JL8051 的頭像
    JL8051

    不會的就放這邊

    JL8051 發表在 痞客邦 留言(0) 人氣()