예제 #1
0
    def _addControl(self, n, res):
        ctl = xrc.XRCCTRL(self, n)

        if ctl:
            ctl.validator = None
            vi = n.find('-')
            if vi > 0:
                vp = n[vi + 1:].split()
                validatorClass = Validator.Get(vp[0])
                if validatorClass:
                    ctl.validator = validatorClass(ctl, vp[1:])
                else:
                    adm.logger.debug("No validator for %s installed.", vp[0])
                name = n[:vi]
            else:
                name = n

            names = name.split(':')
            ctl.name = names[-1]
            ctl.flags = map(lambda x: x.lower(), names[:-1])

            self._ctlList.append(ctl.name)
            for flag in ctl.flags:
                if flag.startswith("label="):
                    labelCtl = self.ctl(flag[6:])
                    if labelCtl:
                        ctl.labelCtl = labelCtl

            if self._ctls.get(name):
                adm.logger.debug("Duplicate Control Name %s", ctl.name)
            self._ctls[ctl.name.lower()] = ctl
        else:
            if n == "StatusBar":
                self.addStatusBar(res)
예제 #2
0
파일: Zone.py 프로젝트: sarkartanzil/admin4
    def Go(self):
        if self.RecordName:
            ttl, rds = self._getRds()
            vlist = []
            for rd in self.rds:
                value = eval("rd.%s" % rd.__slots__[0])
                if isinstance(value, list):
                    value = " ".join(map(quoteIfNeeded, value))
                vlist.append(str(value))
            self.value = "\n".join(vlist)
        else:
            ttl = 86400
            rds = Rdataset(ttl, rdataclass.IN, self.rdtype)
            self.rds = None

        typestr = rdatatype.to_text(self.rdtype)
        self.SetTitle(DnsSupportedTypes[typestr])
        self.RecordNameStatic = typestr
        self.ValueStatic = rds[0].__slots__[0].capitalize()
        self.dataclass = type(eval("rds[0].%s" % rds[0].__slots__[0]))
        if self.dataclass == int:
            validatorClass = Validator.Get("uint")
            if validatorClass:
                self['Value'].validator = validatorClass(self['Value'], "uint")
        elif self.dataclass == Name:
            self.dataclass = DnsName
        self.TTL = floatToTime(ttl, -1)
예제 #3
0
    def AddExtraControls(self, res):
        self.type = self.vals['vartype']
        if self.type == 'bool':
            self.value = wx.CheckBox(self)
        elif self.type == 'enum':
            self.value = wx.ComboBox(self,
                                     style=wx.CB_READONLY | wx.CB_DROPDOWN)
            self.value.AppendItems(self.vals['enumvals'])
        elif self.type == 'integer':
            self.value = wx.TextCtrl(self)
            self.value.validator = Validator.Get('uint')
        elif self.type == 'real':
            self.value = wx.TextCtrl(self)


#      self.value.validator=Validator.Get('real') TODO
        elif self.type == 'string':
            self.value = wx.TextCtrl(self)
        else:
            self.value = wx.TextCtrl(self)
            logger.debug("Unknown pg_settings vartype %s", self.type)

        res.AttachUnknownControl("ValuePlaceholder", self.value)
        self._ctls['value'] = self.value