예제 #1
0
 def openAfterMaybeSave(self):
     """
     This is the method that initiates file opening. It is called by
     actionOpenSlot to spawn a QFileDialog and connect it to a callback
     method.
     """
     path = self._fileOpenPath
     if util.isWindows():  # required for native looking file window#"/",
         fname = QFileDialog.getOpenFileName(
                     None,
                     "Open Document", path,
                     "cadnano1 / cadnano2 Files (*.nno *.json *.cadnano)")
         self.filesavedialog = None
         self.openAfterMaybeSaveCallback(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(
                     self.win,
                     "Open Document",
                     path,
                     "cadnano1 / cadnano2 Files (*.nno *.json *.cadnano)")
         fdialog.setAcceptMode(QFileDialog.AcceptOpen)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         self.fileopendialog = fdialog
         self.fileopendialog.filesSelected.connect(self.openAfterMaybeSaveCallback)
         fdialog.open()
예제 #2
0
 def openClicked(self):
     """docstring for openClicked"""
     # self.filesavedialog = None
     # self.openFile('/Users/nick/Downloads/nanorobot.v2.json')
     # return
     if util.isWindows():  # required for native looking file window
         fname = QFileDialog.getOpenFileName(
                     None,
                     "Open Document", "/",
                     "CADnano1 / CADnano2 Files (*.nno *.json *.cadnano)")
         self.filesavedialog = None
         self.openFile(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(
                     self.win,
                     "Open Document",
                     "/",
                     "CADnano1 / CADnano2 Files (*.nno *.json *.cadnano)")
         fdialog.setAcceptMode(QFileDialog.AcceptOpen)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         # fdialog.exec_()  # or .show(), or .open()
         self.filesavedialog = fdialog
         self.filesavedialog.filesSelected.connect(self.openFile)
         fdialog.open()  # or .show(), or .open()
예제 #3
0
 def saveFileDialog(self):
     fname = self.filename()
     if fname == None:
         directory = "."
     else:
         directory = QFileInfo(fname).path()
     if util.isWindows():  # required for native looking file window
         fname = QFileDialog.getSaveFileName(
                         self.win,
                         "%s - Save As" % QApplication.applicationName(),
                         directory,
                         "%s (*.json)" % QApplication.applicationName())
         self.writeDocumentToFile(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(
                         self.win,
                         "%s - Save As" % QApplication.applicationName(),
                         directory,
                         "%s (*.json)" % QApplication.applicationName())
         fdialog.setAcceptMode(QFileDialog.AcceptSave)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         self.filesavedialog = fdialog
         self.filesavedialog.filesSelected.connect(
                                             self.saveFileDialogCallback)
         fdialog.open()
예제 #4
0
 def saveFileDialog(self):
     """Spawn a QFileDialog to allow user to choose a filename and path."""
     fname = self.filename()
     if fname == None:
         directory = "."
     else:
         directory = QFileInfo(fname).path()
     if util.isWindows():  # required for native looking file window
         fname = QFileDialog.getSaveFileName(
             self.win,
             "%s - Save As" % QApplication.applicationName(),
             directory,
             "%s (*.nno)" % QApplication.applicationName(),
         )
         self.writeDocumentToFile(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(
             self.win,
             "%s - Save As" % QApplication.applicationName(),
             directory,
             "%s (*.nno)" % QApplication.applicationName(),
         )
         fdialog.setAcceptMode(QFileDialog.AcceptSave)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         # fdialog.exec_()  # or .show(), or .open()
         self.filesavedialog = fdialog
         self.filesavedialog.filesSelected.connect(self.saveFileDialogCallback)
         fdialog.open()
예제 #5
0
 def exportCSV(self):
     fname = self.filename()
     if fname == None:
         directory = "."
     else:
         directory = QFileInfo(fname).path()
     if util.isWindows():  # required for native looking file window
         fname = QFileDialog.getSaveFileName(
                         self.win,
                         "%s - Export As" % QApplication.applicationName(),
                         directory,
                         "(*.csv)")
         self.filesavedialog = None
         self.exportFile(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(
                         self.win,
                         "%s - Export As" % QApplication.applicationName(),
                         directory,
                         "(*.csv)")
         fdialog.setAcceptMode(QFileDialog.AcceptSave)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         # fdialog.exec_()  # or .show(), or .open()
         self.filesavedialog = fdialog
         self.filesavedialog.filesSelected.connect(self.exportFile)
         fdialog.open()
예제 #6
0
 def actionExportStaplesSlot(self):
     """
     Triggered by clicking Export Staples button. Opens a file dialog to
     determine where the staples should be saved. The callback is
     exportCSVCallback which collects the staple sequences and exports
     the file.
     """
     fname = self.filename()
     if fname == None:
         directory = "."
     else:
         directory = QFileInfo(fname).path()
     if util.isWindows():  # required for native looking file window
         fname = QFileDialog.getSaveFileName(
             self.win, "%s - Export As" % QApplication.applicationName(), directory, "(*.csv)"
         )
         self.saveCSVdialog = None
         self.exportFile(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(self.win, "%s - Export As" % QApplication.applicationName(), directory, "(*.csv)")
         fdialog.setAcceptMode(QFileDialog.AcceptSave)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         # fdialog.exec_()  # or .show(), or .open()
         self.saveCSVdialog = fdialog
         self.saveCSVdialog.filesSelected.connect(self.exportCSVCallback)
         fdialog.open()
예제 #7
0
 def actionCloseSlot(self):
     """This will trigger a Window closeEvent."""
     #print "closing"
     if util.isWindows():
         #print "close win"
         self.win.close()
         if not app().isInMaya():
             #print "exit app"
             import sys
             sys.exit(1)
예제 #8
0
 def actionCloseSlot(self):
     """This will trigger a Window closeEvent."""
     #print "closing"
     if util.isWindows():
         #print "close win"
         self.win.close()
         if not app().isInMaya():
             #print "exit app"
             import sys
             sys.exit(1)
예제 #9
0
def initAppWithGui(appArgs=sys.argv):
    util.qtFrameworkList = ['PyQt', 'PySide']
    from cadnanoqt import CadnanoQt
    global sharedApp
    sharedApp = CadnanoQt(appArgs)
    sharedApp.finishInit()
    if util.isWindows():
        pass
        # import ctypes
        # myappid = 'harvard.cadnano.cadnano2.2' # arbitrary string
        # ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
    return sharedApp
예제 #10
0
def initAppWithGui(appArgs=sys.argv):
    util.qtFrameworkList = ['PyQt', 'PySide']
    from cadnanoqt import CadnanoQt
    global sharedApp
    sharedApp = CadnanoQt(appArgs)
    sharedApp.finishInit()
    if util.isWindows():
        pass
        # import ctypes
        # myappid = 'harvard.cadnano.cadnano2.2' # arbitrary string
        # ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
    return sharedApp
예제 #11
0
    def actionExportStaplesSlot(self):
        """
        Triggered by clicking Export Staples button. Opens a file dialog to
        determine where the staples should be saved. The callback is
        exportStaplesCallback which collects the staple sequences and exports
        the file.
        """
        # Validate that no staple oligos are loops.
        part = self.activePart()
        stapLoopOlgs = part.getStapleLoopOligos()
        if stapLoopOlgs:
            from ui.dialogs.ui_warning import Ui_Warning
            dialog = QDialog()
            dialogWarning = Ui_Warning()  # reusing this dialog, should rename
            dialog.setStyleSheet("QDialog { background-image: url(ui/dialogs/images/cadnano2-about.png); background-repeat: none; }")
            dialogWarning.setupUi(dialog)

            locs = ", ".join([o.locString() for o in stapLoopOlgs])
            msg = "Part contains staple loop(s) at %s.\n\nUse the break tool to introduce 5' & 3' ends before exporting. Loops have been colored red; use undo to revert." % locs
            dialogWarning.title.setText("Staple validation failed")
            dialogWarning.message.setText(msg)
            for o in stapLoopOlgs:
                o.applyColor(styles.stapColors[0].name())
            dialog.exec_()
            return

        # Proceed with staple export.
        fname = self.filename()
        if fname == None:
            directory = "."
        else:
            directory = QFileInfo(fname).path()
        if util.isWindows():  # required for native looking file window
            fname = QFileDialog.getSaveFileName(
                            self.win,
                            "%s - Export As" % QApplication.applicationName(),
                            directory,
                            "(*.csv)")
            self.saveStaplesDialog = None
            self.exportStaplesCallback(fname)
        else:  # access through non-blocking callback
            fdialog = QFileDialog(
                            self.win,
                            "%s - Export As" % QApplication.applicationName(),
                            directory,
                            "(*.csv)")
            fdialog.setAcceptMode(QFileDialog.AcceptSave)
            fdialog.setWindowFlags(Qt.Sheet)
            fdialog.setWindowModality(Qt.WindowModal)
            self.saveStaplesDialog = fdialog
            self.saveStaplesDialog.filesSelected.connect(self.exportStaplesCallback)
            fdialog.open()
    def actionExportStaplesSlot(self):
        """
        Triggered by clicking Export Staples button. Opens a file dialog to
        determine where the staples should be saved. The callback is
        exportStaplesCallback which collects the staple sequences and exports
        the file.
        """
        # Validate that no staple oligos are loops.
        part = self.activePart()
        stapLoopOlgs = part.getStapleLoopOligos()
        if stapLoopOlgs:
            from ui.dialogs.ui_warning import Ui_Warning
            dialog = QDialog()
            dialogWarning = Ui_Warning()  # reusing this dialog, should rename
            dialog.setStyleSheet(
                "QDialog { background-image: url(ui/dialogs/images/cadnano2-about.png); background-repeat: none; }"
            )
            dialogWarning.setupUi(dialog)

            locs = ", ".join([o.locString() for o in stapLoopOlgs])
            msg = "Part contains staple loop(s) at %s.\n\nUse the break tool to introduce 5' & 3' ends before exporting. Loops have been colored red; use undo to revert." % locs
            dialogWarning.title.setText("Staple validation failed")
            dialogWarning.message.setText(msg)
            for o in stapLoopOlgs:
                o.applyColor(styles.stapColors[0].name())
            dialog.exec_()
            return

        # Proceed with staple export.
        fname = self.filename()
        if fname == None:
            directory = "."
        else:
            directory = QFileInfo(fname).path()
        if util.isWindows():  # required for native looking file window
            fname = QFileDialog.getSaveFileName(
                self.win, "%s - Export As" % QApplication.applicationName(),
                directory, "(*.csv)")
            self.saveStaplesDialog = None
            self.exportStaplesCallback(fname)
        else:  # access through non-blocking callback
            fdialog = QFileDialog(
                self.win, "%s - Export As" % QApplication.applicationName(),
                directory, "(*.csv)")
            fdialog.setAcceptMode(QFileDialog.AcceptSave)
            fdialog.setWindowFlags(Qt.Sheet)
            fdialog.setWindowModality(Qt.WindowModal)
            self.saveStaplesDialog = fdialog
            self.saveStaplesDialog.filesSelected.connect(
                self.exportStaplesCallback)
            fdialog.open()
예제 #13
0
 def openAfterMaybeSave(self):
     """docstring for openAfterMaybeSave"""
     if util.isWindows():  # required for native looking file window
         fname = QFileDialog.getOpenFileName(
             None, "Open Document", "/", "CADnano1 / CADnano2 Files (*.nno *.json *.cadnano)"
         )
         self.filesavedialog = None
         self.openAfterMaybeSaveCallback(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(self.win, "Open Document", "/", "CADnano1 / CADnano2 Files (*.nno *.json *.cadnano)")
         fdialog.setAcceptMode(QFileDialog.AcceptOpen)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         # fdialog.exec_()  # or .show(), or .open()
         self.fileopendialog = fdialog
         self.fileopendialog.filesSelected.connect(self.openAfterMaybeSaveCallback)
         fdialog.open()  # or .show(), or .open()
 def writeDocumentToFile(self, filename=None):
     if filename == None:
         assert (not self._hasNoAssociatedFile)
         filename = self.filename()
     try:
         if util.isWindows():
             filename = filename[0]
         with open(filename, 'w') as f:
             helixOrderList = self.win.pathroot.getSelectedPartOrderedVHList(
             )
             encode(self._document, helixOrderList, f)
     except IOError:
         flags = Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint | Qt.Sheet
         errorbox = QMessageBox(QMessageBox.Critical, "cadnano",
                                "Could not write to '%s'." % filename,
                                QMessageBox.Ok, self.win, flags)
         errorbox.setWindowModality(Qt.WindowModal)
         errorbox.open()
         return False
     self.undoStack().setClean()
     self.setFilename(filename)
     return True
 def saveFileDialog(self):
     fname = self.filename()
     if fname == None:
         directory = "."
     else:
         directory = QFileInfo(fname).path()
     if util.isWindows():  # required for native looking file window
         fname = QFileDialog.getSaveFileName(
             self.win, "%s - Save As" % QApplication.applicationName(),
             directory, "%s (*.json)" % QApplication.applicationName())
         self.writeDocumentToFile(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(
             self.win, "%s - Save As" % QApplication.applicationName(),
             directory, "%s (*.json)" % QApplication.applicationName())
         fdialog.setAcceptMode(QFileDialog.AcceptSave)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         self.filesavedialog = fdialog
         self.filesavedialog.filesSelected.connect(
             self.saveFileDialogCallback)
         fdialog.open()
 def openAfterMaybeSave(self):
     """
     This is the method that initiates file opening. It is called by
     actionOpenSlot to spawn a QFileDialog and connect it to a callback
     method.
     """
     path = self._fileOpenPath
     if util.isWindows():  # required for native looking file window#"/",
         fname = QFileDialog.getOpenFileName(
             None, "Open Document", path,
             "cadnano1 / cadnano2 Files (*.nno *.json *.cadnano)")
         self.filesavedialog = None
         self.openAfterMaybeSaveCallback(fname)
     else:  # access through non-blocking callback
         fdialog = QFileDialog(
             self.win, "Open Document", path,
             "cadnano1 / cadnano2 Files (*.nno *.json *.cadnano)")
         fdialog.setAcceptMode(QFileDialog.AcceptOpen)
         fdialog.setWindowFlags(Qt.Sheet)
         fdialog.setWindowModality(Qt.WindowModal)
         self.fileopendialog = fdialog
         self.fileopendialog.filesSelected.connect(
             self.openAfterMaybeSaveCallback)
         fdialog.open()
예제 #17
0
 def closeClicked(self):
     """This will trigger a Window closeEvent"""
     if util.isWindows():
         self.win.close()
예제 #18
0
 def actionCloseSlot(self):
     """This will trigger a Window closeEvent."""
     if util.isWindows():
         self.win.close()
예제 #19
0
파일: immjob.py 프로젝트: mkawserm/iMovMan
'''
Created on Aug 13, 2013

@author: KaWsEr
'''


import util
if util.isLinux():from immjoblinux import *
elif util.isWindows():from immjobwin import *
elif util.isMac():from immjobmac import *
예제 #20
0
파일: styles.py 프로젝트: vdt/cadnano2
    SEQUENCEFONTMETRICS = QFontMetricsF(SEQUENCEFONT)
    SEQUENCEFONTCHARWIDTH = SEQUENCEFONTMETRICS.width('A')
    SEQUENCEFONTCHARHEIGHT = SEQUENCEFONTMETRICS.height()
    SEQUENCEFONTEXTRAWIDTH = PATH_BASE_WIDTH - SEQUENCEFONTCHARWIDTH
    SEQUENCEFONT.setLetterSpacing(QFont.AbsoluteSpacing,
                                 SEQUENCEFONTEXTRAWIDTH)
    SEQUENCETEXTXCENTERINGOFFSET = SEQUENCEFONTEXTRAWIDTH / 4.
    SEQUENCETEXTYCENTERINGOFFSET = PATH_BASE_WIDTH * 0.6


if util.isMac():
    thefont = "Times"
    thefont = "Arial"
    thefontsize = 10
    XOVER_LABEL_FONT = QFont(thefont, thefontsize, QFont.Bold)
elif util.isWindows():
    thefont = "Segoe UI"
    thefont = "Calibri"
    thefont = "Arial"
    thefontsize = 9
    XOVER_LABEL_FONT = QFont(thefont, thefontsize, QFont.Bold)
else: # linux
    thefont = "DejaVu Sans"
    thefontsize = 9
    XOVER_LABEL_FONT = QFont(thefont, thefontsize, QFont.Bold)
 
SLICE_NUM_FONT = QFont(thefont, 10, QFont.Bold)
VIRTUALHELIXHANDLEITEM_FONT = QFont(thefont, 3*thefontsize, QFont.Bold)
XOVER_LABEL_COLOR = QColor(0,0,0) 

# Overwrite for Maya