Skip to content

Commit

Permalink
Adding option to hide GUI window in CLI mode (#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus authored Nov 18, 2024
1 parent 29e3a94 commit bd0cbc8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions buzz/buzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ def main():

app = Application(sys.argv)
parse_command_line(app)
app.show_main_window()
sys.exit(app.exec())
4 changes: 4 additions & 0 deletions buzz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def parse(app: Application, parser: QCommandLineParser):
srt_option = QCommandLineOption(["srt"], "Output result in an SRT file.")
vtt_option = QCommandLineOption(["vtt"], "Output result in a VTT file.")
txt_option = QCommandLineOption("txt", "Output result in a TXT file.")
hide_gui_option = QCommandLineOption("hide-gui", "Hide the main application window.")

parser.addOptions(
[
Expand All @@ -124,6 +125,7 @@ def parse(app: Application, parser: QCommandLineParser):
srt_option,
vtt_option,
txt_option,
hide_gui_option,
]
)

Expand Down Expand Up @@ -216,6 +218,8 @@ def parse(app: Application, parser: QCommandLineParser):
)
app.add_task(transcription_task, quit_on_complete=True)

if parser.isSet(hide_gui_option):
app.hide_main_window = True

T = typing.TypeVar("T", bound=enum.Enum)

Expand Down
6 changes: 5 additions & 1 deletion buzz/widgets/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, argv: list) -> None:

self.setApplicationName(APP_NAME)
self.setApplicationVersion(VERSION)
self.hide_main_window = False

if sys.platform.startswith("win") and darkdetect.isDark():
palette = QPalette()
Expand Down Expand Up @@ -173,7 +174,10 @@ def __init__(self, argv: list) -> None:
)

self.window = MainWindow(transcription_service)
self.window.show()

def show_main_window(self):
if not self.hide_main_window:
self.window.show()

def add_task(self, task: FileTranscriptionTask, quit_on_complete: bool = False):
self.window.quit_on_complete = quit_on_complete
Expand Down
3 changes: 3 additions & 0 deletions buzz/widgets/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import (
QApplication,
QMainWindow,
QMessageBox,
QFileDialog,
Expand Down Expand Up @@ -395,6 +396,7 @@ def on_task_completed(self, task: FileTranscriptionTask, segments: List[Segment]

if self.quit_on_complete:
self.close()
QApplication.quit()


def on_task_error(self, task: FileTranscriptionTask, error: str):
Expand All @@ -403,6 +405,7 @@ def on_task_error(self, task: FileTranscriptionTask, error: str):

if self.quit_on_complete:
self.close()
QApplication.quit()

def on_shortcuts_changed(self):
self.menu_bar.reset_shortcuts()
Expand Down
1 change: 1 addition & 0 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Options:
--srt Output result in an SRT file.
--vtt Output result in a VTT file.
--txt Output result in a TXT file.
--hide-gui Hide the main application window.
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-v, --version Displays version information.
Expand Down
14 changes: 13 additions & 1 deletion docs/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@ sidebar_position: 5

If a model download was incomplete or corrupted, Buzz may crash. Try to delete the downloaded model files in `Help -> Preferences -> Models` and re-download them.

If that does not help, check the log file for errors and [report the issue](https://github.com/chidiwilliams/buzz/issues) so we can fix it. The log file is located in `~/Library/Logs/Buzz` (Mac OS) or `%USERPROFILE%\AppData\Local\Buzz\Buzz\Logs` (Windows). On Linux run the Buzz from the command line to see the relevant messages.
If that does not help, check the log file for errors and [report the issue](https://github.com/chidiwilliams/buzz/issues) so we can fix it. The log file is located in `~/Library/Logs/Buzz` (Mac OS) or `%USERPROFILE%\AppData\Local\Buzz\Buzz\Logs` (Windows). On Linux run the Buzz from the command line to see the relevant messages.

9. **Where can I get latest development version?**

Latest development version will have latest bug fixes and most recent features. If you feel a bit adventurous it is recommended to try the latest development version as they needs some testing before they get released to everybody.

Linux users can get the latest version with this command `sudo snap install buzz --edge`

For other platforms do the following:
- Go to the [build section](https://github.com/chidiwilliams/buzz/actions/workflows/ci.yml?query=branch%3Amain)
- Click on the link to the latest build
- Scroll down to the artifacts section in the build page
- Download the installation file. Please note that you need to be logged in the Github to see the download links.

0 comments on commit bd0cbc8

Please sign in to comment.