def dropEvent(self, event): def _url_to_path(url): path = url.toLocalFile() if spimagine.config.__SYSTEM_DARWIN__: path = spimagine.config._parseFileNameFix(path) return path self.setCursor(QtCore.Qt.BusyCursor) urls = event.mimeData().urls() if len(urls) == 0: return elif len(urls) == 1: path = _url_to_path(urls[0]) elif len(urls) > 1: path = tuple(_url_to_path(url) for url in urls) try: if self.dataModel: self.dataModel.loadFromPath(path, prefetchSize=self.N_PREFETCH) else: self.setModel(DataModel.fromPath(path, prefetchSize=self.N_PREFETCH)) self.setCursor(QtCore.Qt.ArrowCursor) except Exception as e: QtWidgets.QMessageBox.warning(self, "", "Error loading Data:\n %s" % str(e))
def dropEvent(self, event): for url in event.mimeData().urls(): path = url.toLocalFile().toLocal8Bit().data() if self.dataModel: self.dataModel.loadFromPath(path, prefetchSize=self.N_PREFETCH) else: self.setModel(DataModel.fromPath(path, prefetchSize=self.N_PREFETCH))
def openFile(self, e): # path = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Path (File or Folder)', # '.', selectedFilter='*.tif') f = QtWidgets.QFileDialog() f.setWindowTitle('Open Path (File or Folder)') f.setFileMode(QtWidgets.QFileDialog.ExistingFile & QtWidgets.QFileDialog.Directory) f.exec_() path = f.selectedFiles() if len(path) == 0: return path = str(path[0]) if path: try: if self.glWidget.dataModel: self.glWidget.dataModel.loadFromPath( path, prefetchSize=self.glWidget.N_PREFETCH) else: self.glWidget.setModel( DataModel.fromPath( path, prefetchSize=self.glWidget.N_PREFETCH)) except Exception as e: mbox = QtWidgets.QMessageBox() mbox.setText(str(e)) mbox.setIcon(QtWidgets.QMessageBox.Warning) mbox.exec_()
def dropEvent(self, event): def _url_to_path(url): path = url.toLocalFile() if spimagine.config.__SYSTEM_DARWIN__: path = spimagine.config._parseFileNameFix(path) return path self.setCursor(QtCore.Qt.BusyCursor) urls = event.mimeData().urls() if len(urls) == 0: return elif len(urls) == 1: path = _url_to_path(urls[0]) elif len(urls) > 1: path = tuple(_url_to_path(url) for url in urls) try: if self.dataModel: self.dataModel.loadFromPath(path, prefetchSize=self.N_PREFETCH) else: self.setModel( DataModel.fromPath(path, prefetchSize=self.N_PREFETCH)) self.setCursor(QtCore.Qt.ArrowCursor) except Exception as e: QtWidgets.QMessageBox.warning(self, "", "Error loading Data:\n %s" % str(e))
def openFile(self,e): # path = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Path (File or Folder)', # '.', selectedFilter='*.tif') f = QtWidgets.QFileDialog() f.setWindowTitle('Open Path (File or Folder)') f.setFileMode(QtWidgets.QFileDialog.ExistingFile & QtWidgets.QFileDialog.Directory) f.exec_() path = f.selectedFiles() if len(path)==0: return path = str(path[0]) if path: try: if self.glWidget.dataModel: self.glWidget.dataModel.loadFromPath(path, prefetchSize = self.glWidget.N_PREFETCH) else: self.glWidget.setModel(DataModel.fromPath(path, prefetchSize = self.glWidget.N_PREFETCH)) except Exception as e: mbox = QtWidgets.QMessageBox() mbox.setText(str(e)) mbox.setIcon(QtWidgets.QMessageBox.Warning) mbox.exec_()
def dropEvent(self, event): for url in event.mimeData().urls(): # path = url.toLocalFile().toLocal8Bit().data() path = url.toLocalFile() if spimagine.config.__SYSTEM_DARWIN__: path = spimagine.config._parseFileNameFix(path) self.setCursor(QtCore.Qt.BusyCursor) if self.dataModel: self.dataModel.loadFromPath(path, prefetchSize=self.N_PREFETCH) else: self.setModel(DataModel.fromPath(path, prefetchSize=self.N_PREFETCH)) self.setCursor(QtCore.Qt.ArrowCursor)
def main(): parser = argparse.ArgumentParser(description='spimagine rendering application ') parser.add_argument('fname', type=str, nargs='*', help='the files/folder to open (e.g. tif, folder of tif) ', default = None) parser.add_argument('-p', dest='prefetch', type = int, default=0, help='prefetch size (should not be negative, e.g. -p 2)') parser.add_argument('-u', dest='units', nargs = 3, type=float, default=[1.,1.,1.], help='voxel units') parser.add_argument('-D', action='store_true', help="output DEBUG messages") parser.add_argument('-v',"--verbose", action='store_true', help="output DEBUG messages") try: args = parser.parse_args() except Exception as e: print(e) parser.print_help() sys.exit(0) logger = logging.getLogger("spimagine") if args.D or args.verbose: logger.setLevel(logging.DEBUG) # if sys.platform.startswith("win"): # QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create("CleanLooks")) # print(QtWidgets.QStyleFactory.create("Fusion")) # QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create("Fusion")) # QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create(QtWidgets.QStyleFactory.keys()[1])) app = QtWidgets.QApplication(sys.argv) logger.debug("available qt styles: %s " % str(QtWidgets.QStyleFactory.keys())) logger.debug("used qt styles: %s " % app.style().metaObject().className()) #splash screen pixmap = QtGui.QPixmap(absPath('../gui/images/splash.png')) splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) splash.show() app.processEvents() import spimagine from spimagine.gui.mainwidget import MainWidget from spimagine.models.data_model import DemoData, DataModel app.setWindowIcon(QtGui.QIcon(absPath('../gui/images/spimagine.png'))) win = MainWidget() win.resize(spimagine.config.__DEFAULT_WIDTH__, spimagine.config.__DEFAULT_HEIGHT__) splash.hide() if args.fname: if len(args.fname)==1: win.setModel(DataModel.fromPath(args.fname[0])) else: win.setModel(DataModel.fromPath(args.fname)) else: win.setModel(DataModel(DemoData())) win.transform.setStackUnits(*args.units) win.show() win.raise_window() splash.finish(win) sys.exit(app.exec_())
def main(): parser = argparse.ArgumentParser( description='spimagine rendering application ') parser.add_argument( 'fname', type=str, nargs='*', help='the files/folder to open (e.g. tif, folder of tif) ', default=None) parser.add_argument( '-p', dest='prefetch', type=int, default=0, help='prefetch size (should not be negative, e.g. -p 2)') parser.add_argument('-u', dest='units', nargs=3, type=float, default=[1., 1., 1.], help='voxel units') parser.add_argument('-D', action='store_true', help="output DEBUG messages") parser.add_argument('-v', "--verbose", action='store_true', help="output DEBUG messages") try: args = parser.parse_args() except Exception as e: print(e) parser.print_help() sys.exit(0) logger = logging.getLogger("spimagine") if args.D or args.verbose: logger.setLevel(logging.DEBUG) # if sys.platform.startswith("win"): # QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create("CleanLooks")) # print(QtWidgets.QStyleFactory.create("Fusion")) # QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create("Fusion")) # QtWidgets.QApplication.setStyle(QtWidgets.QStyleFactory.create(QtWidgets.QStyleFactory.keys()[1])) app = QtWidgets.QApplication(sys.argv) logger.debug("available qt styles: %s " % str(QtWidgets.QStyleFactory.keys())) logger.debug("used qt styles: %s " % app.style().metaObject().className()) #splash screen pixmap = QtGui.QPixmap(absPath('../gui/images/splash.png')) splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) splash.show() app.processEvents() import spimagine from spimagine.gui.mainwidget import MainWidget from spimagine.models.data_model import DemoData, DataModel app.setWindowIcon(QtGui.QIcon(absPath('../gui/images/spimagine.png'))) win = MainWidget() win.resize(spimagine.config.__DEFAULT_WIDTH__, spimagine.config.__DEFAULT_HEIGHT__) splash.hide() if args.fname: if len(args.fname) == 1: win.setModel(DataModel.fromPath(args.fname[0])) else: win.setModel(DataModel.fromPath(args.fname)) else: win.setModel(DataModel(DemoData())) win.transform.setStackUnits(*args.units) win.show() win.raise_window() splash.finish(win) sys.exit(app.exec_())