Skip to content

Commit f13079a

Browse files
Added credits link to About dialog and enhanced visibility of credits in status bar
1 parent 8e11c8f commit f13079a

File tree

7 files changed

+100
-33
lines changed

7 files changed

+100
-33
lines changed

compiler/compiler.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,53 @@
11
import subprocess
22
import os
3-
import shutil
43

54
def check_gcc_installed():
65
"""Check if GCC is installed and available in PATH"""
76
try:
8-
# Try to run gcc --version to check if GCC is installed
97
subprocess.run(['gcc', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
108
return True
119
except FileNotFoundError:
1210
return False
1311

1412
def compile_c_code(source_path, output_path):
15-
"""Compiles C source code with GCC
16-
13+
"""
14+
Compiles a C source file using GCC and returns compilation status and output message.
15+
1716
Args:
18-
source_path: Path to .c source file
19-
output_path: Path to output executable
20-
17+
source_path (str): Path to the C source file.
18+
output_path (str): Path for the output executable.
19+
2120
Returns:
22-
(success, message): Tuple containing success status and output message
21+
(bool, str): (True, success_message) if compiled successfully,
22+
(False, error_message) if compilation failed.
2323
"""
2424
if not os.path.exists(source_path):
25-
return False, "[ERROR] Source file not found"
26-
27-
# Delete output file if it already exists
25+
return False, "[ERROR] Source file not found."
26+
27+
# Remove previous executable if exists
2828
if os.path.exists(output_path):
2929
try:
3030
os.remove(output_path)
31-
except:
32-
return False, "[ERROR] Could not remove previous executable"
33-
34-
# Compile the code
31+
except Exception as e:
32+
return False, f"[ERROR] Could not remove previous executable: {e}"
33+
3534
try:
35+
# Compile with warnings and non-colored error output
3636
result = subprocess.run(
37-
['gcc', source_path, '-o', output_path],
38-
stdout=subprocess.PIPE,
37+
['gcc', '-Wall', '-Wextra', '-fdiagnostics-color=never', source_path, '-o', output_path],
38+
stdout=subprocess.PIPE,
3939
stderr=subprocess.PIPE,
4040
text=True
4141
)
42-
43-
# Check if compilation was successful
42+
43+
stdout = result.stdout.strip()
44+
stderr = result.stderr.strip()
45+
output = "\n".join(filter(None, [stdout, stderr]))
46+
4447
if result.returncode == 0:
4548
return True, "[SUCCESS] Compilation completed. Running program..."
4649
else:
47-
# Return compilation errors
48-
error_msg = result.stderr if result.stderr else "Unknown compilation error"
49-
return False, f"[ERROR] Compilation failed:\n{error_msg}"
50-
50+
return False, f"[ERROR] Compilation failed:\n{output}"
51+
5152
except Exception as e:
52-
return False, f"[ERROR] Compilation process failed: {str(e)}"
53+
return False, f"[ERROR] Compilation process failed:\n{str(e)}"

screenshots/Screenshot (88).png

83.3 KB
Loading

screenshots/Screenshot (89).png

112 KB
Loading

screenshots/Screenshot (90).png

97.4 KB
Loading

screenshots/Screenshot (91).png

77.6 KB
Loading

screenshots/Screenshot (92).png

111 KB
Loading

ui/widgets.py

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from utils.highlighter import highlight
55
import os
66
import tkinter as tk
7+
import webbrowser # Added for making the credits clickable
78

89
# Unicode icons (no external files needed)
910
ICONS = {
@@ -260,8 +261,60 @@ def toggle_theme():
260261
)
261262
theme_btn.pack(side="right", padx=2)
262263

264+
# Add About button
265+
about_btn = ctk.CTkButton(
266+
theme_frame,
267+
text="About",
268+
command=lambda: show_about_dialog(parent),
269+
**button_style
270+
)
271+
about_btn.pack(side="right", padx=5)
272+
263273
return frame
264274

275+
def show_about_dialog(parent):
276+
about_window = ctk.CTkToplevel(parent)
277+
about_window.title("About ChiX")
278+
about_window.geometry("400x200")
279+
about_window.resizable(False, False)
280+
281+
# Center on screen
282+
about_window.update_idletasks()
283+
width = about_window.winfo_width()
284+
height = about_window.winfo_height()
285+
x = (about_window.winfo_screenwidth() // 2) - (width // 2)
286+
y = (about_window.winfo_screenheight() // 2) - (height // 2)
287+
about_window.geometry(f'{width}x{height}+{x}+{y}')
288+
289+
# Add content
290+
ctk.CTkLabel(
291+
about_window,
292+
text="ChiX - C Code Editor & Runner",
293+
font=("Arial", 16, "bold")
294+
).pack(pady=(20, 5))
295+
296+
ctk.CTkLabel(
297+
about_window,
298+
text="Created by Prakhar Doneria",
299+
font=("Arial", 14)
300+
).pack(pady=5)
301+
302+
ctk.CTkLabel(
303+
about_window,
304+
text="© 2025 - Open Source Project",
305+
font=("Arial", 12)
306+
).pack(pady=5)
307+
308+
# GitHub link
309+
def open_github():
310+
webbrowser.open("https://github.com/PrakharDoneria/ChiX")
311+
312+
ctk.CTkButton(
313+
about_window,
314+
text="Visit GitHub Repository",
315+
command=open_github
316+
).pack(pady=15)
317+
265318
class StatusBar(ctk.CTkFrame):
266319
def __init__(self, parent, state, **kwargs):
267320
super().__init__(parent, height=25, fg_color="#007acc", **kwargs)
@@ -275,15 +328,6 @@ def __init__(self, parent, state, **kwargs):
275328
)
276329
self.file_info.pack(side="left", padx=10)
277330

278-
# Credits/GitHub link (right side)
279-
self.credits = ctk.CTkLabel(
280-
self,
281-
text="",
282-
text_color="#ffffff",
283-
font=("Arial", 11)
284-
)
285-
self.credits.pack(side="right", padx=10)
286-
287331
# Line/column indicator (right side)
288332
self.position_indicator = ctk.CTkLabel(
289333
self,
@@ -293,10 +337,32 @@ def __init__(self, parent, state, **kwargs):
293337
)
294338
self.position_indicator.pack(side="right", padx=10)
295339

340+
# Create a dedicated credits frame with distinct background
341+
self.credits_frame = ctk.CTkFrame(self, fg_color="#333333", corner_radius=8)
342+
self.credits_frame.pack(side="right", padx=10, pady=2)
343+
344+
# Credits/GitHub link with enhanced visibility
345+
self.credits = ctk.CTkLabel(
346+
self.credits_frame,
347+
text="",
348+
text_color="#00FFFF", # Cyan color for high contrast
349+
font=("Arial", 12, "bold"),
350+
padx=8,
351+
pady=2,
352+
cursor="hand2" # Hand cursor to indicate clickability
353+
)
354+
self.credits.pack()
355+
356+
# Make credits clickable
357+
self.credits.bind("<Button-1>", self._open_github)
358+
296359
# Setup cursor position tracking
297360
if state and "editor" in state and state["editor"]:
298361
state["editor"].bind("<KeyRelease>", self.update_position)
299362
state["editor"].bind("<Button-1>", self.update_position)
363+
364+
def _open_github(self, event):
365+
webbrowser.open("https://github.com/PrakharDoneria/ChiX")
300366

301367
def update_file_info(self, filepath=None):
302368
if filepath:

0 commit comments

Comments
 (0)