[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] style sheets, sliders and buttons
From:       Scott Frankel <frankel () circlesfx ! com>
Date:       2008-08-29 17:53:34
Message-ID: A5F1AA0D-D38E-411F-ADD8-67B731B92796 () circlesfx ! com
[Download RAW message or body]

Hi,

I'm exploring the use of style sheets with PyQt to control the look of  
my application and have run into some squirrelly behavior:  most  
notably, scrolling sliders no long scroll upwards!

(See attached sample code file.)

Should I have expected that by changing background and foreground  
widget colors, the app's scrollbars and buttons would be rendered  
"flat?"

Ultimately, I'd like to have all widgets pick up the look defined in  
the style sheet, except for scrollbars and buttons.  I'd like  
scrollbars and buttons to have their default appearances.  Is there a  
way to specify a "default appearance" parameter in the style sheet for  
buttons and scrollbars?  Or do I have to declare a specific parameter  
set for each selector (widget) in my app, except for buttons and  
scrollbars?

Note I'm using:
PyQt-mac-commercial-4.4.2
qt-mac-commercial-src-4.4.2-snapshot-20080711
sip-4.7.6
Mac OSX 10.5.2

Thanks in advance!
Scott





["styleSliderButtonTest.py" (styleSliderButtonTest.py)]

#!/usr/bin/env python

import sys
from PyQt4 import QtCore, QtGui


#-------------------------------------------------------------------------------
# class
#-------------------------------------------------------------------------------
class StyleSliderButtonTest(QtGui.QDialog):

	StyleSheet = """

QWidget  {
    background-color: rgb(48, 48, 48);
    color: rgb(196, 196, 196);
	}

QListView {
    alternate-background-color: rgb(64, 64, 64);
    }	

"""

	def __init__(self, parent=None):
		QtGui.QDialog.__init__(self)


		self.setStyleSheet(StyleSliderButtonTest.StyleSheet)

		# init widgets
		# ------------------------------------------------		
		self.theFrame		    = QtGui.QFrame()
		self.theFrame.setFrameStyle(QtGui.QFrame.StyledPanel|QtGui.QFrame.Sunken)

		tmpItems                = ["010.10", "010.20", "010.30", "010.40", "010.50",
								   "010.60", "010.70", "010.80", "010.90",
								   "020.10", "020.20", "020.30", "020.40", "020.50",
								   "020.60", "020.70", "020.80", "020.90",
								   "030.10", "030.20", "030.30", "030.40", "030.50",
								   "030.60", "030.70", "030.80", "030.90",
								   "040.10", "040.20", "040.30", "040.40", "040.50",
								   "040.60", "040.70", "040.80", "040.90"]
		
		self.searchList         = QtGui.QListWidget()
		self.searchList.setAlternatingRowColors(True)
		self.searchList.addItems(tmpItems)

		self.searchLayout		= QtGui.QVBoxLayout()
		self.searchLayout.addWidget(self.searchList)


		
		# buttons
		# ------------------------------------------------		
		self.yesButton	        = QtGui.QPushButton("Yes")
		self.noButton	        = QtGui.QPushButton("No")
		self.buttonGroup        = QtGui.QGroupBox()

		self.buttonLayout   	= QtGui.QHBoxLayout()
		self.buttonLayout.addWidget(self.yesButton)
		self.buttonLayout.addWidget(self.noButton)
		self.buttonGroup.setLayout(self.buttonLayout)
		


		# main layout
		# ------------------------------------------------
		self.widgetLayout		= QtGui.QVBoxLayout()
		self.widgetLayout.addWidget(self.buttonGroup)

		self.formLayout		    = QtGui.QHBoxLayout()
		self.formLayout.addLayout(self.searchLayout)
		self.formLayout.addLayout(self.widgetLayout)

		self.theFrame.setLayout(self.formLayout)

		self.theLayout		    = QtGui.QVBoxLayout()
		self.theLayout.addWidget(self.theFrame)
		self.setLayout(self.theLayout)



		# signals/slots
		# ------------------------------------------------
		self.connect(self.searchList, QtCore.SIGNAL("itemSelectionChanged()"), self.searchItem)
		self.connect(self.yesButton,	QtCore.SIGNAL("clicked()"), self.yes)
		self.connect(self.noButton,	QtCore.SIGNAL("clicked()"), self.no)



	# methods
	# ------------------------------------------------

	def yes(self):
		print "yes() ..."

	def no(self):
		print "no() ..."

	def searchItem(self):
		print "currentItem: ", self.searchList.currentItem().text()




#-------------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------------
if __name__ == "__main__":

	app = QtGui.QApplication(sys.argv)
	form = StyleSliderButtonTest()
	form.setWindowTitle("Style Slider Button Test")
	form.show()
	sys.exit(app.exec_())


Scott Frankel
As seen on TV
President/VFX Supervisor
Circle-S Studios
510-339-7477 (o)
510-332-2990 (c)







_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic