练习使用selenium来登入FB
from selenium import webdriverdriver = webdriver.Chrome()driver.get('https://www.facebook.com/')driver.find_element_by_id('email').send_keys('E-mail')driver.find_element_by_id('pass').send_keys('密码')driver.find_element_by_name('login').click()#driver.close()
使用tkinter模组製作GUI画面
import tkinter as tkbase = tk.Tk()Label01 = tk.Label(base, text = 'Red', bg = 'red', font = ('Arial', 12), width = 20).pack()Label02 = tk.Label(base, text = 'Green', bg = 'green', width = 20, height = 3).pack()Label03 = tk.Label(base, text = 'Blue', fg = 'white', bg = 'blue', width = 20).pack()base.mainloop()
base = tk.Tk()textvar = tk.StringVar() # 设定一个tk的字串变数Label01 = tk.Label(base, textvariable = textvar, fg = 'white', bg = 'red', font = ('Arial', 12), width = 20, height = 2).pack()textvar.set('Hello World !!!')base.mainloop()
# Radiobuttonimport tkinter as tkdef select(): selection = 'Radio button ' + str(My_value.get()) + ' is chosen' My_String.set(selection)base = tk.Tk()My_String = tk.StringVar()My_value = tk.IntVar()Button01 = tk.Radiobutton(base, text = 'Option01', variable = My_value, value = 1, command = select).pack()Button02 = tk.Radiobutton(base, text = 'Option02', variable = My_value, value = 2, command = select).pack()Button03 = tk.Radiobutton(base, text = 'Option03', variable = My_value, value = 3, command = select).pack()Label01 = tk.Label(base, textvar = My_String).pack()base.mainloop()
# Checkbuttondef leave(): base.destroy()base = tk.Tk()Choice01 = tk.IntVar()Choice02 = tk.IntVar()Choice03 = tk.IntVar()CB01 = tk.Checkbutton(base, text = 'Math', variable = Choice01, offvalue = 0,onvalue = 1, ).pack(anchor = tk.W)CB02 = tk.Checkbutton(base, text = 'Chinese', variable = Choice02, offvalue = 0,onvalue = 1, ).pack(anchor = tk.W)CB03 = tk.Checkbutton(base, text = 'English', variable = Choice03, offvalue = 0,onvalue = 1, ).pack(anchor = tk.W)Button01 = tk.Button(base, text = 'Submit', command=leave).pack()base.mainloop()