Skip to content

Commit

Permalink
Add progress indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfFan committed Feb 15, 2024
1 parent 8125f66 commit 0f90722
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
31 changes: 21 additions & 10 deletions standalone_app/Snap2LaTeX.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
from PyQt6.QtCore import Qt
from PyQt6.QtCore import Qt, QTimer

import multiprocessing as mp

Expand Down Expand Up @@ -105,24 +105,18 @@ def app_show_progress(model_name):

path_to_icon = path.abspath(path.join(path.dirname(__file__), "icon.png"))
icon = QIcon(path_to_icon)
path_to_inproc_icon = path.abspath(path.join(path.dirname(__file__), "inproc.png"))
icon_inproc = QIcon(path_to_inproc_icon)

# Create the tray
tray = QSystemTrayIcon()
tray.setIcon(icon)
tray.setVisible(True)
tray.setObjectName("Image2LaTeX")

def capture():
# capture the screen interactively
def analyze_image(temp_file, temp_dir):
import os

# make a temp folder
import tempfile

temp_dir = tempfile.mkdtemp("image2latex")
temp_file = os.path.join(temp_dir, "capture.png")
os.system(f"screencapture -i -Jselection {temp_file}")

try:
image = Image.open(temp_file)
if not image.mode == "RGB":
Expand Down Expand Up @@ -166,6 +160,23 @@ def capture():
finally:
os.remove(temp_file)
os.rmdir(temp_dir)
tray.setIcon(icon)

def capture():
# capture the screen interactively
import os

# make a temp folder
import tempfile

temp_dir = tempfile.mkdtemp("image2latex")
temp_file = os.path.join(temp_dir, "capture.png")
os.system(f"screencapture -i -Jselection {temp_file}")

# set the qicon to a processing icon
tray.setIcon(icon_inproc)

QTimer.singleShot(1, lambda: analyze_image(temp_file, temp_dir))

# Create the menu
menu = QMenu()
Expand Down
2 changes: 1 addition & 1 deletion standalone_app/Snap2LaTeX.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ a = Analysis(
['Snap2LaTeX.py'],
pathex=[],
binaries=[],
datas=[("icon.png", ".")],
datas=[("icon.png", "."), ("inproc.png", ".")],
hiddenimports=[],
hookspath=[],
hooksconfig={},
Expand Down
Binary file added standalone_app/inproc.icns
Binary file not shown.
Binary file added standalone_app/inproc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0f90722

Please sign in to comment.