forked from RosettaTechnologies/AnkiBrain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenAIAPIKeyDialog.py
More file actions
30 lines (21 loc) · 871 Bytes
/
Copy pathOpenAIAPIKeyDialog.py
File metadata and controls
30 lines (21 loc) · 871 Bytes
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
from aqt.qt import *
class OpenAIAPIKeyDialog(QDialog):
on_key_save_callback = None
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Set OpenAI API Key")
self.label = QLabel()
self.label.setText('OpenAI API Key')
self.input_field = QLineEdit(self)
self.save_button = QPushButton('Save')
self.save_button.clicked.connect(self._handle_key_save)
self.layout = QVBoxLayout()
self.layout.addWidget(self.label)
self.layout.addWidget(self.input_field)
self.layout.addWidget(self.save_button)
self.setLayout(self.layout)
def _handle_key_save(self):
if self.on_key_save_callback is not None:
self.on_key_save_callback(self.input_field.text())
def on_key_save(self, cb):
self.on_key_save_callback = cb