You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the problem is , the application create a new window, but old window still exists , so now there are two application windows,
i need only one window, it seems old window can't close by itself, even i use page.window_close()
here is sample code
import flet as ft
import os
import time
import sys
def main(page: ft.Page):
def restart(e):
# Restart the application...
executable = sys.executable
print(executable)
executable_filename = os.path.split(executable)[1]
page.window_close()
if executable_filename.lower().startswith('python'):
# application is running within a python interpreter
python = executable
os.execv(python, [python, ] + sys.argv)
else:
# application is running as a standalone executable
os.execv(executable, sys.argv)
print('start')
lbl_time = ft.Text(time.ctime())
btn_restart = ft.ElevatedButton('restart', on_click=restart)
page.add(lbl_time, btn_restart)
ft.app(main)
This discussion was converted from issue #3174 on May 03, 2024 16:37.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
for example
i need to restart the application to reload some config file
how to do this , like click a button to restart itself
i tried some code , use os.execv from linke below, without packaed , the code works fine
https://stackoverflow.com/questions/72868924/restart-compiled-python-script-with-pyinstaller
the problem is , the application create a new window, but old window still exists , so now there are two application windows,
i need only one window, it seems old window can't close by itself, even i use page.window_close()
here is sample code
Beta Was this translation helpful? Give feedback.
All reactions