Welcome, guest | Sign In | My Account | Store | Cart

This code is QMacCocoaViewContainer on PyQt4 example.

Python, 23 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from Cocoa import NSTextView, NSMakeRect
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class WindowWidget(QWidget):
    def __init__(self, parent=None):
        super(WindowWidget, self).__init__(parent)
        cv = QMacCocoaViewContainer(0, self)
        cv.move(100, 100)
        cv.resize(300, 300)
        tv = NSTextView.alloc().initWithFrame_(NSMakeRect(0, 0, 300, 300))
        cv.setCocoaView(tv.__c_void_p__().value)

def main():
    import sys
    app = QApplication(sys.argv)
    w = WindowWidget()
    w.show()
    w.raise_()
    app.exec_()

if __name__ == '__main__':
    main()
Created by Keisuke URAGO on Fri, 17 Oct 2014 (MIT)
Python recipes (4591)
Keisuke URAGO's recipes (12)

Required Modules

  • (none specified)

Other Information and Tasks