PyQt Custom Windows

Опубликовано: 10 Декабрь 2021
на канале: MadPonyInteractive
6,029
109

In this video we will learn how to create custom windows that can have any shape we like.
We will also re-implement most of the window functionality like dragging, resizing, full screen, multiple monitor support etc.

We will also check out how we can use web links, get screen and window size, mouse position and a few more handy methods.

If you are just looking for the code you can skip to the last chapter:
22:09 'Recap and grab the code'

NOTES:

I forgot to add an important flag that is responsible for minimization when you press the app icon in the taskbar and that is the Qt.WindowMinimizeButtonHint
So the full flags would be:
self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowMaximizeButtonHint|Qt.WindowMinimizeButtonHint)

^ is a python operator called XOR

If you don't want the window to be constrained to the screen you can replace:
x = max(pos.x(), 0)
y = max(pos.y(), 0)
screen = QGuiApplication.screenAt(QPoint(x, y)).size()
x = min(x, screen.width() - gr.width())
y = min(y, screen.height() - gr.height())
self.move(x, y)

with:
self.move(pos.x(), pos.y())


Timestamps:
00:00 Intro
01:57 Channel news
03:13 Removing the frame
04:26 Transparency
07:15 Functionality setup
08:17 Checking what's under mouse
08:43 Adding a web link
10:14 Full screen toggle
11:08 Event propagation
12:10 Getting event methods
13:24 Maximizing to single screen
15:30 Getting previous mouse position
17:04 Dragging the window
20:44 Getting the screen size
22:09 Recap and grab the code

Relevant Links
Window types documentation: https://doc.qt.io/qtforpython/PySide6...
Qt Style Sheets: https://doc.qt.io/qtforpython/overvie...
PyQt & PySide Course Playlist:    • PyQt6 & PySide6 Course  



Support me on:
https://www.buymeacoffee.com/MadPonyInt
https://gumroad.com/mad_pony_interactive
  / madponyinteractive  
https://madponyinteractive.artstation...
https://flippednormals.com/creator/ma...


Смотрите видео PyQt Custom Windows онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь MadPonyInteractive 10 Декабрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 6,029 раз и оно понравилось 109 людям.