def backgroundInfoDialog(parent, rsrc): dlg = BackgroundInfoDialog(parent, rsrc) result = dlg.showModal() if result.accepted: result.name = dlg.components.fldName.text result.title = dlg.components.fldTitle.text result.position = eval(dlg.components.fldPosition.text) result.size = eval(dlg.components.fldSize.text) result.statusBar = dlg.components.chkStatusBar.checked result.foregroundColor = util.colorFromString( dlg.components.fldForegroundColor.text) result.backgroundColor = util.colorFromString( dlg.components.fldBackgroundColor.text) if dlg.components.fldImage.text != '': result.image = dlg.components.fldImage.text else: result.image = None result.tiled = dlg.components.chkTiled.checked result.visible = dlg.components.chkVisible.checked if dlg.components.chkResizeable.checked: result.style = ['resizeable'] else: result.style = [] if dlg.components.fldIcon.text != '': result.icon = dlg.components.fldIcon.text else: result.icon = None dlg.destroy() return result
def on_color_command(self, event): which = event.target.name.replace("clr", "") result = dialog.colorDialog(self, color=util.colorFromString(self.components["fld"+which].text)) if result.accepted: self.components["fld"+which].text = str(result.color) self.components["clr"+which].backgroundColor = util.colorFromString(self.components["fld"+which].text) self.updateComponent(which)
def on_btnBackgroundColor_mouseClick(self, event): result = dialog.colorDialog( self, color=util.colorFromString( self.components.fldBackgroundColor.text)) if result.accepted: self.components.fldBackgroundColor.text = str(result.color)
def on_wColor_mouseClick(self, event): result = dialog.colorDialog(self, color=util.colorFromString( self.components.wField.text)) if result.accepted: self.components.wField.text = str(result.color) if self.autoAttributeUpdate: self.updateComponent()
def displayProperties(self, wName, wClass): maxy = 0 for theprop in self.standardProps: prop = theprop if prop == "text" and wClass == "TextArea": prop = "textArea" if prop in self.propertyList: vis = True else: vis = False for prefix in self.standardPrefixes: if prefix+prop in self.components.iterkeys(): self.components[prefix+prop].visible = vis self.components[prefix+prop].enabled = vis maxy = max(maxy, self.components[prefix+prop].position[1]) #rint self.components[prefix+prop].name, self.components[prefix+prop].position, self.components[prefix+prop].size, self.components[prefix+prop].GetBestSize() x,y = self.components.Properties.position # get values from one of the standard fields - use backgroundCcolor # for text, field and button sizes # get the size as defined in the resource file, adjust for BestSize tx, ty = self.components.txtbackgroundColor.position tdefx, tdefy = self.components.txtbackgroundColor.size tsx, tsy = self.components.txtbackgroundColor.GetBestSize() ## + (20,10) tx = tx + tdefx - tsx fx, fy = self.components.fldbackgroundColor.position fdefx, fdefy = self.components.fldbackgroundColor.size fsx, fsy = self.components.fldbackgroundColor.GetBestSize() ## + (20,10) fx = fx + fdefx - fsx #rint fx, fy, fsx, fsy # Color buttons are odd, so use the font button for button positioning bx, by = self.components.fntfont.position bdefx, bdefy = self.components.fntfont.size bsx, bsy = self.components.fntfont.GetBestSize() ## + (20,10) #rint bx, by, bdefx, bdefy, bsx, bsy # bx = bx + bdefx - bsx bsx = bdefx #rint bx, by, bsx, bsy y = maxy+fsy if DO_TRICKY_NAME_DERIVATIONS and ('label' in self.propertyList or 'text' in self.propertyList): self.components["chkallowNameLabelVariation"].visible = True self.components["chkallowNameLabelVariation"].enabled = True self.determineNameLabelState(wName) else: self.components["chkallowNameLabelVariation"].visible = False self.components["chkallowNameLabelVariation"].enabled = True self.determineNameLabelState(wName) for propName in self.propertyList: widget = self._comp[wName] if propName in ['label', 'stringSelection', 'text', 'toolTip'] or propName in self.checkItems: value = getattr(widget, propName) else: value = str(getattr(widget, propName)) if propName in self.checkItems: if not propName in self.standardProps: if not "chk"+propName in self.components.iterkeys(): self.add_chk("chk"+propName, (fx, y), (fsx,fsy)) else: self.components["chk"+propName].position = (fx, y) self.components["chk"+propName].size = (fsx, fsy) y += fsy + 5 self.components["chk"+propName].label = propName self.components["chk"+propName].visible = True self.components["chk"+propName].enabled = True self.components["chk"+propName].checked = value else: self.components["chk"+propName].visible = True self.components["chk"+propName].checked = value elif propName in self.popItems: if not propName in self.standardProps: if not "txt"+propName in self.components.iterkeys(): self.add_field("StaticText", "txt"+propName, (tx, y), (tsx,tsy), propName, "right") else: self.components["txt"+propName].position = (tx, y) self.components["txt"+propName].size = (tsx, tsy) if not "pop"+propName in self.components.iterkeys(): self.add_pop("pop"+propName, (fx, y), (fsx,fsy)) else: self.components["pop"+propName].position = (fx, y) self.components["pop"+propName].size = (fsx, fsy) y += max(tsy, fsy) + 5 self.components["txt"+propName].visible = True self.components["txt"+propName].enabled = True self.components["pop"+propName].visible = True self.components["pop"+propName].enabled = True self.components["pop"+propName].Clear() if propName == 'stringSelection': for v in widget.items: self.components["pop"+propName].Append(v) else: for v in widget._spec.getAttributes()[propName].values: self.components["pop"+propName].Append(v) try: self.components["pop"+propName].stringSelection = value except: # if value is empty or doesn't already exist pass elif propName in ('items', 'userdata') or (wClass == 'TextArea' and propName == 'text'): if not propName in self.standardProps: if not "txt"+propName in self.components.iterkeys(): self.add_field("StaticText", "txt"+propName, (tx, y), (tsx,tsy), propName, "right") else: self.components["txt"+propName].position = (tx, y) self.components["txt"+propName].size = (tsx, tsy) if not "fld"+propName in self.components.iterkeys(): self.add_field("TextArea", "fld"+propName, (fx, y), (fsx,fsy*3), value, "left") else: self.components["fld"+propName].position = (fx, y) self.components["fld"+propName].size = (fsx, fsy*3) y += 3*fsy+5 if wClass == 'TextArea' and propName == 'text': propName = 'textArea' self.components["txt"+propName].visible = True self.components["txt"+propName].enabled = True self.components["fld"+propName].visible = True self.components["fld"+propName].enabled = True self.components["fld"+propName].text = value else: if not propName in self.standardProps: if not "txt"+propName in self.components.iterkeys(): self.add_field("StaticText", "txt"+propName, (tx, y), (tsx,tsy), propName, "right") else: self.components["txt"+propName].position = (tx, y) self.components["txt"+propName].size = (tsx, tsy) if not "fld"+propName in self.components.iterkeys(): self.add_field("TextField", "fld"+propName, (fx, y), (fsx,fsy), value, "left") else: self.components["fld"+propName].position = (fx, y) self.components["fld"+propName].size = (fsx, fsy) if propName == 'file': if not "btn"+propName in self.components.iterkeys(): self.add_btnFile("btn"+propName, (bx, y), (bsx,bsy)) else: self.components["btn"+propName].position = (bx, y) self.components["btn"+propName].size = (bsx, bsy) print "btn"+propName, bx, y, bsx, bsy self.components["btn"+propName].visible = True self.components["btn"+propName].enabled = True # allow extra space for the "file" button y += max(tsy, fsy, bsy) - max(tsy,fsy) y += max(tsy, fsy) + 5 else: # all colors and fonts are "standard" items if propName == 'foregroundColor' or propName == 'backgroundColor': self.components["clr"+propName].visible = True #rint propName, self.components["fld"+propName].text, value self.components["clr"+propName].backgroundColor = util.colorFromString(value) self.components["txt"+propName].visible = True self.components["txt"+propName].enabled = True if propName == "font": self.components["fld"+propName].visible = False else: self.components["fld"+propName].visible = True self.components["fld"+propName].enabled = True self.components["fld"+propName].text = value ## self.components.wName.text = propName + ":" # KEA 2002-02-23 # I can't remember why this is actually necessary if propName == 'size': width, height = getattr(widget, propName) if wClass not in ['BitmapCanvas', 'HtmlWindow']: bestWidth, bestHeight = widget.GetBestSize() if width == bestWidth: width = -1 if height == bestHeight: height = -1 size = (width, height) value = str(size) self.components["fld"+propName].text = value