Skip to content

Instantly share code, notes, and snippets.

import maya.OpenMaya as om
def resolve_file_path_callback(retCode, fileObject, clientData):
old_path = fileObject.rawFullName()
new_path = resolve_path(old_path) # fome resolve function
if new_path:
print('Resolved path {} => {}'.format(old_path, new_path))
fileObject.setRawFullName(new_path)
om.MScriptUtil.setBool(retCode, True)
from PySide6.QtWidgets import *
from PySide6.QtCore import *
from PySide6.QtGui import *
class CourseWidget(QWidget):
def __init__(self):
super().__init__()
self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
from pytube import Playlist, YouTube, Stream
import re
from pathlib import Path
PLAYLIST_URL = 'https://www.youtube.com/playlist?list=XXXXXXXXXXXXXXXX'
SAVE_PATH = Path('~/yt').expanduser()
skip_chars = r"""!"#$%&'()*+,./:;<=>?@[\]^`{|}~"""
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2.QtGui import *
class TransparentWidget(QWidget):
def __init__(self):
super().__init__()
self.setAttribute(Qt.WA_TranslucentBackground, True)
self.setWindowFlags(Qt.FramelessWindowHint)
from pymel.core import *
class CopyOffset(object):
def __init__(self):
self.offs_mx = None
with window():
with verticalLayout():
button(label='Copy', command=Callback(self.copy))
button(label='Paste', command=Callback(self.paste))
import tarfile
import hashlib
import timeit
import os
from pathlib import Path
# create random test files
files_to_archive = []
for i in range(5):
from PySide2.QtGui import *
from PySide2.QtCore import *
from PySide2.QtWidgets import *
def create_icon(text, bg_color, text_color='white', size=64):
pix = QPixmap(QSize(size, size))
pix.fill(Qt.black)
painter = QPainter()
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from pymel.core import *
text = '''<h2>Title</h2>
Some text
<a href="https://google.com">Help</a>
from PySide2.QtCore import Qt
from PySide2.QtGui import QFontMetrics
from PySide2.QtWidgets import QWidget, QLabel, QSizePolicy, QApplication, QVBoxLayout
class TruncatedLabel(QLabel):
"""
QLabel with truncated text
"""
def __init__(self, text='', elide=Qt.ElideLeft, *args, **kwargs):
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2.QtGui import *
import base64
icon_file_no = b'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ\nbWFnZVJlYWR5ccllPAAAA3ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdp\nbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6\neD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1\nOTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJo\ndHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlw\ndGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEu\nMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVz\nb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1N\nOk9yaWdpbmFsRG9jdW1lbnRJRD0iQTREMkMxMTRCOTIwNTExNEUyNkQ1ODMwNDQ3MDVCNjkiIHht\ncE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDAzNkZEMTRCNzhDMTFFQUI3Q0ZDQjdDM0Y2NzdBRDQi\nIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NDAzNkZE