Authorhappyneal

PySide: Using standard system Icons

You can add Icons to many types of QWidgets. PySide provides you with a method to access the native system icons.
A complete list of icons can be found here: PySide.QtGui.PySide.QtGui.QStyle.StandardPixmap

To apply the QIcon you need to

btn = QPushButton("Folder")
style = btn.style()
icon = style.standardIcon(QStyle.SP_DirIcon)
btn.setIcon(icon)
#or short:
btn.setIcon(btn.style().standardIcon(QStyle.SP_DirIcon))

Here a small example:

import sys
from PySide.QtCore import *
from PySide.QtGui import *

class Widget(QWidget):
    
    def __init__(self, parent= None):
        super(Widget, self).__init__()
        
        
        btn_folder = QPushButton("Folder")
        btn_folder.setIcon(self.style().standardIcon(QStyle.SP_DirIcon))
        
        btn_one = QPushButton("Play")
        btn_one.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
        
        btn_two = QPushButton("Stop")
        btn_two.setIcon(self.style().standardIcon(QStyle.SP_MediaStop))
        
        btn_three = QPushButton("Pause")
        btn_three.setIcon(self.style().standardIcon(QStyle.SP_MediaPause))
        
        layout = QHBoxLayout()
        layout.addWidget(btn_folder)
        layout.addWidget(btn_one)
        layout.addWidget(btn_two)
        layout.addWidget(btn_three)
        
        self.setLayout(layout)
        
if __name__ == '__main__':
    app = QApplication(sys.argv)
    
    dialog = Widget()
    dialog.show()

    app.exec_()

PySide: QMessageBox with QCheckBox

The QMessageBox is very useful for creating standard filesystem dialogs (it even comes with alert sounds) and is limited to display an icon, text and standard buttons. If you want to add something extra like a checkbox for “do not ask me again”, you need to extend the base class.

Windows 8.1: Boot to Desktop

Windows 8.1 finally gives you the option to boot directly to the desktop (without the need for a 3rd party program). You can enable this option by opening the preferences for the taskbar and go to the tab for “Navigation”.

win8.1-boottodesktop

Advanced Users can use the Registry to Boot to desktop by setting following key:

PySide: Rightclick Button Menu

PySide (www.pyside.org) is an awesome Framework that allows you to use Qt with Python. Installation is as straightforward as typing

pip install pyside

I will be creating a menu that opens with a right click.
This menu is called “Context Menu” in QT.
In this example the right click menu on the button removes the button at runtime.

Project Euler

Project Euler is a collection of challenging mathematical and computational problems. The first couple of problems are rather straightforward, however the difficulty gets very hard after the first 10 problems.

So if you like programming and solve math problems go to www.projecteuler.net and try to solve a couple of the problems.

project euler progress

Ubuntu 13.04: Post Install Setup

After the installation of Ubuntu you want to start being productive as fast as possible. There are three things you need to do:
1. Install the Programs you need
2. Remove the unwanted pre-installed Programs (for example Amazon Integration, Rhythm box)
3. Install all System Updates

While you could use the Ubuntu Store to install all programs by clicking through various screens. You will have a great performance gain by using the console and the “apt-get” package manager.

In the spirit of never having to repeat myself, I simply collected all the console commands I needed to complete the three steps.

Your personal setup will be slightly different to my setup, feel free to modify and adjust the script to suit your needs.

© 2017 Neal Bürger

Theme by Anders NorénUp ↑