PySide and Python Tips

Growing Reference Page For PySide and Python tips and tricks.

PySide – Set A QComboBox Value To String

# How to set selected item of a  QComboBox (myQComboBox) to a string (myString)

PySide – Update Layout & Window Size After Removing Content

# How to make a Layout & window update properly in size after removing layout content
# Make Layout Update
widget = None  
# Make Layout Recalculate & Resize Window properly

PySide – Making a window always stay ontop

# Making a window always stay ontop
class Widget(PySide.QtGui.QWidget):
    def __init__(self, parent=None):
        super(Widget, self).__init__( parent, PySide.QtCore.Qt.WindowStaysOnTopHint )

PySide – How to store all string items of a QComboBox

# How to store all string items of a QComboBox
allItems = [QComboBoxName.itemText(i) for i in range(QComboBoxName.count())]

PySide – Query Windows Registry for my Documents Folder

# How to query the registry for the built in default folders in Windows through PyQt
if platform.system() == 'Windows':
    # Windows Registry settings - query
    winSettings = QSettings("Microsoft", "Windows")
    winSettings.beginGroup("CurrentVersion/Explorer/Shell Folders")
    self.myDocFolder =  winSettings.value("Personal").toString()

To see what other values are available for query, run… regedit and browse to HKEY_CURRENT_USER→ Software→ Microsoft→ Windows→ CurrentVarsion→ Explorer→ Shell Folders

Python – Removing Duplicate List Items

# Python - How to remove duplicate list items from a list (myList)
myList= list(set(myList))

Hope these help you as much as it will serve as a quick reference for me…

/Christian Akesson

2 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *