Skip to content

Instantly share code, notes, and snippets.

View ShenTengTu's full-sized avatar
🇹🇼
working & study

涂紳騰(Shen-Teng Tu) ShenTengTu

🇹🇼
working & study
View GitHub Profile
@ShenTengTu
ShenTengTu / pkg.sh
Last active August 14, 2024 08:30
shell script provides advanced output of `pkg-config`
#!/bin/bash
action=$1
shift 1
no_flag=0
quote=0
while getopts "nqf:" opt; do
case ${opt} in
@ShenTengTu
ShenTengTu / profile.ps1
Created July 9, 2024 16:17
Custom prompt of PowerShell (posh-git, Python virtualenv)
### Custom prompt ###
Import-Module posh-git
# disable default python virtualenv prompt
$env:VIRTUAL_ENV_DISABLE_PROMPT = "1"
# store the original prompt function
function _prompt {
""
}
@ShenTengTu
ShenTengTu / notepad_monitor.py
Created May 8, 2024 14:57
Python class for monitoring a file in Notepad++
import atexit
import subprocess as subp
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
class NotepadMonitor:
"""
A class to monitor a file in Notepad++.
"""
@ShenTengTu
ShenTengTu / style_QCheckBox.py
Created March 26, 2024 06:47
Function that generates a stylesheet for styling QCheckBox
import sys
from qtpy.QtWidgets import (
QApplication,
QMainWindow,
QCheckBox,
QFrame,
QGridLayout,
)
@ShenTengTu
ShenTengTu / style_QSpinBox.py
Created March 26, 2024 05:52
Function that generates a stylesheet for styling QSpinBox & QDoubleSpinBox
import sys
from qtpy.QtWidgets import (
QApplication,
QMainWindow,
QSpinBox,
QDoubleSpinBox,
QFrame,
QGridLayout,
)
@ShenTengTu
ShenTengTu / style_QLineEdit.py
Created March 26, 2024 05:13
Function that generates a stylesheet for styling QLineEdit.
import sys
from qtpy.QtWidgets import (
QApplication,
QMainWindow,
QLineEdit,
QFrame,
QGridLayout,
)
@ShenTengTu
ShenTengTu / style_QComboBox.py
Created March 24, 2024 14:32
Function that generates a stylesheet for styling QComboBox & QListView (popup list)
import sys
from qtpy import QtCore
from qtpy.QtWidgets import (
QApplication,
QMainWindow,
QComboBox,
QFrame,
QGridLayout,
)
@ShenTengTu
ShenTengTu / style_QPushButton.py
Created March 24, 2024 05:56
Function that generates a stylesheet for styling QPushButton
import sys
from qtpy.QtWidgets import (
QApplication,
QMainWindow,
QPushButton,
QFrame,
QGridLayout,
)
@ShenTengTu
ShenTengTu / style_QTabWidget.py
Created March 21, 2024 14:51
Function that generates a stylesheet for styling the QTabWidget, supporting four tab positions.
import sys
from qtpy.QtWidgets import (
QApplication,
QMainWindow,
QTabWidget,
QFrame,
QVBoxLayout,
)
@ShenTengTu
ShenTengTu / qt_defaultEditorFactory.py
Created March 13, 2024 13:34
[Python] Qt: Function with overloaded type hints, equivalent to "QItemEditorFactory.defaultFactory().createEditor"
@overload
def defaultEditorFactory(arg: Type[bool], parent: QWidget) -> QComboBox: ...
@overload
def defaultEditorFactory(arg: Type[float], parent: QWidget) -> QDoubleSpinBox: ...
@overload
def defaultEditorFactory(arg: Type[int], parent: QWidget) -> QSpinBox: ...
@overload
def defaultEditorFactory(arg: Type[QDate], parent: QWidget) -> QDateEdit: ...
@overload
def defaultEditorFactory(arg: Type[QDateTime], parent: QWidget) -> QDateTimeEdit: ...