def __init__(self, args=None): QtCore.QObject.__init__(self) self.app = QtGui.QApplication(["FireSim"]) self.args = args self.config = Config("data/config.json") self._selected_fixture_strand = 0 self._selected_fixture_address = 0 self._selected_fixture_pixels = 0 self.selected_fixture = None self.scene = Scene(os.path.join(self.config.get("scene_root"), self.args.scene) + ".json") self.scenecontroller = SceneController(app=self, scene=self.scene) QtDeclarative.qmlRegisterType(CanvasWidget, "FireSim", 1, 0, "SimCanvas") QtDeclarative.qmlRegisterType(FixtureWidget, "FireSim", 1, 0, "Fixture") self.view = QtDeclarative.QDeclarativeView() self.view.setWindowTitle("FireSim") self.view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) self.view.closeEvent = self.on_close self.context = self.view.rootContext() self.context.setContextProperty("main", self) self.fixture_info_list = [] self.context.setContextProperty("fixtureInfoModel", self.fixture_info_list) self.view.setSource(QtCore.QUrl("ui/qml/FireSimGUI.qml")) self.root = self.view.rootObject() self.item_frame = self.root.findChild(QtDeclarative.QDeclarativeItem) self.canvas = self.root.findChild(CanvasWidget) self.scenecontroller.set_canvas(self.canvas) cw, ch = self.scenecontroller.scene.get("extents") self.canvas.setWidth(cw) self.canvas.setHeight(ch) self.root.backdrop_showhide_callback.connect(self.on_btn_backdrop_showhide) self.root.labels_showhide_callback.connect(self.on_btn_labels_showhide) self.root.lock_callback.connect(self.on_btn_lock) self.netcontroller = NetController(self) self.canvas_timer = QtCore.QTimer(self) self.canvas_timer.timeout.connect(self.on_canvas_timer) self.view.setFixedSize(max(640, cw + 130), max(480, ch)) log.info("FireSimGUI Ready.") self.view.show() self.canvas_timer.start(300)
def main(): app = QtGui.QApplication([]) QtDeclarative.qmlRegisterType(Message, "utils", 1, 0, "Message") win = QtDeclarative.QDeclarativeView() win.setSource("main.qml") win.setWindowTitle("Hello World") win.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) win.show() app.exec_()
def main(argv): # Launch a DeclarativeView app = ButtleApp(argv) decView = QtDeclarative.QDeclarativeView() decView.setViewport(QtOpenGL.QGLWidget()) decView.setViewportUpdateMode(QtDeclarative.QDeclarativeView.FullViewportUpdate) if tuttleofx_installed: QtDeclarative.qmlRegisterType(GLViewport_tuttleofx, "Viewport", 1, 0, "GLViewport") else: QtDeclarative.qmlRegisterType(GLViewport_pil, "Viewport", 1, 0, "GLViewport") decView.setSource(os.path.join(currentFilePath, "Viewer.qml")) decView.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) decView.setWindowTitle("Viewer OpenGL") decView.show() app.exec_()
def main(argv): # Launch a DeclarativeView app = ButtleApp(argv) decView = QtDeclarative.QDeclarativeView() decView.setViewport(QtOpenGL.QGLWidget()) decView.setViewportUpdateMode( QtDeclarative.QDeclarativeView.FullViewportUpdate) if tuttleofx_installed: QtDeclarative.qmlRegisterType(GLViewport_tuttleofx, "Viewport", 1, 0, "GLViewport") else: QtDeclarative.qmlRegisterType(GLViewport_pil, "Viewport", 1, 0, "GLViewport") decView.setSource(os.path.join(currentFilePath, "Viewer.qml")) decView.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) decView.setWindowTitle("Viewer OpenGL") decView.show() app.exec_()
import sys from PySide import QtCore, QtGui, QtDeclarative import helper class TestModel(QtCore.QAbstractListModel): def __init__(self, parent=None): super(TestModel, self).__init__(parent) self._data = ["one", "two", "three"] # this _must_ crash without the fix obj = QtCore.QObject() def rowCount(self, parent=QtCore.QModelIndex()): return len(self._data) def data(self, index, role): return self._data[index.row()] if __name__ == "__main__": QtDeclarative.qmlRegisterType(TestModel, "Test", 1,0, "TestModel") app = QtGui.QApplication(sys.argv) view = QtDeclarative.QDeclarativeView() url = QtCore.QUrl.fromLocalFile(helper.adjust_filename("bug_1113.qml", __file__)) view.setSource(url) QtCore.QTimer.singleShot(70, app.quit) view.show() sys.exit(app.exec_())
from PySide import QtGui, QtDeclarative import sys import os # data from buttleofx.datas import ButtleData # undo_redo from buttleofx.core.undo_redo.manageTools import CommandManager #connections from buttleofx.gui.graph.connection import LineItem currentFilePath = os.path.dirname(os.path.abspath(__file__)) if __name__ == '__main__': QtDeclarative.qmlRegisterType(LineItem, "ConnectionLineItem", 1, 0, "ConnectionLine") app = QtGui.QApplication(sys.argv) view = QtDeclarative.QDeclarativeView() rc = view.rootContext() # create undo-redo context cmdManager = CommandManager() cmdManager.setActive() cmdManager.clean() # data buttleData = ButtleData().init(view) # expose to QML rc.setContextProperty("_buttleData", buttleData)
def main(argv): #preload Tuttle tuttle.core().preload() # give to QML acces to TimerPlayer defined in buttleofx/gui/viewer QtDeclarative.qmlRegisterType(TimerPlayer, "TimerPlayer", 1, 0, "TimerPlayer") # add new QML type QtDeclarative.qmlRegisterType(Finder, "FolderListViewItem", 1, 0, "FolderListView") if tuttleofx_installed: QtDeclarative.qmlRegisterType(GLViewport_tuttleofx, "Viewport", 1, 0, "GLViewport") else: QtDeclarative.qmlRegisterType(GLViewport_pil, "Viewport", 1, 0, "GLViewport") # init undo_redo contexts cmdManager = CommandManager() cmdManager.setActive() cmdManager.clean() # create QApplication app = ButtleApp(argv) # create the declarative view view = QtDeclarative.QDeclarativeView() view.setViewport(QtOpenGL.QGLWidget()) view.setViewportUpdateMode(QtDeclarative.QDeclarativeView.FullViewportUpdate) # data buttleData = ButtleDataSingleton().get().init(view, currentFilePath) # manager buttleManager = ButtleManagerSingleton().get().init() # event buttleEvent = ButtleEventSingleton().get() # Menus fileMenu = MenuWrapper("file", 0, view, app) editMenu = MenuWrapper("edit", 0, view, app) addMenu = MenuWrapper("buttle/", 1, view, app) # expose data to QML rc = view.rootContext() rc.setContextProperty("_buttleApp", app) rc.setContextProperty("_buttleData", buttleData) rc.setContextProperty("_buttleManager", buttleManager) rc.setContextProperty("_buttleEvent", buttleEvent) rc.setContextProperty("_fileMenu", fileMenu) rc.setContextProperty("_editMenu", editMenu) rc.setContextProperty("_addMenu", addMenu) # set the view view.setSource(os.path.join(currentFilePath, "MainWindow.qml")) view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) view.setWindowTitle("ButtleOFX") view.setWindowIcon(QtGui.QIcon("blackMosquito.png")) view.setWindowIconText("ButtleOFX") view.setVisible(True) # Declare we are using instant coding tool on this view qic = QmlInstantCoding(view, verbose=True) # Add any source file (.qml and .js by default) in current working directory qic.addFilesFromDirectory(os.getcwd(), recursive=True) #add._menu.popup(view.mapToGlobal(QtCore.QPoint(0, 0))) view.show() app.exec_()
#!/usr/bin/env python import os.path import platform import sys from PySide import QtCore as qt from PySide.QtGui import QApplication, QMainWindow from PySide import QtDeclarative as qml import imap import models on_device = platform.machine() == 'armv7l' app = QApplication(sys.argv) qml.qmlRegisterType(imap.ServiceAction, "Maily", 1, 0, "ServiceAction"); qml.qmlRegisterType(models.ConversationsModel, "Maily", 1, 0, "ConversationsModel"); view = qml.QDeclarativeView() view.setResizeMode(qml.QDeclarativeView.SizeRootObjectToView) ctx = view.rootContext() ctx.setContextProperty('ServiceActionState', dict(zip(imap.State._fields, imap.State))) ctx.engine().addImportPath('./qml-plugin') view.setSource(os.path.join(os.path.dirname(__file__), 'qml' if on_device else 'qml-desktop', 'main.qml')) window = QMainWindow() window.setCentralWidget(view)
def __init__(self, args=None): QtCore.QObject.__init__(self) self.app = QtGui.QApplication(["FireSim"]) self.args = args self.config = Config("data/config.json") if self.args.profile: try: import yappi yappi.start() except ImportError: log.error("Could not enable YaPPI profiling") self._selected_fixture_strand = 0 self._selected_fixture_address = 0 self._selected_fixture_pixels = 0 self.selected_fixture = None self.is_blurred = False self.scene = Scene(os.path.join(self.config.get("scene_root"), self.args.scene) + ".json") self.scenecontroller = SceneController(app=self, scene=self.scene) QtDeclarative.qmlRegisterType(CanvasWidget, "FireSim", 1, 0, "SimCanvas") QtDeclarative.qmlRegisterType(FixtureWidget, "FireSim", 1, 0, "Fixture") self.view = QtDeclarative.QDeclarativeView() self.view.setWindowTitle("FireSim") self.view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) self.view.closeEvent = self.on_close self.context = self.view.rootContext() self.context.setContextProperty('main', self) self.fixture_info_list = [] self.context.setContextProperty('fixtureInfoModel', self.fixture_info_list) self.view.setSource(QtCore.QUrl('ui/qml/FireSimGUI.qml')) self.root = self.view.rootObject() self.item_frame = self.root.findChild(QtDeclarative.QDeclarativeItem) self.canvas = self.root.findChild(CanvasWidget) self.canvas.gui = self cw, ch = self.scenecontroller.scene.extents() self.canvas.setWidth(cw) self.canvas.setHeight(ch) self.scenecontroller.set_canvas(self.canvas) self.root.backdrop_showhide_callback.connect(self.on_btn_backdrop_showhide) self.root.labels_showhide_callback.connect(self.on_btn_labels_showhide) self.root.lock_callback.connect(self.on_btn_lock) self.root.show_center_callback.connect(self.on_btn_show_center) self.root.toggle_blurred_callback.connect(self.on_btn_toggle_blurred) #self.net_thread = QtCore.QThread() #self.net_thread.start() self.netcontroller = NetController(self) #self.netcontroller.moveToThread(self.net_thread) #self.netcontroller.start.emit() self.net_stats_timer = QtCore.QTimer() self.net_stats_timer.setInterval(1000) self.net_stats_timer.timeout.connect(self.update_net_stats) self.net_stats_timer.start() self.netcontroller.data_received.connect(self.on_network_event) self.scenecontroller.new_frame.connect(self.netcontroller.frame_complete) self.netcontroller.data_received.connect(self.scenecontroller.process_command) self.view.setFixedSize(max(640, cw + 130), max(480, ch)) log.info("FireSimGUI Ready.") self.view.show()
def __init__(self, args=None): QtCore.QObject.__init__(self) self.app = QtGui.QApplication(["FireSim"]) self.args = args self.config = Config("data/config.json") self._selected_fixture_strand = 0 self._selected_fixture_address = 0 self._selected_fixture_pixels = 0 self.selected_fixture = None self.scene = Scene(os.path.join(self.config.get("scene_root"), self.args.scene) + ".json") self.scenecontroller = SceneController(app=self, scene=self.scene) QtDeclarative.qmlRegisterType(CanvasWidget, "FireSim", 1, 0, "SimCanvas") QtDeclarative.qmlRegisterType(FixtureWidget, "FireSim", 1, 0, "Fixture") self.view = QtDeclarative.QDeclarativeView() format = QtOpenGL.QGLFormat(QtOpenGL.QGL.DirectRendering) glwidget = QtOpenGL.QGLWidget(format) glwidget.setAutoFillBackground(False) self.view.setViewport(glwidget) self.view.setWindowTitle("FireSim") self.view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) self.view.closeEvent = self.on_close self.context = self.view.rootContext() self.context.setContextProperty('main', self) self.fixture_info_list = [] self.context.setContextProperty('fixtureInfoModel', self.fixture_info_list) self.view.setSource(QtCore.QUrl('ui/qml/FireSimGUI.qml')) self.root = self.view.rootObject() self.item_frame = self.root.findChild(QtDeclarative.QDeclarativeItem) self.canvas = self.root.findChild(CanvasWidget) self.scenecontroller.set_canvas(self.canvas) cw, ch = self.scenecontroller.scene.extents() self.canvas.setWidth(cw) self.canvas.setHeight(ch) self.root.backdrop_showhide_callback.connect(self.on_btn_backdrop_showhide) self.root.labels_showhide_callback.connect(self.on_btn_labels_showhide) self.root.lock_callback.connect(self.on_btn_lock) self.root.show_center_callback.connect(self.on_btn_show_center) self.netcontroller = NetController(self) self.ups_timer = QtCore.QTimer() self.ups_timer.setInterval(1000) self.ups_timer.timeout.connect(self.update_ups) self.ups_timer.start() self.netcontroller.data_received.connect(self.on_network_event) self.view.setFixedSize(max(640, cw + 130), max(480, ch)) log.info("FireSimGUI Ready.") self.view.show()
def __init__(self, args=None): QtCore.QObject.__init__(self) self.app = QtGui.QApplication(["FireSim"]) self.args = args self.config = Config("data/config.json") if self.args.profile: try: import yappi yappi.start() except ImportError: log.error("Could not enable YaPPI profiling") self._selected_fixture_strand = 0 self._selected_fixture_address = 0 self._selected_fixture_pixels = 0 self.selected_fixture = None self.is_blurred = False self.scene = Scene( os.path.join(self.config.get("scene_root"), self.args.scene) + ".json") self.scenecontroller = SceneController(app=self, scene=self.scene) QtDeclarative.qmlRegisterType(CanvasWidget, "FireSim", 1, 0, "SimCanvas") QtDeclarative.qmlRegisterType(FixtureWidget, "FireSim", 1, 0, "Fixture") self.view = QtDeclarative.QDeclarativeView() self.view.setWindowTitle("FireSim") self.view.setResizeMode( QtDeclarative.QDeclarativeView.SizeRootObjectToView) self.view.closeEvent = self.on_close self.context = self.view.rootContext() self.context.setContextProperty('main', self) self.fixture_info_list = [] self.context.setContextProperty('fixtureInfoModel', self.fixture_info_list) self.view.setSource(QtCore.QUrl('ui/qml/FireSimGUI.qml')) self.root = self.view.rootObject() self.item_frame = self.root.findChild(QtDeclarative.QDeclarativeItem) self.canvas = self.root.findChild(CanvasWidget) self.canvas.gui = self cw, ch = self.scenecontroller.scene.extents() self.canvas.setWidth(cw) self.canvas.setHeight(ch) self.scenecontroller.set_canvas(self.canvas) self.root.backdrop_showhide_callback.connect( self.on_btn_backdrop_showhide) self.root.labels_showhide_callback.connect(self.on_btn_labels_showhide) self.root.lock_callback.connect(self.on_btn_lock) self.root.show_center_callback.connect(self.on_btn_show_center) self.root.toggle_blurred_callback.connect(self.on_btn_toggle_blurred) #self.net_thread = QtCore.QThread() #self.net_thread.start() self.netcontroller = NetController(self) #self.netcontroller.moveToThread(self.net_thread) #self.netcontroller.start.emit() self.net_stats_timer = QtCore.QTimer() self.net_stats_timer.setInterval(1000) self.net_stats_timer.timeout.connect(self.update_net_stats) self.net_stats_timer.start() self.netcontroller.data_received.connect(self.on_network_event) self.scenecontroller.new_frame.connect( self.netcontroller.frame_complete) self.netcontroller.data_received.connect( self.scenecontroller.process_command) self.view.setFixedSize(max(640, cw + 130), max(480, ch)) log.info("FireSimGUI Ready.") self.view.show()
from PySide import QtGui, QtDeclarative import sys import os # data from buttleofx.datas import ButtleData # undo_redo from buttleofx.core.undo_redo.manageTools import CommandManager #connections from buttleofx.gui.graph.connection import LineItem currentFilePath = os.path.dirname(os.path.abspath(__file__)) if __name__ == '__main__': QtDeclarative.qmlRegisterType(LineItem, "ConnectionLineItem", 1, 0, "ConnectionLine") app = QtGui.QApplication(sys.argv) view = QtDeclarative.QDeclarativeView() rc = view.rootContext() # create undo-redo context cmdManager = CommandManager() cmdManager.setActive() cmdManager.clean() # data buttleData = ButtleData().init(view) # expose to QML rc.setContextProperty("_buttleData", buttleData)
''' Created on 2012/11/06 @author: unseon_pro ''' ''' Created on 2012/11/01 @author: unseon_pro ''' import sys from PySide.QtCore import * from PySide.QtGui import QApplication, QWidget from PySide import QtDeclarative from QmlGameFrame import QmlGameFrame from BehaviorController import BehaviorController QtDeclarative.qmlRegisterType(BehaviorController, "engine", 1, 0, "BehaviorController") # Create Qt application and the QDeclarative view app = QApplication(sys.argv) view = QmlGameFrame() view.resize(400, 500) view.show() # Enter Qt main loop sys.exit(app.exec_())