def __init__(self, title, msg, duration=2): QDialog.__init__(self) self.duration = duration self.title_label = QLabel(self.make_bold(title)) self.title_label.setWordWrap(True) # self.title_label.setAlignment(QtCore.Qt.AlignLeft) self.msg_label = QLabel(msg) self.msg_label.setWordWrap(True) self.icon_button = QLabelButton() img_b64 = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAITgAACE4BjDEA7AAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABJdEVYdENvcHlyaWdodABQdWJsaWMgRG9tYWluIGh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL3B1YmxpY2RvbWFpbi9Zw/7KAAAB2ElEQVRIibWVPW/TUBiFz7mJTBFSGgnUqmABRgpMUYi53pCK1IWxUxd2BgYk/goDAzuq+AFILEhIZUuq/ACPrYRKGSJPdHkPQx3UOK7tJOKd7Guf57nXH++lJFRVr9e70el03pLcBnAnH/4t6SzLsvdpml5U5duVdABhGDLLsj6AjSvD9wFshWHIujzrVgBcrqLb7b6U9AoASH6aTqdf62YPAK6WDiBN0wszO52dm9lpEzhQs4LhcNhzzj13zj2TtDUXJH+Z2bGZ/ZhMJulSApL03r+WtNdoluS38Xj8USWw0kcUx/F+UzgASNqL43i/7NqCwHu/A+CgKfxKHeTZagGAPsnWsvQ8028ieLIsvCq7IJD0eFV6WXZO4L3fzFvCSkVy23u/ea2A5KNV4dcx5gRm9nBdQZFRfAcP1hUUGXMC59zagiLjn2AwGNwCsPCjrFA7OWteEATBrqRG3bWqJLkgCHZn523gsrnFcdwi+YXkrGEJAMxMs+OSonNutukwF9DMWiQpSUyS5Kmku+vOvKzM7KxtZu8A3PwfAgB/2iQ/m9m9qrtIxgBuF4bPJY1qBD8b7clJkryQ9KYg/TAajb7XZRt9NVEUHUk6BHAC4ETSYRRFR02yfwEMBLRPQVtfqgAAAABJRU5ErkJggg==" pixmap = QtGui.QPixmap() pixmap.loadFromData(base64.b64decode(img_b64)) self.icon_button.setPixmap(pixmap) self.icon_button.resize(20, 20) self.accepted.connect(self.close_all) #self.connect(self.icon_button, QtCore.SIGNAL("clicked()"), self.close_all) title_layout = QtWidgets.QVBoxLayout() title_layout.addWidget(self.title_label) title_layout.addWidget(self.msg_label) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.icon_button) layout.addLayout(title_layout, 1) self.setGeometry(0, 0, 300, 100) self.setLayout(layout) self.setWindowFlags(QtCore.Qt.FramelessWindowHint) # self.setStyleSheet("border: 1px solid red; border-radius: 5px;") self.toastThread = ToastThread(self.duration) self.toastThread.finished.connect(self.close_all) self.toastThread.start()
def __init__(self, uniqueName, options = KDDockWidgets.MainWindowOption_None, dockWidget0IsNonClosable = False, nonDockableDockWidget9 = False, restoreIsRelative = False, maxSizeForDockWidget8 = False, affinityName = "", parent = None): super().__init__(uniqueName, options, parent) self.m_dockWidget0IsNonClosable = dockWidget0IsNonClosable self.m_dockWidget9IsNonDockable = nonDockableDockWidget9 self.m_restoreIsRelative = restoreIsRelative self.m_maxSizeForDockWidget8 = maxSizeForDockWidget8 self.m_dockwidgets = [] menubar = self.menuBar() fileMenu = QtWidgets.QMenu("File") self.m_toggleMenu = QtWidgets.QMenu("Toggle") menubar.addMenu(fileMenu) menubar.addMenu(self.m_toggleMenu) newAction = fileMenu.addAction("New DockWidget") newAction.triggered.connect(self._newDockWidget) saveLayoutAction = fileMenu.addAction("Save Layout") saveLayoutAction.triggered.connect(self._saveLayout) restoreLayoutAction = fileMenu.addAction("Restore Layout") restoreLayoutAction.triggered.connect(self._restoreLayout) closeAllAction = fileMenu.addAction("Close All") closeAllAction.triggered.connect(self._closeAll) layoutEqually = fileMenu.addAction("Layout Equally") layoutEqually.triggered.connect(self.layoutEqually) quitAction = fileMenu.addAction("Quit") quitAction.triggered.connect(QtWidgets.QApplication.instance().quit) self.setAffinities([ affinityName ]) self.createDockWidgets()
def handleUpdateDevices(self): p = listDevices() self.menuPort.clear() ag = QtWidgets.QActionGroup(self, exclusive=True) for port in p: menu = ag.addAction(QtWidgets.QAction(port, self, checkable=True)) self.menuPort.addAction(menu) if port == self.port: menu.setChecked(True) self.ports[port] = menu
def loadCSVButtonClicked(self): msg = QtWidgets.QMessageBox() reply = msg.question( self, 'Load waypoints from CSV?', "Are you sure? This will overwrite your existing waypoints.", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: del dataPoints[0][:] del dataPoints[1][:] del dataPoints[2][:] del dataPoints[3][:] del dataPoints[4][:] del dataPoints[5][:] aw.list.clear() with open('flightPath.csv', 'r') as csvfile: csvReader = csv.reader(csvfile) for row in csvReader: if len(row) == 3: try: self.dc.addPoint(int(row[0]), int(row[1]), int(row[2])) print(row) except ValueError: True
def newDocument(self): self.documentCount += 1 sub = QtWidgets.QMdiSubWindow() sub.setWidget(DocumentWindow(Document(), self, sub)) sub.setWindowTitle("Untitled" + str(self.documentCount)) self.mdiArea.addSubWindow(sub) sub.show() return sub
def openDocument(self): dir = self.settings.value('OpenFilePath') (filename, ftype) = QtWidgets.QFileDialog.getOpenFileName( self, 'Open file', dir, "All supported files (*.uarm *.plt *.svg);;uArmUI plot files (*.uarm);;HP plotter plot files (*.plt);;SVG vector graphics (*.svg)" ) if filename: self.settings.setValue('OpenFilePath', os.path.dirname(str(filename))) self.documentCount += 1 sub = QtWidgets.QMdiSubWindow() sub.setWidget(DocumentWindow(Document.load(filename), self, sub)) sub.setWindowTitle(filename) self.mdiArea.addSubWindow(sub) sub.show()
def beginButtonClicked(self): msg = QtWidgets.QMessageBox() reply = msg.question( self, 'Begin Flight?', "Flight path will be saved to flightPath.csv. Are you sure you want to begin flight?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: with open('flightPath.csv', 'w') as csvfile: fieldnames = ['x', 'y'] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() for i in range(0, 3): writer.writerow({ 'x': str(dataPoints[2 * i]), 'y': str(dataPoints[2 * i + 1]) }) dictList = [] for i in range(0, 3): currentDict = { 'x': dataPoints[2 * i], 'y': dataPoints[2 * i + 1] } dictList.append(currentDict) #uncomment below when ready to start testing data, as well as uncommenting line 30 #com.send(dictList) for i in range(0, 3): #send x com.send(dataPoints[2 * i]) #space for seperation com.send(" ") #send y com.send(dataPoints[2 * i + 1]) com.send(" ") com.send("EndOfFile")
def __init__(self): QtWidgets.QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("application main window") self.file_menu = QtWidgets.QMenu('&File', self) self.file_menu.addAction('&Quit', self.fileQuit, QtCore.Qt.CTRL + QtCore.Qt.Key_Q) self.menuBar().addMenu(self.file_menu) self.help_menu = QtWidgets.QMenu('&Help', self) self.menuBar().addSeparator() self.menuBar().addMenu(self.help_menu) self.help_menu.addAction('&About', self.about) self.main_widget = QtWidgets.QWidget(self) l = QtWidgets.QGridLayout(self.main_widget) # sc = MyStaticMplCanvas(self.main_widget, width=5, height=4, dpi=100) self.dc = MyDynamicMplCanvas(self.main_widget, width=10, height=8, dpi=100) self.list = QListWidget(self) self.list.setFont(QFont('Courier')) self.list.doubleClicked.connect(self.listItemDoubleClicked) # l.addWidget(sc) self.xEdit = QLineEdit() self.yEdit = QLineEdit() self.xEdit2 = QLineEdit() self.yEdit2 = QLineEdit() self.xEdit3 = QLineEdit() self.yEdit3 = QLineEdit() #self.altitudeEdit = QLineEdit() self.xEdit.setText('0') self.yEdit.setText('0') self.xEdit2.setText('0') self.yEdit2.setText('0') self.xEdit3.setText('0') self.yEdit3.setText('0') #self.altitudeEdit.setText('5') self.xLabel = QLabel('ISU #1 Longitude') self.yLabel = QLabel('ISU #1 Latitude') self.xLabel2 = QLabel('ISU #2 Longitude') self.yLabel2 = QLabel('ISU #2 Latitude') self.xLabel3 = QLabel('Ground Station Longitude') self.yLabel3 = QLabel('Ground Station Latitude') #self.altitudeLabel = QLabel('Altitude in Feet') self.gpsLabel = QLabel(' Use GPS as position') self.addButton = QPushButton("Add Point") self.addButton.clicked.connect(self.addPointButtonClicked) self.startButton = QPushButton("Begin") self.startButton.clicked.connect(self.beginButtonClicked) self.loadCSVButton = QPushButton("Load from CSV") self.loadCSVButton.clicked.connect(self.loadCSVButtonClicked) self.gpsCheckBox = QCheckBox() self.altitudeCheckBox = QCheckBox() self.altitudeCheckBoxLabel = QLabel(' Show altitude annotations') self.altitudeCheckBox.stateChanged.connect( self.altitudeCheckBoxClicked) self.altitudeCheckBox.toggle() l.addWidget(self.xLabel, 0, 0, 1, 1) l.addWidget(self.yLabel, 0, 1, 1, 1) l.addWidget(self.xLabel2, 0, 2, 1, 1) l.addWidget(self.yLabel2, 0, 3, 1, 1) l.addWidget(self.xLabel3, 0, 4, 1, 1) l.addWidget(self.yLabel3, 0, 5, 1, 1) #l.addWidget(self.altitudeLabel, 0, 6, 1, 1) l.addWidget(self.gpsLabel, 1, 8, 1, 1) l.addWidget(self.xEdit, 1, 0, 1, 1) l.addWidget(self.yEdit, 1, 1, 1, 1) l.addWidget(self.xEdit2, 1, 2, 1, 1) l.addWidget(self.yEdit2, 1, 3, 1, 1) l.addWidget(self.xEdit3, 1, 4, 1, 1) l.addWidget(self.yEdit3, 1, 5, 1, 1) #l.addWidget(self.altitudeEdit, 1, 6, 1, 1) l.addWidget(self.addButton, 1, 7, 1, 1) l.addWidget(self.gpsCheckBox, 1, 8, 1, 1) l.addWidget(self.startButton, 3, 8, 1, 1) l.addWidget(self.loadCSVButton, 3, 7, 1, 1) #l.addWidget(self.altitudeCheckBoxLabel, 0, 8, 1, 1) #l.addWidget(self.altitudeCheckBox, 0, 8, 1, 1) l.addWidget(self.dc, 2, 0, 1, 7) l.addWidget(self.list, 2, 7, 1, 2) # self.addButton.clicked.connect(dc.addPoint(str(self.xEdit.text()), str(self.yEdit.text()), str(self.altitudeEdit.text()))) lenCoords = len(dataPoints[0]) for i in range(0, lenCoords): self.list.addItem( str(i + 1) + ". " + "(" + str(dataPoints[0][i]) + ", " + str(dataPoints[1][i]) + ") Alt: " + str(dataPoints[2][i])) # lenCoords = len(exampleData[0]) # for i in range(0,lenCoords): # self.list.addItem("(" + str(exampleData[0][i]) + ", " + str(exampleData[1][i]) + ") Altitude: " + str(exampleData[2][i]) + " Temp: " + str(exampleData[3][i]) + " °C") # self.list.addItem('{:16s} {:18s} {:18s}'.format("(" + str(exampleData[0][i]) + ", " + str(exampleData[1][i]) + ")", "Altitude: " + str(exampleData[2][i]), "Temp: " + str(exampleData[3][i]) + " °C")) self.main_widget.setFocus() self.setCentralWidget(self.main_widget)
self.list.takeItem(deletedRow) self.dc.removePoint(deletedRow) # Left and Right key to increase or decrease altitude if event.key() == QtCore.Qt.Key_Right: self.altitudeEdit.setText(str(int(self.altitudeEdit.text()) + 1)) elif event.key() == QtCore.Qt.Key_Left: self.altitudeEdit.setText(str(int(self.altitudeEdit.text()) - 1)) if event.modifiers() & QtCore.Qt.ControlModifier and event.key( ) == QtCore.Qt.Key_Z: rowToDelete = len(dataPoints[0]) - 1 if rowToDelete != 0: print('deleted ' + str(rowToDelete)) self.list.takeItem(rowToDelete) self.dc.removePoint(rowToDelete) def about(self): QtWidgets.QMessageBox.about( self, "About", """A program to plot a flight path for an autonomous UAV.""") qApp = QtWidgets.QApplication(sys.argv) aw = ApplicationWindow() aw.setWindowTitle("%s" % progname) aw.show() sys.exit(qApp.exec_()) # qApp.exec_()
def __init__(self): QtWidgets.QWidget.__init__(self) self.default = dict() # DIAL -------------------------------------------- # Dial x self.nDialx = QtWidgets.QDial() self.nDialx.setNotchesVisible(True) self.nDialx.setMinimum(0) self.nDialx.setMaximum(360) self.nDialx.setValue(0) # default start from the beginning # Dial y self.nDialy = QtWidgets.QDial() self.nDialy.setNotchesVisible(True) self.nDialy.setMinimum(0) self.nDialy.setMaximum(360) self.nDialy.setValue(0) # default start from the beginning # Dial z self.nDialz = QtWidgets.QDial() self.nDialz.setNotchesVisible(True) self.nDialz.setMinimum(0) self.nDialz.setMaximum(360) self.nDialz.setValue(0) # default start from the beginning # SLIDE ------------------------------------------- # Slide Horizontal X self.nSlidex = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.nSlidex.setMinimum(-20) self.nSlidex.setMaximum(20) self.nSlidex.setValue(0) # Slide Vertical Y self.nSlidey = QtWidgets.QSlider(QtCore.Qt.Vertical) self.nSlidey.setMinimum(-20) self.nSlidey.setMaximum(20) self.nSlidey.setValue(0) # Slide Horizontal Z self.nSlidez = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.nSlidez.setMinimum(-20) self.nSlidez.setMaximum(20) self.nSlidez.setValue(0) # Reset button self.resetBtn = QtWidgets.QPushButton('Reset') # Close button self.closeBtn = QtWidgets.QPushButton('Close') self.nGridLayout = QtWidgets.QGridLayout() self.nGridLayout.addWidget(self.nDialx, 1, 0) self.nGridLayout.addWidget(self.nDialy, 1, 1) self.nGridLayout.addWidget(self.nDialz, 1, 2) self.nGridLayout.addWidget(self.nSlidex, 2, 0) self.nGridLayout.addWidget(self.nSlidey, 2, 1) self.nGridLayout.addWidget(self.nSlidez, 2, 2) self.nGridLayout.addWidget(self.resetBtn, 3, 1) self.nGridLayout.addWidget(self.closeBtn, 3, 2) self.setLayout(self.nGridLayout) self.setWindowTitle('Soovii - Bulk loader') # Create connection self.connect(self.nDialx, QtCore.SIGNAL("valueChanged(int)"), self.nRT) self.connect(self.nDialy, QtCore.SIGNAL("valueChanged(int)"), self.nRT) self.connect(self.nDialz, QtCore.SIGNAL("valueChanged(int)"), self.nRT) self.connect(self.nSlidex, QtCore.SIGNAL("valueChanged(int)"), self.nRT) self.connect(self.nSlidey, QtCore.SIGNAL("valueChanged(int)"), self.nRT) self.connect(self.nSlidez, QtCore.SIGNAL("valueChanged(int)"), self.nRT) self.connect(self.resetBtn, QtCore.SIGNAL("clicked()"), self.nReset) self.connect(self.closeBtn, QtCore.SIGNAL("clicked()"), self.close)