[英]How to start another window using eel python?
I am creating a GUI application using eel library in python.我正在使用 python 中的 eel 库创建一个 GUI 应用程序。 index.html
contains login form and if login is successful I want to open retrieve.html
. index.html
包含登录表单,如果登录成功,我想打开retrieve.html
。
This is my python code and please consider login as successful.这是我的 python 代码,请认为登录成功。
@eel.expose
def retrieve():
eel.start('retrieve.html', size=(1000, 700))
eel.start('index.html', size=(1000, 700))
This is my javascript code这是我的 javascript 代码
function login_func()
{
var username = document.getElementById("username").value
var pword = document.getElementById("pword").value
eel.login(username, pword)(set_result)
}
function set_result(result)
{
if(result == "Failed")
{
window.alert("Please insert correct username and password")
}
else
{
window.close()
eel.retrieve()
}
}
Everything works fine but I am getting an error message and that is一切正常,但我收到一条错误消息,那就是
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted: ('localhost', 8000)
How can I avoid this?我怎样才能避免这种情况?
Use different port No. for 2nd window, as mentioned below:第二个 window 使用不同的端口号,如下所述:
@eel.expose def retrieve(): eel.start('retrieve.html', size=(1000, 700), **port = 8080**)
@eel.expose def retrieve(): eel.start('retrieve.html', size=(1000, 700), **port = 8080**)
eel.start('index.html', size=(1000, 700), port = 8000 ) eel.start('index.html', size=(1000, 700), port = 8000 )
or Alternatively, check this https://deecode.net/?p=438&lang=en或者,检查这个https://deecode.net/?p=438&lang=en
Make sure that the your port is different for each window确保每个 window 的端口都不同
You shouldn't call eel.start
again... that will setup a new local server, websockets, etc. In this case, you can call eel.show
which will re-use your existing web instance to show the new window and page.你不应该再次调用eel.start
......这将设置一个新的本地服务器、websocket 等。在这种情况下,你可以调用eel.show
它将重新使用你现有的 web 实例来显示新的 window 和页面.
So change your code to something like:因此,将您的代码更改为:
@eel.expose
def retrieve():
eel.show('retrieve.html', size=(1000, 700))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.