Embarcadero/DelphiVCL4Python

Setting Color property of Panel and other components

aerilox opened this issue · 5 comments

Setting Color property of self works ok. Setting Color property of components placed on self does not work. True for all components that have a Color property like Panel, GroupBox aso. Does not work at runtime either. Other properties can be assigned without problem.

	def __init__(self, Owner):
	### object Form
		self.SetBounds(310, 137, 730, 256) #self
		self.Caption = 'Form1'
		self.Color = clSkyBlue  ###colors all components on form, even if ParentColor is set False for each component
		self.Font.Color = clWindowText
		self.Font.Height = -11
		self.Font.Name = 'MS Sans Serif'
		self.Font.Style = []
		self.OldCreateOrder = False
		self.PixelsPerInch = 96
		self.TextHeight = 13
	### object GroupBox1, parent self
		self.GroupBox1 = GroupBox(self)
		self.GroupBox1.Parent = self
		self.GroupBox1.SetBounds(20, 20, 266, 136) #GroupBox1
		self.GroupBox1.Caption = 'GroupBox1'
		self.GroupBox1.Color = clRed   ###does not work
		self.GroupBox1.SetProps(Parent=self, Color=clRed)  ###nor does this help
		self.GroupBox1.Font.Color = clWindowText

@aerilox we are working on a reproducible script. We will move more news soon.

@aerilox, please, try again after setting up the "ParentBackground" property of the GroupBox component to false before changing its color. See the exemple bellow:

self.GroupBox1.ParentBackground = False
self.GroupBox1.Color = clRed

@aerilox can I close this issue?

yes, thanks

Setting Color property of self works ok. Setting Color property of components placed on self does not work. True for all components that have a Color property like Panel, GroupBox aso. Does not work at runtime either. Other properties can be assigned without problem.

	def __init__(self, Owner):
	### object Form
		self.SetBounds(310, 137, 730, 256) #self
		self.Caption = 'Form1'
		self.Color = clSkyBlue  ###colors all components on form, even if ParentColor is set False for each component
		self.Font.Color = clWindowText
		self.Font.Height = -11
		self.Font.Name = 'MS Sans Serif'
		self.Font.Style = []
		self.OldCreateOrder = False
		self.PixelsPerInch = 96
		self.TextHeight = 13
	### object GroupBox1, parent self
		self.GroupBox1 = GroupBox(self)
		self.GroupBox1.Parent = self
		self.GroupBox1.SetBounds(20, 20, 266, 136) #GroupBox1
		self.GroupBox1.Caption = 'GroupBox1'
		self.GroupBox1.Color = clRed   ###does not work
		self.GroupBox1.SetProps(Parent=self, Color=clRed)  ###nor does this help
		self.GroupBox1.Font.Color = clWindowText

Just to add some extra info to this.

The GroupBox needs ParentBackground = False to show color, but the Panel needs StyleElements = "" to show color.

It's two different reasons why Color isn't show for these two components.

I created two StackOverflow questions/answers for this also in case any one else searches for this or needs help on it: