【问题标题】:how to show google chrome window in a form that in python?如何以 python 的形式显示谷歌浏览器窗口?
【发布时间】:2020-12-24 13:17:39
【问题描述】:

好的,这就是我有一个非常简单的程序

import tkinter as tk 
from tkinter import ttk
from tkinter import * 
import os
import webbrowser

# this is the function called when the button is clicked

def Jazz():
    browserExe = "chrome"
    os.system("pkill "+browserExe)
    webbrowser.open("http://us4.internet-radio.com:8266/listen.pls&title=Smooth%20Jazz%20Florida&website=http://www.SmoothJazzFlorida.com")


def Oldies():
    browserExe = "chrome"
    os.system("pkill "+browserExe )
    webbrowser.open("https://www.internet-radio.com/player/?mount=http://uk3.internet-radio.com:8405/live.m3u&title=Majestic%20Jukebox%20Radio%20#HIGH%20QUALITY%20SOUND&website=https://www.majesticjukeboxradio.com/")

def ClassicRock():
    browserExe = "chrome"
    os.system("pkill "+browserExe )
    webbrowser.open("https://www.internet-radio.com/player/?mount=http://us4.internet-radio.com:8258/listen.pls&title=Classic%20Rock%20Florida%20HD&website=http://www.classicrockflorida.com")

def Top40():
    browserExe = "chrome"
    os.system("pkill "+browserExe )
    webbrowser.open("https://www.internet-radio.com/player/?mount=http://uk7.internet-radio.com:8226/listen.pls&title=Box%20UK%20Radio%20danceradiouk&website=https://www.danceradiouk.com")

root = Tk()

# This is the section of code which creates the main window
root.geometry('690x530')
root.configure(background='#F0F8F0')
root.title('Radio')


# This is the section of code which creates a button
Button(root, text='Jazz', bg='#F0F8FF', font=('arial', 22, 'normal'), command=Jazz).place(x=8, y=32)
Button(root, text='Oldies', bg='#F0F8FF', font=('arial', 22, 'normal'), command=Oldies).place(x=8, y=96)
Button(root, text='Classic_Rock', bg='#F0F8FF', font=('arial', 22, 'normal'), command=ClassicRock).place(x=8, y=160)
Button(root, text='Top40', bg='#F0F8FF', font=('arial', 22, 'normal'), command=Top40).place(x=8, y=224)
root.mainloop()

我想要做的是将谷歌放在这个表单/窗口上,也使用 python...

【问题讨论】:

  • 您是否在问如何将 chrome 嵌入到您的 tkinter 应用程序中?
  • 是的,我不确定 embed 是否适合使用

标签: python google-chrome


【解决方案1】:

无法将网络浏览器添加到 tkinter 应用程序。还有其他用于 python 的 GUI 框架确实具有 Web 浏览器小部件。 PyQT 和 wxPython 都有一个用于显示网页的 webview 小部件。但是这个问题已经在这里回答了......

Web Browser in Tkinter

我确实找到了一个名为 cefpython 的 python 库,它可能适用于 tkinter 应用程序。

【讨论】:

    猜你喜欢
    • 2012-12-15
    • 2018-03-06
    • 2012-05-21
    • 1970-01-01
    • 1970-01-01
    • 2013-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多