Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Qcolor name pyside6
#1
I have an error that works if I print but not if I try to use the value. I've tried everything I can think of but can't understand what is going wrong.

I get a color from a QColordialog then try to get the string from it. The print statement shows "#000000" but then I get a QColor not callable error on the " Prefs.fontColor(_color)" line. Any clues?

	def chooseColor(self):
		color = QColorDialog()
		color.setCurrentColor(Prefs.fontColor)
		color.exec()
		_color = color.currentColor()
		print(_color.name())
		_color = str(_color.name())
		Prefs.fontColor(_color)
#and the Prefs part is
	@property
	def fontColor(self):
		return QColor.fromString(self._dict["fontColor"])
	@fontColor.setter
	def fontColor(self,val):
		self._dict["fontColor"] = val
Reply
#2
fontColor is a property. You do not use function calling syntax when getting or setting a property value
Instead of this:
Prefs.fontColor(_color)
Do this:
Prefs.fontColor = _color
Reply
#3
Arg, I just couldn't figure it out, to fixated on the QColor error message and completely forgetting my years of windows properties Ugh!

Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyside6 module not found ForeverNoob 4 1,517 Aug-18-2023, 04:36 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020