我在kivy上实现了pywebview。单击该按钮后,它将创建该窗口,但在关闭该窗口并再次单击该按钮后,该窗口没有创建。
我该如何解决这个问题?
下面是我的代码:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
import threading
import webview
class LoginScreen(BoxLayout):
def __init__(self, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
self.btn1 = self.add_widget(Button(text='Web',on_press=self.on_web))
def on_web(self,instance):
url='http://www.google.com'
print("Im open windows")
webview.create_window('My Web App', url=url,debug=True)
class MyApp(App):
def build(self):
return LoginScreen()
if __name__ == '__main__':
MyApp().run()发布于 2020-06-13 03:11:12
在下面的行中,从debug=True中删除webview.create_window。然后将webview.start(debug=True)添加到https://github.com/r0x0r/pywebview和https://pywebview.flowrl.com/examples/debug.html中
webview.create_window('My Web App', url=url)
webview.start(debug=True) 另外,下面是create_window函数的参数,注意每个https://pypi.org/project/pywebview/0.5/没有debug
webview.create_window(title, url, width=800, height=600, resizable=True, fullscreen=False)在对代码进行编辑和测试之后,上面的内容(Python3,Kivy 1.11,Windows10)适用于我。
https://stackoverflow.com/questions/51038839
复制相似问题