Skip to content

Instantly share code, notes, and snippets.

@oglops
oglops / gist:7120f0fcd1a9be31959221b4caf048c4
Created Jul 4, 2017 — forked from manuelmacha/gist:6cc29ec040734e21a768
QTextEdit extended with a signal 'lineNumbersChanged' which gets triggered when the line-numbers of the visible text change. Such functionality already exists for QPlainTextEdit via firstVisibleBlock().blockNumber() and lastVisibleBlock().blockNumber(). However these methods are not accessible using QTextEdit and PyQt. The signal can be used to …
View gist:7120f0fcd1a9be31959221b4caf048c4
from PyQt4 import QtGui, QtCore
class TextEdit(QtGui.QTextEdit):
'''
QTextEdit extended with a signal 'lineNumbersChanged' which gets triggered when the line-numbers of the visible text change.
Such functionality already exists for QPlainTextEdit via firstVisibleBlock().blockNumber() and lastVisibleBlock().blockNumber()
However these functions are not accessible using QTextEdit and PyQt.
The signal can be used to update custom widgets that compliment the QTextEdit such as lineNumberWidgets or miniMapWidgets.
'''
@oglops
oglops / gifplayer.html
Last active Jul 2, 2017
qwebview load() does not need to load js and css manually
View gifplayer.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>gifplayer</title>
<base href="http://rubentd.com"></base>
<link rel="stylesheet" type="text/css" href="bower_components/jquery.gifplayer/dist/gifplayer.css"></link>
<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="bower_components/jquery.gifplayer/dist/jquery.gifplayer.js"></script>
<script>
@oglops
oglops / 1.html
Created Jun 30, 2017
qwebview visited link color not changing ?
View 1.html
<html>
<head>
<title></title>
<meta content="">
<style></style>
</head>
<body>
page 1
<a href="2.html"> open page 2</a>
</body>
@oglops
oglops / gifplayer.css
Last active Jun 29, 2017
use gifplayer jquery plugin in qwebview to control gif, user-select: none; hides blinking text cursor when used in an editable qwebview
View gifplayer.css
ins.play-gif{
position: absolute;
font-family: Arial, sans serif;
width: 50px;
height: 50px;
line-height: 52px;
text-align: center;
background: #222;
font-size: 18px;
@oglops
oglops / pyqt4_webkit_video_css.py
Created Jun 27, 2017
Load one or multiple css files into qwebview
View pyqt4_webkit_video_css.py
import sys
from PyQt4.QtWebKit import QWebView, QWebInspector, QWebSettings
from PyQt4.QtGui import QApplication, QDialog, QHBoxLayout
from PyQt4.QtCore import QUrl, QByteArray, QString
class Dialog(QDialog):
def __init__(self, parent=None):
View mayaWidgetEmbeddingIntoPyQtWidget.py
import maya.OpenMayaUI
import maya.cmds as cmds
import sip
from PyQt4.QtGui import *
from PyQt4.QtCore import *
mainWindow = QMainWindow()
centralWidget = QListView()
mainWindow.setCentralWidget(centralWidget)
dockWidget = QDockWidget("DockWidget", mainWindow)
@oglops
oglops / contextDecorator3.py
Last active May 12, 2017
test classmethod
View contextDecorator3.py
#!/usr/bin/env python
from abc import ABCMeta, abstractmethod
from functools import wraps
import time
class ContextDecorator(object):
_built = False
@oglops
oglops / contextDecorator.py
Last active May 12, 2017
context aware context decorator for maya
View contextDecorator.py
#!/usr/bin/env python
from abc import ABCMeta, abstractmethod
from functools import wraps
import time
class Singleton(ABCMeta):
_instance = None
def __call__(cls, *args, **kwargs):
@oglops
oglops / batch_keys.sh
Created Apr 22, 2017 — forked from ShadowKyogre/batch_keys.sh
Select multiple windows with slop. Needs slop, xwininfo, and xprop. Edit batch_keys.sh if you want to pass different params to the slop wrapper.
View batch_keys.sh
#!/bin/bash
happened=1
for window in $(recsel_windows.py -l -c 0,0.5,1,0.6)
do
happened=0
xdotool windowactivate --sync $window key "$1"
done
if [ $happened -a -n "$2" ];then
@oglops
oglops / mayaCustomMarkers.py
Created Apr 19, 2017 — forked from dgovil/mayaCustomMarkers.py
Allows a user to create custom markers in maya.Based off of this pastebin: http://pastebin.com/Uc8S4QPx (which may further be from createive Crash) and further work by https://github.com/achayan and his pasteBin http://pastebin.com/JGJZ5uu1
View mayaCustomMarkers.py
from PyQt4 import QtGui, QtCore
import maya.cmds as cmds
import maya.OpenMayaUI as mui
import sip
def convertToQT(controlName):
controlPoniter = mui.MQtUtil.findControl(controlName)
if controlPoniter is not None:
return sip.wrapinstance(long(controlPoniter), QtCore.QObject)