-
Notifications
You must be signed in to change notification settings - Fork 0
/
snip2tex.py
59 lines (47 loc) · 1.47 KB
/
snip2tex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""
===================================
Program : snip2tex/snip2tex.py
===================================
Summary:
"""
__author__ = "Sadman Ahmed Shanto"
__date__ = "04/22/2023"
__email__ = "[email protected]"
#libraries used
import os
import platform
import subprocess
# Define the command to execute
if platform.system() == "Windows":
command = r"C:\\path\\to\\latexocr.exe"
elif platform.system() == "Linux":
command = "/path/to/latexocr"
else: # macOS
command = "/Users/shanto/anaconda3/bin/latexocr"
# Define a function to execute the command and return the output
def execute_command():
result = subprocess.run(command, capture_output=True, text=True)
return result.stdout
if platform.system() == "Darwin": # macOS
import rumps
# Define the path to the icon file (replace with your own path)
icon_path = "assets/icon.png"
# Create a rumps App class
class LatexOCRApp(rumps.App):
def __init__(self):
super(LatexOCRApp, self).__init__("LatexOCR", icon=icon_path)
# Define the "Execute" menu item
@rumps.clicked("Snip2TeX")
def execute_menu_item(self, _):
output = execute_command()
rumps.alert(output)
# Override the default behavior when the app is closed
def quit(self, _):
pass
# Create an instance of the app
app = LatexOCRApp()
# Run the app
app.run()
else: # Windows and Linux
output = execute_command()