forked from RosettaTechnologies/AnkiBrain
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstallDialog.py
More file actions
95 lines (74 loc) · 3.02 KB
/
Copy pathInstallDialog.py
File metadata and controls
95 lines (74 loc) · 3.02 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import platform
import webbrowser
from aqt.qt import *
from util import run_win_install, run_macos_install, run_linux_install
pyenv_generic_instr = '''
Create a python 3.9.13 venv:
<p><code>pyenv install 3.9.13</code></p>
<p><code>pyenv local 3.9.13</code></p>
<p><code>python -m venv venv</code></p>
<p>Activate virtualenv:</p>
<p>Windows: <code>.\\venv\\Scripts\\activate</code></p>
<p>MacOS/Linux: <code>./venv/bin/activate</code></p>
<p><code>pip install -r requirements.txt</code></p>
<p><code></code></p>
'''
win_auto_install_instr = '''
<html>
<p>Windows Install Instructions</p>
<ol>
<li>Install C++ build tools</li>
<ol>
<li>Download: <a href="https://visualstudio.microsoft.com/visual-cpp-build-tools">Microsoft Visual C++ Build Tools</a></li>
<li>Run installer: make sure "Desktop Development with C++" is checked (about 8 GB)</li>
</ol>
<li><p>Run the Python environment setup script below.</p>
<p>It will launch two terminals (one may be be hidden in the taskbar).</p>
<p><b>Make sure to press a key to continue on the second terminal when prompted.\n</b></p>
</li>
</ol>
</html>
'''
macos_linux_auto_install_instr = '''
<html><p>
Simply run the setup script below.
If issues, see manual install instructions.
</p></html>
'''
def show_manual_install_instr():
webbrowser.open('https://www.reddit.com/r/ankibrain/comments/14ej1bq/how_to_install_ankibrain/')
class InstallDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Install Instructions")
system = platform.system()
install_instr = ''
install_button = None
if system == 'Windows':
install_instr = win_auto_install_instr
install_button = QPushButton('Run Windows Installer')
install_button.clicked.connect(run_win_install)
elif system == 'Darwin':
install_instr = macos_linux_auto_install_instr
install_button = QPushButton('Run MacOS Installer')
install_button.clicked.connect(run_macos_install)
elif system == 'Linux':
install_instr = macos_linux_auto_install_instr
install_button = QPushButton('Run Ubuntu/Debian Installer')
install_button.clicked.connect(run_linux_install)
label = QLabel()
label.setText(install_instr)
label.setOpenExternalLinks(True)
restart_text = QLabel('\n\nFinal step: Restart Anki\n')
show_manual_install_instr_button = QPushButton('Show Manual Install Instructions')
show_manual_install_instr_button.clicked.connect(show_manual_install_instr)
layout = QVBoxLayout()
layout.addWidget(label)
layout.addWidget(install_button)
layout.addWidget(restart_text)
layout.addWidget(QLabel('Stuck? Get Help:'))
layout.addWidget(show_manual_install_instr_button)
self.setLayout(layout)
def show_install_dialog():
from aqt import mw
mw.installDialog.show()