我正在尝试使消息弹出,如“行动完成”,我想要一个按钮上关闭弹出窗口(一个简单的OK,退出弹出窗口)。它有时也会移动到窗口后面,这是很烦人的。我有一些按钮的代码,但它有一个关于形状的几何问题,因为形状不是精确定义的,因为它是通过字体大小和文本长度而变化的。
import tkinter as tk
from tkinter import *
import pygame
import sys
def Text(Text_input, Font, Background, Foreground):
my_window = tk.Tk()
my_window.title(Text_input)
my_window.geometry()
help_label = tk.Label(my_window, font = Font, bg=Background, fg=Foreground, text = Text_input)
help_label.grid(row=0, column=0)
button = tk.Button(my_window, text="QUIT", fg="red", command=quit)
button.pack(side=tk.BOTTOM)
my_window.mainloop()
Text("Hello", "calibri 80", "white", "black")发布于 2021-06-15 19:50:28
根据我自己想要实现这个目标的经验,我编写了一个简单的tkinter代码export_success.py,如下所示:
from tkinter import *
from tkinter import ttk
import sqlite3
from tkinter.ttk import *
root = Tk()
root.geometry('280x100')
root.title("Export Status")
root.config(bg="")
style = ttk.Style()
label_0 = Label(root, text="Export Successful", width=20, background="white", foreground="grey15", font=("Arial, bold", 15)).place(x=50, y=23)
exit1 = Button(root, text='Exit', style='C.TButton', width=11, command=root.destroy).place(x=100, y=60)
root.mainloop()然后,我只需将此代码os.system('python export_success.py')插入到我正在处理的tkinker窗口的末尾。
在这种情况下,我正在导出我的信息,并想知道它何时成功。
我并不是说这是最好的实践,可能还有其他方法,我只是发现它对我来说是有效的。
https://stackoverflow.com/questions/67985586
复制相似问题