Skip to content

Instantly share code, notes, and snippets.

View Patitotective's full-sized avatar
🏫

Patitotective Patitotective

🏫
View GitHub Profile
@Patitotective
Patitotective / scrollable_label.py
Last active August 19, 2021 21:34
Scrollable label example with good looking scroll bar and smooth scroll.
import sys
from PyQt5.QtWidgets import (QApplication, QLabel,
QVBoxLayout, QWidget, QMainWindow,
QGridLayout, QDialog, QScrollBar,
QScrollArea, qApp)
from PyQt5 import QtGui, QtCore
from PyQt5.QtCore import Qt, QCoreApplication, QEvent
@Patitotective
Patitotective / collapsible_widget.py
Last active September 12, 2021 19:39
Collapsible widget using PyQt5.
import sys
from PyQt5.QtWidgets import QFrame, QWidget, QHBoxLayout, QVBoxLayout, QLabel, QPushButton, QApplication, QMainWindow
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
import collapsible_widget_resources
VERTICAL_ARROW_PATH = ":/vertical_arrow_collapsible.png"
HORIZONTAL_ARROW_PATH = ":/horizontal_arrow_collapsible.png"
@Patitotective
Patitotective / custom_context_menu.py
Last active June 26, 2024 10:27
Minimal example of how to use a custom context menu and add actions to it.
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QMenu, QAction
from PyQt5.QtGui import QCursor
from PyQt5.QtCore import Qt
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.text_edit = QTextEdit()
@Patitotective
Patitotective / QMarkdownPreviewer.py
Last active October 11, 2021 17:29
Simple Markdown previewer with live update.
import sys
import commonmark
from PyQt5.QtWidgets import QDialog, QWidget, QLabel, QApplication, QVBoxLayout, QTextBrowser
from PyQt5.QtCore import QObject, QThread, pyqtSignal, QTimer
from PyQt5.QtWebEngineWidgets import QWebEngineView
from github_markdown_style import GITHUB_MARKDOWN_STYLE
class CheckFileWorker(QObject):
@Patitotective
Patitotective / numbered_lines_text_edit.py
Created October 11, 2021 17:33
A QPlainTextEdit with numbered lines.
import sys
from PyQt5.QtWidgets import QFrame, QHBoxLayout, QTextEdit, QPlainTextEdit, QWidget, QMainWindow, QApplication
from PyQt5.QtGui import QPainter, QTextFormat, QColor
from PyQt5.QtCore import QRect, QVariant, Qt
class NumberedLinesTextEdit(QFrame):
class NumberBar(QWidget):
def __init__(self, edit):