当前位置: 首页>>代码示例>>Python>>正文


Python QCheckBox.setChecked方法代码示例

本文整理汇总了Python中PySide.QtGui.QCheckBox.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.setChecked方法的具体用法?Python QCheckBox.setChecked怎么用?Python QCheckBox.setChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QCheckBox的用法示例。


在下文中一共展示了QCheckBox.setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: qLabeledCheck

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class qLabeledCheck(QWidget): 
    def __init__(self, name, arg_dict, pos = "side", max_size = 200):
        QWidget.__init__(self)
        self.setContentsMargins(1, 1, 1, 1)
        if pos == "side":
            self.layout1=QHBoxLayout()
        else:
            self.layout1 = QVBoxLayout()
        self.layout1.setContentsMargins(1, 1, 1, 1)
        self.layout1.setSpacing(1)
        self.setLayout(self.layout1)
        self.cbox = QCheckBox()
        # self.efield.setMaximumWidth(max_size)
        self.cbox.setFont(QFont('SansSerif', 12))
        self.label = QLabel(name)
        # self.label.setAlignment(Qt.AlignLeft)
        self.label.setFont(QFont('SansSerif', 12))
        self.layout1.addWidget(self.label)
        self.layout1.addWidget(self.cbox)
        self.arg_dict = arg_dict
        self.name = name
        self.mytype = type(self.arg_dict[name])
        if self.mytype != bool:
            self.cbox.setChecked(bool(self.arg_dict[name]))
        else:
            self.cbox.setChecked(self.arg_dict[name])
        self.cbox.toggled.connect(self.when_modified)
        self.when_modified()
        
    def when_modified(self):
        self.arg_dict[self.name]  = self.cbox.isChecked()
        
    def hide(self):
        QWidget.hide(self)
开发者ID:bsherin,项目名称:shared_tools,代码行数:36,代码来源:mywidgets.py

示例2: populate_fields

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
 def populate_fields(self, fields):
     for field, hidden in fields:
         item = QCheckBox(self.fieldScrollArea)
         item.setObjectName(field)
         item.setText(field)
         item.setChecked(not hidden)
         self.fieldLayout.addWidget(item)
开发者ID:jlehtoma,项目名称:MaeBird,代码行数:9,代码来源:dialogs.py

示例3: __init__

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
 def __init__(self, *args, **kwargs ):
     QWidget.__init__( self, *args, **kwargs )
     
     mainLayout = QHBoxLayout( self )
     mainLayout.setContentsMargins(0,0,0,0)
     label = QLabel( "Aim Direction  : " )
     lineEdit1 = QLineEdit()
     lineEdit2 = QLineEdit()
     lineEdit3 = QLineEdit()
     verticalSeparator = Widget_verticalSeparator()
     checkBox = QCheckBox( "Set Auto" )
     mainLayout.addWidget( label )
     mainLayout.addWidget( lineEdit1 )
     mainLayout.addWidget( lineEdit2 )
     mainLayout.addWidget( lineEdit3 )
     mainLayout.addWidget( verticalSeparator )
     mainLayout.addWidget( checkBox )
     
     validator = QDoubleValidator( -10000.0, 10000.0, 2 )
     lineEdit1.setValidator( validator )
     lineEdit2.setValidator( validator )
     lineEdit3.setValidator( validator )
     lineEdit1.setText( "0.0" )
     lineEdit2.setText( "1.0" )
     lineEdit3.setText( "0.0" )
     checkBox.setChecked( True )
     self.label = label; self.lineEdit1 = lineEdit1; 
     self.lineEdit2 = lineEdit2; self.lineEdit3 = lineEdit3; self.checkBox = checkBox
     self.setVectorEnabled()
     
     
     QtCore.QObject.connect( checkBox, QtCore.SIGNAL( 'clicked()' ), self.setVectorEnabled )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:34,代码来源:tangentConstraintByGroup.py

示例4: testSignalMapper

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
    def testSignalMapper(self):
        checkboxMapper = QSignalMapper()
        box = QCheckBox('check me')
        box.stateChanged.connect(checkboxMapper.map)

        checkboxMapper.setMapping(box, box.text())
        checkboxMapper.mapped[str].connect(self.cb_changed)
        self._changed = False
        box.setChecked(True)
        self.assert_(self._changed)
开发者ID:Hasimir,项目名称:PySide,代码行数:12,代码来源:bug_860.py

示例5: EditPreferencesDlg

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class EditPreferencesDlg(QDialog):
	
	def __init__(self, parent=None):
		super(EditPreferencesDlg, self).__init__(parent)
		self.setWindowTitle("Preferences")
		# define widgets
		pref_list = QListWidget()
		pref_list.addItem("General")
		pref_list.addItem("Display")
		pref_list.setMaximumWidth(150)
		pref_list.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
		
		button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
		
		general_page = QWidget()
		general_layout = QGridLayout()
		general_layout.setAlignment(Qt.AlignTop)
		general_layout.addWidget(QLabel("<b>General</b>"), 0, 0)
		general_page.setLayout(general_layout)
		
		display_page = QWidget()
		display_layout = QGridLayout()
		display_layout.setAlignment(Qt.AlignTop)
		display_layout.addWidget(QLabel("<b>Display Options</b>"), 0, 0)
		self.multitabs_checkbox = QCheckBox("Limit the display of tabs to one relief device (and the device's scenarios) at a time")
		if parent.limit_tabs is True:
			self.multitabs_checkbox.setChecked(True)
		display_layout.addWidget(self.multitabs_checkbox, 1, 0)
		display_page.setLayout(display_layout)

		stacked_widget = QStackedWidget()
		for page in general_page, display_page:
			stacked_widget.addWidget(page)
		
		main_layout = QVBoxLayout()
		widgets_layout = QHBoxLayout()
		widgets_layout.addWidget(pref_list)
		widgets_layout.addWidget(stacked_widget)
		buttons_layout = QHBoxLayout()
		buttons_layout.addStretch()
		buttons_layout.addWidget(button_box)
		main_layout.addLayout(widgets_layout)
		main_layout.addLayout(buttons_layout)
		self.setLayout(main_layout)
		
		pref_list.currentRowChanged.connect(stacked_widget.setCurrentIndex)
		
		button_box.accepted.connect(self.accept)
		button_box.rejected.connect(self.reject)
		
	def sizeHint(self):
		return QSize(400, 400)
		
	def returnVals(self):
		return self.multitabs_checkbox.isChecked()
开发者ID:nb1987,项目名称:rvac,代码行数:57,代码来源:dlg_classes.py

示例6: CheckinConfirmation

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class CheckinConfirmation(QDialog):
    def __init__(self, parent, venue):
        super(CheckinConfirmation, self).__init__(parent)
        self.setWindowTitle("Checkin")
        self.centralWidget = QWidget()

        #Main Layout
        layout = QGridLayout()
        #layout.setSpacing(0)
        self.setLayout(layout)


        text = "You're checking in @<b>" + venue['name'] + "</b>"
        if 'address' in venue['location']:
            text += ", " + venue['location']['address']
        text += "."
        textLabel = QLabel(text, self)
        textLabel.setWordWrap(True)

        okButton = QPushButton("Ok")
        self.connect(okButton, SIGNAL("clicked()"), self.accept)
        cancelButton = QPushButton("Cancel")
        self.connect(cancelButton, SIGNAL("clicked()"), self.reject)

        # TODO: make this a separate widget
        #----
        self.tw = QCheckBox("Twitter")
        self.fb = QCheckBox("Facebook")

        broadcast = foursquare.config_get("broadcast")
        if broadcast:
            if not ", " in broadcast:
                self.tw.setChecked("twitter" in broadcast)
                self.fb.setChecked("facebook" in broadcast)
        #----

        layout.addWidget(textLabel, 0, 0, 1, 3)
        layout.addWidget(self.tw, 1, 0)
        layout.addWidget(self.fb, 1, 1)
        layout.addWidget(okButton, 1, 2)
        #layout.addWidget(cancelButton, 1, 1)

    def broadcast(self):
        broadcast = "public"
        if self.tw.isChecked():
            broadcast += ",twitter"
        if self.fb.isChecked():
            broadcast += ",facebook"
开发者ID:Mad-Halfling,项目名称:ubersquare,代码行数:50,代码来源:checkins.py

示例7: addLine

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
 def addLine(self):
     
     baseLayout = self.currentWidget().children()[0]
     
     lineLayout = QHBoxLayout()
     lineLayout.setContentsMargins(1,1,1,1)
     checkBox = QCheckBox(); checkBox.setChecked(True); checkBox.setContentsMargins(1,1,1,1)
     lineEdit = QLineEdit(); lineEdit.setContentsMargins(1,1,1,1)
     lineEdit.installEventFilter( self.lineEditEventFilter )
     button = QPushButton( " - " ); button.setContentsMargins(1,1,1,1)
     lineLayout.addWidget( checkBox )
     lineLayout.addWidget( lineEdit )
     lineLayout.addWidget( button )
     baseLayout.insertLayout( baseLayout.count()-2, lineLayout )
     
     QtCore.QObject.connect( button, QtCore.SIGNAL( "clicked()" ), partial( self.removeLine, lineLayout ) )
     self.lineLayouts.append( lineLayout )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:19,代码来源:createRenderLayer.py

示例8: _ChannelsResultOptionsToolItem

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class _ChannelsResultOptionsToolItem(_ResultToolItem):
    def _initUI(self):
        # Widgets
        self._chk_errorbar = QCheckBox("Show error bars")
        self._chk_errorbar.setChecked(True)

        # Layouts
        layout = _ResultToolItem._initUI(self)
        layout.addRow(self._chk_errorbar)

        # Signals
        self._chk_errorbar.stateChanged.connect(self.stateChanged)

        return layout

    def showErrorbar(self):
        return self._chk_errorbar.isChecked()
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:19,代码来源:result.py

示例9: _PhotonSpectrumResultOptionsToolItem

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class _PhotonSpectrumResultOptionsToolItem(_ResultToolItem):
    def _initUI(self):
        # Widgets
        self._chk_total = QCheckBox("Show total intensity")
        self._chk_total.setChecked(True)

        self._chk_background = QCheckBox("Show background intensity")
        self._chk_background.setChecked(False)

        self._chk_errorbar = QCheckBox("Show error bars")
        self._chk_errorbar.setChecked(True)

        # Layouts
        layout = _ResultToolItem._initUI(self)
        layout.addRow(self._chk_total)
        layout.addRow(self._chk_background)
        layout.addRow(self._chk_errorbar)

        # Signals
        self._chk_total.stateChanged.connect(self.stateChanged)
        self._chk_background.stateChanged.connect(self.stateChanged)
        self._chk_errorbar.stateChanged.connect(self.stateChanged)

        return layout

    def isTotal(self):
        return self._chk_total.isChecked()

    def isBackground(self):
        return self._chk_background.isChecked()

    def isErrorbar(self):
        return self._chk_errorbar.isChecked()
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:35,代码来源:result.py

示例10: TrajectoryDetectorWidget

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class TrajectoryDetectorWidget(_DetectorWidget):

    def __init__(self, parent=None):
        _DetectorWidget.__init__(self, parent)
        self.setAccessibleName("Trajectory")

    def _initUI(self):
        # Widgets
        self._chk_secondary = QCheckBox("Simulation secondary electrons")
        self._chk_secondary.setChecked(True)

        # Layouts
        layout = _DetectorWidget._initUI(self)
        layout.addRow(self._chk_secondary)

        return layout

    def value(self):
        secondary = self._chk_secondary.isChecked()
        return TrajectoryDetector(secondary)

    def setValue(self, value):
        self._chk_secondary.setChecked(value.secondary)
开发者ID:pymontecarlo,项目名称:pymontecarlo-gui,代码行数:25,代码来源:detector.py

示例11: __loadUsers

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
    def __loadUsers(self):
        """Loads user's data from DB"""
        users = self.parentWidget().app.getUsers()
        self.user_table.clearContents()
        self.user_table.setRowCount(len(users))
        for i in range(len(users)):
            username_item = QTableWidgetItem(users[i].username)
            username_item.setFlags(username_item.flags() ^ Qt.ItemIsEditable)

            blocked_checkbox = QCheckBox()
            if users[i].blocked:
                blocked_checkbox.setChecked(True)

            def create_blocked_toggle(checkbox, user):
                def blocked_toggle():
                    user.blocked = (1 if checkbox.isChecked() else 0)
                    self.parentWidget().app.updateUser(user)
                    self.__loadUsers()
                return blocked_toggle
            blocked_checkbox.toggled.connect(create_blocked_toggle(blocked_checkbox, users[i]))

            password_restrict_checkbox = QCheckBox()
            if users[i].restrictions:
                password_restrict_checkbox.setChecked(True)

            def create_password_restrict_toggle(checkbox, user):
                def password_restrict_toggle():
                    user.restrictions = (1 if checkbox.isChecked() else 0)
                    self.parentWidget().app.updateUser(user)
                    self.__loadUsers()
                return password_restrict_toggle
            password_restrict_checkbox.toggled.connect(
                create_password_restrict_toggle(password_restrict_checkbox, users[i]))

            self.user_table.setItem(i, 0, username_item)
            self.user_table.setCellWidget(i, 1, blocked_checkbox)
            self.user_table.setCellWidget(i, 2, password_restrict_checkbox)
开发者ID:oleksiyivanenko,项目名称:pyAuth,代码行数:39,代码来源:pyAuth.py

示例12: ConfigDialog

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class ConfigDialog(QtGui.QDialog):

    pressedclosebutton = False
    moreToggling = False

    def moreToggled(self):
        if self.moreToggling == False:
            self.moreToggling = True

            if self.showmoreCheckbox.isChecked() and self.showmoreCheckbox.isVisible():
                self.showmoreCheckbox.setChecked(False)
                self.moreSettingsGroup.setChecked(True)
                self.moreSettingsGroup.show()
                self.showmoreCheckbox.hide()
                self.saveMoreState(True)
            else:
                self.moreSettingsGroup.setChecked(False)
                self.moreSettingsGroup.hide()
                self.showmoreCheckbox.show()
                self.saveMoreState(False)

            self.moreToggling = False
            self.adjustSize()
            self.setFixedSize(self.sizeHint())

    def runButtonTextUpdate(self):
        if (self.donotstoreCheckbox.isChecked()):
            self.runButton.setText(getMessage("en", "run-label"))
        else:
            self.runButton.setText(getMessage("en", "storeandrun-label"))

    def openHelp(self):
        self.QtGui.QDesktopServices.openUrl("http://syncplay.pl/guide/client/")

    def _tryToFillPlayerPath(self, playerpath, playerpathlist):
        settings = QSettings("Syncplay", "PlayerList")
        settings.beginGroup("PlayerList")
        savedPlayers = settings.value("PlayerList", [])
        if(not isinstance(savedPlayers, list)):
            savedPlayers = []
        playerpathlist = list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist + savedPlayers)))
        settings.endGroup()
        foundpath = ""

        if playerpath != None and playerpath != "":
            if not os.path.isfile(playerpath):
                expandedpath = PlayerFactory().getExpandedPlayerPathByPath(playerpath)
                if expandedpath != None and os.path.isfile(expandedpath):
                    playerpath = expandedpath

            if os.path.isfile(playerpath):
                foundpath = playerpath
                self.executablepathCombobox.addItem(foundpath)

        for path in playerpathlist:
            if(os.path.isfile(path) and os.path.normcase(os.path.normpath(path)) != os.path.normcase(os.path.normpath(foundpath))):
                self.executablepathCombobox.addItem(path)
                if foundpath == "":
                    foundpath = path

        if foundpath != "":
            settings.beginGroup("PlayerList")
            playerpathlist.append(os.path.normcase(os.path.normpath(foundpath)))
            settings.setValue("PlayerList", list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist))))
            settings.endGroup()
        return(foundpath)

    def updateExecutableIcon(self):
        currentplayerpath = unicode(self.executablepathCombobox.currentText())
        iconpath = PlayerFactory().getPlayerIconByPath(currentplayerpath)
        if iconpath != None and iconpath != "":
            self.executableiconImage.load(self.resourcespath + iconpath)
            self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(self.executableiconImage))
        else:
            self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage()))


    def browsePlayerpath(self):
        options = QtGui.QFileDialog.Options()
        defaultdirectory = ""
        browserfilter = "All files (*)"

        if os.name == 'nt':
            browserfilter = "Executable files (*.exe);;All files (*)"
            if "PROGRAMFILES(X86)" in os.environ:
                defaultdirectory = os.environ["ProgramFiles(x86)"]
            elif "PROGRAMFILES" in os.environ:
                defaultdirectory = os.environ["ProgramFiles"]
            elif "PROGRAMW6432" in os.environ:
                defaultdirectory = os.environ["ProgramW6432"]
        elif sys.platform.startswith('linux'):
            defaultdirectory = "/usr/bin"

        fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,
                "Browse for media player executable",
                defaultdirectory,
                browserfilter, "", options)
        if fileName:
            self.executablepathCombobox.setEditText(os.path.normpath(fileName))

#.........这里部分代码省略.........
开发者ID:DerGenaue,项目名称:syncplay,代码行数:103,代码来源:GuiConfiguration.py

示例13: testSimpleSignal

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
 def testSimpleSignal(self):
     box = QCheckBox('check me')
     box.stateChanged[int].connect(self.cb_changedVoid)
     self._changed = False
     box.setChecked(True)
     self.assert_(self._changed)
开发者ID:Hasimir,项目名称:PySide,代码行数:8,代码来源:bug_860.py

示例14: Layer

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]
class Layer(object):

    def __init__(self):
        super(Layer, self).__init__()
        self.orientation = Quaternion()
        self.picked = None
        self.show = QCheckBox()
        self.show.setChecked(True)
        self.alpha_slider = QSlider(QtCore.Qt.Orientation.Horizontal)
        self.alpha_slider.setRange(0, 1024)
        self.alpha_slider.setValue(1024)
        self.alpha_number = QDoubleSpinBox()
        self.alpha_number.setDecimals(3)
        self.alpha_number.setSingleStep(0.01)
        self.alpha_number.setRange(0, 1)
        self.alpha_number.setValue(1)
        self.alpha_slider.valueChanged.connect(self._alphaSliderChanged)
        self.alpha_number.valueChanged.connect(self._alphaNumberChanged)
        self.move = QCheckBox()
        self.move.setChecked(True)
        self.quat = QLineEdit()
        font = QFont('monospace')
        font.setStyleHint(QFont.TypeWriter)
        self.quat.setFont(font)
        default_quat = '+0.000, +1.000, +0.000, +0.000'
        margins = self.quat.textMargins()
        self.quat.setFixedWidth(
            # HACK -------------------------------------------v
            QFontMetrics(self.quat.font()).width(default_quat + '  ') +
            margins.left() + margins.right()
        )
        self.quat.setInputMask('#0.000, #0.000, #0.000, #0.000')
        self.quat.setMaxLength(30)
        self.quat.setText(default_quat)
        self.quat.editingFinished.connect(self._orientationChanged)
        self.nbytes = QLabel()
        self.nbytes.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.nbytes.setText('0')
        self.label = QLabel()
        self.label.setText('<empty>')

    def multiplyOrientation(self, quat):
        self.setOrientation(quat * self.orientation)

    def setOrientation(self, quat):
        self.orientation = quat
        self.quat.setText(
            '%+1.3f, %+1.3f, %+1.3f, %+1.3f' % (
                self.orientation.w,
                self.orientation.x,
                self.orientation.y,
                self.orientation.z,
            )
        )

    def _orientationChanged(self):
        text = self.quat.text()

    def alpha(self):
        return self.alpha_number.value() if self.show.isChecked() else 0.0

    def _alphaSliderChanged(self):
        self.alpha_number.setValue(self.alpha_slider.value() / 1024.0)

    def _alphaNumberChanged(self):
        self.alpha_slider.setValue(1024 * self.alpha_number.value())

    def setup_ui(self, table, row):
        widgets = [
            None,
            CenterH(self.show),
            self.alpha_slider,
            self.alpha_number,
            CenterH(self.move),
            self.quat,
            self.nbytes,
            self.label,
        ]
        for (column, widget) in enumerate(widgets):
            if widget is not None:
                table.setCellWidget(row, column, widget)

    def load_file(self, file_name, in_format):
        self.sphere = proj.load_sphere(file_name, projection=in_format)
        in_format = self.sphere.__class__
        print('Loaded input %s from %s.' % (in_format.__name__, file_name))
        self.texture_id = glGenTextures(1)
        self.sphere.to_gl(self.texture_id)
        self.shader = Shader(
            vert=VERTEX_SHADER,
            frag=FRAGMENT_SHADER + self.sphere.get_glsl_sampler(),
        )
        self.label.setText(file_name)
        self.nbytes.setText(read_bsize(self.sphere.array.nbytes))
开发者ID:mkovacs,项目名称:sphaira,代码行数:96,代码来源:layer.py

示例15: LoginView

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setChecked [as 别名]

#.........这里部分代码省略.........
        fieldsLayout.addStretch(30)
        
        buttonLayout.addStretch(50)
        buttonLayout.addWidget(self.loginButton, 50, Qt.AlignRight)
        
        fieldsLayout.addLayout(buttonLayout)
        fieldsLayout.addStretch(20)
        
        mainLayout.addLayout(fieldsLayout, 30)
        mainLayout.addStretch(20)
        
        self.setLayout(mainLayout)
        
    def createWidgets(self):
        """Create children widgets needed by this view"""

        fieldsWidth = 200
        labelsFont = View.labelsFont()
        editsFont = View.editsFont()
        self.setLogo()
        
        self.hostLabel = QLabel(self)
        self.hostEdit = QLineEdit(self)
        self.sslLabel = QLabel(self)
        self.sslCheck = QCheckBox(self)     
        self.hostLabel.setText('FTP Location')
        self.hostLabel.setFont(labelsFont)
        self.hostEdit.setFixedWidth(fieldsWidth)
        self.hostEdit.setFont(editsFont)
        self.sslLabel.setText('SSL')
        self.sslLabel.setFont(labelsFont)
        
        self.usernameLabel = QLabel(self)
        self.usernameEdit = QLineEdit(self)
        self.usernameLabel.setText('Username')
        self.usernameLabel.setFont(labelsFont)
        self.usernameEdit.setFixedWidth(fieldsWidth)
        self.usernameEdit.setFont(editsFont)
        
        self.passwdLabel = QLabel(self)
        self.passwdEdit = QLineEdit(self)
        self.passwdLabel.setText('Password')
        self.passwdLabel.setFont(labelsFont)
        self.passwdEdit.setFixedWidth(fieldsWidth)
        self.passwdEdit.setEchoMode(QLineEdit.Password)
        self.passwdEdit.setFont(editsFont)
        self.passwdEdit.returnPressed.connect(self.onLoginClicked)
        
        self.loginButton = QPushButton(self)
        self.loginButton.setText('Login')
        self.loginButton.setFont(labelsFont)
        self.loginButton.setFixedWidth(fieldsWidth / 2)
        self.loginButton.clicked.connect(self.onLoginClicked)
        
        # Sets previously stored values into the fields, if any
        settings = get_settings()
        
        self.hostEdit.setText(settings.value(SettingsKeys['host'], ''))
        self.usernameEdit.setText(settings.value(SettingsKeys['username'], ''))
        self.passwdEdit.setText(crypt.decrypt(settings.value(SettingsKeys['passwd'], '')))
        
        # Unicode to boolean conversion
        ssl = settings.value(SettingsKeys['ssl'], u'true') 
        ssl = True if ssl == u'true' else False
        self.sslCheck.setChecked(ssl)
        
    @Slot() 
    def onLoginClicked(self):
        """
        Slot. Called on the user clicks on the `loginButton` button
        """
        # Takes out the user input from the fields
        host = self.hostEdit.text()
        username = self.usernameEdit.text()
        passwd = self.passwdEdit.text()
        ssl = self.sslCheck.isChecked()
        
        print 'Logging in: %s, %s, %s' % (host, username, '*' * len(passwd))
        
        if len(host) > 0:
            # If the fields are valid, store them using a `QSettings` object
            # and triggers a log in request
            settings = get_settings()
            
            settings.setValue(SettingsKeys['host'], host)
            settings.setValue(SettingsKeys['username'], username)
            settings.setValue(SettingsKeys['passwd'], crypt.encrypt(passwd))
            settings.setValue(SettingsKeys['ssl'], ssl)
            
            self.setEnabled(False)
            self.login.emit(host.strip(), username, passwd, ssl)
            
    @Slot()
    def onFailedLogIn(self):
        """
        Slot. Called when the log in request fails
        """
        
        # Enables the fields again for user input
        self.setEnabled(True)
开发者ID:ShareByLink,项目名称:iqbox-ftp,代码行数:104,代码来源:views.py


注:本文中的PySide.QtGui.QCheckBox.setChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。