1
我已經搜索了網頁,找到了將方法放在PyQt4應用程序邊界的頂部。我看到setCaption()方法(如http://nullege.com/codes/search/PyQt4.QtGui.QDialog.setCaption),但我不知道如何使用它,如果這是好方法(我已經測試browser.setCaption(「foobar」)) 我的應用程序基於spynner,也許我應該在腳本中導入PyQt4.QtGui.QDialog? 任何例子進行真正理解:)如何在spynner/PyQt4中設置應用程序名稱?
這是整個代碼(可以運行原樣):
#!/usr/bin/python2
# -*- coding: utf8 -*-
# vim:ts=4:sw=4
login = "[email protected]"
passwd = "tartempionisthebest"
useragent = "Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
import spynner
def displayCurrentUri():
return browser.webpage.mainFrame().url().toString()
browser = spynner.Browser(
#debug_level=spynner.WARNING,
debug_level=spynner.ERROR,
#debug_level=spynner.DEBUG,
#debug_level=spynner.INFO,
user_agent = useragent
)
browser.create_webview(True)
browser.hide()
browser.load("http://television.telerama.fr/tele/grille.php")
browser.wk_fill("input[name=email]", login)
browser.wk_fill("input[name=password]", passwd)
browser.click("input[name=go-ident]")
browser.wait_load()
JS_str = (
"""
// VARIABLES PARAMETRABLES
var bgcol = 'black'; // optionnel : couleur du fond compatible avec les CSS
// BODY CONTENT
document.getElementsByClassName("megabanner-top")[0].innerHTML = "";
document.getElementById("listeurl").parentNode.removeChild(document.getElementById("listeurl"));
document.getElementById("barre-ident").parentNode.removeChild(document.getElementById("barre-ident"));
document.getElementById("barre-nav").parentNode.removeChild(document.getElementById("barre-nav"));
document.getElementById("bottom1").parentNode.removeChild(document.getElementById("bottom1"));
document.getElementById("bottom2").parentNode.removeChild(document.getElementById("bottom2"));
document.getElementById("fil").parentNode.removeChild(document.getElementById("fil"));
document.getElementById("mentions-2008").parentNode.removeChild(document.getElementById("mentions-2008"));
document.getElementById("contenu_pied_de_page_fixe").innerHTML=" ";
// CSS CONTENT
document.body.style.setProperty('background-color', bgcol, null);
document.body.style.backgroundImage="none";
document.getElementById("ventre").style.setProperty('padding-top', '0px', null);
document.getElementById("ventre").style.setProperty('padding-bottom', '0px', null);
document.getElementById("gene").style.setProperty('margin', '0%', null);
document.getElementById("gene").style.setProperty('background-color', "white", null);
document.getElementById("sur-gene").style.setProperty('width', '1000px', null);
document.getElementById("contenu_pied_de_page_fixe").style.setProperty('height', '0px', null);
// TRANCHE HORAIRE
changerMaintenant(0);
"""
)
browser.webview.setGeometry(0,0,1440,1800) # x, y, w, h -> http://doc.qt.nokia.com/stable/application-windows.html#window-geometry
browser.webview.resize(1440,1800) # w, h
browser.show()
browser.runjs(JS_str)
browser.wait_load()
#browser.close()
哇,BIG UP謝謝,merci,danke! –