MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / OpenProject

Class OpenProject

deeplabcut/gui/tabs/open_project.py:17–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class OpenProject(QtWidgets.QDialog):
18 def __init__(self, parent):
19 super().__init__(parent)
20
21 self.setWindowTitle("Load Existing Project")
22
23 self.config = None
24 self.loaded = False
25
26 main_layout = QtWidgets.QVBoxLayout(self)
27 self.layout_open()
28
29 self.ok_button = QtWidgets.QPushButton("Load")
30 self.ok_button.setDefault(True)
31 self.ok_button.clicked.connect(self.open_project)
32
33 main_layout.addWidget(self.open_frame)
34 main_layout.addWidget(self.ok_button, alignment=QtCore.Qt.AlignRight)
35
36 def layout_open(self):
37 self.open_frame = QtWidgets.QFrame(self)
38 self.open_frame.setFrameShape(self.open_frame.Shape.StyledPanel)
39 self.open_frame.setLineWidth(0)
40 self.open_frame.setMinimumWidth(600)
41
42 open_label = QtWidgets.QLabel("Select the config file:", self.open_frame)
43 self.open_line = QtWidgets.QLineEdit(self.open_frame)
44 self.open_line.textChanged[str].connect(self.open_config_name)
45
46 load_button = QtWidgets.QPushButton("Browse")
47 load_button.clicked.connect(self.load_config)
48
49 grid = QtWidgets.QGridLayout(self.open_frame)
50 grid.setSpacing(30)
51 grid.addWidget(open_label, 0, 0)
52 grid.addWidget(self.open_line, 0, 1)
53 grid.addWidget(load_button, 1, 1)
54
55 return self.open_frame
56
57 def open_config_name(self):
58 self.open_line.text()
59
60 def load_config(self):
61 cwd = os.getcwd()
62 config = QtWidgets.QFileDialog.getOpenFileName(
63 self, "Select a configuration file", cwd, "Config files (*.yaml)"
64 )
65 if not config:
66 return
67 self.config = config[0]
68 self.open_line.setText(self.config)
69 self.ok_button.setFocus()
70
71 def open_project(self):
72 if self.config == "":
73 msg = QtWidgets.QMessageBox()
74 msg.setIcon(QtWidgets.QMessageBox.Critical)

Callers 1

_open_projectMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected