iT邦幫忙

0

Day17 參加職訓(機器學習與資料分析工程師培訓班),Python程式設計

  • 分享至 

  • twitterImage
  •  

練習使用selenium來登入FB

from selenium import webdriver

driver = 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 tk
base = 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()

https://ithelp.ithome.com.tw/upload/images/20210722/20139039QkTIczrWl1.png

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()

https://ithelp.ithome.com.tw/upload/images/20210722/2013903968LgTJQ3JR.png

# Radiobutton
import tkinter as tk
def 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()

https://ithelp.ithome.com.tw/upload/images/20210722/20139039KLdUigEdRw.png

# Checkbutton
def 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()

https://ithelp.ithome.com.tw/upload/images/20210722/201390397F3XMGJoJB.png


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言