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


Python Dialog.addWidget方法代码示例

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


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

示例1: __init__

# 需要导入模块: from yali.gui.YaliDialog import Dialog [as 别名]
# 或者: from yali.gui.YaliDialog.Dialog import addWidget [as 别名]
class ShrinkEditor:
    def __init__(self, parent, storage):
        self.storage = storage
        self.intf = parent.intf
        self.parent = parent
        self.dialog = Dialog(_("Partitions to Shrink"), closeButton=False)
        self.dialog.addWidget(ShrinkWidget(self))
        self.dialog.resize(QSize(0,0))

    def run(self):
        if self.dialog is None:
            return []

        while 1:
            rc = self.dialog.exec_()
            operations = []

            if not rc:
                self.destroy()
                return (rc, operations)

            widget = self.dialog.content

            request = widget.partitions.itemData(widget.partitions.currentIndex()).toPyObject()
            newsize = widget.sizeSpin.value()

            try:
                operations.append(OperationResizeFormat(request, newsize))
            except ValueError as e:
                self.intf.messageWindow(_("Resize FileSystem Error"),
                                        _("%(device)s: %(msg)s") %
                                        {'device': request.format.device, 'msg': e.message},
                                        type="error")
                continue

            try:
                operations.append(OperationResizeDevice(request, newsize))
            except ValueError as e:
                self.intf.messageWindow(_("Resize Device Error"),
                                              _("%(name)s: %(msg)s") %
                                               {'name': request.name, 'msg': e.message},
                                               type="warning")
                continue

            # everything ok, fall out of loop
            break

        self.dialog.destroy()

        return (rc, operations)

    def destroy(self):
        if self.dialog:
            self.dialog = None
开发者ID:Pardus-Linux,项目名称:yali,代码行数:56,代码来源:shrink_gui.py

示例2: __init__

# 需要导入模块: from yali.gui.YaliDialog import Dialog [as 别名]
# 或者: from yali.gui.YaliDialog.Dialog import addWidget [as 别名]
class LogicalVolumeEditor:
    def __init__(self, parent, request, isNew=False):
        self.parent = parent
        self.storage = parent.parent.storage
        self.intf = parent.parent.intf
        self.origrequest = request
        self.isNew = isNew

        if isNew:
            title = _("Make Logical Volume")
        else:
            title = _("Edit Logical Volume: %s") % request.lvname

        self.dialog = Dialog(title, closeButton=False)
        self.dialog.addWidget(LogicalVolumeWidget(self, request, isNew))
        self.dialog.resize(QSize(0, 0))

    def run(self):
        if self.dialog is None:
            return None

        while 1:
            rc = self.dialog.exec_()

            if not rc:
                if self.isNew:
                    if self.parent.parent.lvs.has_key(self.origrequest.lvname):
                        del self.parent.parent.lvs[self.origrequest.lvname]
                self.destroy()
                return None

            format = None
            widget = self.dialog.content

            format = self.origrequest.format

            mountpoint = unicode(widget.mountpointMenu.currentText())
            if mountpoint and widget.mountpointMenu.isEditable():
                msg = sanityCheckMountPoint(mountpoint)
                if msg:
                    self.intf.messageWindow(_("Mount Point Error"), msg,
                                            type="error")
                    continue

            if not self.origrequest.exists:
                format_type = str(widget.filesystemMenu.currentText())
            else:
                format_type = str(widget.formatCombo.currentText())

            format_class = formats.getFormat(format_type)
            if mountpoint and format_class.mountable:
                used = False

                current_mountpoint = getattr(format, "mountpoint", None)

                for lv in self.parent.parent.lvs.values():
                    format = lv["format"]
                    if not format.mountable or current_mountpoint and \
                        format.mountpoint == current_mountpoint:
                        continue

                    if format.mountpoint == mountpoint:
                        used = True
                        break

                for (mp, dev) in self.parent.parent.storage.mountpoints.iteritems():
                    if (dev.type != "lvmlv" or dev.vg.id != self.origrequest.vg.id) and mp == mountpoint:
                        used = True
                        break

                if used:
                    self.intf.messageWindow(_("Mount point in use"),
                                            _("The mount point \"%s\" is in "
                                              "use. Please pick another.") %
                                            (mountpoint,),
                                            type="warning")
                    continue


            name = str(widget.name.text())
            if not self.origrequest.exists:
                msg = sanityCheckLogicalVolumeName(name)
                if msg:
                    self.intf.messageWindow(_("Illegal Logical Volume Name"),
                                            msg, type="warning")
                    continue

            # check that the name is not already in use
            used = 0
            for lv in self.parent.parent.lvs.values():
                if self.origrequest.lvname != name and lv['name'] == name:
                    used = 1
                    break

            if used:
                self.intf.messageWindow(_("Illegal logical volume name"),
                                        _("The logical volume name \"%s\" is "
                                          "already in use. Please pick another.")
                                        % (name,), type="warning")
                continue
#.........这里部分代码省略.........
开发者ID:hrngultekin,项目名称:yali-family,代码行数:103,代码来源:lvm_gui.py

示例3: LVMEditor

# 需要导入模块: from yali.gui.YaliDialog import Dialog [as 别名]
# 或者: from yali.gui.YaliDialog.Dialog import addWidget [as 别名]
class LVMEditor(object):
    def __init__(self, parent, request, isNew=False):
        self.parent = parent
        self.storage = parent.storage
        self.origrequest = request
        self.peSize = request.peSize
        self.pvs = request.pvs[:]
        self.isNew = isNew
        self.intf = parent.intf
        self.operations = []
        self.dialog = None
        self.lvs = {}

        for lv in self.origrequest.lvs:
            self.lvs[lv.lvname] = {"name": lv.lvname,
                                   "size": lv.size,
                                   "format": copy.copy(lv.format),
                                   "originalFormat": lv.originalFormat,
                                   "stripes": lv.stripes,
                                   "logSize": lv.logSize,
                                   "snapshotSpace": lv.snapshotSpace,
                                   "exists": lv.exists}

        self.availlvmparts = self.storage.unusedPVS(vg=request)
        # if no PV exist, raise an error message and return
        if len(self.availlvmparts) < 1:
            self.intf.messageWindow(_("Not enough physical volumes"),
                                    _("At least one unused physical "
                                      "volume partition is "
                                      "needed to\ncreate an LVM Volume Group.\n"
                                      "Create a partition or RAID array "
                                      "of type \"physical volume\n(LVM)\" and then "
                                      "select the \"LVM\" option again."),
                                    type="warning")
            self.dialog = None
            return

        if isNew:
            title = _("Make LVM Volume Group")
        else:
            try:
                title = _("Edit LVM Volume Group: %s") % (request.name,)
            except AttributeError:
                title = _("Edit LVM Volume Group")

        self.dialog = Dialog(title, closeButton=False)
        self.dialog.addWidget(VolumeGroupWidget(self, self.origrequest, isNew=isNew))
        self.dialog.resize(QSize(450, 200))

    def run(self):
        if self.dialog is None:
            return []

        while 1:
            rc = self.dialog.exec_()
            operations = []
            if not rc:
                if self.isNew:
                    if self.lvs.has_key(self.origrequest.name):
                        del self.lvs[self.origrequest.name]
                self.destroy()
                return []

            widget = self.dialog.content

            name =  str(widget.name.text())
            pvs = widget.selectedPhysicalVolumes
            msg = sanityCheckVolumeGroupName(name)
            if msg:
                self.intf.messageWindow(_("Invalid Volume Group Name"),
                                        msg, type="warning")
                continue

            origname = self.origrequest.name
            if origname != name:
                if name in [vg.name for vg in self.storage.vgs]:
                    self.intf.messageWindow(_("Name in use"),
                                            _("The volume group name \"%s\" is "
                                              "already in use. Please pick another.")
                                              % (name,), type="warning")
                    continue

            peSize = int(widget.physicalExtends.itemData(widget.physicalExtends.currentIndex())) / 1024.0
            
            origlvs = self.origrequest.lvs
            if not self.origrequest.exists:
                ctx.logger.debug("non-existing vg -- setting up lvs, pvs, name, peSize")
                for lv in self.origrequest.lvs:
                    self.origrequest._removeLogicalVolume(lv)

                for pv in self.origrequest.pvs:
                    if pv not in self.pvs:
                        self.origrequest._removePhysicalVolume(pv)

                for pv in self.pvs:
                    if pv not in self.origrequest.pvs:
                        self.origrequest._addPhysicalVolume(pv)

                self.origrequest.name = name
                self.origrequest.peSize = peSize
#.........这里部分代码省略.........
开发者ID:hrngultekin,项目名称:yali-family,代码行数:103,代码来源:lvm_gui.py

示例4: __init__

# 需要导入模块: from yali.gui.YaliDialog import Dialog [as 别名]
# 或者: from yali.gui.YaliDialog.Dialog import addWidget [as 别名]
class PartitionEditor:
    def __init__(self, parent, origrequest, isNew=False, partedPartition=None, restricts=None):
        self.storage = parent.storage
        self.intf = parent.intf
        self.origrequest = origrequest
        self.isNew = isNew
        self.parent = parent
        self.partedPartition = partedPartition

        if isNew:
            title = _("Create Partition on %(path)s (%(model)s)") %  {"path":os.path.basename(partedPartition.disk.device.path),
                                                                      "model":partedPartition.disk.device.model}
        else:
            try:
                title = _("Edit Partition %s") % origrequest.path
            except:
                title = _("Edit Partition")

        self.dialog = Dialog(title, closeButton=False)
        self.dialog.addWidget(PartitionWidget(self, origrequest, isNew, restricts))
        self.dialog.resize(QSize(350, 175))

    def run(self):
        if self.dialog is None:
            return []

        while 1:
            rc = self.dialog.exec_()
            operations = []

            if not rc:
                self.destroy()
                return []

            widget = self.dialog.content

            mountpoint = unicode(widget.mountpointMenu.currentText())
            active = widget.mountpointMenu.isEnabled()
            if active and mountpoint:
                msg = sanityCheckMountPoint(mountpoint)
                if msg:
                    ctx.interface.messageWindow(_("Mount Point Error"), msg,
                                                type="warning")
                    continue

                used = False
                for (mp, dev) in self.storage.mountpoints.iteritems():
                    if mp == mountpoint and \
                       dev.id != self.origrequest.id and \
                       not (self.origrequest.format.type == "luks" and
                            self.origrequest in dev.parents):
                        used = True
                        break

                if used:
                    ctx.interface.messageWindow(_("Mount point in use"),
                                                _("The mount point \"%s\" is in "
                                                  "use. Please pick another.") %
                                                (mountpoint,),
                                                type="warning")
                    continue

            if not self.origrequest.exists:
                if widget.primaryCheck.isChecked():
                    primary = True
                else:
                    primary = None

                size = widget.sizeSpin.value()

                formatType = str(widget.filesystemMenu.currentText())
                format = formats.getFormat(formatType, mountpoint=mountpoint)
                if self.isNew:
                    disk = self.storage.devicetree.getDeviceByPath(self.partedPartition.disk.device.path)
                else:
                    disk = self.origrequest.disk

                err = doUIRAIDLVMChecks(format, [disk.name], self.storage)
                if err:
                    self.intf.messageWindow(_("Error With Request"),
                                            err, type="error")
                    continue

                weight = partitioning.weight(mountpoint=mountpoint, fstype=format.type)

                if self.isNew:
                    request = self.storage.newPartition(size=size,
                                                        grow=None,
                                                        maxsize=0,
                                                        primary=primary,
                                                        format=format,
                                                        parents=disk)
                else:
                    request = self.origrequest
                    request.weight = weight

                usedev = request

                if self.isNew:
                    operations.append(OperationCreateDevice(request))
#.........这里部分代码省略.........
开发者ID:hrngultekin,项目名称:yali-family,代码行数:103,代码来源:partition_gui.py

示例5: Widget

# 需要导入模块: from yali.gui.YaliDialog import Dialog [as 别名]
# 或者: from yali.gui.YaliDialog.Dialog import addWidget [as 别名]

#.........这里部分代码省略.........
    def slotMenu(self, action):
        if action == self.shutDownAction:
            reply = QuestionDialog(_("Warning"),
                                   _("Are you sure you want to shut down your computer now?"))
            if reply == "yes":
                yali.util.shutdown()
        elif action == self.rebootAction:
            reply = QuestionDialog(_("Warning"),
                                   _("Are you sure you want to restart your computer now?"))
            if reply == "yes":
                yali.util.reboot()
        else:
            reply = QuestionDialog(_("Warning"),
                                   _("Are you sure you want to restart the YALI installer now?"))
            if reply == "yes":
                os.execv("/usr/bin/yali-bin", sys.argv)

    def toggleTheme(self):
        if self._style == ctx.consts.stylesheet:
            self._style = ctx.consts.alternatestylesheet
        else:
            self._style = ctx.consts.stylesheet
        self.updateStyle()

    def toggleConsole(self):
        if not self.terminal:
            self.terminal = Dialog(_("Terminal"), self._terminal, self, True, QtGui.QKeySequence(Qt.Key_F11))
            self.terminal.resize(700,500)
        self.terminal.exec_()

    def toggleTetris(self):
        self.tetris = Dialog(_("Tetris"), None, self, True, QtGui.QKeySequence(Qt.Key_F6))
        _tetris = Tetris(self.tetris)
        self.tetris.addWidget(_tetris)
        self.tetris.resize(240,500)
        _tetris.start()
        self.tetris.exec_()

    def toggleCursor(self):
        if self.cursor().shape() == QtGui.QCursor(Qt.ArrowCursor).shape():
            raw = QtGui.QPixmap(":/gui/pics/pardusman-icon.png")
            raw.setMask(raw.mask())
            self.setCursor(QtGui.QCursor(raw,2,2))
        else:
            self.unsetCursor()

    # show/hide help text
    def slotToggleHelp(self):
        self.ui.helpContentFrame.setFixedHeight(self.ui.helpContent.height())
        if self.ui.helpContentFrame.isVisible():
            self.ui.helpContentFrame.hide()
        else:
            self.ui.helpContentFrame.show()
        _w = self.ui.mainStack.currentWidget()
        _w.update()

    # show/hide debug window
    def toggleDebug(self):
        if ctx.debugger.isVisible():
            ctx.debugger.hideWindow()
        else:
            ctx.debugger.showWindow()

    # returns the id of current stack
    def getCurrent(self, d):
        new   = self.ui.mainStack.currentIndex() + d
开发者ID:Tayyib,项目名称:uludag,代码行数:70,代码来源:YaliWindow.py

示例6: RaidEditor

# 需要导入模块: from yali.gui.YaliDialog import Dialog [as 别名]
# 或者: from yali.gui.YaliDialog.Dialog import addWidget [as 别名]
class RaidEditor(object):
    def __init__(self, parent, request, isNew=False):
        self.parent = parent
        self.storage = parent.storage
        self.intf = parent.intf
        self.origrequest = request
        self.isNew = isNew

        availraidparts = self.parent.storage.unusedRaidMembers(array=self.origrequest)
        if availraidparts < 2:
            self.intf.messageWindow(_("Invalid Raid Members"),
                                    _("At least two unused software RAID "
                                     "partitions are needed to create "
                                     "a RAID device.\n\n"
                                     "First create at least two partitions "
                                     "of type \"software RAID\", and then "
                                     "select the \"RAID\" option again."),
                                    customIcon="error")
            return

        if isNew:
            title = _("Make RAID Device")
        else:
            if request.minor is not None:
                title = _("Edit RAID Device: %s") % request.path
            else:
                title = _("Edit RAID Device")

        self.dialog = Dialog(title, closeButton=False)
        self.dialog.addWidget(RaidWidget(self, request, isNew))
        if self.origrequest.exists:
            self.dialog.resize(QSize(450, 200))
        else:
            self.dialog.resize(QSize(450, 400))

    def run(self):
        if self.dialog is None:
            return []

        while 1:
            rc = self.dialog.exec_()
            operations = []
            raidmembers = []

            if not rc:
                self.destroy()
                return []

            widget = self.dialog.content
            for index in range(widget.raidMembers.count()):
                if widget.raidMembers.item(index).checkState() == Qt.Checked:
                    raidmembers.append(widget.raidMembers.item(index).partition)

            # The user has to select some devices to be part of the array.
            if not raidmembers:
                continue

            mountpoint = str(widget.mountpointMenu.currentText())
            active = widget.mountpointMenu.isEnabled()
            if active and mountpoint:
                msg = sanityCheckMountPoint(mountpoint)
                if msg:
                    self.intf.messageWindow(_("Mount Point Error"),
                                            msg,
                                            customIcon="error")
                    continue

                used = False
                for (mp, dev) in self.storage.mountpoints.iteritems():
                    if mp == mountpoint and \
                       dev.id != self.origrequest.id and \
                       not (self.origrequest.format.type == "luks" and
                            self.origrequest in dev.parents):
                        used = True
                        break

                if used:
                    self.intf.messageWindow(_("Mount point in use"),
                                            _("The mount point \"%s\" is in "
                                              "use. Please pick another.") %
                                            (mountpoint,),
                                            customIcon="error")
                    continue

            if not self.origrequest.exists:
                formatType = str(widget.filesystemMenu.currentText())
                raidminor = widget.raidMinors.itemData(widget.raidMinors.currentIndex()).toInt()[0]
                raidlevel = widget.raidMinors.itemData(widget.raidLevels.currentIndex()).toInt()[0]

                if not raid.isRaid(raid.RAID0, raidlevel):
                    spares = widget.spareSpin.value()
                else:
                    spares = 0

                format = formats.getFormat(formatType, mountpoint=mountpoint)
                members = len(raidmembers) - spares

                try:
                    request = self.storage.newRaidArray(minor=raidminor,
                                                        level=raidlevel,
#.........这里部分代码省略.........
开发者ID:Tayyib,项目名称:uludag,代码行数:103,代码来源:raid_gui.py

示例7: Widget

# 需要导入模块: from yali.gui.YaliDialog import Dialog [as 别名]
# 或者: from yali.gui.YaliDialog.Dialog import addWidget [as 别名]

#.........这里部分代码省略.........
        elif action == self.reboot:
            reply = QuestionDialog(_("Warning"), _("Are you sure you want to restart your computer now?"))
            if reply == "yes":
                yali.util.reboot()
        else:
            reply = QuestionDialog(_("Warning"), _("Are you sure you want to restart the YALI installer now?"))
            if reply == "yes":
                os.execv("/usr/bin/yali-bin", sys.argv)

    def toggleTheme(self):
        "This easter egg will be implemented later"
        """
        if self._style == os.path.join(ctx.consts.theme_dir, "%s/style.qss" % ctx.flags.theme):
            if os.path.join(ctx.consts.theme_dir, "%s/style.glass.qss" % ctx.flags.theme):
                self._style = os.path.join(ctx.consts.theme_dir, "%s/style.glass.qss" % ctx.flags.theme)
        else:
            self._style = os.path.join(ctx.consts.theme_dir, "%s/style.qss" % ctx.flags.theme)
        self.updateStyle()
        """

    def toggleConsole(self):
        if not self.terminal:
            terminal = QTermWidget()
            terminal.setScrollBarPosition(QTermWidget.ScrollBarRight)
            terminal.setColorScheme(1)
            terminal.sendText("export TERM='xterm'\nclear\n")
            self.terminal = Dialog(_("Terminal"), terminal, True, QKeySequence(Qt.Key_F11))
            self.terminal.resize(700, 500)
        self.terminal.exec_()

    def toggleTetris(self):
        self.tetris = Dialog(_("Tetris"), None, True, QKeySequence(Qt.Key_F6))
        _tetris = Tetris(self.tetris)
        self.tetris.addWidget(_tetris)
        self.tetris.resize(240, 500)
        _tetris.start()
        self.tetris.exec_()

    def toggleCursor(self):
        if self.cursor().shape() == QCursor(Qt.ArrowCursor).shape():
            raw = QPixmap(":/gui/pics/pardusman-icon.png")
            raw.setMask(raw.mask())
            self.setCursor(QCursor(raw, 2, 2))
        else:
            self.unsetCursor()

    #  show/hide help text
    def slotToggleHelp(self):
        self.ui.helpContentFrame.setFixedHeight(self.ui.helpContent.height())
        if self.ui.helpContentFrame.isVisible():
            self.ui.helpContentFrame.hide()
        else:
            self.ui.helpContentFrame.show()
        widget = self.ui.mainStack.currentWidget()
        widget.update()

    # show/hide debug window
    def toggleDebug(self):
        if ctx.debugger.isVisible():
            ctx.debugger.hideWindow()
        else:
            ctx.debugger.showWindow()

    #  returns the id of current stack
    def getCurrent(self, index):
        new_index = self.ui.mainStack.currentIndex() + index
开发者ID:Pardus-Linux,项目名称:yali,代码行数:70,代码来源:YaliWindow.py


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