Below you will find pages that utilize the taxonomy term “Python”
Posts
Python - Install on Termux
要在 Termux 安裝 Python,可透過 pkg 安裝 python 套件。
pkg install python 安裝完可查閱 Python 版本做過確認,Python 命令應可正常運行,回應安裝的 Python 版本。
python --version
read morePosts
Visual Studio Code - Analyze Python with Pylint
要在 Visual Studio Code 中開發 Python 並使用 Pylint 進行程式碼的分析,Visual Studio Code 要先安裝 Python 的套件,完成 Python 開發環境的設定。
然後安裝 Pylint,不同環境有不同的安裝方式,因為筆者用的是 Mac,所以是用 pip 安裝。
沒有 pip 的話要先進行安裝。
開啟 Visual Studio Code 運行 Python 程式,Visual Studio Code 偵測到 Pylint 沒安裝的話會彈出通知,並提供安裝的按鈕。
點選安裝的按鈕,安裝命令會帶到 TERMINAL 視窗調用。
如果有權限問題的話,還是需要自己調整命令後再調用。
安裝好後就可以支援 Python 的分析。
Link Pylint - code analysis for Python | www.pylint.org
read morePosts
Visual Studio Code - Python on Visual Studio Code
要在 Visual Studio Code 使用 Python,可安裝 Visual Studio Code 的 Python 套件。
套件安裝完按下熱鍵打開 Command Palette (Windows 為 Ctrl+ Shift + P, OS X 為CMD + SHIFT + P),搜尋並運行 Tasks: Configure Task Runner。
接著選取 TypeScript - tsconfig.json。
修改 tasks.json 設定,command 設為 python、args 設為 ${file}、showOutput 設為 always。
設定修改完存檔,按下熱鍵運行 Tasks: Run Build Task (Windows 為 Ctrl+ Shift + B, OS X 為CMD + SHIFT + B),即可運行 Python 程式。
Link Python with Visual Studio Code [Python] 使用 Visual Studio Code 作為開發環境
read morePosts
Hello, Tkinter
Tkinter._test()
form = Tk() … form.mainloop()
form = Tk() form.title(“HelloWorld Demo”) form.geometry(“300x200”)
lbl = Label(form, text=“Hello, world!”) lbl.pack()
form.mainloop()
read morePosts
Tkinter.TK
form = Tk()
form.title(“Tkinter.TK Demo”) form.geometry(“300x200+10+10”) form.iconbitmap(‘Icon.ico’) #form.resizable(False, False) form.minsize(300, 200) form.maxsize(600, 400) #form.attributes("-toolwindow", 1) form.attributes("-topmost", 1) #form.state(“zoomed”) #form.iconify() #form.deiconify() form.configure(background=‘black’)
form.mainloop()
read morePosts
Tkinter's grid geometry manage
form = Tk()
form.columnconfigure(0, weight=0) form.columnconfigure(1, weight=1) form.rowconfigure(0, weight=0) form.rowconfigure(1, weight=0) form.rowconfigure(2, weight=1)
Label(form, text=“First”).grid(row=0, sticky=W) Label(form, text=“Second”).grid(row=1, sticky=W)
Entry(form).grid(row=0, column=1, sticky=W+E) Entry(form).grid(row=1, column=1, sticky=W+E)
Button(form, text=“GO”).grid(row=2, column=0, columnspan=2, padx=5, pady=5, sticky=W+E+S+N)
form.mainloop()
read morePosts
Tkinter's pack geometry manager
lbl = Label(form, text=“pack test2”, bg=“yellow”) lbl.pack()
lbl = Label(form, text=“pack test3”, bg=“blue”) lbl.pack() …
lbl = Label(form, text=“fill test2”, bg=“yellow”) lbl.pack(side=LEFT, fill=Y)
lbl = Label(form, text=“fill test2”, bg=“blue”) lbl.pack(fill=BOTH, expand=1) …
lbl = Label(form, text=“ipad test”, bg=“blue”) lbl.pack(fill=X, ipadx=5, ipady=5) …
read morePosts
Tkinter's place geometry manager
lbl = Label(form, text=“place test2”, bg=“white”) lbl.place(x=20, y=20) …
lbl = Label(form, text=“place test4”, bg=“yellow”) lbl.place(y=150, anchor=E, relx=1)
lbl = Label(form, text=“place test5”, bg=“yellow”) lbl.place(y=180, relx=0.5, anchor=CENTER) …
form = Tk() form.geometry(“300x200”)
lbl = Label(form, text=“place test0”, bg=“gray”) lbl.place(x=5, y=5, relwidth=1, relheight=1, width=-10, height=-10)
lbl = Label(form, text=“place test1”, bg=“red”) lbl.place(x=10, y=10, width=100, height=100)
lbl = Label(form, text=“place test2”, bg=“white”) lbl.place(x=20, y=20)
lbl = Label(form, text=“place test3”, bg=“yellow”) lbl.place(y=120, relx=0.
read morePosts
Tkinter's tkColorChooser
print tkColorChooser.askcolor(title=“test”) print tkColorChooser.askcolor(“red”) print tkColorChooser.askcolor(initialcolor=“red”)
read morePosts
Tkinter's tkFileDialog
if fs: print fs.name else: print “Without selected!” …
print files
if files: for fs in files: print fs.name else: print “Without selected!” …
print tkFileDialog.asksaveasfile(**options).name …
options = {} options[‘filetypes’] = [(“allfiles”,""),(“text”,".txt")] options[‘initialdir’] = “c:" options[‘multiple’] = True
options[’title’] = “tkFileDialog.askopenfilename” print tkFileDialog.askopenfilename(**options) or “Without selected!”
options[’title’] = “tkFileDialog.askopenfilenames” print Tk().tk.splitlist(tkFileDialog.askopenfilenames(**options)) or “Without selected!”
options[’title’] = “tkFileDialog.askopenfile” fs = tkFileDialog.askopenfile(**options)
if fs: print fs.name else: print “Without selected!”
read morePosts
Tkinter's tkMessageBox
tkMessageBox.showinfo(“showinfo demo”, “Info”) tkMessageBox.showwarning(“showwarning demo”, “Warning”) tkMessageBox.showerror(“showerror demo”, “Error”)
print “askquestion’s dialogresult: %s” % tkMessageBox.askquestion(“askquestion demo”, “Sure?!”) print “askokcancel’s dialogresult: %s” % tkMessageBox.askokcancel(“askokcancel demo”, “OK?! CANCEL?!”, default = “ok”) print “askyesno’s dialogresult: %s” % tkMessageBox.askyesno(“askyesno demo”, “Yes?! No?!”, default = “no”) print “askretrycancel’s dialogresult: %s” % tkMessageBox.askretrycancel(“askretrycancel demo”, “Retry?! Cancel?!”, default = “cancel”)
read more