-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.py
69 lines (58 loc) · 2.92 KB
/
MainWindow.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
60
61
62
63
64
65
66
67
68
69
#!python
import subprocess
import sys
import os
from PySide6.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QLabel, QLineEdit, QFileDialog
from PySide6 import QtWidgets
from PySide6.QtCore import QFile, Qt, QObject
from PySide6.QtUiTools import QUiLoader, loadUiType
import Tool_Box
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
# super().__init__(*args, **kwargs, parent=None)
self.loader = QUiLoader()
# self.user_name = self.window.findChild(QLineEdit, 'UserName')
# self.btn = self.window.findChild(QPushButton, 'Button1')
#self.left_pipette_cb = self.window.findChild(QtWidgets.QComboBox, 'LeftPipette')
#self.right_pipette_cb = self.window.findChild(QtWidgets.QComboBox, 'RightPipette')
#self.slot1_cb = self.window.findChild(QtWidgets.QComboBox, 'slot1ComboBox')
#self.slot2_cb = self.window.findChild(QtWidgets.QComboBox, 'slot2ComboBox')
self.file_select_button = self.window.findChild(QPushButton, "file_select_btn")
self.load_ui()
def load_ui(self):
path = os.path.join(os.path.dirname(__file__), "MainWindow.ui")
ui_file = QFile(path)
ui_file.open(QFile.ReadOnly)
self.window = self.loader.load(ui_file, self)
ui_file.close()
# self.window.show()
# btn = self.window.findChild(QPushButton, 'Button1')
self.file_select_button.clicked.connect(self.the_button_was_clicked)
# sys.exit(app.exec_())
def the_button_was_clicked(self):
path_to_file, _ = QFileDialog.getOpenFileName(self, self.tr("Upload File"),
self.tr("C:{0}Users{0}dennis{0}Documents{0}".format(os.sep)))
if path_to_file:
cmd = "scp -i ot2_ssh_key {} root@169.254.48.252:/var/lib/jupyter/notebooks/ProcedureFile.tsv" \
.format(path_to_file)
proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
print("CMD: ", cmd)
print(proc.stdout.decode())
if proc.stderr:
# dlg = QtWidgets.QMessageBox(self)
QtWidgets.QMessageBox.critical(self, "Well, that didn't go so well.", proc.stderr.decode())
# dlg.setIcon(QtWidgets.QMessageBox.Critical)
# dlg.setWindowTitle("Well, that didn't go so well.")
# dlg.setText(proc.stderr.decode())
# dlg.exec_()
elif proc.stdout:
QtWidgets.QMessageBox.information(self, "Transfer Succeeded", proc.stdout.decode())
def tr(self, text):
return QObject.tr(self, text)
if __name__ == "__main__":
app = QApplication([]) # This is our main application instance
app.setStyle("windows")
main_window = MainWindow() # This is our main window
main_window.show()
sys.exit(app.exec()) # shut it all down