Skip to content

Commit 4231b29

Browse files
authored
Merge pull request #6 from shubhmrj/conflict
Conflict
2 parents 82e8a58 + 1306f1e commit 4231b29

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed

Logging system/logger_gui.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import tkinter as tk
2+
from tkinter import scrolledtext, messagebox
3+
from PIL import Image, ImageTk
4+
import threading
5+
6+
class LoggerSingleton:
7+
_instance = None
8+
_lock = threading.Lock()
9+
10+
def __new__(cls):
11+
with cls._lock:
12+
if cls._instance is None:
13+
cls._instance = super(LoggerSingleton, cls).__new__(cls)
14+
cls._instance.logs = []
15+
return cls._instance
16+
17+
def log(self, message):
18+
self.logs.append(message)
19+
20+
def get_logs(self):
21+
return self.logs
22+
23+
class LoggerGUI:
24+
def __init__(self, root):
25+
self.root = root
26+
self.root.title("Unique Logger System")
27+
self.root.geometry("700x500")
28+
self.root.resizable(False, False)
29+
30+
# Load and set background image
31+
try:
32+
self.bg_image = Image.open("background.jpg")
33+
self.bg_image = self.bg_image.resize((700, 500))
34+
self.bg_photo = ImageTk.PhotoImage(self.bg_image)
35+
self.bg_label = tk.Label(root, image=self.bg_photo)
36+
self.bg_label.place(x=0, y=0, relwidth=1, relheight=1)
37+
except Exception as e:
38+
messagebox.showwarning("Background Image", f"Could not load background.jpg: {e}")
39+
40+
# Unique interface styling
41+
self.frame = tk.Frame(root, bg='#2d2d44', bd=4, relief=tk.RIDGE)
42+
self.frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER, width=480, height=340)
43+
44+
self.title_label = tk.Label(self.frame, text="Logger System", font=("Segoe Script", 20, "bold"), fg="#ffb347", bg="#2d2d44")
45+
self.title_label.pack(pady=(15, 5))
46+
47+
self.log_entry = tk.Entry(self.frame, font=("Segoe UI", 12), width=35, bg="#f4e2d8")
48+
self.log_entry.pack(pady=10)
49+
50+
self.log_button = tk.Button(self.frame, text="Add Log", font=("Segoe UI", 11, "bold"), bg="#5f4b8b", fg="white", command=self.add_log)
51+
self.log_button.pack(pady=5)
52+
53+
self.logs_display = scrolledtext.ScrolledText(self.frame, font=("Consolas", 11), width=50, height=10, bg="#f4e2d8", fg="#2d2d44", wrap=tk.WORD)
54+
self.logs_display.pack(pady=10)
55+
self.logs_display.config(state=tk.DISABLED)
56+
57+
self.refresh_button = tk.Button(self.frame, text="Refresh Logs", font=("Segoe UI", 10, "bold"), bg="#ffb347", fg="#2d2d44", command=self.refresh_logs)
58+
self.refresh_button.pack(pady=5)
59+
60+
self.logger = LoggerSingleton()
61+
62+
def add_log(self):
63+
message = self.log_entry.get().strip()
64+
if message:
65+
self.logger.log(message)
66+
self.log_entry.delete(0, tk.END)
67+
self.refresh_logs()
68+
else:
69+
messagebox.showinfo("Input Needed", "Please enter a log message.")
70+
71+
def refresh_logs(self):
72+
self.logs_display.config(state=tk.NORMAL)
73+
self.logs_display.delete(1.0, tk.END)
74+
for idx, log in enumerate(self.logger.get_logs(), 1):
75+
self.logs_display.insert(tk.END, f"{idx}. {log}\n")
76+
self.logs_display.config(state=tk.DISABLED)
77+
78+
if __name__ == "__main__":
79+
root = tk.Tk()
80+
app = LoggerGUI(root)
81+
root.mainloop()

Logging system/main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This is a sample Python script.
2+
3+
# Press Shift+F10 to execute it or replace it with your code.
4+
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
5+
6+
7+
def print_hi(name):
8+
# Use a breakpoint in the code line below to debug your script.
9+
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
10+
11+
12+
# Press the green button in the gutter to run the script.
13+
if __name__ == '__main__':
14+
print_hi('PyCharm')
15+
16+
# See PyCharm help at https://www.jetbrains.com/help/pycharm/

list compreshion/dictionary.py

Whitespace-only changes.

list compreshion/file2.txt

Whitespace-only changes.

list compreshion/new.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)