Posts
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 more