Skip to content

Conversation

@abhigyaabs2
Copy link
Contributor

@abhigyaabs2 abhigyaabs2 commented Jul 26, 2025

@thynash
@Gagandeep-2003
Fixes: #26

  1. Use sys.executable Instead of "python"
    This ensures that subprocess runs in the same environment (especially useful when using virtual environments or Python 3+).
    import sys
    subprocess.call([sys.executable, "face-try.py"])

  2. Prevent GUI Freeze with threading
    Currently, when running subprocess.call(...), it blocks the GUI until the subprocess ends. To keep the GUI responsive, run each script in a separate thread.
    from threading import Thread

def run_script(script_name):
def target():
subprocess.call([sys.executable, script_name])
Thread(target=target).start()

def face():
run_script("face-try.py")

def blink():
run_script("blinkDetect.py")

def lane():
run_script("lanedetection.py")

  1. Improve Layout Using Padding and Sticky
    The current layout is functional but not visually centered. Using .grid(..., sticky='ew') or switching to pack() with better padding for cleaner UI.

@thynash
Copy link
Collaborator

thynash commented Jul 26, 2025

@abhigyaabs2 also do mention what issue this pr solves

@abhigyaabs2
Copy link
Contributor Author

@thynash
My pull request solves the following issues:-

GUI Freezing During Script Execution

Previously, the GUI would freeze while executing external Python scripts (e.g., face detection, blink detection, lane detection) because subprocess.call() was blocking the main thread.

•Fix: Introduced multithreading using the threading module to execute subprocesses without blocking the GUI.

Python Environment Compatibility

Hardcoded "python" could fail in systems with multiple Python versions or virtual environments.

•Fix: Replaced with sys.executable to ensure subprocesses run with the same interpreter as the GUI app.

Unstructured and Inconsistent Layout

The original grid layout lacked consistent spacing and alignment.

•Fix: Switched to pack() with strategic padding (pady) for a cleaner and centered button layout.

Readability and Maintainability

Repeated subprocess logic was hardcoded in each button function.

• Fix: Introduced a single run_script(script_name) method for better code reuse and readability.

@abhigyaabs2
Copy link
Contributor Author

abhigyaabs2 commented Jul 28, 2025

👋 Hi @thynash,
Just checking in regarding this pull request. I noticed other PRs were recently reviewed , I’d love to hear your thoughts on mine as well! 😊

It resolves the GUI freezing issue and improves layout + maintainability.

If there’s anything you'd like me to tweak or split into smaller commits, I’m happy to do that! 🙌

Looking forward to your feedback.

@Gagandeep-2003
Copy link
Owner

Thanks @abhigyaabs2 for working on this issue.
I noticed that instead of updating the existing files (ui.py), the PR creates new files (ui1.py).
For maintainability and to avoid duplicate code, please make changes directly in the existing files rather than creating new ones.
This way, the fix will integrate seamlessly into the main project and be easier to maintain.

👋 Hi @thynash, Just checking in regarding this pull request. I noticed other PRs were recently reviewed , I’d love to hear your thoughts on mine as well! 😊

It resolves the GUI freezing issue and improves layout + maintainability.

If there’s anything you'd like me to tweak or split into smaller commits, I’m happy to do that! 🙌

Looking forward to your feedback.

@abhigyaabs2
Copy link
Contributor Author

@Gagandeep-2003 I have resolved the issue, if there is anything else then please let me know.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve GUI Responsiveness & Script Execution in Tkinter Interface

3 participants