-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
41 lines (33 loc) · 1.51 KB
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
from soccer_display import fetch_data, display_results
def fetch_data_and_display():
results_text.config(state=tk.NORMAL)
results_text.delete('1.0', tk.END)
try:
matches = fetch_data()
except Exception as e:
messagebox.showerror("Error", f"Failed to fetch data: {e}")
else:
display_results(matches, results_text)
results_text.config(state=tk.DISABLED)
root = tk.Tk()
root.title("Sports Results Display")
root.configure(bg="#f0f0f0")
root.option_add("*TCombobox*Listbox*Background", "#ffffff")
root.option_add("*TCombobox*Listbox*Foreground", "#333333")
root.option_add("*TCombobox*Listbox*selectBackground", "#0078d4")
root.option_add("*TCombobox*Listbox*selectForeground", "#ffffff")
root.option_add("*TCombobox*Foreground", "#333333")
root.option_add("*TCombobox*Background", "#ffffff")
results_frame = ttk.Frame(root, padding="10", relief=tk.RIDGE)
results_frame.pack(padx=20, pady=20, fill=tk.BOTH, expand=True)
# Add a header label with bold text and centered alignment
header_label = ttk.Label(results_frame, text="Soccer Scores", font=("TkDefaultFont", 14, "bold"), anchor="center")
header_label.pack(fill=tk.X, pady=10)
fetch_button = ttk.Button(root, text="Fetch Data", command=fetch_data_and_display)
fetch_button.pack(padx=20, pady=10)
results_text = tk.Text(results_frame, height=20, width=50, wrap=tk.WORD, state=tk.DISABLED)
results_text.pack(padx=10, pady=10, fill=tk.BOTH, expand=True)
root.mainloop()