我想在 if save_perm == 0 之后跳過整個函式:然后我想跳過其余的代碼
我是初學者,正在制作一個具有基本功能的基本記事本任何簡單的關鍵字或命令建議將被應用
from tkinter import *
from tkinter.messagebox import askyesno
def save_func():
global file_path
txt = text.get("1.0", END)
if "file_path" in globals():
save_perm = askyesno("Save the File", "Do You Want to Save the File")
if save_perm:
breakpoint
else:
text_savefile_window = asksaveasfile(
initialfile="Untitled.txt",
title="Select Name and Path",
defaultextension=".txt",
filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")],
)
file_path = text_savefile_window.name()
text_file = open(file_path, "w ")
text_file.write(txt)
text_file.close()
save_func()
uj5u.com熱心網友回復:
使用return退出功能
uj5u.com熱心網友回復:
在條件之后,寫
return
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/365762.html
上一篇:單擊按鈕并打開框架中的內容(框架中的直接方式和匯入腳本.py的方式)
下一篇:Automapper和多維串列
