def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.init_all_tabs() #initialize icon editor widget self.ui.widget_iconeditor.newCleanImage(size=self.ICON_EDITOR_SIZE) self.initialize_radio_buttons_events()
def __init__(self, parent=None): super(MainWinGui, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.myName.setText(getStoredName() or "") self.ui.myName.textEdited.connect(self.nameChanged) self.communicator = Communicator(self) self.communicator.peersUpdated.connect(self.refreshPeers) self.communicator.fileReceived.connect(self.fileReceived) self.ui.refreshPeersButton.clicked.connect(self.discoverPeers) self.ui.peerList.itemClicked.connect(self.peerSelected) self.progressIndeterminate.connect(self.progressIndeterminateSlot) self.progressSet.connect(self.progressSetSlot) self.progressStop.connect(self.progressStopSlot) self.progressIndicator = QProgressBar(self.ui.statusbar) self.progressIndicator.setMinimumHeight(5) self.progressIndicator.setVisible(False) self.progressIndicator.setMaximum(0) self.progressIndicator.setMinimum(0) self.ui.statusbar.addWidget(self.progressIndicator)
def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self) self.mediaObject = Phonon.MediaObject(self) self.ui.seekSlider_2.setMediaObject(self.mediaObject) self.ui.volumeSlider_2.setAudioOutput(self.audioOutput) Phonon.createPath(self.mediaObject, self.audioOutput) self.settingsDialog = None self.tagmodel = TagModel(self) self.ui.tagView.setModel(self.tagmodel) self.filemodel = SoundfileModel(self) self.ui.fileView.setModel(self.filemodel) self.ui.fileView.setLayoutMode(self.ui.fileView.Batched) self.ui.fileView.setBatchSize(40) self.stackmodel = SimpleFileModel(self) self.ui.stack.setModel(self.stackmodel) self.ui.actionShow_tags.setChecked(0) self.ui.actionShow_volume.setChecked(0) # # Set shortcuts self.ui.actionPreferences.setShortcut(QtGui.QKeySequence.Preferences) self.ui.actionPreferences.setShortcut(QtGui.QKeySequence.Quit) self.ui.actionEdit_all.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_E)) self.ui.actionEdit_one_by_one.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_E)) self._init_menus() self.connect(self.ui.lineEdit, SIGNAL("returnPressed()"), self.start_search) self.connect(self.ui.lineEdit, SIGNAL("textChanged(const QString &)"), self.on_lineEdit_textChanged) self.connect(self.ui.tagView, SIGNAL("clicked(const QModelIndex &)"), self.on_tagView_click) self.connect(self.ui.actionPreferences, SIGNAL("triggered()"), self.manage_folders) self.ui.fileView.doubleClicked.connect(self.edit_all) self.ui.actionEdit_all.triggered.connect(self.edit_all) self.ui.actionEdit_one_by_one.triggered.connect(self.edit_one_by_one) self.ui.fileView.selectionModel().currentChanged.connect(self.on_fileView_currentChanged) self.ui.actionStack.triggered.connect(self.on_actionStack)
class CallMainWindow(QMainWindow): CLASS_IMAGES = "alpha.gif beta.png delta.png".split() DISTANCE_NORMS = { "Norm 1": distance_norm_1, "Norm 2": distance_norm_2, "Norm P": distance_norm_p } DESCRIPTOR_CALCULATORS = { "Descriptor 1": calculate_descriptor_1, "Descriptor 2": calculate_descriptor_2, "Descriptor 3": calculate_descriptor_3 } ICON_EDITOR_SIZE = (16, 16) def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.init_all_tabs() #initialize icon editor widget self.ui.widget_iconeditor.newCleanImage(size=self.ICON_EDITOR_SIZE) self.initialize_radio_buttons_events() def initialize_radio_buttons_events(self): # trap events from descriptor radio buttons for rb in self.ui.groupBox_descriptor.children(): rb.toggled.connect(self.calculate_classes) # trap events from distance radio buttons for rb in self.ui.groupBox_distance.children(): rb.toggled.connect(self.calculate_classes) def keyPressEvent(self, event): if event.key() == Qt.Key_P: LOGD("hey you press the P key :D") def appendToLogWindow(self, text): logWindow = self.ui.plainTextEdit logWindow.setText(logWindow.getText() + "\n" + text) def process_image(self, img_array, descriptor_func=None, distance_func=None, class_name=None): """ process the image data and returns a tuple containing the descriptor and the distance @param img_array: the image data @param descriptor: function that computes how are we going to describe our image data @param distance: selects the distance calculator among many @param class_name: a name to use for DEBUG purposes """ LOGI("Computing %s data" % (class_name)) calculate_descriptor = descriptor_func descriptor_data = calculate_descriptor(img_array) LOGD("Descriptor Data:\n%s" % (str(descriptor_data))) distance_data = distance_func(descriptor_data) LOGD("Distance Data:\n%s" % (str(distance_data))) return (descriptor_data, distance_data) def array_to_string(self, array): pass def get_selected_distance_method(self): for rb in self.ui.groupBox_distance.children(): if rb.isChecked(): LOGD("distance=%s" % rb.text()) return self.DISTANCE_NORMS[str(rb.text())] def get_selected_descriptor_method(self): for rb in self.ui.groupBox_descriptor.children(): if rb.isChecked(): LOGD("descriptor=%s" % rb.text()) return self.DESCRIPTOR_CALCULATORS[str(rb.text())] def find_closest_distance(self): css_clear = """QLineEdit { background:; } """ # highlight the closes match css_highlighted_bg = """QLineEdit { background-color: yellow; }""" icon_distance = self.ui.lineEdit_icon.text().toFloat()[0] closest_distance = 10000000 # initialize this to a largest value closest_lineEdit = None for lned in self.ui.tabMinDistance.findChildren(PyQt4.QtGui.QLineEdit): lned.setStyleSheet(css_clear) cur_distance = lned.text().toFloat()[0] distance_diff = abs(icon_distance - cur_distance) if distance_diff < closest_distance: closest_distance = distance_diff closest_lineEdit = lned closest_lineEdit.setStyleSheet(css_highlighted_bg) def on_pbtn_calculate_clicked(self): self.calculate_classes() def on_groupBox_descriptor_clicked(self, event): print "hello" def calculate_classes(self): LOGD("Update options classifier and distance methods") descriptor_func = self.get_selected_descriptor_method() distance_func = self.get_selected_distance_method() # calculate the first class LOGD("class alpha") img_array = convert_image_to_array(self.class1img) descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "alpha" ) self.ui.textEdit_info1.setText(str(descriptor)) self.ui.lineEdit_class1.setText(str(distance)) # calculate the second class LOGD("class beta") img_array = convert_image_to_array(self.class2img) descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "beta" ) self.ui.textEdit_info2.setText(str(descriptor)) self.ui.lineEdit_class2.setText(str(distance)) # calculate the third class LOGD("class gamma") img_array = convert_image_to_array(self.class3img) descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "gamma" ) self.ui.textEdit_info3.setText(str(descriptor)) self.ui.lineEdit_class3.setText(str(distance)) # calculate the Drew class LOGD("class drawing") img_array = self.ui.widget_iconeditor.getIconData() descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "Drawing" ) self.ui.textEdit_info4.setText(str(descriptor)) self.ui.lineEdit_icon.setText(str(distance)) # find closest match self.find_closest_distance() def on_widget_iconeditor_updated(self): self.calculate_classes() def init_all_tabs(self): self.init_minimum_distance() def compute_descriptors(self, class_data, descriptor_type): pass def init_minimum_distance(self): self.ui.label_desc1.setText("class alpha") self.ui.label_img1.setPixmap(QPixmap("alpha.png")) self.ui.label_img1.setScaledContents(True) self.ui.label_desc2.setText("class beta") self.ui.label_img2.setPixmap(QPixmap("beta.png")) self.ui.label_img2.setScaledContents(True) self.ui.label_desc3.setText("class delta") self.ui.label_img3.setPixmap(QPixmap("delta.png")) self.ui.label_img3.setScaledContents(True) self.class1img = Image.open("alpha.png") self.class2img = Image.open("beta.png") self.class3img = Image.open("delta.png")
class MainWinGui(QtGui.QMainWindow): progressIndeterminate = QtCore.pyqtSignal() progressSet = QtCore.pyqtSignal(int) progressStop = QtCore.pyqtSignal() def __init__(self, parent=None): super(MainWinGui, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.myName.setText(getStoredName() or "") self.ui.myName.textEdited.connect(self.nameChanged) self.communicator = Communicator(self) self.communicator.peersUpdated.connect(self.refreshPeers) self.communicator.fileReceived.connect(self.fileReceived) self.ui.refreshPeersButton.clicked.connect(self.discoverPeers) self.ui.peerList.itemClicked.connect(self.peerSelected) self.progressIndeterminate.connect(self.progressIndeterminateSlot) self.progressSet.connect(self.progressSetSlot) self.progressStop.connect(self.progressStopSlot) self.progressIndicator = QProgressBar(self.ui.statusbar) self.progressIndicator.setMinimumHeight(5) self.progressIndicator.setVisible(False) self.progressIndicator.setMaximum(0) self.progressIndicator.setMinimum(0) self.ui.statusbar.addWidget(self.progressIndicator) def nameChanged(self, newName): storeName(newName) self.communicator.updateName(newName) def progressStart(self): self.progressIndicator.setVisible(True) def progressSetSlot(self, value): self.progressStart() self.progressIndicator.setMaximum(100) self.progressIndicator.setValue(value) def progressIndeterminateSlot(self): self.progressStart() self.progressIndicator.setMaximum(0) def progressStopSlot(self): self.progressIndicator.setVisible(False) def show(self): super(MainWinGui, self).show() self.refreshPeers() self.discoverPeers() def discoverPeers(self): self.communicator.discoverPeers() def refreshPeers(self): self.ui.peerList.clear() for peer in self.communicator.peers: peer = self.communicator.peers[peer] peerName = QListWidgetItem(self.ui.peerList) peerName.peer = peer nameFont = QtGui.QFont() nameFont.setPointSize(14) peerDetails = QListWidgetItem(self.ui.peerList) peerDetails.peer = peer detailsFont = QtGui.QFont() detailsFont.setPointSize(10) name = peer.name details = "" if peer.publicKey is None: details += "Unpaired, " else: details += "Paired, " if peer.lastKnownIP is None: details += "unavailable" else: details += "available: " + peer.lastKnownIP peerName.setFont(nameFont) peerName.setText(name) peerDetails.setFont(detailsFont) peerDetails.setText(details) self.ui.peerList.addItem(peerName) self.ui.peerList.addItem(peerDetails) separatorItem = QListWidgetItem(self.ui.peerList) separatorItem.guid = peer.guid separatorItem.peer = None separatorItem.setFlags(QtCore.Qt.NoItemFlags) self.ui.peerList.addItem(separatorItem) def peerSelected(self, selectedItem): selectedItem.setSelected(False) if selectedItem.peer: PeerOptionsUi(self, selectedItem.peer, self.communicator).show() else: pass def sendFile(self, guid): fileName = QtGui.QFileDialog.getOpenFileName() if not fileName: return fileContents = open(fileName, "rb").read() basename = os.path.basename(fileName) self.communicator.sendFile(basename, fileContents, guid) def fileReceived(self, fileName, fileContents): fileName = QtGui.QFileDialog.getSaveFileName(directory=fileName) if not fileName: return with open(fileName, mode="wb") as file: file.write(fileContents)
class MyWindow(QtGui.QMainWindow): def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self) self.mediaObject = Phonon.MediaObject(self) self.ui.seekSlider_2.setMediaObject(self.mediaObject) self.ui.volumeSlider_2.setAudioOutput(self.audioOutput) Phonon.createPath(self.mediaObject, self.audioOutput) self.settingsDialog = None self.tagmodel = TagModel(self) self.ui.tagView.setModel(self.tagmodel) self.filemodel = SoundfileModel(self) self.ui.fileView.setModel(self.filemodel) self.ui.fileView.setLayoutMode(self.ui.fileView.Batched) self.ui.fileView.setBatchSize(40) self.stackmodel = SimpleFileModel(self) self.ui.stack.setModel(self.stackmodel) self.ui.actionShow_tags.setChecked(0) self.ui.actionShow_volume.setChecked(0) # # Set shortcuts self.ui.actionPreferences.setShortcut(QtGui.QKeySequence.Preferences) self.ui.actionPreferences.setShortcut(QtGui.QKeySequence.Quit) self.ui.actionEdit_all.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_E)) self.ui.actionEdit_one_by_one.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_E)) self._init_menus() self.connect(self.ui.lineEdit, SIGNAL("returnPressed()"), self.start_search) self.connect(self.ui.lineEdit, SIGNAL("textChanged(const QString &)"), self.on_lineEdit_textChanged) self.connect(self.ui.tagView, SIGNAL("clicked(const QModelIndex &)"), self.on_tagView_click) self.connect(self.ui.actionPreferences, SIGNAL("triggered()"), self.manage_folders) self.ui.fileView.doubleClicked.connect(self.edit_all) self.ui.actionEdit_all.triggered.connect(self.edit_all) self.ui.actionEdit_one_by_one.triggered.connect(self.edit_one_by_one) self.ui.fileView.selectionModel().currentChanged.connect(self.on_fileView_currentChanged) self.ui.actionStack.triggered.connect(self.on_actionStack) def on_actionStack(self): [self.stackmodel.appendRow(self.filemodel.itemFromIndex(m).clone()) for m in self.ui.fileView.selectedIndexes()] def on_actionPlay_toggled(self, boo): """Plays current sound.""" file = self.filemodel.pathFromIndex(self.ui.fileView.currentIndex()) if boo or self.mediaObject.currentSource().fileName() != file: self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) self.mediaObject.play() self.ui.actionPlay.setChecked(True) else: self.ui.actionPlay.setChecked(False) self.mediaObject.stop() def on_tagView_click(self, mi): """Append selected tags to search.""" fa = self.ui.lineEdit.text() f = ",".join([f.strip() for f in fa.split(",") if f.strip() and not f.strip()[0]=="t"]) if f: self.ui.lineEdit.setText( f + ", t=" + ", t=".join([mi.data().toString() for mi in self.ui.tagView.selectedIndexes()]) ) else: self.ui.lineEdit.setText( "t=" + ", t=".join([mi.data().toString() for mi in self.ui.tagView.selectedIndexes()]) ) self.start_search() def on_fileView_currentChanged(self, mi, mip): sf = self.filemodel.soundfileFromIndex(mi) if sf.channels is None: metadata = "<br/>Couldn't fetch metadata." else: ch = min(sf.channels, 3) channels = [0, "Mono", "Stereo", "{0} channels".format(sf.channels)][ch] metadata = """<br/>{1}kHz {2} {0} {4} <br/>Encoding: {3}<br/>Length: {5:.2f} s ({6} samples) """.format( sf.file_format, sf.samplerate/1000.0, channels, sf.encoding, sf.endianness, sf.length, sf.nframes) self.ui.fileInfoLabel.setText("<b>{0}</b>\n{1}".format(sf.path, metadata)) def edit_all(self, mi, all=False): """Open file dialog.""" items = [self.filemodel.itemFromIndex(m) for m in self.ui.fileView.selectedIndexes()] d = MyDialog(*items) result = d.exec_() if result: self.filemodel.rebuild() def edit_one_by_one(self): items = [self.filemodel.itemFromIndex(m) for m in self.ui.fileView.selectedIndexes()] for i in items: d = MyDialog(i) d.exec_() self.filemodel.rebuild() def on_lineEdit_textChanged(self, s): """Check if current string calls for a new search. """ try: test = s.strip()[-1] == "," except IndexError: self.start_search() else: if test: self.start_search() def manage_folders(self): """Open repository dialog. """ if not self.settingsDialog: self._setupSettings() self.settingsDialog.setTab("repositories") self.settingsDialog.show() def start_search(self): """Make list from searchbox, and start search. """ searches = [t.strip() for t in unicode(self.ui.lineEdit.text()).split(",") if t.strip()] self.filemodel.search(searches) #self.ui.fileView.resizeColumnToContents(0) def rebuild(self): """Expensive redo-search-and-redraw-all method.""" self.filemodel.rebuild() self.tagmodel.reload() def _init_menus(self): #TODO: remove dummy menu items self.ui.menuOpen_with.clear() self.ui.menuOpen_copy_with.clear() self.ui.menuExport_as.clear() self.ui.actionAll_folders.triggered.connect(self.on_repo_rescan) for repo in Repo.query.all(): ac = self.ui.menuRescan_folders.addAction(repo.path) ac.triggered.connect(self.on_repo_rescan) settings = QtCore.QSettings("ljud.org", "Sampleman") size = settings.beginReadArray("apps") for i in range(size): settings.setArrayIndex(i) s = settings.value("key").toString() if not s: continue ac = self.ui.menuOpen_with.addAction(s) ac.triggered.connect(self.on_open_with) ac = self.ui.menuOpen_copy_with.addAction(s) ac.triggered.connect(self.on_open_copy_with) settings.endArray() size = settings.beginReadArray("folders") for i in range(size): if not s: continue settings.endArray() size = settings.beginReadArray("formats") for i in range(size): if not s: continue settings.setArrayIndex(i) s = settings.value("key").toString() ac = self.ui.menuExport_as.addAction(s) ac.triggered.connect(self.on_export_as) settings.endArray() def on_newRepo(self, s): self.ui.menuRescan_folders.addAction( s).triggered.connect(self.on_repo_rescan) def on_newFolder(self, s): pass #TODO def on_newFormat(self, s): self.ui.menuExport_as.addAction( s).triggered.connect(self.on_export_as) def on_newApp(self, s): self.ui.menuOpen_with.addAction( s).triggered.connect(self.on_open_with) self.ui.menuOpen_copy_with.addAction( s).triggered.connect(self.on_open_copy_with) def on_export_as(self): #TODO print "export" def on_open_with(self): #TODO pgm = self.sender().text() file = self.filemodel.pathFromIndex(self.ui.fileView.currentIndex()) utils.open_with(pgm, file) def on_open_copy_with(self): #TODO print "opencopy" def on_repo_rescan(self): path = self.sender().text() if path == "All folders": repos = Repo.query.all() else: repos = (Repo.get_by(path=unicode(path)),) repomodel = RepoModel() for repo in repos: repomodel.scan_repo(repo) def _setupSettings(self): self.settingsDialog = SettingsDialog(self) self.settingsDialog.newRepo.connect(self.on_newRepo) self.settingsDialog.newFolder.connect(self.on_newFolder) self.settingsDialog.newFormat.connect(self.on_newFormat) self.settingsDialog.newApp.connect(self.on_newApp)
class CallMainWindow(QMainWindow): CLASS_IMAGES = "alpha.gif beta.png delta.png".split() DISTANCE_NORMS = { "Norm 1": distance_norm_1, "Norm 2": distance_norm_2, "Norm P": distance_norm_p } DESCRIPTOR_CALCULATORS = { "Descriptor 1": calculate_descriptor_1, "Descriptor 2": calculate_descriptor_2, "Descriptor 3": calculate_descriptor_3 } ICON_EDITOR_SIZE = (16, 16) def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.init_all_tabs() #initialize icon editor widget self.ui.widget_iconeditor.newCleanImage(size=self.ICON_EDITOR_SIZE) self.initialize_radio_buttons_events() def initialize_radio_buttons_events(self): # trap events from descriptor radio buttons for rb in self.ui.groupBox_descriptor.children(): rb.toggled.connect(self.calculate_classes) # trap events from distance radio buttons for rb in self.ui.groupBox_distance.children(): rb.toggled.connect(self.calculate_classes) def keyPressEvent(self, event): if event.key() == Qt.Key_P: LOGD("hey you press the P key :D") def appendToLogWindow(self, text): logWindow = self.ui.plainTextEdit logWindow.setText(logWindow.getText() + "\n" + text) def process_image(self, img_array, descriptor_func=None, distance_func=None, class_name=None): """ process the image data and returns a tuple containing the descriptor and the distance @param img_array: the image data @param descriptor: function that computes how are we going to describe our image data @param distance: selects the distance calculator among many @param class_name: a name to use for DEBUG purposes """ LOGI("Computing %s data" % (class_name)) calculate_descriptor = descriptor_func descriptor_data = calculate_descriptor(img_array) LOGD("Descriptor Data:\n%s" % (str(descriptor_data))) distance_data = distance_func(descriptor_data) LOGD("Distance Data:\n%s" % (str(distance_data))) return (descriptor_data, distance_data) def array_to_string(self, array): pass def get_selected_distance_method(self): for rb in self.ui.groupBox_distance.children(): if rb.isChecked(): LOGD("distance=%s" % rb.text()) return self.DISTANCE_NORMS[str(rb.text())] def get_selected_descriptor_method(self): for rb in self.ui.groupBox_descriptor.children(): if rb.isChecked(): LOGD("descriptor=%s" % rb.text()) return self.DESCRIPTOR_CALCULATORS[str(rb.text())] def find_closest_distance(self): css_clear = """QLineEdit { background:; } """ # highlight the closes match css_highlighted_bg = """QLineEdit { background-color: yellow; }""" icon_distance = self.ui.lineEdit_icon.text().toFloat()[0] closest_distance = 10000000 # initialize this to a largest value closest_lineEdit = None for lned in self.ui.tabMinDistance.findChildren(PyQt4.QtGui.QLineEdit): lned.setStyleSheet(css_clear) cur_distance = lned.text().toFloat()[0] distance_diff = abs(icon_distance - cur_distance) if distance_diff < closest_distance: closest_distance = distance_diff closest_lineEdit = lned closest_lineEdit.setStyleSheet(css_highlighted_bg) def on_pbtn_calculate_clicked(self): self.calculate_classes() def on_groupBox_descriptor_clicked(self, event): print "hello" def calculate_classes(self): LOGD("Update options classifier and distance methods") descriptor_func = self.get_selected_descriptor_method() distance_func = self.get_selected_distance_method() # calculate the first class LOGD("class alpha") img_array = convert_image_to_array(self.class1img) descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "alpha") self.ui.textEdit_info1.setText(str(descriptor)) self.ui.lineEdit_class1.setText(str(distance)) # calculate the second class LOGD("class beta") img_array = convert_image_to_array(self.class2img) descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "beta") self.ui.textEdit_info2.setText(str(descriptor)) self.ui.lineEdit_class2.setText(str(distance)) # calculate the third class LOGD("class gamma") img_array = convert_image_to_array(self.class3img) descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "gamma") self.ui.textEdit_info3.setText(str(descriptor)) self.ui.lineEdit_class3.setText(str(distance)) # calculate the Drew class LOGD("class drawing") img_array = self.ui.widget_iconeditor.getIconData() descriptor, distance = self.process_image(img_array, descriptor_func, distance_func, "Drawing") self.ui.textEdit_info4.setText(str(descriptor)) self.ui.lineEdit_icon.setText(str(distance)) # find closest match self.find_closest_distance() def on_widget_iconeditor_updated(self): self.calculate_classes() def init_all_tabs(self): self.init_minimum_distance() def compute_descriptors(self, class_data, descriptor_type): pass def init_minimum_distance(self): self.ui.label_desc1.setText("class alpha") self.ui.label_img1.setPixmap(QPixmap("alpha.png")) self.ui.label_img1.setScaledContents(True) self.ui.label_desc2.setText("class beta") self.ui.label_img2.setPixmap(QPixmap("beta.png")) self.ui.label_img2.setScaledContents(True) self.ui.label_desc3.setText("class delta") self.ui.label_img3.setPixmap(QPixmap("delta.png")) self.ui.label_img3.setScaledContents(True) self.class1img = Image.open("alpha.png") self.class2img = Image.open("beta.png") self.class3img = Image.open("delta.png")
if i+1 < NFRAMES: naptime = (acquisitiontimes[i+1] - dt.datetime.utcnow()).total_seconds() if naptime > 0: time.sleep(naptime) camera0.endCapture() camera0.revokeAllFrames() camera0.closeCamera() UI.pushButtonStart.setEnabled(True) UI.statusBar.showMessage("Idle.") UI.pushButtonStart.update() UI.statusBar.update() APP = QApplication(sys.argv) WINDOW = QMainWindow() UI = Ui_MainWindow() UI.setupUi(WINDOW) UI.label.resizeEvent = drawimage UI.checkBoxExpT.stateChanged.connect(spinboxchanged) UI.checkBoxHCView.stateChanged.connect(drawimage) UI.doubleSpinBoxDT0.valueChanged.connect(spinboxchanged) UI.doubleSpinBoxTMax.valueChanged.connect(spinboxchanged) #UI.pushButtonStart.clicked.connect(saveimageseriesinbackground) UI.pushButtonStart.clicked.connect(saveimageseries) UI.spinBoxNFrames.valueChanged.connect(spinboxchanged) UI.toolButtonChooseFolder.clicked.connect(outputdialog) #UI.pushButtonShoot.clicked.connect(acquirephotoinbackground) UI.pushButtonShoot.clicked.connect(acquirephoto) if NFRAMES is not None:
dt.datetime.utcnow()).total_seconds() if naptime > 0: time.sleep(naptime) camera0.endCapture() camera0.revokeAllFrames() camera0.closeCamera() UI.pushButtonStart.setEnabled(True) UI.statusBar.showMessage("Idle.") UI.pushButtonStart.update() UI.statusBar.update() APP = QApplication(sys.argv) WINDOW = QMainWindow() UI = Ui_MainWindow() UI.setupUi(WINDOW) UI.label.resizeEvent = drawimage UI.checkBoxExpT.stateChanged.connect(spinboxchanged) UI.checkBoxHCView.stateChanged.connect(drawimage) UI.doubleSpinBoxDT0.valueChanged.connect(spinboxchanged) UI.doubleSpinBoxTMax.valueChanged.connect(spinboxchanged) #UI.pushButtonStart.clicked.connect(saveimageseriesinbackground) UI.pushButtonStart.clicked.connect(saveimageseries) UI.spinBoxNFrames.valueChanged.connect(spinboxchanged) UI.toolButtonChooseFolder.clicked.connect(outputdialog) #UI.pushButtonShoot.clicked.connect(acquirephotoinbackground) UI.pushButtonShoot.clicked.connect(acquirephoto) if NFRAMES is not None: