def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("KhtNotes") self.settings = Settings() self.view = FilteredDeclarativeView(settings=self.settings) if os.path.exists('/etc/mer-release'): fullscreen = True elif os.path.exists('/etc/aegis'): fullscreen = True self.glformat = QGLFormat().defaultFormat() self.glformat.setSampleBuffers(False) self.glw = QGLWidget(self.glformat) self.glw.setAutoFillBackground(False) self.view.setViewport(self.glw) else: fullscreen = False self.notesModel = NotesModel() self.note = Note(settings=self.settings) self.conboyImporter = TomboyImporter() self.syncer = Sync() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty("__upgrade__", __upgrade__ .replace('\n', '<br />')) self.rootContext.setContextProperty("Settings", self.settings) self.rootContext.setContextProperty("Sync", self.syncer) self.rootContext.setContextProperty("Importer", self.conboyImporter) self.rootContext.setContextProperty('notesModel', self.notesModel) self.rootContext.setContextProperty('Note', self.note) try: self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'Harmattan_main.qml'))) except: self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'Desktop_main.qml'))) self.rootObject = self.view.rootObject() if fullscreen: self.view.showFullScreen() else: self.view.show() self.note.on_error.connect(self.rootObject.onError) self.syncer.on_error.connect(self.rootObject.onError) self.syncer.on_finished.connect(self.rootObject.refresh) self.conboyImporter.on_finished.connect(self.notesModel.reload)
def serve_forever(self): self.jid = 'Err@localhost' self.connect() # be sure we are "connected" before the first command self.connect_callback() # notify that the connection occured # create window and components app = QtGui.QApplication(sys.argv) self.mainW = QtGui.QWidget() self.mainW.setWindowTitle('Err...') icon_path = os.path.dirname(errbot.__file__) + os.sep + 'err.svg' bg_path = os.path.dirname(errbot.__file__) + os.sep + 'err-bg.svg' self.mainW.setWindowIcon(QtGui.QIcon(icon_path)) vbox = QtGui.QVBoxLayout() help = QtGui.QLabel( "CTRL+Space to autocomplete -- CTRL+Enter to send your message") self.input = CommandBox(self.cmd_history, self.commands) self.output = QtWebKit.QWebView() # init webpage self.buffer = """<html> <head> <link rel="stylesheet" type="text/css" href="%s/style/style.css" /> </head> <body style=" background-image: url('%s'); background-repeat: no-repeat; background-position:center center; background-attachment:fixed; background-size: contain; margin:0;"> """ % (QUrl.fromLocalFile(BOT_DATA_DIR).toString(), QUrl.fromLocalFile(bg_path).toString()) self.output.setHtml(self.buffer) # layout vbox.addWidget(self.output) vbox.addWidget(self.input) vbox.addWidget(help) self.mainW.setLayout(vbox) # setup web view to open liks in external browser self.output.page().setLinkDelegationPolicy( QtWebKit.QWebPage.DelegateAllLinks) # connect signals/slots self.output.page().mainFrame().contentsSizeChanged.connect( self.scroll_output_to_bottom) self.output.page().linkClicked.connect(QtGui.QDesktopServices.openUrl) self.input.newCommand.connect(self.send_command) self.conn.newAnswer.connect(self.new_message) self.mainW.show() try: app.exec_() finally: self.disconnect_callback() self.shutdown() exit(0)
def serve_forever(self): self.jid = 'Err@localhost' self.connect() # be sure we are "connected" before the first command self.connect_callback() # notify that the connection occured # create window and components app = QtGui.QApplication(sys.argv) self.mainW = QtGui.QWidget() self.mainW.setWindowTitle('Err...') icon_path = os.path.dirname(errbot.__file__) + os.sep + 'err.svg' bg_path = os.path.dirname(errbot.__file__) + os.sep + 'err-bg.svg' self.mainW.setWindowIcon(QtGui.QIcon(icon_path)) vbox = QtGui.QVBoxLayout() help = QtGui.QLabel("CTRL+Space to autocomplete -- CTRL+Enter to send your message") self.input = CommandBox(self.cmd_history, self.commands) self.output = QtWebKit.QWebView() # init webpage self.buffer = """<html> <head> <link rel="stylesheet" type="text/css" href="%s/style/style.css" /> </head> <body style=" background-image: url('%s'); background-repeat: no-repeat; background-position:center center; background-attachment:fixed; background-size: contain; margin:0;"> """ % (QUrl.fromLocalFile(BOT_DATA_DIR).toString(), QUrl.fromLocalFile(bg_path).toString()) self.output.setHtml(self.buffer) # layout vbox.addWidget(self.output) vbox.addWidget(self.input) vbox.addWidget(help) self.mainW.setLayout(vbox) # setup web view to open liks in external browser self.output.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) # connect signals/slots self.output.page().mainFrame().contentsSizeChanged.connect(self.scroll_output_to_bottom) self.output.page().linkClicked.connect(QtGui.QDesktopServices.openUrl) self.input.newCommand.connect(self.send_command) self.conn.newAnswer.connect(self.new_message) self.mainW.show() try: app.exec_() finally: self.disconnect_callback() self.shutdown() exit(0)
def testMetaData(self): self.view = QWebView() QObject.connect(self.view, SIGNAL('loadFinished(bool)'), self.load_finished) url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) self.view.setUrl(url) self.app.exec_()
def parseMarkdown(self): """ Parse the Markdown stuff. """ self.updateStructure() if self.sync is False: return y = self.web.page().mainFrame().scrollPosition().y() txt = self.editor.toPlainText().encode('utf-8') if txt is '' or None: return p = Popen([self.parser], stdout=PIPE, stdin=PIPE, stderr=STDOUT, shell=False) grep_stdout = p.communicate(input=txt)[0].decode('utf-8') path = QUrl.fromUserInput(os.getcwd() + os.sep) grep_stdout = grep_stdout.replace('img src=\"', 'img src=\"' + path.toString()) # Can't use baseUrl=path because external img will not be loaded # than :-/ self.web.setHtml(grep_stdout) self.web.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(os.getcwd() + os.sep + "/style.css")) if y: self.web.scroll(0, y) self.web.page().mainFrame().scroll(0, y) self.web.page().mainFrame().setScrollPosition(QPoint(0, y))
def testAbstractItemModelTransferToQML(self): view = QDeclarativeView() view.setSource(QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__))) root = view.rootObject() model = ListModel() root.setProperty('model', model) view.show()
def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("KhtSimpleText") self.view = QtDeclarative.QDeclarativeView() #Are we on mer ? So don't use opengl #As it didn't works on all devices if not os.path.exists('/etc/mer-release'): self.glformat = QGLFormat().defaultFormat() self.glformat.setSampleBuffers(False) self.glw = QGLWidget(self.glformat) self.glw.setAutoFillBackground(False) self.view.setViewport(self.glw) self.document = Document('~') self.documentsModel= DocumentsModel(currentDoc=self.document) self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty("__upgrade__", __upgrade__ .replace('\n', '<br>')) self.rootContext.setContextProperty("Settings", Settings()) self.rootContext.setContextProperty("DocumentsModel", self.documentsModel) self.rootContext.setContextProperty("Document", self.document) self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'main.qml'))) self.rootObject = self.view.rootObject() self.view.showFullScreen()
def parseMarkdown(self): """ Parse the Markdown stuff. """ self.updateStructure() if self.sync is False: return y = self.web.page().mainFrame().scrollPosition().y() txt = self.editor.toPlainText().encode('utf-8') if txt is '' or None: return p = Popen([self.parser], stdout=PIPE, stdin=PIPE, stderr=STDOUT, shell=False) grep_stdout = p.communicate(input=txt)[0].decode('utf-8') path = QUrl.fromUserInput(os.getcwd() + os.sep) grep_stdout = grep_stdout.replace('img src=\"', 'img src=\"' + path.toString()) # Can't use baseUrl=path because external img will not be loaded # than :-/ self.web.setHtml(grep_stdout) self.web.settings().setUserStyleSheetUrl( QUrl.fromLocalFile(os.getcwd() + os.sep + "/style.css")) if y: self.web.scroll(0, y) self.web.page().mainFrame().scroll(0, y) self.web.page().mainFrame().setScrollPosition(QPoint(0, y))
def image_url(name): """ @param name str id @return QUrl not None @throw KeyError when unknown name """ return QUrl.fromLocalFile(os.path.abspath(image_path(name)))
def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("KhtNotes") self.view = QtDeclarative.QDeclarativeView() self.glw = QGLWidget() self.view.setViewport(self.glw) self.notesModel = NotesModel() self.note = Note() self.conboyImporter = TomboyImporter() self.syncer = Sync() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty("__upgrade__", __upgrade__ .replace('\n', '<br>')) self.rootContext.setContextProperty("Settings", Settings()) self.rootContext.setContextProperty("Sync", self.syncer) self.rootContext.setContextProperty("Importer", self.conboyImporter) self.rootContext.setContextProperty("QmlDirReaderWriter", QmlDirReaderWriter()) self.rootContext.setContextProperty('notesModel', self.notesModel) self.rootContext.setContextProperty('Note', self.note) self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'Harmattan_main.qml'))) self.rootObject = self.view.rootObject() self.view.showFullScreen() self.note.on_error.connect(self.rootObject.onError) self.syncer.on_error.connect(self.rootObject.onError) self.syncer.on_finished.connect(self.notesModel.reload) self.conboyImporter.on_finished.connect(self.notesModel.reload)
def qml_url(name): """ @param name unicode @return QUrl @throw KeyError when unknown name """ return QUrl.fromLocalFile(config.QML_LOCATIONS[name])
def testAbstractItemModelTransferToQML(self): view = QDeclarativeView() view.setSource( QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__))) root = view.rootObject() model = ListModel() root.setProperty('model', model) view.show()
def testSignalEmission(self): qmlRegisterType(MyItem, "my.item", 1, 0, "MyItem") view = QDeclarativeView() view.setSource(QUrl.fromLocalFile(adjust_filename('bug_951.qml', __file__))) self.app.exec_() self.assertTrue(MyItem.COMPONENT_COMPLETE_CALLED)
def iconName(self): if 'Icon' in self._prop.keys(): icon_name = './qml/icons/%s.png' % self._prop['Icon'] if not os.path.exists(icon_name): icon_name = './qml/icons/unknow.png' else: icon_name = './qml/icons/unknow.png' return QUrl.fromLocalFile(icon_name)
def testQDeclarativeNetworkFactory(self): view = QDeclarativeView() url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__)) view.setSource(url) view.show() self.assertEqual(view.status(), QDeclarativeView.Ready) self.app.exec_()
def __init__(self, parent=None): super(MainLogic, self).__init__(parent) self.setWindowTitle("RDA") # Renders given file self.setSource(QUrl.fromLocalFile("gui/main.qml")) # QML resizes to main window self.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.rootContext().setContextProperty("Logic", self) self.connected = False # get an instance of the network client self.net = Client()
def drawMap(self): #======================================================================= # with open("sweattrails/qt/maps.html") as fd: # html = fd.read() # templ = string.Template(html) # html = templ.substitute( # bgcolor = "#343434", # fgcolor = "#FFFFFF", # mapskey = gripe.Config.app["config"].google_api_key) #======================================================================= self.setUrl(QUrl.fromLocalFile(os.path.join(gripe.root_dir(), "sweattrails/qt/maps.html")))
def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("BitPurse") self.view = QtDeclarative.QDeclarativeView() # Are we on mer ? So don't use opengl # As it didn't works on all devices if os.path.exists('/etc/mer-release'): fullscreen = True elif os.path.exists('/etc/aegis'): fullscreen = True self.glformat = QGLFormat().defaultFormat() self.glformat.setSampleBuffers(False) self.glw = QGLWidget(self.glformat) self.glw.setAutoFillBackground(False) self.view.setViewport(self.glw) else: fullscreen = False self.walletController = WalletController() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty("__upgrade__", __upgrade__ .replace('\n', '<br />')) self.rootContext.setContextProperty('WalletController', self.walletController) self.rootContext.setContextProperty('AddressesModel', self.walletController .addressesModel) self.rootContext.setContextProperty('TransactionsModel', self.walletController .transactionsModel) self.rootContext.setContextProperty('Settings', self.walletController .settings) self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'main.qml'))) self.rootObject = self.view.rootObject() if fullscreen: self.view.showFullScreen() else: self.view.show() # self.loginPage = self.rootObject.findChild(QObject, "loginPage") self.sendPage = self.rootObject.findChild(QObject, "sendPage") self.aboutPage = self.rootObject.findChild(QObject, "aboutPage") self.walletController.onError.connect(self.rootObject.onError) # self.walletController.onConnected.connect(self.loginPage.onConnected) self.walletController.onTxSent.connect(self.sendPage.onTxSent)
def changePage(self, page): if isinstance(page, QUrl) and not page.scheme(): page = page.toString() if isinstance(page, str): url = QUrl.fromLocalFile(Lib.get_path(os.path.join("doc", page))) else: url = page if not url.isLocalFile(): webbrowser.open(url.toString()) return self.browser.setUrl(url)
def testModelExport(self): view = QDeclarativeView() dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")] ctxt = view.rootContext() ctxt.setContextProperty("myModel", dataList) url = QUrl.fromLocalFile(adjust_filename("viewmodel.qml", __file__)) view.setSource(url) view.show() self.assertEqual(view.status(), QDeclarativeView.Ready)
def __init__(self, filename): QMainWindow.__init__(self) self.playButton = QPushButton('Play!') self.source = QUrl.fromLocalFile(filename) self.player = QMediaPlayer() self.player.setMedia(self.source) self.playButton.clicked.connect(self.play) self.setCentralWidget(self.playButton) self.playButton.show()
def createQmlComponent(filename, engine, context, parent=None): # Load the QML UI (this could take a while...) qcomponent = QDeclarativeComponent( engine, QUrl.fromLocalFile(QML(filename)), parent ) qobject = qcomponent.create(context) error = qcomponent.errorString() if len(error) > 0: print('Error while loading QML file: ' + error) return QmlGuiComponent(qobject, qcomponent)
def testQDeclarativeViewList(self): view = QDeclarativeView() dataList = ["Item 1", "Item 2", "Item 3", "Item 4"] ctxt = view.rootContext() ctxt.setContextProperty("myModel", dataList) url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__)) view.setSource(url) view.show() self.assertEqual(view.status(), QDeclarativeView.Ready)
def newMessage(self,jid,contactName,message,picture=None,callback=False): activeConvJId = self.ui.getActiveConversation() max_len = min(len(message),20) if self.enabled: if(activeConvJId == jid or activeConvJId == ""): if self.vibra: self.vibra.start() return n = MNotification("wazapp.message.new",contactName, message); n.image = picture n.manager = self.manager; action = lambda: self.notificationCallback(jid) n.setAction(action); notifications = n.notifications(); if self.notifications.has_key(jid): nId = self.notifications[jid]['id']; for notify in notifications: if int(notify[0]) == nId: n.id = nId break if n.id != nId: del self.notifications[jid] if(n.publish()): nId = n.id; self.saveNotification(jid,{"id":nId,"callback":callback}); #if self.vibra: # self.vibra.start() if self.audio: soundPath = self.getCurrentSoundPath(); self._d(soundPath) self.audio.setMedia(QUrl.fromLocalFile(soundPath)); self.audio.play();
def newMessage(self,jid,contactName,message,picture=None,callback=False): activeConvJId = self.ui.getActiveConversation() max_len = min(len(message),20) if self.enabled: if(activeConvJId == jid or activeConvJId == ""): if self.vibra: self.vibra.start() return n = MNotification("wazapp.message.new",contactName, message); n.image = picture n.manager = self.manager; action = lambda: self.notificationCallback(jid) n.setAction(action); notifications = n.notifications(); if self.notifications.has_key(jid): nId = self.notifications[jid]['id']; for notify in notifications: if int(notify[0]) == nId: n.id = nId break if n.id != nId: del self.notifications[jid] if(n.publish()): nId = n.id; self.saveNotification(jid,{"id":nId,"callback":callback}); #if self.vibra: # self.vibra.start() if self.audio: soundPath = self.getCurrentSoundPath(); print soundPath self.audio.setMedia(QUrl.fromLocalFile(soundPath)); self.audio.play();
def generateHtml(self): doc = urlopen('http://news.ycombinator.com/') unicode_string = doc.read().decode('utf-8') e = etree.fromstring(unicode_string, etree.HTMLParser()) entries = [] for i in e.xpath('//td/a'): if len(i.getparent().keys()) == 1 and i.getparent().values()[0] == 'title': if isinstance(i.text, str): u_s = i.text.decode('utf-8') else: u_s = i.text if u_s == u'More': continue entry = dict() entry['site'] = u'' entry['comments_url'] = u'' entry['comments_count'] = u'' entry['story_link'] = u_s entry['story_url'] = i.get('href').decode('utf-8') span_tag = i.getnext() #may be None if 'Ask HN' if not span_tag is None: entry['site'] = span_tag.text.decode('utf-8').strip() tr_subtext = i.getparent().getparent().getnext() if not tr_subtext is None: d = self.processSubtexttr(tr_subtext) entry['timestamp'] = d['timestamp'] if 'comments_url' in d: entry['comments_url'] = d['comments_url'] if 'comments_count' in d: entry['comments_count'] = d['comments_count'] entries.append(entry) template_file = QUrl.fromLocalFile('template.html') template = Template( filename=template_file.path() ) return template.render_unicode(rows=entries)
def __init__(self, gui_queue, worker_queue, parent=None): super(MainWindow, self).__init__(parent) self.queue = gui_queue self.worker_queue = worker_queue self.setWindowTitle('Main Window') self.setSource(QUrl.fromLocalFile('main.qml')) self.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.timer = QTimer(self) self.timer.timeout.connect(self.on_timer) self.timer.start(30)
def __init__(self, parent=None): platform = 'common' platform = 'desktop' src = 'qml/redak/' + platform + '/main.qml' super(Redak, self).__init__(parent) self.setWindowTitle(__package__) self.setSource(QUrl.fromLocalFile(src)) self.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.setGeometry(200, 200, 400, 400) # self.showFullScreen() root = self.rootObject() root.quit.connect(self.quit) root.test.connect(self.test) self.rootContext().setContextProperty("parentCore", self) print "http://bugs.pyside.org/show_bug.cgi?id=1000"
def __init__(self, parent=None): platform = 'common' platform = 'desktop' src = 'qml/redak/' + platform + '/main.qml' super(Redak, self).__init__(parent) self.setWindowTitle(__package__) self.setSource(QUrl.fromLocalFile(src)) self.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.setGeometry(200, 200, 400, 400) # self.showFullScreen() root = self.rootObject() root.quit.connect( self.quit ) root.test.connect( self.test ) self.rootContext().setContextProperty("parentCore", self); print "http://bugs.pyside.org/show_bug.cgi?id=1000"
def __init__(self): QMainWindow.__init__(self, parent=None) self.view = QtDeclarative.QDeclarativeView() #For unknow reason, gl rendering didn't work on my installation #self.glw = QGLWidget() #self.view.setViewport(self.glw) self.pagesModel = PagesModel() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty('PagesModel', self.pagesModel) self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'View.qml'))) self.setCentralWidget(self.view)
def convert_html_to_pdf(source, destination, page_size=QPrinter.Letter, print_format=QPrinter.PdfFormat, timeout=10000, app=None): """Converts an .html file at the source to a .pdf at the destination Any external files linked in the source file must be paths relative to the location of the source file itself. If building the html file dynamically, the rel_path function can be used to create proper relative paths using the .html location as the source location. The conversion is done using th ability of a QPrinter to print a QWebView to a PDF. This means we must have some Qt bindings, either PySide (default) or PyQt4 (5 support incoming?), but then are only limited by what the QWebView can display. While the intent is so print to a PDF, the format parameter is exposed so that this can be used to print directly to a printer or (if >=Qt4.2) PostScript format. If this is being used in a larger QApplication, we should only have one instance of QApplication, so pass the existing instance to the `app` parameter. """ if app is None: app = QApplication(sys.argv) view = QWebView() # We want to ensure the page was fully loaded before printing, so # we wait for the loadFinished event to fire. with wait_for_signal(view.loadFinished, timeout=timeout): # QUrl requires absolute path names view.load(QUrl.fromLocalFile(os.path.abspath(source))) # With the QWebView loaded, we now print to the destination PDF printer = QPrinter() printer.setPageSize(page_size) printer.setOutputFormat(print_format) printer.setOutputFileName(destination) view.print_(printer) # Exit the application app.exit()
def convert_html_to_pdf( source, destination, page_size=QPrinter.Letter, print_format=QPrinter.PdfFormat, timeout=10000, app=None): """Converts an .html file at the source to a .pdf at the destination Any external files linked in the source file must be paths relative to the location of the source file itself. If building the html file dynamically, the rel_path function can be used to create proper relative paths using the .html location as the source location. The conversion is done using th ability of a QPrinter to print a QWebView to a PDF. This means we must have some Qt bindings, either PySide (default) or PyQt4 (5 support incoming?), but then are only limited by what the QWebView can display. While the intent is so print to a PDF, the format parameter is exposed so that this can be used to print directly to a printer or (if >=Qt4.2) PostScript format. If this is being used in a larger QApplication, we should only have one instance of QApplication, so pass the existing instance to the `app` parameter. """ if app is None: app = QApplication(sys.argv) view = QWebView() # We want to ensure the page was fully loaded before printing, so # we wait for the loadFinished event to fire. with wait_for_signal(view.loadFinished, timeout=timeout): # QUrl requires absolute path names view.load(QUrl.fromLocalFile(os.path.abspath(source))) # With the QWebView loaded, we now print to the destination PDF printer = QPrinter() printer.setPageSize(page_size) printer.setOutputFormat(print_format) printer.setOutputFileName(destination) view.print_(printer) # Exit the application app.exit()
def main(): QApplication.setGraphicsSystem('raster') app = QApplication([]) bug = Bugzilla() # Register PieChart components registerComponents() view = FullScreenSwitcherView() view.setResizeMode(QDeclarativeView.SizeRootObjectToView) view.rootContext().setContextProperty('bugmodel', bug) view.setSource(QUrl.fromLocalFile('./qml/Board.qml')) timer = QTimer() timer.timeout.connect(bug.update) timer.start(1000 * 60 * 10) view.showFullScreen() app.exec_()
def main(): QApplication.setOrganizationName('OpenBossa') QApplication.setApplicationName('mobtrans') QApplication.setGraphicsSystem('raster') app = QApplication([]) serverConfig = ServerConfig() server = Server(serverConfig) model = TorrentModel(server) searchModel = SearchModel() view = QDeclarativeView() #view.setMinimumSize(800, 600) view.setResizeMode(QDeclarativeView.SizeRootObjectToView) view.rootContext().setContextProperty('server', server) view.rootContext().setContextProperty('torrentModel', model) view.rootContext().setContextProperty('searchModel', searchModel) view.setSource(QUrl.fromLocalFile('./qml/main.qml')) view.show() app.exec_()
def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("KhtBMA") self.view = QtDeclarative.QDeclarativeView() self.glw = QGLWidget() self.view.setViewport(self.glw) self.auth = Authenticator() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty('Authenticator',self.auth) self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'main.qml'))) self.rootObject = self.view.rootObject() self.auth.on_error.connect(self.rootObject.onError) self.view.showFullScreen()
def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("Wleux") self.view = QtDeclarative.QDeclarativeView() self.glw = QGLWidget() self.view.setViewport(self.glw) self.wallpapersModel = WallpapersModel() self.wallpaper = Wallpaper() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty('wallpapersModel', self.wallpapersModel) self.rootContext.setContextProperty('wallpaper', self.wallpaper) self.view.setSource(QUrl.fromLocalFile( \ os.path.join(os.path.dirname(__file__), 'qml', 'main.qml'))) self.rootObject = self.view.rootObject() self.view.showFullScreen() self.wallpapersModel.on_error.connect(self.rootObject.onError)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setWindowTitle("Title on Main Window") # Renders 'view.qml' self.setSource(QUrl.fromLocalFile('view.qml')) # QML resizes to main window self.setResizeMode(QDeclarativeView.SizeRootObjectToView) con = Console() rotatevalue = RotateValue() context = self.rootContext() context.setContextProperty('con', con) context.setContextProperty('rotatevalue', rotatevalue) root = self.rootObject() root.textRotationChanged.connect(self.rotationStatus) button = root.findChild(QObject, 'btnMouseArea') button.clicked.connect(lambda: con.outputStr('click button')) self.timer = QTimer() self.timer.start(2000) self.timer.timeout.connect(root.updateRotater)
def __init__(self, args, gpodder_core, dbus_bus_name): QObject.__init__(self) self.dbus_bus_name = dbus_bus_name # TODO: Expose the same D-Bus API as the Gtk UI D-Bus object (/gui) # TODO: Create a gpodder.dbusproxy.DBusPodcastsProxy object (/podcasts) self.app = QApplication(args) signal.signal(signal.SIGINT, signal.SIG_DFL) self.quit.connect(self.on_quit) self.episodeUpdated.connect(self.on_episode_updated) self.setEpisodeListModel.connect(self.on_set_episode_list_model) self.core = gpodder_core self.config = self.core.config self.db = self.core.db self.model = self.core.model self.config_proxy = ConfigProxy(self.config) # Initialize the gpodder.net client self.mygpo_client = my.MygPoClient(self.config) gpodder.user_extensions.on_ui_initialized( self.model, self.extensions_podcast_update_cb, self.extensions_episode_download_cb) self.view = DeclarativeView() self.view.closing.connect(self.on_quit) self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.controller = Controller(self) self.media_buttons_handler = helper.MediaButtonsHandler() self.tracker_miner_config = helper.TrackerMinerConfig() self.podcast_model = gPodderPodcastListModel() self.episode_model = gPodderEpisodeListModel(self.config, self) self.last_episode = None # A dictionary of episodes that are currently active # in some way (i.e. playing back or downloading) self.active_episode_wrappers = {} engine = self.view.engine() # Add the cover art image provider self.cover_provider = images.LocalCachedImageProvider() engine.addImageProvider('cover', self.cover_provider) root_context = self.view.rootContext() root_context.setContextProperty('controller', self.controller) root_context.setContextProperty('configProxy', self.config_proxy) root_context.setContextProperty('mediaButtonsHandler', self.media_buttons_handler) root_context.setContextProperty('trackerMinerConfig', self.tracker_miner_config) # Load the QML UI (this could take a while...) self.view.setSource(QUrl.fromLocalFile(QML('main_default.qml'))) # Proxy to the "main" QML object for direct access to Qt Properties self.main = helper.QObjectProxy( self.view.rootObject().property('main')) self.main.podcastModel = self.podcast_model self.main.episodeModel = self.episode_model self.view.setWindowTitle('gPodder') if gpodder.ui.harmattan: self.view.showFullScreen() else: # On the Desktop, scale to fit my small laptop screen.. desktop = self.app.desktop() if desktop.height() < 1000: FACTOR = .8 self.view.scale(FACTOR, FACTOR) size = self.view.size() size *= FACTOR self.view.resize(size) self.view.show() self.do_start_progress.connect(self.on_start_progress) self.do_end_progress.connect(self.on_end_progress) self.do_show_message.connect(self.on_show_message) podcasts = self.load_podcasts() self.resumable_episodes = None self.do_offer_download_resume.connect(self.on_offer_download_resume) util.run_in_background(self.find_partial_downloads(podcasts))
def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("BitPurse") self.view = QtDeclarative.QDeclarativeView() # Are we on mer ? So don't use opengl # As it didn't works on all devices if os.path.exists('/etc/mer-release'): fullscreen = True elif os.path.exists('/etc/aegis'): fullscreen = True self.glformat = QGLFormat().defaultFormat() self.glformat.setSampleBuffers(False) self.glw = QGLWidget(self.glformat) self.glw.setAutoFillBackground(False) self.view.setViewport(self.glw) else: fullscreen = False self.walletController = WalletController() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty( "__upgrade__", __upgrade__.replace('\n', '<br />')) self.rootContext.setContextProperty('WalletController', self.walletController) self.rootContext.setContextProperty( 'AddressesModel', self.walletController.addressesModel) self.rootContext.setContextProperty( 'TransactionsModel', self.walletController.transactionsModel) self.rootContext.setContextProperty('Settings', self.walletController.settings) self.view.setSource( QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'main.qml'))) self.rootObject = self.view.rootObject() if fullscreen: self.view.showFullScreen() else: self.view.show() self.sendPage = self.rootObject.findChild(QObject, "sendPage") self.aboutPage = self.rootObject.findChild(QObject, "aboutPage") self.walletController.onError.connect(self.rootObject.onError) self.walletController.onTxSent.connect(self.sendPage.onTxSent) if len(sys.argv) >= 2: if sys.argv[1].startswith('bitcoin:'): params = sys.argv[1][8:].split('?') addr = params[0].strip('/') amount = 0 if params > 1: for param in params: if param.startswith('amount='): if len(param.split('=')) > 1: amount = param.split('=')[1] self.rootObject.sendTo(addr, amount) if self.walletController.settings.numberOfLaunch == 25: self.rootObject.showDonation() self.walletController.settings.numberOfLaunch += 1
def __init__(self): QDeclarativeView.__init__(self) self.setSource( QUrl.fromLocalFile(adjust_filename('bug_847.qml', __file__))) self.rootObject().setProperty('pythonObject', self)
def __init__(self): QApplication.__init__(self, sys.argv) self.setOrganizationName("Khertan Software") self.setOrganizationDomain("khertan.net") self.setApplicationName("BitPurse") self.view = QtDeclarative.QDeclarativeView() # Are we on mer ? So don't use opengl # As it didn't works on all devices if os.path.exists('/etc/mer-release'): fullscreen = True elif os.path.exists('/etc/aegis'): fullscreen = True self.glformat = QGLFormat().defaultFormat() self.glformat.setSampleBuffers(False) self.glw = QGLWidget(self.glformat) self.glw.setAutoFillBackground(False) self.view.setViewport(self.glw) else: fullscreen = False self.walletController = WalletController() self.rootContext = self.view.rootContext() self.rootContext.setContextProperty("argv", sys.argv) self.rootContext.setContextProperty("__version__", __version__) self.rootContext.setContextProperty("__upgrade__", __upgrade__ .replace('\n', '<br />')) self.rootContext.setContextProperty('WalletController', self.walletController) self.rootContext.setContextProperty('AddressesModel', self.walletController .addressesModel) self.rootContext.setContextProperty('TransactionsModel', self.walletController .transactionsModel) self.rootContext.setContextProperty('Settings', self.walletController .settings) self.view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml', 'main.qml'))) self.rootObject = self.view.rootObject() if fullscreen: self.view.showFullScreen() else: self.view.show() self.sendPage = self.rootObject.findChild(QObject, "sendPage") self.aboutPage = self.rootObject.findChild(QObject, "aboutPage") self.walletController.onError.connect(self.rootObject.onError) self.walletController.onTxSent.connect(self.sendPage.onTxSent) if len(sys.argv) >= 2: if sys.argv[1].startswith('bitcoin:'): params = sys.argv[1][8:].split('?') addr = params[0].strip('/') amount = 0 if params > 1: for param in params: if param.startswith('amount='): if len(param.split('=')) > 1: amount = param.split('=')[1] self.rootObject.sendTo(addr, amount) if self.walletController.settings.numberOfLaunch == 25: self.rootObject.showDonation() self.walletController.settings.numberOfLaunch += 1
def on_open(self): if sys.platform.startswith('darwin'): url = '/Applications/Listen 1.app/Contents/MacOS/media/music/' QDesktopServices.openUrl(QUrl.fromLocalFile(url)) else: QDesktopServices.openUrl(QUrl.fromLocalFile('./media/music'))
def testFindSelectText(self): url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) self.page.mainFrame().load(url) self.app.exec_() self.assert_(self.called)
def __init__(self, path): super(DocumentView, self).__init__() self.setWindowTitle(path) self.load(QUrl.fromLocalFile(path))
def __init__(self): QDeclarativeView.__init__(self) self.setSource(QUrl.fromLocalFile(adjust_filename('bug_847.qml', __file__))) self.rootObject().setProperty('pythonObject', self)
def url(self): return QUrl.fromLocalFile(self.__resourcePath + "/")
def testLoadFinishedFromFile(self): url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) self.view.setUrl(url) self.app.exec_() self.assert_(self.called)
def setPath(self, v): self.path = v self.q.imageUrlChanged.emit(QUrl.fromLocalFile(v))
class OcrImageObject(QObject): def __init__(self, parent=None, **kwargs): """ @param parent QObject @param pixmap QPixmap @param settings OcrSettings """ super(OcrImageObject, self).__init__(parent) self.__d = _OcrImageObject(self, **kwargs) imageUrlChanged = Signal(QUrl) imageUrl = Property(QUrl, lambda self: QUrl.fromLocalFile(self.__d.path), notify=imageUrlChanged) def language(self): """ @return str """ return self.__d.settings.language() def setEditable(self, t): self.__d.editable = t def isEditable(self): return self.__d.editable editableChanged = Signal(bool) editable = Property(bool, lambda self: self.__d.editable, setEditable, notify=editableChanged) #winIdChanged = Signal(long) #winId = Property(long, # lambda self: self.__d.hwnd, # notify=winIdChanged) #@Slot(result=bool) #def hasWindow(self): return bool(self.__d.hwnd) def setX(self, v): self.__d.x = v xChanged = Signal(int) x = Property(int, lambda self: self.__d.x, setX, notify=xChanged) def setY(self, v): self.__d.y = v yChanged = Signal(int) y = Property(int, lambda self: self.__d.y, setY, notify=yChanged) def setWidth(self, v): self.__d.width = v widthChanged = Signal(int) width = Property(int, lambda self: self.__d.width, setWidth, notify=widthChanged) def setHeight(self, v): self.__d.height = v heightChanged = Signal(int) height = Property(int, lambda self: self.__d.height, setHeight, notify=heightChanged) # Zoom image def setScaleEnabled(self, t): self.__d.scaleEnabled = t scaleEnabledChanged = Signal(bool) scaleEnabled = Property(bool, lambda self: self.__d.scaleEnabled, setScaleEnabled, notify=scaleEnabledChanged) def setScaleFactor(self, v): self.__d.scaleFactor = v scaleFactorChanged = Signal(float) scaleFactor = Property(float, lambda self: self.__d.scaleFactor, setScaleFactor, notify=scaleFactorChanged) # Color intensity def setColorIntensityEnabled(self, t): self.__d.colorIntensityEnabled = t colorIntensityEnabledChanged = Signal(bool) colorIntensityEnabled = Property( bool, lambda self: self.__d.colorIntensityEnabled, setColorIntensityEnabled, notify=colorIntensityEnabledChanged) def setMinimumColorIntensity(self, v): self.__d.minimumColorIntensity = v minimumColorIntensityChanged = Signal(float) minimumColorIntensity = Property( float, lambda self: self.__d.minimumColorIntensity, setMinimumColorIntensity, notify=minimumColorIntensityChanged) def setMaximumColorIntensity(self, v): self.__d.maximumColorIntensity = v maximumColorIntensityChanged = Signal(float) maximumColorIntensity = Property( float, lambda self: self.__d.maximumColorIntensity, setMaximumColorIntensity, notify=maximumColorIntensityChanged) # Color saturation def setSaturationEnabled(self, t): self.__d.saturationEnabled = t saturationEnabledChanged = Signal(bool) saturationEnabled = Property(bool, lambda self: self.__d.saturationEnabled, setSaturationEnabled, notify=saturationEnabledChanged) def setMinimumSaturation(self, v): self.__d.minimumSaturation = v minimumSaturationChanged = Signal(float) minimumSaturation = Property(float, lambda self: self.__d.minimumSaturation, setMinimumSaturation, notify=minimumSaturationChanged) def setMaximumSaturation(self, v): self.__d.maximumSaturation = v maximumSaturationChanged = Signal(float) maximumSaturation = Property(float, lambda self: self.__d.maximumSaturation, setMaximumSaturation, notify=maximumSaturationChanged) # Color hue def setHueEnabled(self, t): self.__d.hueEnabled = t hueEnabledChanged = Signal(bool) hueEnabled = Property(bool, lambda self: self.__d.hueEnabled, setHueEnabled, notify=hueEnabledChanged) def setMinimumHue(self, v): self.__d.minimumHue = v minimumHueChanged = Signal(float) minimumHue = Property(float, lambda self: self.__d.minimumHue, setMinimumHue, notify=minimumHueChanged) def setMaximumHue(self, v): self.__d.maximumHue = v maximumHueChanged = Signal(float) maximumHue = Property(float, lambda self: self.__d.maximumHue, setMaximumHue, notify=maximumHueChanged) @Slot(result=unicode) def ocr(self): """ @return unicode """ return self.__d.ocr() @Slot() def captureWindow(self): self.__d.captureWindow() @Slot() def captureDesktop(self): self.__d.captureDesktop() @Slot() def release(self): skfileio.removefile(self.__d.path) self.setParent(None) dprint("pass") #@classmethod #def create(cls, x, y, width, height, hwnd=0, **kwargs): # -> cls or None # """ # @param x int # @param y int # @param width int # @param height int # @param* hwnd int # @param* kwargs parameters to create OcrImageObject # """ # pm = capture_pixmap(x, y, width, height, hwnd) # if not pm or pm.isNull(): # dwarn("failed to capture image") # return # return cls(pixmap=pm, x=x, y=y, width=width, height=height, hwnd=hwnd, **kwargs) def transformPixmap(self, pm): """ @param pm QPixmap @return QPixmap or QImage or None """ #with SkProfiler(): # 9/12/2014: time = 1.3e-05 return self.__d.transformPixmap(pm)
def __init__(self, args, gpodder_core, dbus_bus_name): QObject.__init__(self) self.dbus_bus_name = dbus_bus_name # TODO: Expose the same D-Bus API as the Gtk UI D-Bus object (/gui) # TODO: Create a gpodder.dbusproxy.DBusPodcastsProxy object (/podcasts) self.app = QApplication(args) signal.signal(signal.SIGINT, signal.SIG_DFL) self.quit.connect(self.on_quit) self.episodeUpdated.connect(self.on_episode_updated) self.setEpisodeListModel.connect(self.on_set_episode_list_model) self.core = gpodder_core self.config = self.core.config self.db = self.core.db self.model = self.core.model self.config_proxy = ConfigProxy(self.config) # Initialize the gpodder.net client self.mygpo_client = my.MygPoClient(self.config) gpodder.user_extensions.on_ui_initialized(self.model, self.extensions_podcast_update_cb, self.extensions_episode_download_cb) self.view = DeclarativeView() self.view.closing.connect(self.on_quit) self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView) self.controller = Controller(self) self.media_buttons_handler = helper.MediaButtonsHandler() self.tracker_miner_config = helper.TrackerMinerConfig() self.podcast_model = gPodderPodcastListModel() self.episode_model = gPodderEpisodeListModel(self.config, self) self.last_episode = None # A dictionary of episodes that are currently active # in some way (i.e. playing back or downloading) self.active_episode_wrappers = {} engine = self.view.engine() # Add the cover art image provider self.cover_provider = images.LocalCachedImageProvider() engine.addImageProvider('cover', self.cover_provider) root_context = self.view.rootContext() root_context.setContextProperty('controller', self.controller) root_context.setContextProperty('configProxy', self.config_proxy) root_context.setContextProperty('mediaButtonsHandler', self.media_buttons_handler) root_context.setContextProperty('trackerMinerConfig', self.tracker_miner_config) # Load the QML UI (this could take a while...) self.view.setSource(QUrl.fromLocalFile(QML('main_default.qml'))) # Proxy to the "main" QML object for direct access to Qt Properties self.main = helper.QObjectProxy(self.view.rootObject().property('main')) self.main.podcastModel = self.podcast_model self.main.episodeModel = self.episode_model self.view.setWindowTitle('gPodder') if gpodder.ui.harmattan: self.view.showFullScreen() else: # On the Desktop, scale to fit my small laptop screen.. desktop = self.app.desktop() if desktop.height() < 1000: FACTOR = .8 self.view.scale(FACTOR, FACTOR) size = self.view.size() size *= FACTOR self.view.resize(size) self.view.show() self.do_start_progress.connect(self.on_start_progress) self.do_end_progress.connect(self.on_end_progress) self.do_show_message.connect(self.on_show_message) podcasts = self.load_podcasts() self.resumable_episodes = None self.do_offer_download_resume.connect(self.on_offer_download_resume) util.run_in_background(self.find_partial_downloads(podcasts))
def loadFile(self, path): self.load(QUrl.fromLocalFile(path))