Gostaria de uma borda vermelha na janela pop-up. A largura da borda funciona, mas não a cor. A cor da borda continua preta, não vermelha. Eu tentei de duas maneiras diferentes. Ambos apresentam bordas pretas.
Método nº 1 (preferencial)
import tkinter as tk
from tkinter.scrolledtext import ScrolledText
def display_dataframe():
# Create a tkinter window
window = tk.Tk()
window.title('Stock Alert')
# Create a scrolled text widget to display the DataFrame
text_widget = ScrolledText(window, width=100, height=15, borderwidth=5, relief="solid", highlightbackground="red")
text_widget.insert(tk.END, alert_list_display.to_string(index=False)) # Insert DataFrame content
text_widget.pack()
# Start the tkinter main loop
window.mainloop()
# Call the function to display the DataFrame in a pop-up window
display_dataframe()
Método #2
import tkinter as tk
from tkinter import scrolledtext
def change_border_color(frame, color):
frame.configure(highlightbackground=color)
# Create a tkinter window
window = tk.Tk()
window.title('ScrolledText Border Color')
# Create a custom frame with a ScrolledText widget
frame = tk.Frame(window, borderwidth=10, relief="solid", highlightbackground="red")
frame.pack()
text_widget = scrolledtext.ScrolledText(frame, width=100, height=15)
text_widget.pack(fill="both", expand=True)
# Change the border color of the custom frame
change_border_color(frame, "blue")
# Start the tkinter main loop
window.mainloop()
A solução mais simples é colorir o pai do texto rolado e usar preenchimento para tornar visível a área ao redor do texto rolado.