Bottom Page

Thread Rating:
  • 3 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Modern looking GUI
(Jan-11-2019, 12:23 AM)Larz60+ Wrote: Qt is a fine GUI 'system' I do use it myself. My only concern is the commercial side of the product. I've been at this a very long time, and have seen, not free, (as nothing was free back in the late 60's and early 70's), but inexpensive products, eventually become upgrade or leave, with upgrade being price prohibitive for a small company. So I do use it, but not for anything that I intend to sell myself.

Python is now officially supported by the Qt company, they call it PySide2 or Qt for Python. It is released under LGPL so I think that would allow free commercial use.

(Jan-10-2019, 09:56 PM)Cuz Wrote: @Alfalfa
I checked out those apps and I think we're slowly getting there :D VLC for Win 10 is looking way better. Especially using CSS looks promising. Would you by any chance know any intelligible materials I could use to learn more on combining CSS with PyQt5?

I feel like I didn't express what I want to achieve clearly enough. You can have GUI that looks like this:


You can definetly do something similar with PyQt. Here is an example I made for a draggable frameless window:

Then with a simple layout and CSS:

import sys
from PyQt5 import QtCore, QtGui, QtWidgets

CSS = \
        'background-color': '#333333',
        'color': '#888888',
        'background-color': '#444444',
        'font-weight': 'bold',
        'color': '#1d90cd',
        'color': '#888888',
        'background-color': '#444444',
        'font-weight': 'bold',
        'border': 'none',
        'padding': '5px',
        'color': '#ffffff',
        'color': '#1d90cd',

def dictToCSS(dictionnary):
    stylesheet = ""
    for item in dictionnary:
        stylesheet += item + "\n{\n"
        for attribute in dictionnary[item]:
            stylesheet += "  " + attribute + ": " + dictionnary[item][attribute] + ";\n"
        stylesheet += "}\n"
    return stylesheet

class Main(QtWidgets.QMainWindow):
    def __init__(self, parent):
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
        self.resize(200, 150)
        self.ui = QtWidgets.QWidget(self)

        self.ui.button = QtWidgets.QPushButton("Close")

        self.ui.label = QtWidgets.QLabel("Hello World")

        self.ui.layout = QtWidgets.QVBoxLayout()
        self.ui.layout.setContentsMargins(50, 50, 50, 50)

    def mouseMoveEvent(self, event):
        # Enable mouse dragging
        if event.buttons() == QtCore.Qt.LeftButton:
            self.move(event.globalPos() - self.dragPosition)

    def mousePressEvent(self, event):
        # Enable mouse dragging
        if event.button() == QtCore.Qt.LeftButton:
            self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()

    def keyPressEvent(self, event):
        # Escape key close the window
        if event.key() == QtCore.Qt.Key_Escape:
        QtWidgets.QMainWindow.keyPressEvent(self, event)

    def paintEvent(self, event):
        # Draw a one pixel border
        borderColor = QtGui.QColor("black")
        bgColor = QtGui.QColor(self.palette().color(QtGui.QPalette.Background))
        painter = QtGui.QPainter(self)
        painter.drawRect(0, 0, self.width(), self.height())
        painter.drawRect(1, 1, self.width()-2, self.height()-2)

if __name__== '__main__':
    app = QtWidgets.QApplication([])
    gui = Main(app)
You may also use image or border-image to customize buttons and labels:
Quote: image: url('img1.svg');
border-image: url('img2.svg');
metulburr likes this post
(Jan-10-2019, 09:56 PM)Cuz Wrote: İmage

or like this:

For this style of UI take a look at PySciter
Quote:Alfalfa wrote:
Python is now officially supported by the Qt company, they call it PySide2 or Qt for Python
Yes, I was aware of that, but it doesn't eliminate my cautiousness. Once burnt, you have a greater respect for fire.
This looks quite modern :)
That looks better, but I think I'll stick with Qt for now.

And I think now what you've said really wraps it up pretty accurately. Those are just details, that can be changed if you're persistent enough. I'll try to think like that more often :)

Big kudos for the code, I'll try to learn from it :)

I stumbled upon it few days ago, but I'm concerned I couldn't find too much good info on how to use it, and I'm just a newbie who wouldn't be able to just dive in it and understand right away.

Looks way better. Thanks for that!

@All - I'm gonna repeat myself, but once again I'm heppy seeing how helpful is the python community (no one called me stupid so far :D). I will just start from scratch and approach it similarly to how artists start with the painting. Make a sketch and then replace one element after another until you're satisfied.

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)