Skip to content

Instantly share code, notes, and snippets.

@diegoponciano
Created October 26, 2011 22:32
Show Gist options
  • Save diegoponciano/1318211 to your computer and use it in GitHub Desktop.
Save diegoponciano/1318211 to your computer and use it in GitHub Desktop.
QWidget won't apply background-color through setStyleSheet using PySide
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>661</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>57</x>
<y>78</y>
<width>370</width>
<height>22</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<widget class="QWidget" name="widget1" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>22</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QWidget { background-color: #fff;border:2px solid #CCC; } QLabel { border:none; }</string>
</property>
<widget class="QLabel" name="label1">
<property name="geometry">
<rect>
<x>10</x>
<y>3</y>
<width>291</width>
<height>17</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>661</width>
<height>25</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created: Wed Oct 26 19:22:30 2011
# by: pyside-uic 0.2.13 running on PySide 1.0.7
#
# WARNING! All changes made in this file will be lost!
from PySide import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(661, 487)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setStyleSheet("")
self.centralwidget.setObjectName("centralwidget")
self.frame = QtGui.QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(57, 78, 370, 22))
self.frame.setAutoFillBackground(True)
self.frame.setFrameShape(QtGui.QFrame.Box)
self.frame.setFrameShadow(QtGui.QFrame.Sunken)
self.frame.setObjectName("frame")
self.widget1 = QtGui.QWidget(self.centralwidget)
self.widget1.setGeometry(QtCore.QRect(0, 0, 369, 22))
self.widget1.setAutoFillBackground(False)
self.widget1.setStyleSheet("QWidget { background-color: #fff;border:2px solid #CCC; } QLabel { border:none; }")
self.widget1.setObjectName("widget1")
self.label1 = QtGui.QLabel(self.widget1)
self.label1.setGeometry(QtCore.QRect(10, 3, 291, 17))
self.label1.setStyleSheet("")
self.label1.setObjectName("label1")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 661, 25))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.label1.setText(QtGui.QApplication.translate("MainWindow", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
#!/usr/bin/python
import sys
import pprint
from PySide import QtCore
from PySide import QtUiTools
from PySide import QtGui
from PySide import QtDeclarative
import ui_widget
# Comment the line below if you don't want to use OpenGL for QML rendering or if it is not supported
from PySide import QtOpenGL
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent=parent)
self.ui = ui_widget.Ui_MainWindow()
self.ui.setupUi(self)
def main():
app = QtGui.QApplication(sys.argv)
#loader = QtUiTools.QUiLoader()
#uifile = QtCore.QFile("./mainwindow.ui")
#window = loader.load(uifile)
window = MainWindow()
window.show()
return app.exec_()
if __name__ == "__main__":
main()
@marcelotozzi
Copy link

xml!
ecat!

@diegoponciano
Copy link
Author

kkkkk
é Qt mano, a ferramenta visual, pra criar GUI, gera essa beleza ae

@marcelotozzi
Copy link

num dá pra usar NoSQL?
lol

@diegoponciano
Copy link
Author

ahuahauahua
dá pra usar NoGUI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment