QIcon( os.path.join( os.path.dirname(__file__), "../../../data/icons/scalable/apps/softwarecenter.svg"))) view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) # if running locally, fixup softwarecenter.paths mangle_paths_if_running_in_local_checkout() # ideally this should be part of the qml by using a qmlRegisterType() # but that does not seem to be supported in pyqt yet(?) so we need # to cowboy it in here pkglistmodel = PkgListModel() reviewslistmodel = ReviewsListModel() categoriesmodel = CategoriesModel() rc = view.rootContext() rc.setContextProperty('pkglistmodel', pkglistmodel) rc.setContextProperty('reviewslistmodel', reviewslistmodel) rc.setContextProperty('categoriesmodel', categoriesmodel) # debug if len(sys.argv) > 1: # FIXME: we really should set the text entry here pkglistmodel.setSearchQuery(sys.argv[1]) # load the main QML file into the view qmlpath = os.path.join(os.path.dirname(__file__), "sc.qml") view.setSource(QUrl.fromLocalFile(qmlpath)) # show it view.show()
from PyQt4.QtCore import QUrl from PyQt4.QtGui import QPushButton, QApplication from PyQt4.QtDeclarative import QDeclarativeView # This example uses a QML file to show a scrolling list containing # all the items listed into dataList. dataList = ["Item 1", "Item 2", "Item 3", "Item 4"] app = QApplication([]) view = QDeclarativeView() ctxt = view.rootContext() ctxt.setContextProperty("myModel", dataList) url = QUrl( 'view.qml' ) # <-- Problem seems to be here, the file gets copied correctly to Resources folder view.setSource(url) view.show() app.exec_()
from PyQt4.QtCore import QDateTime, QObject, QUrl, pyqtSignal from PyQt4.QtGui import QApplication, QGraphicsColorizeEffect, QColor from PyQt4.QtDeclarative import QDeclarativeView from triangle import * from weather import * def upArrowClicked(): print 'Testing!' app = QApplication(sys.argv) # Create the QML user interface. view = QDeclarativeView() view.rootContext().setContextProperty("dp", 1) view.setSource(QUrl('qml/nest.qml')) view.setResizeMode(QDeclarativeView.SizeViewToRootObject) rootObject = view.rootObject() upArrow = rootObject.findChild(QObject, 'upArrow') up = Triangle(upArrow) downArrow = rootObject.findChild(QObject, 'downArrow') down = Triangle(downArrow) weatherView = rootObject.findChild(QObject, 'weatherView') weather = Weather(weatherView) weather.start()
from PyQt4.QtCore import QUrl from PyQt4.QtGui import QPushButton, QApplication from PyQt4.QtDeclarative import QDeclarativeView # This example uses a QML file to show a scrolling list containing # all the items listed into dataList. dataList = ["Item 1", "Item 2", "Item 3", "Item 4"] app = QApplication([]) view = QDeclarativeView() ctxt = view.rootContext() ctxt.setContextProperty("myModel", dataList) url = QUrl('view.qml') # <-- Problem seems to be here, the file gets copied correctly to Resources folder view.setSource(url) view.show() app.exec_()
return unicode(cat.name, "utf8", "ignore") elif role == "_iconname": # funny, but it appears like Qt does not have something # to lookup the icon path in QIcon icons = Gtk.IconTheme.get_default() info = icons.lookup_icon(cat.iconname, 48, 0) if info: return info.get_filename() return "" if __name__ == "__main__": from PyQt4.QtGui import QApplication from PyQt4.QtDeclarative import QDeclarativeView import sys app = QApplication(sys.argv) app.cache = get_pkg_info() app.cache.open() view = QDeclarativeView() categoriesmodel = CategoriesModel() rc = view.rootContext() rc.setContextProperty('categoriesmodel', categoriesmodel) # load the main QML file into the view qmlpath = os.path.join(os.path.dirname(__file__), "CategoriesView.qml") view.setSource(qmlpath) # show it view.show() sys.exit(app.exec_())