1
我在python中做了一个os,但我需要一个web浏览器。目前我正在使用os.startfile方法启动chrome,但我需要另一种方式。我想一个程序,用户可以输入一个网页,显示该网页不使用Chrome,Firefox和Safari等用Python显示网站
下面是基本的框架,我有:
from tkinter import *
import webbrowser as wb
window = Tk()
window.configure(bg="Dark Red")
window.geometry("1000x1000")
window.title("Hyper Web Browser")
window.iconbitmap("icon.ico")
''' Defined Functions'''
def submit_url():
wb.open_new_tab(Address_Bar.get())
file2write = open("History.txt", "a")
file2write.write(["\n", Address_Bar.get()])
return submit_url
'''Objects'''
Address_Bar = Entry(
bg="White",
bd=0,
font=("Comic", 25),
width=100
)
Tab_1 = Label(
bg="Red",
bd=0,
width=20,
height=3
)
Return = Button(
command=submit_url()
)
Address_Bar.place(x=20, y=60)
Tab_1.place(x=0, y=0)
Return.pack()
window.mainloop()
不过,这一方案启动网页导入用户的默认浏览器。因此,我想在不使用任何其他Web浏览器的情况下显示网页。
任何显示网页的程序都称为Web浏览器。您尝试实施您自己的Web浏览器。祝你好运。 – DyZ
这可能是有用的:http://stackoverflow.com/questions/15138614/how-can-i-read-the-contents-of-an-url-with-python –
添加到@DYZ评论。默认情况下,Tkinter没有任何HTML呈现功能。 – Vallentin