3+

2014-09-01から1ヶ月間の記事一覧

QPainter and QScrollArea plactice

#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from PyQt4 import QtCore,QtGui class paintArea(QtGui.QWidget): def __init__(self): super(paintArea, self).__init__() self.setMinimumWidth(500) self.setMinimumHeight(500) self.offscre…

QTreeWidget example

ツリー構造のリストを、割りと簡単に作るサンプル。 タプルのリストからツリーアイテムを作る。タプル(k,v,n)の構造は、 k:ノードの名前 v:ノードの値 n:子ノード(のリスト) 以下ソース。 #!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os, pp…

QTreeViewWidget example

#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from PyQt4.QtGui import * from PyQt4.QtCore import * def main(): app = QApplication(sys.argv) treeWidget = QTreeWidget() treeWidget.setColumnCount(1) items = [] child = [] for i in r…

;(function(document){ var pres = document.getElementsByTagName("pre") for(var i=pres.length; i--; ){  var el = makeOl(pres[i]) pres[i].appendChild(el) } function makeOl(pre){ var ol = document.createElement("ol") , li = document.createElement("li") , df = document.createDocumentFragment() , br = pre.innerHTML.match(/\n/g) || 0 ol.className = "preLine" ol.setAttribute("role", "presentation") // no lang, no line-number if( pre.className && ! /lang-./.test(pre.className) ){ br.length += 1 } for(var i=br.length; i--; ){ var li2 = li.cloneNode(true) df.appendChild(li2) } ol.appendChild(df) return ol } })(document)