Beispiel #1
0
    def getFontFromCmnd(self, fontinfo):
        '''
        Returns a QFont based on the information in the dictionary
        fontinfo.

        Recognized keys in the font dictionary are:
            "family": font family name (string)
            "size": text size in points (1/72 inches)
            "italic": italicize? (False/True)
            "bold": make bold? (False/True)
            "underline": underline?  (False/True)
        '''
        try:
            myfont = QFont(fontinfo["family"])
        except KeyError:
            myfont = self.__viewer.font()
        try:
            myfont.setPointSizeF(fontinfo["size"])
        except KeyError:
            pass
        try:
            myfont.setItalic(fontinfo["italic"])
        except KeyError:
            pass
        try:
            myfont.setBold(fontinfo["bold"])
        except KeyError:
            pass
        try:
            myfont.setUnderline(fontinfo["underline"])
        except KeyError:
            pass
        return myfont
Beispiel #2
0
    def data(self, idx, role=Qt.DisplayRole):
        if not idx.isValid() or \
                idx.row() < 0 or \
                idx.row() >= self.rowCount() or \
                idx.column() < 0 or \
                idx.column() >= self.columnCount() or \
                self._feed is None:
            return None
        if role != Qt.DisplayRole and role != Qt.FontRole:
            return None

        entry = list(self._feed.entries)[idx.row()]
        if role == Qt.DisplayRole:
            if idx.column() == 0:
                if entry.important:
                    return "!"
                return ""
            elif idx.column() == 1:
                return entry.title
            elif idx.column() == 2:
                return entry.author
            elif idx.column() == 3:
                return qDateTimeFromTimeStruct(entry.updated)
        elif role == Qt.FontRole:
            fnt = QFont()
            if not entry.read:
                fnt.setBold(True)
            if entry.important:
                fnt.setItalic(True)
            return fnt
        return None
Beispiel #3
0
    def changeSymbologySettings( self, theMapLayer, itemList ):
        if not theMapLayer:
            return

        # Remove previous symbology items
        self.takeChildren()

        # Add the name of classification field as the first symbology item
        renderer = theMapLayer.renderer()
        if renderer.name() == "Graduated Symbol" or \
            renderer.name() == "Unique Value":
            fields = theMapLayer.pendingFields()
            self.child = QTreeWidgetItem( self )
            self.child.setText( 0, fields[ renderer.classificationAttributes()[ 0 ] ].name() )
            childFont = QFont()
            childFont.setItalic( True )
            self.child.setFont( 0, childFont )

        # Add the new symbology items
        for i in range( len( itemList ) ):
            self.child = QTreeWidgetItem( self )
            self.child.setText( 0, unicode( itemList[ i ][ 0 ] ) )
            iconChild = QIcon()
            iconChild.addPixmap( itemList[ i ][ 1 ] )
            self.child.setIcon( 0, iconChild )

            childFont = QFont()
            childFont.setPointSize( 9 )
            self.child.setFont( 0, childFont )
Beispiel #4
0
def splash_screen():
    """
    """
    pm = QPixmap(
        pkg_resources.resource_filename(
            __name__, "icons/orange-splash-screen.png")
    )

    version = QCoreApplication.applicationVersion()
    size = 21 if len(version) < 5 else 16
    font = QFont("Helvetica")
    font.setPixelSize(size)
    font.setBold(True)
    font.setItalic(True)
    font.setLetterSpacing(QFont.AbsoluteSpacing, 2)
    metrics = QFontMetrics(font)
    br = metrics.boundingRect(version).adjusted(-5, 0, 5, 0)
    br.moveCenter(QPoint(436, 224))

    p = QPainter(pm)
    p.setRenderHint(QPainter.Antialiasing)
    p.setRenderHint(QPainter.TextAntialiasing)
    p.setFont(font)
    p.setPen(QColor("#231F20"))
    p.drawText(br, Qt.AlignCenter, version)
    p.end()
    return pm, QRect(88, 193, 200, 20)
Beispiel #5
0
    def data(self, index, role):
        if role != Qt.DisplayRole and role != Qt.FontRole:
            return None

        val = self.getData(index.row(), index.column())

        if role == Qt.FontRole:  # draw NULL in italic
            if val is not None:
                return None
            f = QFont()
            f.setItalic(True)
            return f

        if val is None:
            return "NULL"
        elif isinstance(val, buffer):
            # hide binary data
            return None
        elif isinstance(val, (str, unicode)) and len(val) > 300:
            # too much data to display, elide the string
            val = val[:300]
        try:
            return unicode(val)  # convert to unicode
        except UnicodeDecodeError:
            return unicode(
                val, 'utf-8',
                'replace')  # convert from utf8 and replace errors (if any)
def select_profile(profiles_dict):
    title = _('Profile Selection')
    input_label = _('Select a stored profile:')
    ok_label = _('OK')
    cancel_label = _('Quit')

    input_dialog = ComboBoxInputDialog(autoaccept=True)
    input_dialog.set_window_title(title)
    input_dialog.set_label_text(input_label)
    input_dialog.set_ok_button_text(ok_label)
    input_dialog.set_cancel_button_text(cancel_label)
    input_dialog.set_items(sorted(profiles_dict.keys()) + [NEW_PROFILE_LABEL])
    _last_used_profile = last_used_profile()
    if _last_used_profile:
        input_dialog.set_choice_by_text(_last_used_profile)
    input_dialog.set_ok_button_default()

    last_index = input_dialog.count()-1
    custom_font = QFont()
    custom_font.setItalic(True)
    icon = art.Icon('tango/16x16/actions/document-new.png').getQIcon()
    input_dialog.set_data(last_index, custom_font, Qt.FontRole)
    input_dialog.set_data(last_index, icon, Qt.DecorationRole)

    dialog_code = input_dialog.exec_()
    if dialog_code == QDialog.Accepted:
        return unicode(input_dialog.get_text())

    return None
Beispiel #7
0
    def data(self, index, role):
        if role != Qt.DisplayRole and role != Qt.FontRole:
            return None

        val = self.getData(index.row(), index.column())

        if role == Qt.FontRole:  # draw NULL in italic
            if val is not None:
                return None
            f = QFont()
            f.setItalic(True)
            return f

        if val is None:
            return "NULL"
        elif isinstance(val, buffer):
            # hide binary data
            return None
        elif isinstance(val, (str, unicode)) and len(val) > 300:
            # too much data to display, elide the string
            val = val[:300]
        try:
            return unicode(val) # convert to unicode
        except UnicodeDecodeError:
            return unicode(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
Beispiel #8
0
    def __init__(self, pixmap):
        super(SplashScreen, self).__init__(pixmap)

        self._title = QLabel(self)
        self._title.setGeometry(50 * self.width() / 100,
                                20 * self.height() / 100,
                                50 * self.width() / 100,
                                11 * self.height() / 100)
        self._title.setStyleSheet('QLabel { color : rgb(191,180,110); }')
        font = QFont('Exo 2')
        font.setPixelSize(36)
        font.setBold(True)
        font.setItalic(True)
        self._title.setFont(font)

        font = QFont('Exo 2')
        font.setPixelSize(16)
        font.setBold(False)
        font.setItalic(True)
        self.setFont(font)

        self.progressBar = QProgressBar(self)
        self.progressBar.setGeometry(self.width() / 10, 8 * self.height() / 10,
                                     8 * self.width() / 10,
                                     self.height() / 30)
Beispiel #9
0
def update_font(basefont,
                weight=None,
                italic=None,
                underline=None,
                pixelSize=None,
                pointSize=None):
    """
    Return a copy of `basefont` :class:`QFont` with updated properties.
    """
    font = QFont(basefont)

    if weight is not None:
        font.setWeight(weight)

    if italic is not None:
        font.setItalic(italic)

    if underline is not None:
        font.setUnderline(underline)

    if pixelSize is not None:
        font.setPixelSize(pixelSize)

    if pointSize is not None:
        font.setPointSize(pointSize)

    return font
Beispiel #10
0
def select_profile(profiles_dict):
    title = _('Profile Selection')
    input_label = _('Select a stored profile:')
    ok_label = _('OK')
    cancel_label = _('Quit')

    input_dialog = ComboBoxInputDialog(autoaccept=True)
    input_dialog.set_window_title(title)
    input_dialog.set_label_text(input_label)
    input_dialog.set_ok_button_text(ok_label)
    input_dialog.set_cancel_button_text(cancel_label)
    input_dialog.set_items(sorted(profiles_dict.keys()) + [NEW_PROFILE_LABEL])
    _last_used_profile = last_used_profile()
    if _last_used_profile:
        input_dialog.set_choice_by_text(_last_used_profile)
    input_dialog.set_ok_button_default()

    last_index = input_dialog.count() - 1
    custom_font = QFont()
    custom_font.setItalic(True)
    icon = art.Icon('tango/16x16/actions/document-new.png').getQIcon()
    input_dialog.set_data(last_index, custom_font, Qt.FontRole)
    input_dialog.set_data(last_index, icon, Qt.DecorationRole)

    dialog_code = input_dialog.exec_()
    if dialog_code == QDialog.Accepted:
        return unicode(input_dialog.get_text())

    return None
    def createDialog(self):
        """
        Create qt dialog
        """
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStyleSheet("""QDialogButtonBox { 
            dialogbuttonbox-buttons-have-icons: 1;
            dialog-ok-icon: url(:/ok.png);
            dialog-cancel-icon: url(:/test-close-black.png);
        }""")
        if self.noCancel:
            self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)
        else:
            self.buttonBox.setStandardButtons(QDialogButtonBox.Ok
                                              | QDialogButtonBox.Cancel)

        self.argsWidget = BasicWidget(self.actionData,
                                      self.owner,
                                      self.variables,
                                      parent=self,
                                      testParams=self.testParams,
                                      adapterMode=self.adapterMode)

        # input
        mainLayout = QVBoxLayout()
        inputText = ""
        if "action-descr" in self.actionData['data']:
            inputText = self.actionData['data']["action-descr"]
        finalTitle = "%s" % self.actionData['data']['function']
        if len(inputText):
            finalTitle += " - %s" % inputText.lower()
        titleLabel = QLabel(finalTitle)
        font = QFont()
        font.setBold(True)
        titleLabel.setFont(font)

        # output
        outputText = "nothing"
        if self.actionData['data']['return-value'] == 'True':
            outputText = self.actionData['data']['return-descr']
        outputLabel = QLabel("Output: %s" % outputText)
        font = QFont()
        font.setItalic(True)
        outputLabel.setFont(font)

        mainLayout.addWidget(titleLabel)
        mainLayout.addWidget(outputLabel)
        mainLayout.addWidget(self.argsWidget)
        mainLayout.addWidget(self.buttonBox)
        self.setLayout(mainLayout)

        self.setWindowTitle(self.tr("Configuration action"))

        self.resize(self.minimumSizeHint())
        self.resize(750, self.height())

        self.center()
 def data(self, index, role):
     if not index.isValid():
         return QVariant()
     ms = self.mapper.getMergeScanForId(index.internalId())
     if ms is None:
         logger.critical(
             "data: wasn't able to get the FileSystemMerge for internal id {0}"
             .format(index.internalId()))
         return QVariant()
     if role == Qt.CheckStateRole and index.column(
     ) == MergeScanTreeModel.COL_CHECKED:
         return ms.checked
     if role == Qt.DecorationRole and index.column(
     ) == MergeScanTreeModel.COL_ICON:
         return self.IconProvider.icon(
             QFileIconProvider.Folder) if ms.is_dir else None
     if role == Qt.TextColorRole:
         if ms.flags == PersistentScanningState.ITEM_DELETED:
             return QColor(Qt.red)
         return QVariant()
     if role == Qt.FontRole:
         font = QFont()
         info = PathInfo(ms.abs_path, ms.path_info)
         if info.is_symlink or ms.flags == PersistentScanningState.ITEM_UNREADABLE:
             font.setItalic(True)
         return font
     if role == Qt.DisplayRole:
         data = None
         if index.column() == MergeScanTreeModel.COL_NAME:
             data = os.path.basename(ms.abs_path)
             if "Sample" in data:
                 x = 0
         elif index.column() == MergeScanTreeModel.COL_CHANGE_TYPE:
             if ms.flags == PersistentScanningState.ITEM_ADDED:
                 data = "Added"
             elif ms.flags == PersistentScanningState.ITEM_DELETED:
                 data = "Deleted"
             elif ms.flags == PersistentScanningState.ITEM_MODIFIED:
                 data = "Modified"
             elif ms.flags == PersistentScanningState.ITEM_UNCHANGED:
                 data = ""
         elif index.column() == MergeScanTreeModel.COL_SIZE:
             data = PathInfo(
                 ms.abs_path, ms.path_info
             ).size_human_readable if not ms.is_dir else None
         elif index.column() == MergeScanTreeModel.COL_DATE_MODIFIED:
             value = QDateTime.fromTime_t(
                 int(PathInfo(ms.abs_path, ms.path_info).modified_date))
             data = value.toString()
         elif index.column() == MergeScanTreeModel.COL_PERMISSIONS:
             info = PathInfo(ms.abs_path, ms.path_info)
             data = "{0}:{1} {2}".format(info.uid, info.gid,
                                         info.posix_perms_human_readable)
         return data
     return QVariant()
    def displayLayerProperties( self ):
        """ It is required to build the QLabel widget every time it is set """        
        propertiesFont = QFont()
        propertiesFont.setItalic( True )
        propertiesFont.setPointSize( 8 )
        propertiesFont.setStyleStrategy( QFont.PreferAntialias )

        label = QLabel( self.properties )
        label.setTextInteractionFlags( Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard )
        label.setFont( propertiesFont )
        self.legend.setItemWidget( self.child, 0, label )
    def data(self, index, role=Qt.DisplayRole):
        """
        Cell content

        @param index: 
        @type index:

        @param role: 
        @type role:

        @return:
        @rtype:
        """
        if not index.isValid():
            return q()

        value = self.getValue(index)
        if role == Qt.FontRole:
            if index.column() == COL_KEY:
                font = QFont()
                font.setBold(True)
                return q(font)
            if index.column() == COL_VALUE:
                font = QFont()
                font.setItalic(True)
                return q(font)

        elif role == Qt.DisplayRole:
            if index.row() == ROW_COMMENTS:
                if index.column() == COL_VALUE:
                    ret = ''

                    if isinstance(value, str) or isinstance(
                            value, unicode) or isinstance(
                                value, bytes):  # change to support py3
                        value = {'comments': {'comment': []}}

                    if isinstance(value['comments'], str) or isinstance(
                            value['comments'], bytes):  # change to support py3
                        value['comments'] = {'comment': []}
                    if isinstance(value['comments']['comment'], dict):
                        nbcomments = 1
                    else:
                        nbcomments = len(value['comments']['comment'])
                    ret = '- %s -' % nbcomments
                    return q(ret)
                else:
                    return q(value)
            else:
                return q(value)

        elif role == Qt.EditRole:
            return q(value)
Beispiel #15
0
    def displayLayerProperties(self):
        """ It is required to build the QLabel widget every time it is set """
        propertiesFont = QFont()
        propertiesFont.setItalic(True)
        propertiesFont.setPointSize(8)
        propertiesFont.setStyleStrategy(QFont.PreferAntialias)

        label = QLabel(self.properties)
        label.setTextInteractionFlags(Qt.TextSelectableByMouse
                                      | Qt.TextSelectableByKeyboard)
        label.setFont(propertiesFont)
        self.legend.setItemWidget(self.child, 0, label)
    def __init__(self):
        super().__init__()

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        tabs_setting = gui.tabWidget(self.controlArea)

        tab_bas = oasysgui.createTabPage(tabs_setting, "Basic Setting")
        tab_adv = oasysgui.createTabPage(tabs_setting, "Advanced Setting")

        lens_box = oasysgui.widgetBox(tab_bas, "Input Parameters", addSpace=False, orientation="vertical", height=600, width=450)

        oasysgui.lineEdit(lens_box, self, "source_plane_distance", "Source Plane Distance [cm]", labelWidth=350, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(lens_box, self, "image_plane_distance", "Image Plane Distance [cm]", labelWidth=350, valueType=float, orientation="horizontal")

        gui.separator(lens_box)

        oasysgui.lineEdit(lens_box, self, "input_diameter", "Input Diameter [cm]", labelWidth=350, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(lens_box, self, "angular_acceptance", "Angular Acceptance [deg]", labelWidth=350, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(lens_box, self, "inner_diameter", "Central Diameter [cm]", labelWidth=350, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(lens_box, self, "output_diameter", "Output Diameter [cm]", labelWidth=350, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(lens_box, self, "focal_length", "Focal Length [cm]", labelWidth=350, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(lens_box, self, "focus_dimension", "Approximate focus dimension [um]", labelWidth=350, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(lens_box, self, "lens_length", "Lens Total Length [cm]", labelWidth=350, valueType=float, orientation="horizontal")

        gui.separator(lens_box)

        oasysgui.lineEdit(lens_box, self, "transmittance", "Lens Transmittance [%]", labelWidth=350, valueType=float, orientation="horizontal")

        gui.separator(self.controlArea, height=80)

        button_box = oasysgui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Run Shadow/trace", callback=self.traceOpticalElement)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Reset Fields", callback=self.callResetSettings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(100)
Beispiel #17
0
 def getFont(self,
             font_family,
             font_size=10,
             bold=False,
             italic=False,
             Underline=False):
     font = QFont()
     font.setFamily(_fromUtf8(font_family))
     font.setPixelSize(font_size)
     font.setFixedPitch(True)
     font.setBold(bold)
     font.setItalic(italic)
     font.setUnderline(Underline)
     return font
Beispiel #18
0
 def setItemTextFormat(item, f):
     font = QFont(data.font)
     if f.hasProperty(QTextFormat.ForegroundBrush):
         item.setForeground(0, f.foreground().color())
     else:
         item.setForeground(0, data.baseColors['text'])
     if f.hasProperty(QTextFormat.BackgroundBrush):
         item.setBackground(0, f.background().color())
     else:
         item.setBackground(0, QBrush())
     font.setWeight(f.fontWeight())
     font.setItalic(f.fontItalic())
     font.setUnderline(f.fontUnderline())
     item.setFont(0, font)
    def __init__(self, show_automatic_box=True):
        super().__init__(show_automatic_box=show_automatic_box)

        self.runaction = widget.OWAction("Run Shadow/Trace", self)
        self.runaction.triggered.connect(self.traceOpticalElement)
        self.addAction(self.runaction)

        #################################
        # FIX A WEIRD BEHAVIOUR AFTER DISPLAY
        # THE WIDGET: PROBABLY ON SIGNAL MANAGER
        self.dumpSettings()

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        button_box = oasysgui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        self.button_trace = gui.button(button_box, self, "Run Shadow/Trace", callback=self.traceOpticalElement)
        font = QFont(self.button_trace.font())
        font.setBold(True)
        self.button_trace.setFont(font)
        palette = QPalette(self.button_trace.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        self.button_trace.setPalette(palette) # assign new palette
        self.button_trace.setFixedHeight(45)

        self.button_reset = gui.button(button_box, self, "Reset Fields", callback=self.callResetSettings)
        font = QFont(self.button_reset.font())
        font.setItalic(True)
        self.button_reset.setFont(font)
        palette = QPalette(self.button_reset.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        self.button_reset.setPalette(palette) # assign new palette
        self.button_reset.setFixedHeight(45)
        self.button_reset.setFixedWidth(150)

        gui.separator(self.controlArea)
        
        self.tabs_setting = gui.tabWidget(self.controlArea)
        self.tabs_setting.setFixedHeight(self.TABS_AREA_HEIGHT)
        self.tabs_setting.setFixedWidth(self.CONTROL_AREA_WIDTH-5)

        self.tab_bas = oasysgui.createTabPage(self.tabs_setting, "Basic Setting")
        self.tab_adv = oasysgui.createTabPage(self.tabs_setting, "Advanced Setting")

        adv_other_box = oasysgui.widgetBox(self.tab_adv, "Optional file output", addSpace=False, orientation="vertical")

        gui.comboBox(adv_other_box, self, "file_to_write_out", label="Files to write out", labelWidth=150,
                     items=["All", "Mirror", "Image", "None", "Debug (All + start.xx/end.xx)"],
                     sendSelectedValue=False, orientation="horizontal")
Beispiel #20
0
    def __setRevisionText(self):
        " Sets the revision margin text "
        for revNumber in self.__revisionInfo:
            author = self.__revisionInfo[revNumber]['author']
            if '@' in author:
                # Most probably this is an e-mail address. Leave just name.
                self.__revisionInfo[revNumber]['shortAuthor'] = author.split(
                    '@')[0]
            else:
                self.__revisionInfo[revNumber]['shortAuthor'] = author

        skin = GlobalData().skin
        revisionMarginFont = QFont(skin.lineNumFont)
        revisionMarginFont.setItalic(True)
        style = QsciStyle(-1, "Revision margin style",
                          skin.revisionMarginColor, skin.revisionMarginPaper,
                          revisionMarginFont)

        lineNumber = 0
        self.__maxLength = -1

        # Altering line background support
        currentRevision = -1
        needMarker = True

        for lineRevision in self.__lineRevisions:
            if lineRevision in self.__revisionInfo:
                marginText = " " + ":".join([
                    str(lineRevision),
                    self.__revisionInfo[lineRevision]['shortAuthor']
                ])
            else:
                marginText = " " + str(lineRevision)
            textLength = len(marginText)
            if textLength > self.__maxLength:
                self.__maxLength = textLength
            self.setMarginText(lineNumber, marginText, style)

            # Set the line background if needed
            if lineRevision != currentRevision:
                currentRevision = lineRevision
                needMarker = not needMarker
            if needMarker:
                self.markerAdd(lineNumber, self.__alterMarker)

            lineNumber += 1

        self.setRevisionMarginWidth()
        return
Beispiel #21
0
    def __init__(self, *args, **kwargs):
        super(Button_menu, self).__init__(*args, **kwargs)

        # self.setFont(QFont("Times New Roman", 20))
        # self.setStyleSheet("width: 20px;")
        self.setIconSize(QSize(80, 80))
        self.setFocusPolicy(Qt.TabFocus)
        font = QFont()
        font.setBold(True)
        font.setItalic(True)
        font.setUnderline(True)
        font.setWeight(40)
        # font.setStrikeOut(False)
        # font.setKerning(True)
        self.setFont(font)
 def setKeyFont(self, type):
     """
     Set the font of the key
     """
     font = QFont()
     if type == 2:
         font.setItalic(True)
         self.setFont(0, font)
     elif type == 0 and self.siz > 0:
         self.setForeground(0, QColor(Qt.darkBlue))
         self.setIcon(0, QIcon(":/dot.png"))
         font.setBold(True)
         self.setFont(0, font)
     else:
         self.setFont(0, font)
Beispiel #23
0
    def initLogo(self, layout):
        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(12)

        lisa_logo = QLabel()
        logopath = find_logo()
        logo = QPixmap(logopath)
        logo = logo.scaled(130, 130)
        lisa_logo.setPixmap(logo)  # scaledToWidth(128))
        lisa_logo.mousePressEvent = lambda event: self.changeWidget('Main')
        layout.addWidget(lisa_logo)
        return layout
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Run Simulation", self)
        self.runaction.triggered.connect(self.run_simulation)
        self.addAction(self.runaction)

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(QRect(round(geom.width()*0.05),
                               round(geom.height()*0.05),
                               round(min(geom.width()*0.5, self.MAX_WIDTH)),
                               round(min(geom.height()*0.5, self.MAX_HEIGHT))))

        label_box = ShadowGui.widgetBox(self.controlArea, "", orientation="horizontal")

        gui.separator(label_box, height=50)
        gui.label(label_box, self, "                                JUST A DEMO WIDGET!!!!!")
        gui.separator(label_box, height=50)

        self.left_box_1 = ShadowGui.widgetBox(self.controlArea, "Electron Beam", addSpace=True, orientation="vertical")

        ShadowGui.lineEdit(self.left_box_1, self, "lens_position", "Position on beamline", labelWidth=300, valueType=float, orientation="horizontal")
        ShadowGui.lineEdit(self.left_box_1, self, "focal_x", "Focal length (horizontal) [m]", labelWidth=300, valueType=float, orientation="horizontal")
        ShadowGui.lineEdit(self.left_box_1, self, "focal_y", "Focal length (vertical) [m]", labelWidth=300, valueType=float, orientation="horizontal")

        button_box = ShadowGui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Run Simulation", callback=self.run_simulation)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette) # assign new palette
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Reset Fields", callback=self.callResetSettings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette) # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(100)

        gui.rubber(self.controlArea)
 def data(self, index, role):
     if not index.isValid():
         return QVariant()
     ms = self.mapper.getMergeScanForId(index.internalId())
     if ms is None:
         logger.critical("data: wasn't able to get the FileSystemMerge for internal id {0}".format(index.internalId()))
         return QVariant()
     if role == Qt.CheckStateRole and index.column() == MergeScanTreeModel.COL_CHECKED:
         return ms.checked
     if role == Qt.DecorationRole and index.column() == MergeScanTreeModel.COL_ICON:
         return self.IconProvider.icon(QFileIconProvider.Folder) if ms.is_dir else None
     if role == Qt.TextColorRole:
         if ms.flags == PersistentScanningState.ITEM_DELETED:
             return QColor(Qt.red)
         return QVariant()
     if role == Qt.FontRole:
         font = QFont()
         info = PathInfo(ms.abs_path, ms.path_info)
         if info.is_symlink or ms.flags == PersistentScanningState.ITEM_UNREADABLE:
             font.setItalic(True)
         return font
     if role == Qt.DisplayRole:
         data = None
         if index.column() == MergeScanTreeModel.COL_NAME:
             data = os.path.basename(ms.abs_path)
             if "Sample" in data:
                 x = 0
         elif index.column() == MergeScanTreeModel.COL_CHANGE_TYPE:
             if ms.flags == PersistentScanningState.ITEM_ADDED:
                 data = "Added"
             elif ms.flags == PersistentScanningState.ITEM_DELETED:
                 data = "Deleted"
             elif ms.flags == PersistentScanningState.ITEM_MODIFIED:
                 data = "Modified"
             elif ms.flags == PersistentScanningState.ITEM_UNCHANGED:
                 data = ""
         elif index.column() == MergeScanTreeModel.COL_SIZE:
             data = PathInfo(ms.abs_path, ms.path_info).size_human_readable if not ms.is_dir else None
         elif index.column() == MergeScanTreeModel.COL_DATE_MODIFIED:
             value = QDateTime.fromTime_t(int(PathInfo(ms.abs_path, ms.path_info).modified_date))
             data = value.toString()
         elif index.column() == MergeScanTreeModel.COL_PERMISSIONS:
             info = PathInfo(ms.abs_path, ms.path_info)
             data = "{0}:{1} {2}".format(info.uid, info.gid, info.posix_perms_human_readable)
         return data
     return QVariant()
    def __setRevisionText( self ):
        " Sets the revision margin text "
        for revNumber in self.__revisionInfo:
            author = self.__revisionInfo[ revNumber ][ 'author' ]
            if '@' in author:
                # Most probably this is an e-mail address. Leave just name.
                self.__revisionInfo[ revNumber ][ 'shortAuthor' ] = author.split( '@' )[ 0 ]
            else:
                self.__revisionInfo[ revNumber ][ 'shortAuthor' ] = author

        skin = GlobalData().skin
        revisionMarginFont = QFont( skin.lineNumFont )
        revisionMarginFont.setItalic( True )
        style = QsciStyle( -1, "Revision margin style",
                           skin.revisionMarginColor,
                           skin.revisionMarginPaper, revisionMarginFont )

        lineNumber = 0
        self.__maxLength = -1

        # Altering line background support
        currentRevision = -1
        needMarker = True

        for lineRevision in self.__lineRevisions:
            if lineRevision in self.__revisionInfo:
                marginText = " " + ":".join( [ str( lineRevision ),
                        self.__revisionInfo[ lineRevision ][ 'shortAuthor' ] ] )
            else:
                marginText = " " + str( lineRevision )
            textLength = len( marginText )
            if textLength > self.__maxLength:
                self.__maxLength = textLength
            self.setMarginText( lineNumber, marginText, style )

            # Set the line background if needed
            if lineRevision != currentRevision:
                currentRevision = lineRevision
                needMarker = not needMarker
            if needMarker:
                self.markerAdd( lineNumber, self.__alterMarker )

            lineNumber += 1

        self.setRevisionMarginWidth()
        return
Beispiel #27
0
    def list_compatible_canvas_layers(self):
        """Fill the list widget with compatible layers.

        :returns: Metadata of found layers.
        :rtype: list of dicts
        """
        italic_font = QFont()
        italic_font.setItalic(True)
        list_widget = self.lstCanvasExpLayers
        # Add compatible layers
        list_widget.clear()
        for layer in self.parent.get_compatible_canvas_layers('exposure'):
            item = QListWidgetItem(layer['name'], list_widget)
            item.setData(Qt.UserRole, layer['id'])
            if not layer['keywords']:
                item.setFont(italic_font)
            list_widget.addItem(item)
Beispiel #28
0
    def data(self, index, role=Qt.DisplayRole):
        """
        Cell content

        @param index: 
        @type index:

        @param role: 
        @type role:

        @return:
        @rtype:
        """
        if not index.isValid():
            return q()

        value = self.getValue(index)
        if role == Qt.FontRole:
            if index.column() == COLUMN_NAME:
                font = QFont()
                font.setBold(True)
                return q(font)

            elif index.column() == COLUMN_TYPE:
                font = QFont()
                font.setItalic(True)
                return q(font)

            elif index.column() == COLUMN_ARGS:
                font = QFont()
                font.setBold(True)
                return q(font)

        elif role == Qt.DisplayRole:
            if index.column() == COLUMN_ARGS:  # exception for arguments
                ret = ''
                if len(value) != 0:
                    ret = ' [...]'
                return q(ret)

            else:
                return q(value)

        elif role == Qt.EditRole:
            return q(value)
Beispiel #29
0
    def data(self, index, role=Qt.DisplayRole):
        """
        Cell content

        @param index: 
        @type index:

        @param role: 
        @type role:

        @return:
        @rtype:
        """
        if not index.isValid():
            #return q()
            return ''
        value = self.getValue(index)
        if role == Qt.ToolTipRole:
            if index.column() == COL_VALUE:
                return q(value)
        if role == Qt.FontRole:
            if index.column() == COL_NAME:
                font = QFont()
                font.setBold(True)
                return q(font)
            if index.column() == COL_DESCRIPTION:
                font = QFont()
                font.setItalic(True)
                return q(font)
        if role == Qt.DisplayRole:
            if index.column() == COL_VALUE:
                if len(value) > 25:
                    return q( "%s [...]" % value[:25])
                else:
                    return q(value)
            elif index.column() == COL_DESCRIPTION:
                lines = value.splitlines()
                if len(lines) > 1:
                    return q( "%s [...]" % lines[0])
                else:
                    return q(value)
            else:
                return q(value)
        elif role == Qt.EditRole:
            return q(value)
Beispiel #30
0
	def init(self):
		self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
		font = QFont()
		font.setBold(True)
		font.setItalic(True)
		self.__label.setFont(font)

		self.__mainLayout.setAlignment(Qt.AlignVCenter)
		self.__mainLayout.addWidget(self.__iconLabel)
		self.__mainLayout.addWidget(self.__label)
		self.__mainLayout.addStretch(1)

		self.__mainFrame.setAutoFillBackground(True)
		self.__mainFrame.setFrameStyle(QFrame.Box)
		self.__mainFrame.setFrameShadow(QFrame.Sunken)
		self.__mainFrame.setBackgroundRole(QPalette.Base)

		self.__mainFrame.setLayout(self.__mainLayout)
 def changeCurrentFormat(self):
     newFont = QFont()
     newFont.setFamily( self.mFontComboBox.currentFont().family() )
     #bold
     if ( self.mBoldPushButton.isChecked() ):
         newFont.setBold( True )
     else:
         newFont.setBold( False )
     #italic
     if ( self.mItalicsPushButton.isChecked() ):
         newFont.setItalic( True )
     else:
         newFont.setItalic( False )
     #size
     newFont.setPointSize( self.mFontSizeSpinBox.value() )
     self.mTextEdit.setCurrentFont( newFont )
     #color
     self.mTextEdit.setTextColor( self.mFontColorButton.color() )
def tuple_to_qfont(tup):
    """
    Create a QFont from tuple:
        (family [string], size [int], italic [bool], bold [bool])
    """
    if not isinstance(tup, tuple) or len(tup) != 4 \
       or not font_is_installed(tup[0]) \
       or not isinstance(tup[1], int) \
       or not isinstance(tup[2], bool) \
       or not isinstance(tup[3], bool):
        return None
    font = QFont()
    family, size, italic, bold = tup
    font.setFamily(family)
    font.setPointSize(size)
    font.setItalic(italic)
    font.setBold(bold)
    return font
Beispiel #33
0
def tuple_to_qfont(tup):
    """
    Create a QFont from tuple:
        (family [string], size [int], italic [bool], bold [bool])
    """
    if not isinstance(tup, tuple) or len(tup) != 4 \
       or not font_is_installed(tup[0]) \
       or not isinstance(tup[1], int) \
       or not isinstance(tup[2], bool) \
       or not isinstance(tup[3], bool):
        return None
    font = QFont()
    family, size, italic, bold = tup
    font.setFamily(family)
    font.setPointSize(size)
    font.setItalic(italic)
    font.setBold(bold)
    return font
Beispiel #34
0
 def data(self, index, role = Qt.DisplayRole):
     if (not index.isValid() or
         not (0 <= index.row() < len(self.race))):
         return QVariant()
     horse = self.horseList[index.row()]
     column = index.column()
     if role == Qt.DisplayRole:
         retVal = QVariant()
         if self.isColumn("name", column):
             retVal = QVariant(horse.name)
         elif self.isColumn("rating", column):
             retVal = QVariant(horse[self.getColumn("rating", column)])
         elif self.isColumn("adjust", column):
             index = self.getColumn("adjust", column)
             adjust = self.race.adjusts[index]
             retVal = QVariant(self.race.adjusts.getAdjust(adjust, horse))
         elif self.isColumn("adjRating", column):
             index = self.getColumn("adjRating", column)
             rating = self.race.adjusts.getAdjustedRating(horse, index)
             retVal = QVariant(rating)
         elif self.isColumn("round", column):
             index = self.getColumn("round", column)
             odds = self.rounds[index].convert(horse.prob)
             retVal = QVariant(self.oddsDisplay.display(odds))
         return retVal
     elif role == Qt.TextAlignmentRole:
         if self.isColumn("name", column):
             return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
         else:
             return QVariant(int(Qt.AlignRight | Qt.AlignVCenter))
     elif role == Qt.FontRole:
         if self.isColumn("round", column):
             font = QFont()
             font.setBold(True)
             return QVariant(font)
         elif self.isColumn("adjRating", column):
             font = QFont()
             font.setItalic(True)
             return QVariant(font)
         else:
             return QVariant()
     return QVariant()
Beispiel #35
0
    def set_pythonshell_font(self, font=None):
        """Python Shell only"""
        if font is None:
            font = QFont()

        for format in self.formats:
            format.setFont(font)
        
        getstyleconf = lambda name, prop: CONF.get('shell_appearance',
                                                   name+'/'+prop)
        for format, stylestr in self.formats.iteritems():
            foreground = getstyleconf(stylestr, 'foregroundcolor')
            format.setForeground(QColor(foreground))
            background = getstyleconf(stylestr, 'backgroundcolor')
            format.setBackground(QColor(background))
            font = format.font()
            font.setBold(getstyleconf(stylestr, 'bold'))
            font.setItalic(getstyleconf(stylestr, 'italic'))
            font.setUnderline(getstyleconf(stylestr, 'underline'))
            format.setFont(font)
Beispiel #36
0
 def data(self, index, role=Qt.DisplayRole):
     if (not index.isValid() or not (0 <= index.row() < len(self.race))):
         return QVariant()
     horse = self.horseList[index.row()]
     column = index.column()
     if role == Qt.DisplayRole:
         retVal = QVariant()
         if self.isColumn("name", column):
             retVal = QVariant(horse.name)
         elif self.isColumn("rating", column):
             retVal = QVariant(horse[self.getColumn("rating", column)])
         elif self.isColumn("adjust", column):
             index = self.getColumn("adjust", column)
             adjust = self.race.adjusts[index]
             retVal = QVariant(self.race.adjusts.getAdjust(adjust, horse))
         elif self.isColumn("adjRating", column):
             index = self.getColumn("adjRating", column)
             rating = self.race.adjusts.getAdjustedRating(horse, index)
             retVal = QVariant(rating)
         elif self.isColumn("round", column):
             index = self.getColumn("round", column)
             odds = self.rounds[index].convert(horse.prob)
             retVal = QVariant(self.oddsDisplay.display(odds))
         return retVal
     elif role == Qt.TextAlignmentRole:
         if self.isColumn("name", column):
             return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
         else:
             return QVariant(int(Qt.AlignRight | Qt.AlignVCenter))
     elif role == Qt.FontRole:
         if self.isColumn("round", column):
             font = QFont()
             font.setBold(True)
             return QVariant(font)
         elif self.isColumn("adjRating", column):
             font = QFont()
             font.setItalic(True)
             return QVariant(font)
         else:
             return QVariant()
     return QVariant()
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Send Data to Simulators", self)
        self.runaction.triggered.connect(self.send_data)
        self.addAction(self.runaction)

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(QRect(round(geom.width()*0.05),
                               round(geom.height()*0.05),
                               round(min(geom.width()*0.5, self.MAX_WIDTH)),
                               round(min(geom.height()*0.5, self.MAX_HEIGHT))))


        left_box_1 = ShadowGui.widgetBox(self.controlArea, "Image Plane Parameters", addSpace=True, orientation="vertical")

        ShadowGui.lineEdit(left_box_1, self, "image_plane_name", "Image Plane Name", labelWidth=200, valueType=str, orientation="horizontal")
        ShadowGui.lineEdit(left_box_1, self, "image_plane_position", "Position on beamline", labelWidth=300, valueType=float, orientation="horizontal")

        button_box = ShadowGui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Send Data to Simulators", callback=self.send_data)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette) # assign new palette
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Reset Fields", callback=self.callResetSettings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette) # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(100)

        gui.rubber(self.controlArea)
Beispiel #38
0
 def data(self, index, role):  # pylint: disable=R0201
     """get data fom model"""
     # pylint: disable=R0912
     # too many branches
     result = QVariant()
     if index.isValid():
         item = index.internalPointer()
         if role in (Qt.DisplayRole, Qt.EditRole):
             if index.column() == 1:
                 if isinstance(
                         item,
                         RuleItem) and item.rawContent.parType is bool:
                     return QVariant('')
             showValue = item.content(index.column())
             if isinstance(showValue,
                           basestring) and showValue.endswith('.0'):
                 try:
                     showValue = str(int(float(showValue)))
                 except ValueError:
                     pass
             if showValue == '0':
                 showValue = ''
             result = QVariant(showValue)
         elif role == Qt.CheckStateRole:
             if self.isCheckboxCell(index):
                 bData = item.content(index.column())
                 result = QVariant(Qt.Checked if bData else Qt.Unchecked)
         elif role == Qt.TextAlignmentRole:
             result = QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
             if index.column() > 0:
                 result = QVariant(int(Qt.AlignRight | Qt.AlignVCenter))
         elif role == Qt.FontRole and index.column() == 0:
             ruleset = item.ruleset()
             if isinstance(ruleset, PredefinedRuleset):
                 font = QFont()
                 font.setItalic(True)
                 result = QVariant(font)
         elif role == Qt.ToolTipRole:
             tip = '<b></b>%s<b></b>' % m18n(item.tooltip()) if item else ''
             result = QVariant(tip)
     return result
Beispiel #39
0
def get_font(section, option=None):
    """Get console font properties depending on OS and user options"""
    font = FONT_CACHE.get((section, option))
    if font is None:
        if option is None:
            option = 'font'
        else:
            option += '/font'
        families = CONF.get(section, option + "/family", None)
        if families is None:
            return QFont()
        family = get_family(families)
        weight = QFont.Normal
        italic = CONF.get(section, option + '/italic', False)
        if CONF.get(section, option + '/bold', False):
            weight = QFont.Bold
        size = CONF.get(section, option + '/size', 9)
        font = QFont(family, size, weight)
        font.setItalic(italic)
        FONT_CACHE[(section, option)] = font
    return font
Beispiel #40
0
def get_font(section, option=None):
    """Get console font properties depending on OS and user options"""
    font = FONT_CACHE.get((section, option))
    if font is None:
        if option is None:
            option = 'font'
        else:
            option += '/font'
        families = CONF.get(section, option+"/family", None)
        if families is None:
            return QFont()
        family = get_family( families )
        weight = QFont.Normal
        italic = CONF.get(section, option+'/italic', False)
        if CONF.get(section, option+'/bold', False):
            weight = QFont.Bold
        size = CONF.get(section, option+'/size', 9)
        font = QFont(family, size, weight)
        font.setItalic(italic)
        FONT_CACHE[(section, option)] = font
    return font
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Run Shadow/Trace", self)
        self.runaction.triggered.connect(self.traceOpticalElement)
        self.addAction(self.runaction)

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        tabs_setting = gui.tabWidget(self.controlArea)

        tab_bas = ShadowGui.createTabPage(tabs_setting, "Basic Setting")

        lens_box = ShadowGui.widgetBox(tab_bas, "Input Parameters", addSpace=False, orientation="vertical", height=600, width=450)

        self.le_source_plane_distance = ShadowGui.lineEdit(lens_box, self, "source_plane_distance", "Source Plane Distance [cm]", labelWidth=350, valueType=float, orientation="horizontal")
        self.le_image_plane_distance = ShadowGui.lineEdit(lens_box, self, "image_plane_distance", "Image Plane Distance [cm]", labelWidth=350, valueType=float, orientation="horizontal")

        gui.separator(self.controlArea)

        button_box = ShadowGui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Run Shadow/trace", callback=self.traceOpticalElement)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Reset Fields", callback=self.callResetSettings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(100)
Beispiel #42
0
    def data(self, index, role):
        if role != Qt.DisplayRole and role != Qt.FontRole:
            return None

        val = self.getData(index.row(), index.column())

        if role == Qt.FontRole:  # draw NULL in italic
            if val is not None:
                return None
            f = QFont()
            f.setItalic(True)
            return f

        if val is None:
            return "NULL"
        elif isinstance(val, buffer):
            # hide binary data
            return None
        elif isinstance(val, (str, unicode)) and len(val) > 300:
            # too much data to display, elide the string
            return u"%s..." % val[:300]
        return unicode(val)  # convert to string
Beispiel #43
0
    def __init__(self, show_automatic_box=False):
        super().__init__(show_automatic_box=show_automatic_box)

        self.runaction = widget.OWAction("Copy Source Parameters", self)
        self.runaction.triggered.connect(self.copy_src_parameters)
        self.addAction(self.runaction)

        self.runaction = widget.OWAction("Paste Source Parameters", self)
        self.runaction.triggered.connect(self.paste_src_parameters)
        self.addAction(self.runaction)

        self.runaction = widget.OWAction("Run Shadow/Source", self)
        self.runaction.triggered.connect(self.runShadowSource)
        self.addAction(self.runaction)

        self.general_options_box.setVisible(False)

        button_box = oasysgui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Run Shadow/Source", callback=self.runShadowSource)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette) # assign new palette
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Reset Fields", callback=self.callResetSettings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette()) # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette) # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(150)

        gui.separator(self.controlArea)
    def __init__(self):
        super().__init__()

        self.setFixedWidth(500)
        self.setFixedHeight(300)

        left_box_1 = ShadowGui.widgetBox(self.controlArea, "Accumulating Loop Management", addSpace=True, orientation="vertical", height=120)

        ShadowGui.lineEdit(left_box_1, self, "number_of_accumulated_rays", "Number of accumulated good rays\n(before sending signal)", labelWidth=350, valueType=int,
                           orientation="horizontal")

        le = ShadowGui.lineEdit(left_box_1, self, "current_number_of_rays", "Current number of good rays", labelWidth=350, valueType=int, orientation="horizontal")
        le.setReadOnly(True)
        font = QtGui.QFont(le.font())
        font.setBold(True)
        le.setFont(font)
        palette = QtGui.QPalette(le.palette())  # make a copy of the palette
        palette.setColor(QtGui.QPalette.Text, QtGui.QColor('dark blue'))
        palette.setColor(QtGui.QPalette.Base, QtGui.QColor(243, 240, 160))
        le.setPalette(palette)

        gui.comboBox(left_box_1, self, "keep_go_rays", label="Remove lost rays from beam", labelWidth=350, items=["No", "Yes"], sendSelectedValue=False, orientation="horizontal")


        button_box = gui.widgetBox(self.controlArea, "", addSpace=True, orientation="horizontal")

        self.start_button = gui.button(button_box, self, "Send Beam", callback=self.sendSignal)
        self.start_button.setFixedHeight(45)

        button = gui.button(button_box, self, "Reset Accumulation", callback=self.callResetSettings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        gui.rubber(self.controlArea)
Beispiel #45
0
def update_font(basefont, weight=None, italic=None, underline=None, pixelSize=None, pointSize=None):
    """
    Return a copy of `basefont` :class:`QFont` with updated properties.
    """
    font = QFont(basefont)

    if weight is not None:
        font.setWeight(weight)

    if italic is not None:
        font.setItalic(italic)

    if underline is not None:
        font.setUnderline(underline)

    if pixelSize is not None:
        font.setPixelSize(pixelSize)

    if pointSize is not None:
        font.setPointSize(pointSize)

    return font
Beispiel #46
0
        def data(self, index, role):
                if role != Qt.DisplayRole and role != Qt.FontRole:
                        return None

                val = self.getData(index.row(), index.column())

                if role == Qt.FontRole:  # draw NULL in italic
                        if val is not None:
                                return None
                        f = QFont()
                        f.setItalic(True)
                        return f

                if val is None:
                        return "NULL"
                elif isinstance(val, buffer):
                        # hide binary data
                        return None
                elif isinstance(val, (str, unicode)) and len(val) > 300:
                        # too much data to display, elide the string
                        return u"%s..." % val[:300]
                return unicode(val)     # convert to string
Beispiel #47
0
 def data(self, index, role): # pylint: disable=R0201
     """get data fom model"""
     # pylint: disable=R0912
     # too many branches
     result = QVariant()
     if index.isValid():
         item = index.internalPointer()
         if role in (Qt.DisplayRole, Qt.EditRole):
             if index.column() == 1:
                 if isinstance(item, RuleItem) and item.rawContent.parType is bool:
                     return QVariant('')
             showValue = item.content(index.column())
             if isinstance(showValue, basestring) and showValue.endswith('.0'):
                 try:
                     showValue = str(int(float(showValue)))
                 except ValueError:
                     pass
             if showValue == '0':
                 showValue = ''
             result = QVariant(showValue)
         elif role == Qt.CheckStateRole:
             if self.isCheckboxCell(index):
                 bData = item.content(index.column())
                 result = QVariant(Qt.Checked if bData else Qt.Unchecked)
         elif role == Qt.TextAlignmentRole:
             result = QVariant(int(Qt.AlignLeft|Qt.AlignVCenter))
             if index.column() > 0:
                 result = QVariant(int(Qt.AlignRight|Qt.AlignVCenter))
         elif role == Qt.FontRole and index.column() == 0:
             ruleset = item.ruleset()
             if isinstance(ruleset, PredefinedRuleset):
                 font = QFont()
                 font.setItalic(True)
                 result = QVariant(font)
         elif role == Qt.ToolTipRole:
             tip = '<b></b>%s<b></b>' % m18n(item.tooltip()) if item else ''
             result = QVariant(tip)
     return result
 def defaultFont(self, style):
     """
     Public method to get the default font for a style.
     
     @param style style number (integer)
     @return font (QFont)
     """
     if style in [PYGMENTS_COMMENT, PYGMENTS_PREPROCESSOR]:
         if Utilities.isWindowsPlatform():
             f = QFont("Comic Sans MS", 9)
         else:
             f = QFont("Bitstream Vera Serif", 9)
         if style == PYGMENTS_PREPROCESSOR:
             f.setItalic(True)
         return f
     
     if style in [PYGMENTS_STRING]:
         if Utilities.isWindowsPlatform():
             return QFont("Comic Sans MS", 10)
         else:
             return QFont("Bitstream Vera Serif", 10)
     
     if style in [PYGMENTS_KEYWORD, PYGMENTS_OPERATOR, PYGMENTS_WORD, PYGMENTS_BUILTIN,
                  PYGMENTS_ATTRIBUTE, PYGMENTS_FUNCTION, PYGMENTS_CLASS, 
                  PYGMENTS_NAMESPACE, PYGMENTS_EXCEPTION, PYGMENTS_ENTITY, 
                  PYGMENTS_TAG, PYGMENTS_SCALAR, PYGMENTS_ESCAPE, PYGMENTS_HEADING, 
                  PYGMENTS_SUBHEADING, PYGMENTS_STRONG, PYGMENTS_PROMPT]:
         f = LexerContainer.defaultFont(self, style)
         f.setBold(True)
         return f
     
     if style in [PYGMENTS_DOCSTRING, PYGMENTS_EMPHASIZE]:
         f = LexerContainer.defaultFont(self, style)
         f.setItalic(True)
         return f
     
     return LexerContainer.defaultFont(self, style)
    def __init__(self):
        super().__init__()

        # self.resetSettings()

        #################################
        # FIX A WEIRD BEHAVIOUR AFTER DISPLAY
        # THE WIDGET: PROBABLY ON SIGNAL MANAGER
        self.dumpSettings()

        self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH)

        tabs_setting = gui.tabWidget(self.controlArea)
        tabs_setting.setFixedWidth(495)
        tabs_setting.setFixedHeight(750)

        tab_bas = ShadowGui.createTabPage(tabs_setting, "Basic Setting")
        tab_adv = ShadowGui.createTabPage(tabs_setting, "Advanced Setting")

        tabs_button_box = ShadowGui.widgetBox(tab_bas, "", addSpace=False, orientation="horizontal")

        gui.separator(tabs_button_box)

        gui.button(tabs_button_box, self, "Insert C.R.L. Before", callback=self.crl_insert_before)
        gui.button(tabs_button_box, self, "Insert C.R.L. After", callback=self.crl_insert_after)
        gui.button(tabs_button_box, self, "Remove C.R.L.", callback=self.crl_remove)

        gui.separator(tabs_button_box)

        self.tab_crls = gui.tabWidget(tab_bas)
        self.crl_box_array = []

        for index in range(len(self.p)):
            tab_crl = ShadowGui.createTabPage(self.tab_crls, "C.R.L. " + str(index + 1))

            crl_box = CRLBox(transfocator=self,
                             parent=tab_crl,
                             nlenses=self.nlenses[index],
                             slots_empty=self.slots_empty[index],
                             thickness=self.thickness[index],
                             p=self.p[index],
                             q=self.q[index],
                             surface_shape=self.surface_shape[index],
                             convex_to_the_beam=self.convex_to_the_beam[index],
                             has_finite_diameter=self.has_finite_diameter[index],
                             diameter=self.diameter[index],
                             is_cylinder=self.is_cylinder[index],
                             cylinder_angle=self.cylinder_angle[index],
                             ri_calculation_mode=self.ri_calculation_mode[index],
                             prerefl_file=self.prerefl_file[index],
                             refraction_index=self.refraction_index[index],
                             attenuation_coefficient=self.attenuation_coefficient[index],
                             radius=self.radius[index],
                             interthickness=self.interthickness[index],
                             use_ccc=self.use_ccc[index])

            self.crl_box_array.append(crl_box)

        adv_other_box = ShadowGui.widgetBox(tab_adv, "Optional file output", addSpace=False, orientation="vertical")

        gui.comboBox(adv_other_box, self, "file_to_write_out", label="Files to write out", labelWidth=310,
                     items=["All", "Mirror", "Image", "None"],
                     sendSelectedValue=False, orientation="horizontal")

        button_box = ShadowGui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Run Shadow/trace", callback=self.traceOpticalElement)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Reset Fields", callback=self.callResetSettings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(100)
class QnoteroItemDelegate(QStyledItemDelegate):
    """Draws pretty result items"""
    def __init__(self, qnotero):
        """
		Constructor

		Arguments:
		qnotero -- a Qnotero instance
		"""

        QStyledItemDelegate.__init__(self, qnotero)
        self.qnotero = qnotero
        self.boldFont = QFont()
        self.boldFont.setBold(True)
        self.regularFont = QFont()
        self.italicFont = QFont()
        self.italicFont.setItalic(True)
        self.tagFont = QFont()
        self.tagFont.setBold(True)
        self.tagFont.setPointSize(self.boldFont.pointSize() - 2)
        self.dy = QFontMetrics(self.boldFont) \
         .size(Qt.TextSingleLine, u"Dummy").height() \
         *self.qnotero.theme.lineHeight()
        self.margin = 0.5 * self.dy
        self._margin = 0.1 * self.dy
        self.height = 5 * self.dy + self._margin
        self.noPdfPixmap = self.qnotero.theme.pixmap(u"nopdf")
        self.pdfPixmap = self.qnotero.theme.pixmap(u"pdf")
        self.aboutPixmap = self.qnotero.theme.pixmap(u"about")
        self.notePixmap = self.qnotero.theme.pixmap(u"note")
        self.pixmapSize = self.pdfPixmap.height() + 0.5 * self.dy
        self.roundness = self.qnotero.theme.roundness()

    def sizeHint(self, option, index):
        """
		Suggest a size for the widget

		Arguments:
		option -- a QStyleOptionView
		index -- a QModelIndex

		Returns:
		A QSize
		"""

        return QSize(0, self.height)

    def paint(self, painter, option, index):
        """
		Draws the widget

		Arguments:
		painter -- a QPainter
		option -- a QStyleOptionView
		index -- a QModelIndex
		"""

        # Retrieve the data
        model = index.model()
        record = model.data(index)
        text = record.toString()
        zoteroItem = zoteroCache[unicode(text)]
        l = zoteroItem.full_format().split(u"\n")
        if zoteroItem.fulltext == None:
            pixmap = self.noPdfPixmap
        else:
            pixmap = self.pdfPixmap

        # Choose the colors
        self.palette = self.qnotero.ui.listWidgetResults.palette()
        if option.state & QStyle.State_MouseOver:
            background = self.palette.Highlight
            foreground = self.palette.HighlightedText
            _note = zoteroItem.get_note()
            if _note != None:
                self.qnotero.showNoteHint()
            else:
                self.qnotero.hideNoteHint()

        elif option.state & QStyle.State_Selected:
            background = self.palette.Dark
            foreground = self.palette.WindowText
        else:
            background = self.palette.Base
            foreground = self.palette.WindowText

        # Draw the frame
        _rect = option.rect.adjusted(self._margin, self._margin, \
         -2*self._margin, -self._margin)
        pen = painter.pen()
        pen.setColor(self.palette.color(background))
        painter.setPen(pen)
        painter.setBrush(self.palette.brush(background))
        painter.drawRoundedRect(_rect, self.roundness, self.roundness)
        font = painter.font
        pen = painter.pen()
        pen.setColor(self.palette.color(foreground))
        painter.setPen(pen)

        # Draw icon
        _rect = QRect(option.rect)
        _rect.moveBottom(_rect.bottom() + 0.5 * self.dy)
        _rect.moveLeft(_rect.left() + 0.5 * self.dy)
        _rect.setHeight(self.pixmapSize)
        _rect.setWidth(self.pixmapSize)
        painter.drawPixmap(_rect, pixmap)

        # Draw the text
        _rect = option.rect.adjusted(self.pixmapSize+self.dy, 0.5*self.dy, \
         -self.dy, 0)

        f = [self.tagFont, self.italicFont, self.regularFont, \
         self.boldFont]
        l.reverse()
        while len(l) > 0:
            s = l.pop()
            if len(f) > 0:
                painter.setFont(f.pop())
            painter.drawText(_rect, Qt.AlignLeft, s)
            _rect = _rect.adjusted(0, self.dy, 0, 0)
Beispiel #51
0
    def _initUI(self):
        window = QtGui.QWidget()
        self.window = window
        self.setCentralWidget(window)
        self.resize(800, 600)
        self.setWindowTitle('LISA')
        self.statusBar().showMessage('Ready')
        self.mainLayout = QHBoxLayout(window)
        window.setLayout(self.mainLayout)
        self.ui_widgets = {}
        self.ui_buttons = {}


        #### MENU ####
        self.initUIMenu()
        line = QFrame()
        line.setFrameShape(QFrame.VLine)
        self.mainLayout.addWidget(line)


        ##### BODY #####
        bodyLayout = QVBoxLayout()
        self.bodyLayout = bodyLayout
        self.mainLayout.addLayout(bodyLayout)

        #--- title ---
        self.infoBody = QtGui.QWidget()
        infoBodyLayout = QVBoxLayout()
        bodyLayout.addWidget(self.infoBody)
        self.infoBody.setLayout(infoBodyLayout)
        self.ui_widgets["Main"] = self.infoBody

        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(12)
        lisa_title = QLabel('Liver Surgery Analyser')
        info = QLabel('Developed by:\n' +
                      'University of West Bohemia\n' +
                      'Faculty of Applied Sciences\n' +
                      QString.fromUtf8('M. Jiřík, V. Lukeš - 2013') +
                      '\n\nVersion: ' + self.oseg.version
                      )
        info.setFont(font_info)
        lisa_title.setFont(font_label)
        infoBodyLayout.addWidget(lisa_title)
        infoBodyLayout.addWidget(info)

        #--- segmentation option ---
        self.segBody = segmentationQt.SegmentationWidget(oseg=self.oseg)
        # self.segBody.oseg = self.oseg
        bodyLayout.addWidget(self.segBody)
        self.ui_widgets["Segmentation"] = self.segBody
        # self.segBody.lblSegData.setText(self.text_seg_data)
        self.segBody.btnVirtualResectionPV.clicked.connect(self.btnVirtualResectionPV)
        self.segBody.btnVirtualResectionPlanar.clicked.connect(self.btnVirtualResectionPlanar)
        self.segBody.btnVirtualResectionPV_testing.clicked.connect(self.btnVirtualResectionPV_new)


        ###
        self.segBody.btnSegManual.clicked.connect(self.btnManualSeg)
        self.segBody.btnSegSemiAuto.clicked.connect(self.btnSemiautoSeg)
        self.segBody.btnSegMask.clicked.connect(self.maskRegion)
        self.segBody.btnSegPV.clicked.connect(self.btnPortalVeinSegmentation)
        self.segBody.btnSegHV.clicked.connect(self.btnHepaticVeinsSegmentation)

        #--- edit slab ---
        self.slabBody = dictEditQt.DictEdit(dictionary=self.oseg)
        bodyLayout.addWidget(self.slabBody)
        self.ui_widgets["EditSlab"] = self.slabBody
        self.slabBody.btnSaveSlab.clicked.connect(self.segBody.reinitLabels)

        # -- load widget
        import io3d.datareaderqt
        self.read_widget = io3d.datareaderqt.DataReaderWidget(
            before_function=self._before_read_callback,
            after_function=self._after_read_callback
        )
        self.read_widget.cache = self.oseg.cache
        bodyLayout.addWidget(self.read_widget)
        self.ui_widgets["Load"] = self.read_widget

        #--- file info (footer) ---
        bodyLayout.addStretch()


        self.oseg.gui_update = self.gui_update

        ##### OTHERS #####
        self.mainLayout.addStretch()

        self.btnSave.setDisabled(True)
        self.btnSegmentation.setDisabled(True)
        self.btnCompare.setDisabled(True)
        self.changeWidget('Main')
        self.show()
Beispiel #52
0
    def createWidgets(self):
        """
        Create qt widgets

        QTabWidget
         / QWidget \/ QWidget \_________________
        |                                       |
        | ______________________________________|
        """
        self.steps = Steps.StepsQWidget(self)
        self.descrs = Descriptions.DescriptionsQWidget(self)
        self.parameters = Parameters.ParametersQWidget(self)
        self.parametersOutput = Parameters.ParametersQWidget(self, forParamsOutput=True)
        self.probes = Probes.ProbesQWidget(self)
        self.agents = Agents.AgentsQWidget(self)
        self.adapters = Adapters.AdaptersQWidget(self, testParams=self, testDescrs=self.descrs)
        self.libraries = Libraries.LibrariesQWidget(self, testParams=self, testDescrs=self.descrs)
        
        self.parametersTab = QTabWidget()
        self.parametersTab.setTabPosition(QTabWidget.North)
        self.parametersTab.setStyleSheet("QTabWidget { border: 0px; }") # remove 3D border
        self.parametersTab.addTab(self.descrs, QIcon(":/test-config.png"), "Description")
        self.parametersTab.addTab(self.steps, QIcon(":/run-state.png"), "Steps")

        self.paramsTab = QTabWidget()
        self.paramsTab.setStyleSheet("QTabWidget { border: 0px; }") # remove 3D border
        self.paramsTab.setTabPosition(QTabWidget.North)
        self.paramsTab.addTab(self.parameters, QIcon(":/test-input.png"), "Inputs")
        self.paramsTab.addTab(self.parametersOutput, QIcon(":/test-output.png"), "Outputs")
        self.paramsTab.addTab(self.adapters, QIcon(":/adapters.png"), "Adapters")
        self.paramsTab.addTab(self.libraries, QIcon(":/libraries.png"), "Libraries")

        self.miscsTab = QTabWidget()
        self.miscsTab.setStyleSheet("QTabWidget { border: 0px; }") # remove 3D border
        self.miscsTab.setTabPosition(QTabWidget.North)
        self.miscsTab.addTab(self.agents, QIcon(":/agent.png"), "Agents")
        self.miscsTab.addTab(self.probes, QIcon(":/probe.png"), "Probes")

        self.title = QLabel("Test Properties")
        font = QFont()
        font.setBold(True)
        self.title.setFont(font)

        self.labelHelp = QLabel("Prepare the test.")
        font = QFont()
        font.setItalic(True)
        self.labelHelp.setFont(font)

        self.mainTab = QTabWidget()
        self.mainTab.setTabPosition(QTabWidget.North)
        
        self.mainTab.addTab(self.parametersTab, QIcon(":/test-description.png"), "Test Design")
        self.mainTab.addTab(self.paramsTab, QIcon(":/repository.png"), "Test Data")
        self.mainTab.addTab(self.miscsTab, QIcon(":/server-config.png"), "Miscellaneous")


        if Settings.instance().readValue( key = 'TestProperties/inputs-default-tab' ) == "True":
            self.mainTab.setCurrentIndex(1)
            self.paramsTab.setCurrentIndex(TAB_INPUTS)

        layout = QVBoxLayout()
        layout.addWidget( self.title )
        layout.addWidget( self.labelHelp )

        layout.addWidget(self.mainTab)
        layout.setContentsMargins(0,0,0,0)

        self.setLayout(layout)
Beispiel #53
0
    def initUI(self):
        cw = QWidget()
        self.setCentralWidget(cw)
        grid = QGridLayout()
        grid.setSpacing(10)

        # status bar
        self.statusBar().showMessage('Ready')

        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(10)

        # # # # # # #
        # #  LISA logo
        # font_title = QFont()
        # font_title.setBold(True)
        # font_title.setSize(24)

        lisa_title = QLabel('LIver Surgery Analyser')
        info = QLabel('Developed by:\n' +
                      'University of West Bohemia\n' +
                      'Faculty of Applied Sciences\n' +
                      QString.fromUtf8('M. Jiřík, V. Lukeš - 2013') +
                      '\n\nVersion: ' + self.oseg.version
                      )
        info.setFont(font_info)
        lisa_title.setFont(font_label)
        lisa_logo = QLabel()
        logopath = os.path.join(path_to_script, "../applications/LISA256.png")
        logo = QPixmap(logopath)
        lisa_logo.setPixmap(logo)  # scaledToWidth(128))
        grid.addWidget(lisa_title, 0, 1)
        grid.addWidget(info, 1, 1)
        grid.addWidget(lisa_logo, 0, 2, 2, 2)
        # rid.setColumnMinimumWidth(1, logo.width()/2)
        # rid.setColumnMinimumWidth(2, logo.width()/2)
        # rid.setColumnMinimumWidth(3, logo.width()/2)

        # # dicom reader
        rstart = 2
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_dcm = QLabel('DICOM reader')
        text_dcm.setFont(font_label)
        btn_dcmdir = QPushButton("Load DICOM", self)
        btn_dcmdir.clicked.connect(self.loadDataDir)

        btn_datafile = QPushButton("Load file", self)
        btn_datafile.clicked.connect(self.loadDataFile)

        btn_dcmcrop = QPushButton("Crop", self)
        btn_dcmcrop.clicked.connect(self.cropDcm)

        # voxelsize gui comment
        # elf.scaling_mode = 'original'
        # ombo_vs = QComboBox(self)
        # ombo_vs.activated[str].connect(self.changeVoxelSize)
        # eys = scaling_modes.keys()
        # eys.sort()
        # ombo_vs.addItems(keys)
        # ombo_vs.setCurrentIndex(keys.index(self.scaling_mode))
        # elf.text_vs = QLabel('Voxel size:')
        # end-- voxelsize gui
        self.text_dcm_dir = QLabel('DICOM dir:')
        self.text_dcm_data = QLabel('DICOM data:')
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_dcm, rstart + 0, 1, 1, 3)
        grid.addWidget(btn_dcmdir, rstart + 1, 1)
        grid.addWidget(btn_datafile, rstart + 1, 2)
        grid.addWidget(btn_dcmcrop, rstart + 1, 3)
        # voxelsize gui comment
        # grid.addWidget(self.text_vs, rstart + 3, 1)
        # grid.addWidget(combo_vs, rstart + 4, 1)
        grid.addWidget(self.text_dcm_dir, rstart + 6, 1, 1, 3)
        grid.addWidget(self.text_dcm_data, rstart + 7, 1, 1, 3)
        rstart += 9

        # # # # # # # # #  segmentation
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_seg = QLabel('Segmentation')
        text_seg.setFont(font_label)
        btn_mask = QPushButton("Mask region", self)
        btn_mask.clicked.connect(self.maskRegion)
        btn_segauto = QPushButton("Automatic seg.", self)
        btn_segauto.clicked.connect(self.autoSeg)
        btn_segman = QPushButton("Manual seg.", self)
        btn_segman.clicked.connect(self.manualSeg)
        self.text_seg_data = QLabel('segmented data:')
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_seg, rstart + 0, 1)
        grid.addWidget(btn_mask, rstart + 1, 1)
        grid.addWidget(btn_segauto, rstart + 1, 2)
        grid.addWidget(btn_segman, rstart + 1, 3)
        grid.addWidget(self.text_seg_data, rstart + 2, 1, 1, 3)
        rstart += 3

        # # # # # # # # #  save/view
        # hr = QFrame()
        # hr.setFrameShape(QFrame.HLine)
        btn_segsave = QPushButton("Save", self)
        btn_segsave.clicked.connect(self.saveOut)
        btn_segsavedcm = QPushButton("Save Dicom", self)
        btn_segsavedcm.clicked.connect(self.saveOutDcm)
        btn_segview = QPushButton("View3D", self)
        if viewer3D_available:
            btn_segview.clicked.connect(self.view3D)

        else:
            btn_segview.setEnabled(False)

        grid.addWidget(btn_segsave, rstart + 0, 1)
        grid.addWidget(btn_segview, rstart + 0, 3)
        grid.addWidget(btn_segsavedcm, rstart + 0, 2)
        rstart += 2

        # # # # Virtual resection

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        rstart += 1

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_resection = QLabel('Virtual resection')
        text_resection.setFont(font_label)

        btn_vesselseg = QPushButton("Vessel segmentation", self)
        btn_vesselseg.clicked.connect(self.btnVesselSegmentation)

        btn_lesions = QPushButton("Lesions localization", self)
        btn_lesions.clicked.connect(self.btnLesionLocalization)

        btn_resection = QPushButton("Virtual resection", self)
        btn_resection.clicked.connect(self.btnVirtualResection)

        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_resection, rstart + 0, 1)
        grid.addWidget(btn_vesselseg, rstart + 1, 1)
        grid.addWidget(btn_lesions, rstart + 1, 2)
        grid.addWidget(btn_resection, rstart + 1, 3)

        # # # # # # #

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        # rid.addWidget(hr, rstart + 0, 0, 1, 4)

        rstart += 3
        # quit
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        grid.addWidget(btn_quit, rstart + 1, 1, 1, 2)

        cw.setLayout(grid)
        self.setWindowTitle('LISA')
        self.show()
Beispiel #54
0
class SqlEdit(QsciScintilla):

    LEXER_PYTHON = 0
    LEXER_R = 1

    def __init__(self, parent=None):
        QsciScintilla.__init__(self, parent)

        self.mylexer = None
        self.api = None

        self.setCommonOptions()
        self.initShortcuts()

    def setCommonOptions(self):
        # Enable non-ASCII characters
        self.setUtf8(True)

        # Default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setWrapMode(QsciScintilla.WrapWord)
        self.setWrapVisualFlags(QsciScintilla.WrapFlagByText,
                                QsciScintilla.WrapFlagNone, 4)

        self.setSelectionForegroundColor(QColor('#2e3436'))
        self.setSelectionBackgroundColor(QColor('#babdb6'))

        # Show line numbers
        self.setMarginWidth(1, '000')
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor('#2e3436'))
        self.setMarginsBackgroundColor(QColor('#babdb6'))

        # Highlight current line
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor('#d3d7cf'))

        # Folding
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        self.setFoldMarginColors(QColor('#d3d7cf'), QColor('#d3d7cf'))

        # Mark column 80 with vertical line
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QColor('#eeeeec'))

        # Indentation
        self.setAutoIndent(True)
        self.setIndentationsUseTabs(False)
        self.setIndentationWidth(4)
        self.setTabIndents(True)
        self.setBackspaceUnindents(True)
        self.setTabWidth(4)

        # Autocomletion
        self.setAutoCompletionThreshold(2)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        self.setAutoCompletionCaseSensitivity(False)

        # Load font from Python console settings
        settings = QSettings()
        fontName = settings.value('pythonConsole/fontfamilytext', 'Monospace')
        fontSize = int(settings.value('pythonConsole/fontsize', 10))

        self.defaultFont = QFont(fontName)
        self.defaultFont.setFixedPitch(True)
        self.defaultFont.setPointSize(fontSize)
        self.defaultFont.setStyleHint(QFont.TypeWriter)
        self.defaultFont.setStretch(QFont.SemiCondensed)
        self.defaultFont.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        self.defaultFont.setBold(False)

        self.boldFont = QFont(self.defaultFont)
        self.boldFont.setBold(True)

        self.italicFont = QFont(self.defaultFont)
        self.italicFont.setItalic(True)

        self.setFont(self.defaultFont)
        self.setMarginsFont(self.defaultFont)

        self.initLexer()

    def initShortcuts(self):
        (ctrl, shift) = (self.SCMOD_CTRL << 16, self.SCMOD_SHIFT << 16)

        # Disable some shortcuts
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('D') + ctrl)
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl)
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY,
                           ord('L') + ctrl + shift)
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('T') + ctrl)

        #self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord("Z") + ctrl)
        #self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord("Y") + ctrl)

        # Use Ctrl+Space for autocompletion
        self.shortcutAutocomplete = QShortcut(
            QKeySequence(Qt.CTRL + Qt.Key_Space), self)
        self.shortcutAutocomplete.setContext(Qt.WidgetShortcut)
        self.shortcutAutocomplete.activated.connect(self.autoComplete)

    def autoComplete(self):
        self.autoCompleteFromAll()

    def initLexer(self):
        self.mylexer = QsciLexerSQL()

        colorDefault = QColor('#2e3436')
        colorComment = QColor('#c00')
        colorCommentBlock = QColor('#3465a4')
        colorNumber = QColor('#4e9a06')
        colorType = QColor('#4e9a06')
        colorKeyword = QColor('#204a87')
        colorString = QColor('#ce5c00')

        self.mylexer.setDefaultFont(self.defaultFont)
        self.mylexer.setDefaultColor(colorDefault)

        self.mylexer.setColor(colorComment, 1)
        self.mylexer.setColor(colorNumber, 2)
        self.mylexer.setColor(colorString, 3)
        self.mylexer.setColor(colorString, 4)
        self.mylexer.setColor(colorKeyword, 5)
        self.mylexer.setColor(colorString, 6)
        self.mylexer.setColor(colorString, 7)
        self.mylexer.setColor(colorType, 8)
        self.mylexer.setColor(colorCommentBlock, 12)
        self.mylexer.setColor(colorString, 15)

        self.mylexer.setFont(self.italicFont, 1)
        self.mylexer.setFont(self.boldFont, 5)
        self.mylexer.setFont(self.boldFont, 8)
        self.mylexer.setFont(self.italicFont, 12)

        self.setLexer(self.mylexer)

    def lexer(self):
        return self.mylexer
Beispiel #55
0
    def createTempleteAction(self):
        if self.templeteCreateAction.isChecked() and self.basePMCheck:
            font = QFont("Arial", 13)
            font.setItalic(True)
            self.compLabel1 = QgsComposerLabel(self.scene)
            self.compLabel1.setFont(font)
            self.compLabel1.setText("South China Sea")
            self.compLabel1.setBackgroundEnabled(False)
            self.compLabel1.setItemPosition(156, 100)
            self.compLabel1.adjustSizeToText()
            self.compLabel1.setItemRotation(60)
            #             mapitem = self.scene.composerMapItems()
            #             mapitem[0].addItem(self.compLabel1)
            self.scene.addItem(self.compLabel1)

            self.compLabel2 = QgsComposerLabel(self.scene)
            self.compLabel2.setFont(font)
            self.compLabel2.setText("Straits Of Malacca")
            self.compLabel2.setBackgroundEnabled(False)
            self.compLabel2.setItemPosition(35, 100)
            self.compLabel2.adjustSizeToText()
            self.compLabel2.setItemRotation(60)
            self.scene.addItem(self.compLabel2)

            font.setItalic(False)
            self.compLabel3 = QgsComposerLabel(self.scene)
            self.compLabel3.setFont(font)
            self.compLabel3.setBackgroundEnabled(False)
            self.compLabel3.setText("THAILAND")
            self.compLabel3.setItemPosition(68, 60)
            self.compLabel3.adjustSizeToText()
            #             self.compLabel3.setItemRotation(0.5)
            self.scene.addItem(self.compLabel3)
            #             self.templeteCreateAction.setChecked(False)

            self.compLabel4 = QgsComposerLabel(self.scene)
            self.compLabel4.setFont(font)
            self.compLabel4.setBackgroundEnabled(False)
            self.compLabel4.setText("SINGAPORE")
            self.compLabel4.setItemPosition(141, 218)
            self.compLabel4.adjustSizeToText()
            #             self.compLabel3.setItemRotation(0.5)
            self.scene.addItem(self.compLabel4)
            self.templeteCreateAction.setChecked(False)
            self.compLabel4.setSelected(True)
        elif self.templeteCreateAction.isChecked(
        ) and self.basePMCheck == False:
            font = QFont("Arial", 14)
            font.setItalic(True)
            self.compLabel5 = QgsComposerLabel(self.scene)
            self.compLabel5.setFont(font)
            self.compLabel5.setText("South China Sea")
            self.compLabel5.setBackgroundEnabled(False)
            self.compLabel5.setItemPosition(108, 86)
            self.compLabel5.adjustSizeToText()
            self.compLabel5.setItemRotation(-45)
            #             mapitem = self.scene.composerMapItems()
            #             mapitem[0].addItem(self.compLabel1)
            self.scene.addItem(self.compLabel5)

            self.compLabel6 = QgsComposerLabel(self.scene)
            self.compLabel6.setFont(font)
            self.compLabel6.setText("Sulu Sea")
            self.compLabel6.setBackgroundEnabled(False)
            self.compLabel6.setItemPosition(236, 38)
            self.compLabel6.adjustSizeToText()
            self.compLabel6.setItemRotation(45)
            self.scene.addItem(self.compLabel6)

            font.setItalic(False)
            self.compLabel7 = QgsComposerLabel(self.scene)
            self.compLabel7.setFont(font)
            self.compLabel7.setBackgroundEnabled(False)
            self.compLabel7.setText("Celebes Sea")
            self.compLabel7.setItemPosition(242, 112)
            self.compLabel7.adjustSizeToText()
            self.compLabel7.setItemRotation(-45)
            #             self.compLabel3.setItemRotation(0.5)
            self.scene.addItem(self.compLabel7)
            #             self.templeteCreateAction.setChecked(False)

            self.compLabel8 = QgsComposerLabel(self.scene)
            self.compLabel8.setFont(font)
            self.compLabel8.setBackgroundEnabled(False)
            self.compLabel8.setText("INDONESIA\n(Kalimantan)")
            self.compLabel8.setItemPosition(172, 148, 32, 16)
            #             self.compLabel8.setHAlign(Qt.AlignHCenter)
            #             self.compLabel8.setVAlign(Qt.AlignVCenter)
            #             self.compLabel8.setFrameEnabled(False)
            #             self.compLabel8.setItemPosition()
            #             self.compLabel8.adjustSizeToText()
            #             self.compLabl3.setItemRotation(0.5)
            self.scene.addItem(self.compLabel8)

            self.compLabel9 = QgsComposerLabel(self.scene)
            self.compLabel9.setFont(font)
            self.compLabel9.setBackgroundEnabled(False)
            self.compLabel9.setText("BRUNEI")
            self.compLabel9.setItemPosition(136, 83)
            self.compLabel9.adjustSizeToText()
            #             self.compLabl3.setItemRotation(0.5)
            self.scene.addItem(self.compLabel9)
            self.templeteCreateAction.setChecked(False)

        pass
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Calculate Height Profile", self)
        self.runaction.triggered.connect(self.calculate_heigth_profile_ni)
        self.addAction(self.runaction)

        self.runaction = widget.OWAction("Generate Height Profile File", self)
        self.runaction.triggered.connect(self.generate_heigth_profile_file_ni)
        self.addAction(self.runaction)

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(QRect(round(geom.width() * 0.05),
                               round(geom.height() * 0.05),
                               round(min(geom.width() * 0.98, self.MAX_WIDTH)),
                               round(min(geom.height() * 0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        # DABAM INITIALIZATION
        self.server = dabam.dabam()
        self.server.set_input_silent(True)

        gui.separator(self.controlArea)

        button_box = oasysgui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Calculate Height\nProfile", callback=self.calculate_heigth_profile)
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Generate Height\nProfile File", callback=self.generate_heigth_profile_file)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(150)

        button = gui.button(button_box, self, "Reset Fields", callback=self.call_reset_settings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        gui.separator(self.controlArea)

        tabs_setting = gui.tabWidget(self.controlArea)
        tabs_setting.setFixedHeight(self.TABS_AREA_HEIGHT)
        tabs_setting.setFixedWidth(self.CONTROL_AREA_WIDTH-5)

        tab_input = oasysgui.createTabPage(tabs_setting, "DABAM Search Setting")
        tab_gener = oasysgui.createTabPage(tabs_setting, "DABAM Generation Setting")
        tab_out = oasysgui.createTabPage(tabs_setting, "Output")

        manual_box = oasysgui.widgetBox(tab_input, "Manual Entry", addSpace=True, orientation="vertical")

        oasysgui.lineEdit(manual_box, self, "entry_number", "Entry Number",
                           labelWidth=300, valueType=int, orientation="horizontal")

        gui.separator(manual_box)

        button = gui.button(manual_box, self, "Retrieve Profile", callback=self.retrieve_profile)
        button.setFixedHeight(35)
        button.setFixedWidth(self.CONTROL_AREA_WIDTH-35)

        input_box = oasysgui.widgetBox(tab_input, "Search Parameters", addSpace=True, orientation="vertical")

        gui.comboBox(input_box, self, "shape", label="Mirror Shape", labelWidth=300,
                     items=["All", "Plane", "Cylindrical", "Elliptical", "Toroidal", "Spherical"],
                     sendSelectedValue=False, orientation="horizontal")

        gui.separator(input_box)
        
        input_box_1 = oasysgui.widgetBox(input_box, "", addSpace=True, orientation="horizontal")

        oasysgui.lineEdit(input_box_1, self, "slope_error_from", "Slope Error From (" + u"\u03BC" + "rad)",
                           labelWidth=150, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(input_box_1, self, "slope_error_to", "To (" + u"\u03BC" + "rad)",
                           labelWidth=60, valueType=float, orientation="horizontal")

        input_box_2 = oasysgui.widgetBox(input_box, "", addSpace=True, orientation="horizontal")

        self.le_dimension_y_from = oasysgui.lineEdit(input_box_2, self, "dimension_y_from", "Mirror Length From",
                           labelWidth=150, valueType=float, orientation="horizontal")
        self.le_dimension_y_to = oasysgui.lineEdit(input_box_2, self, "dimension_y_to", "To",
                           labelWidth=60, valueType=float, orientation="horizontal")

        table_box = oasysgui.widgetBox(tab_input, "Search Results", addSpace=True, orientation="vertical", height=290)

        self.overlay_search = Overlay(table_box, self.search_profiles)
        self.overlay_search.hide()

        button = gui.button(input_box, self, "Search", callback=self.overlay_search.show)
        button.setFixedHeight(35)
        button.setFixedWidth(self.CONTROL_AREA_WIDTH-35)

        gui.comboBox(table_box, self, "use_undetrended", label="Use Undetrended Profile", labelWidth=300,
                     items=["No", "Yes"], callback=self.table_item_clicked, sendSelectedValue=False, orientation="horizontal")

        gui.separator(table_box)

        self.scrollarea = QScrollArea()
        self.scrollarea.setMinimumWidth(self.CONTROL_AREA_WIDTH-35)

        table_box.layout().addWidget(self.scrollarea, alignment=Qt.AlignHCenter)

        self.table = QTableWidget(1, 5)
        self.table.setAlternatingRowColors(True)
        self.table.horizontalHeader().setResizeMode(QHeaderView.Fixed)
        self.table.verticalHeader().setVisible(False)

        self.table.setColumnWidth(0, 40)
        self.table.setColumnWidth(1, 70)
        self.table.setColumnWidth(2, 70)
        self.table.setColumnWidth(3, 85)
        self.table.setColumnWidth(4, 80)

        self.table.resizeRowsToContents()
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.itemClicked.connect(self.table_item_clicked)

        self.scrollarea.setWidget(self.table)
        self.scrollarea.setWidgetResizable(1)

        output_profile_box = oasysgui.widgetBox(tab_gener, "Surface Generation Parameters", addSpace=True, orientation="vertical", height=270)

        self.le_dimension_x = oasysgui.lineEdit(output_profile_box, self, "dimension_x", "Width",
                           labelWidth=300, valueType=float, orientation="horizontal")
        self.le_step_x = oasysgui.lineEdit(output_profile_box, self, "step_x", "Step Width",
                           labelWidth=300, valueType=float, orientation="horizontal")

        gui.comboBox(output_profile_box, self, "center_y", label="Center Profile in the middle of O.E.", labelWidth=300,
                     items=["No", "Yes"], sendSelectedValue=False, orientation="horizontal")

        gui.comboBox(output_profile_box, self, "modify_y", label="Modify Length?", labelWidth=240,
                     items=["No", "Rescale to new length", "Fit to new length (fill or cut)"], callback=self.set_ModifyY, sendSelectedValue=False, orientation="horizontal")

        self.modify_box_1 = oasysgui.widgetBox(output_profile_box, "", addSpace=False, orientation="vertical", height=50)

        self.modify_box_2 = oasysgui.widgetBox(output_profile_box, "", addSpace=False, orientation="vertical", height=50)
        oasysgui.lineEdit(self.modify_box_2, self, "scale_factor_y", "Scale Factor", labelWidth=300, valueType=float, orientation="horizontal")

        self.modify_box_3 = oasysgui.widgetBox(output_profile_box, "", addSpace=False, orientation="vertical", height=50)
        self.le_new_length = oasysgui.lineEdit(self.modify_box_3, self, "new_length", "New Length", labelWidth=300, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(self.modify_box_3, self, "filler_value", "Filler Value (if new length > profile length) [nm]", labelWidth=300, valueType=float, orientation="horizontal")

        self.set_ModifyY()

        gui.comboBox(output_profile_box, self, "renormalize_y", label="Renormalize Length Profile to different RMS", labelWidth=300,
                     items=["No", "Yes"], callback=self.set_RenormalizeY, sendSelectedValue=False, orientation="horizontal")

        self.output_profile_box_1 = oasysgui.widgetBox(output_profile_box, "", addSpace=True, orientation="vertical")

        gui.comboBox(self.output_profile_box_1, self, "error_type_y", label="Normalization to", labelWidth=270,
                     items=["Figure Error (nm)", "Slope Error (" + u"\u03BC" + "rad)"],
                     sendSelectedValue=False, orientation="horizontal")

        oasysgui.lineEdit(self.output_profile_box_1, self, "rms_y", "Rms Value",
                           labelWidth=300, valueType=float, orientation="horizontal")

        self.set_RenormalizeY()

        output_box = oasysgui.widgetBox(tab_gener, "Outputs", addSpace=True, orientation="vertical")

        select_file_box = oasysgui.widgetBox(output_box, "", addSpace=True, orientation="horizontal")

        self.le_heigth_profile_file_name = oasysgui.lineEdit(select_file_box, self, "heigth_profile_file_name", "Output File Name",
                                                        labelWidth=120, valueType=str, orientation="horizontal")

        gui.button(select_file_box, self, "...", callback=self.selectFile)

        self.shadow_output = QTextEdit()
        self.shadow_output.setReadOnly(True)

        out_box = oasysgui.widgetBox(tab_out, "System Output", addSpace=True, orientation="horizontal", height=500)
        out_box.layout().addWidget(self.shadow_output)

        gui.rubber(self.controlArea)

        self.initializeTabs()

        gui.rubber(self.mainArea)

        self.overlay_search.raise_()
    def initUI(self):
        cw = QWidget()
        self.setCentralWidget(cw)
        grid = QGridLayout()
        grid.setSpacing(15)

        # status bar
        self.statusBar().showMessage('Ready')

        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(10)

        #############

        lisa_title = QLabel('Organ Segmentation with Random Walker')
        info = QLabel('Developed by:\n' +
                      'University of West Bohemia\n' +
                      'Faculty of Applied Sciences\n' +
                      QString.fromUtf8('M. Jirik, V. Lukes, T. Ryba - 2013')
                      )
        info.setFont(font_info)
        lisa_title.setFont(font_label)
        lisa_logo = QLabel()
        logopath = os.path.join(path_to_script, 'kky_small.png')
        logo = QPixmap(logopath)
        lisa_logo.setPixmap(logo)
        grid.addWidget(lisa_title, 0, 1)
        grid.addWidget(info, 1, 1)
        grid.addWidget(lisa_logo, 0, 2, 2, 1)
        grid.setColumnMinimumWidth(1, logo.width())

        ### dicom reader
        rstart = 2
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_dcm = QLabel('DICOM reader')
        text_dcm.setFont(font_label)
        btn_dcmdir = QPushButton("Load DICOM", self)
        btn_dcmdir.clicked.connect(self.loadDcmDir)
        btn_dcmcrop = QPushButton("Crop", self)
        btn_dcmcrop.clicked.connect(self.cropDcm)

        self.text_dcm_dir = QLabel('DICOM dir:')
        self.text_dcm_data = QLabel('DICOM data:')
        grid.addWidget(hr, rstart + 0, 0, 1, 4)
        grid.addWidget(text_dcm, rstart + 1, 1, 1, 2)
        grid.addWidget(btn_dcmdir, rstart + 2, 1)
        grid.addWidget(btn_dcmcrop, rstart + 2, 2)
        grid.addWidget(self.text_dcm_dir, rstart + 5, 1, 1, 2)
        grid.addWidget(self.text_dcm_data, rstart + 6, 1, 1, 2)
        rstart += 8

        # ################ segmentation
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_seg = QLabel('Segmentation')
        text_seg.setFont(font_label)
        btn_segauto = QPushButton("Automatic seg.", self)
        btn_segauto.clicked.connect(self.autoSeg)
        btn_segman = QPushButton("Manual seg.", self)
        btn_segman.clicked.connect(self.manualSeg)
        self.text_seg_data = QLabel('segmented data:')
        grid.addWidget(hr, rstart + 0, 0, 1, 4)
        grid.addWidget(text_seg, rstart + 1, 1)
        grid.addWidget(btn_segauto, rstart + 2, 1)
        grid.addWidget(btn_segman, rstart + 2, 2)
        grid.addWidget(self.text_seg_data, rstart + 3, 1, 1, 2)
        rstart += 4

        # ################ save/view
        btn_segsave = QPushButton("Save", self)
        btn_segsave.clicked.connect(self.saveOut)
        btn_segsavedcm = QPushButton("Save Dicom", self)
        btn_segsavedcm.clicked.connect(self.saveOutDcm)
        btn_segview = QPushButton("View3D", self)
        if viewer3D_available:
            btn_segview.clicked.connect(self.view3D)

        else:
            btn_segview.setEnabled(False)

        grid.addWidget(btn_segsave, rstart + 0, 1)
        grid.addWidget(btn_segview, rstart + 0, 2)
        grid.addWidget(btn_segsavedcm, rstart + 1, 1)
        rstart += 2

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        grid.addWidget(hr, rstart + 0, 0, 1, 4)

        # quit
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        grid.addWidget(btn_quit, rstart + 1, 1, 1, 2)

        cw.setLayout(grid)
        self.setWindowTitle('Organ Segmentation with Random Walker')
        self.show()