本文整理汇总了Python中PySide.QtWebKit.QWebView.setZoomFactor方法的典型用法代码示例。如果您正苦于以下问题:Python QWebView.setZoomFactor方法的具体用法?Python QWebView.setZoomFactor怎么用?Python QWebView.setZoomFactor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtWebKit.QWebView
的用法示例。
在下文中一共展示了QWebView.setZoomFactor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Yame
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setZoomFactor [as 别名]
#.........这里部分代码省略.........
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 initUI(self):
"""
Initialize a UI.
"""
# Panels
self.tree = QtGui.QTreeWidget()
self.tree.itemDoubleClicked.connect(self.gotoLine)
head = QtGui.QTreeWidgetItem()
head.setText(0, 'Structure')
self.tree.setHeaderItem(head)
self.editor = editor.TextEdit()
self.editor.textChanged.connect(self.parseMarkdown)
self.editor.setFrameShape(QtGui.QFrame.StyledPanel)
self.web = QWebView()
self.web.setZoomFactor(0.9)
self.web.setHtml('')
self.web.show()
splitter1 = QtGui.QSplitter(Qt.Horizontal)
splitter1.addWidget(self.editor)
splitter1.addWidget(self.web)
splitter1.setStretchFactor(0, 3)
splitter1.setStretchFactor(1, 1)
splitter2 = QtGui.QSplitter(Qt.Horizontal)
splitter2.addWidget(self.tree)
splitter2.addWidget(splitter1)
splitter2.setStretchFactor(0, 1)
splitter2.setStretchFactor(1, 2)
hbox = QtGui.QHBoxLayout(self)
hbox.addWidget(splitter2)
self.setLayout(hbox)
# Menu
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
newAction = fileMenu.addAction('&New')
newAction.setShortcut('Ctrl+N')
newAction.setStatusTip('New document')
icon = QIcon.fromTheme("document-new", QIcon("img/new.png"))
# print dir(icon), icon.isNull()
newAction.setIcon(icon)
newAction.triggered.connect(self.newFile)
openAction = fileMenu.addAction('&Open...')
示例2: Browser
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setZoomFactor [as 别名]
#.........这里部分代码省略.........
def goNext(self):
self.cmdNext(list())
def onConnection(self):
self.socket = self.server.nextPendingConnection()
self.socket.write(self.hostname + ' % ')
self.connect(self.socket, SIGNAL("readyRead()"), self, SLOT("onDataReceived()"));
def print_(self, text):
if (self.socket != False):
self.socket.write(text + '\n')
print(text)
def onDataReceived(self):
data = self.socket.readAll().data().strip()
try:
args = data.split(' ')
map(lambda x : x.strip(), args)
self.commands.get(args[0])(args)
except Exception:
self.print_('>> syntax error')
self.printCommandsList()
if self.socket.isOpen():
self.socket.write(self.hostname + ' % ')
def printCommandsList(self):
self.print_('avaible commands:')
for command in self.commands:
self.print_(' ' + command)
def onSslErrors(self, reply, errors):
url = unicode(reply.url().toString())
reply.ignoreSslErrors()
# commands
def cmdHelp(self, args):
self.print_('>> help')
self.printCommandsList()
def cmdRefresh(self, args):
self.print_('>> refresh ' + self.url.toString().encode())
self.frontView.reload()
def cmdAdd(self, args):
self.print_('>> add ' + args[1] + ' ' + args[2] + ' ' + args[3])
self.sites.append(Site(QUrl(args[1]), int(args[2], int(args[3]))))
def cmdDel(self, args):
self.print_('>> del ' + args[1])
self.sites.pop(int(args[1]))
def cmdList(self, args):
self.print_('>> list')
self.print_('current list:')
sitesCount = len(self.sites)
i = 0
while i < sitesCount:
self.print_('%1c[%1d] %2ds : %3s' % ((i==self.siteId) and '*' or ' ' ,i, self.sites[i].time, self.sites[i].url.toString().encode()))
i = i + 1
def cmdZoom(self, args):
self.print_('>> zoom ' + args[1])
self.frontView.setZoomFactor(float(args[1]))
def cmdFs(self, args):
self.print_('>> fs ' + args[1])
if (args[1] == '1'):
self.showFullScreen()
else:
self.showNormal()
def cmdExit(self, args):
self.print_('>> exit')
self.socket.close()
def cmdNext(self, args):
self.timer.stop()
self.timer.start(self.sites[self.siteId].time * 1000)
self.siteId = (self.siteId + 1) % len(self.sites)
print('>> next ' + self.sites[self.siteId].url.toString().encode())
self.backView.show()
self.frontView, self.backView = self.backView, self.frontView
self.backView.load(self.sites[self.siteId].url)
self.backView.setZoomFactor(self.sites[self.siteId].zoom)
self.backView.hide()
def cmdRestart(self, args):
self.print_('>> restart')
self.close()
def cmdUpgrade(self, args):
self.print_('>> upgrade')
update = urllib.urlopen('https://raw.githubusercontent.com/tjardick/monitoring_browser/master/webkit.py').read()
script = file('webkit.py', 'w')
script.write(update)
script.close()
self.close()
示例3: PysideGui
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setZoomFactor [as 别名]
class PysideGui(generic.GenericGui):
def __init__(self):
generic.GenericGui.__init__(self)
window = QWidget()
window.setWindowTitle('quichem-pyside')
self.compiler_view = QListWidget()
self.compiler_view.currentRowChanged.connect(self.show_source)
self.stacked_widget = QStackedWidget()
self.stacked_widget.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
self.edit = QLineEdit()
self.edit.setPlaceholderText('Type quichem input...')
self.edit.textChanged.connect(self.change_value)
self.view = QWebView()
self.view.page().mainFrame().setScrollBarPolicy(Qt.Vertical,
Qt.ScrollBarAlwaysOff)
self.view.page().action(QWebPage.Reload).setVisible(False)
self.view.setMaximumHeight(0)
self.view.setUrl('qrc:/web/page.html')
self.view.setZoomFactor(2)
self.view.page().mainFrame().contentsSizeChanged.connect(
self._resize_view)
# For debugging JS:
## from PySide.QtWebKit import QWebSettings
## QWebSettings.globalSettings().setAttribute(
## QWebSettings.DeveloperExtrasEnabled, True)
button_image = QPushButton('Copy as Image')
button_image.clicked.connect(self.set_clipboard_image)
button_image.setToolTip('Then paste into any graphics program')
button_word = QPushButton('Copy as MS Word Equation')
button_word.clicked.connect(self.set_clipboard_word)
button_html = QPushButton('Copy as Formatted Text')
button_html.clicked.connect(self.set_clipboard_html)
line = QFrame()
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
button_layout = QHBoxLayout()
button_layout.addStretch()
button_layout.addWidget(button_image)
button_layout.addWidget(button_word)
button_layout.addWidget(button_html)
source_layout = QHBoxLayout()
source_layout.addWidget(self.compiler_view)
source_layout.addWidget(self.stacked_widget, 1)
QVBoxLayout(window)
window.layout().addWidget(self.edit)
window.layout().addWidget(self.view)
window.layout().addLayout(button_layout)
window.layout().addWidget(line)
window.layout().addLayout(source_layout, 1)
window.show()
window.resize(window.minimumWidth(), window.height())
# To prevent garbage collection of internal Qt object.
self._window = window
def show_source(self, index):
if not self.sources:
return
self.stacked_widget.setCurrentIndex(index)
self.change_value(self.edit.text())
def _resize_view(self):
"""Set the QWebView's minimum height based on its current
contents.
"""
div = self.view.page().mainFrame().findFirstElement('.output')
scrollbar_width = QApplication.style().pixelMetric(
QStyle.PM_ScrollBarExtent)
self.view.setMaximumHeight(
div.geometry().height() + scrollbar_width + 16)
def make_source(self, name):
self.compiler_view.addItem(name)
self.compiler_view.setCurrentRow(0)
scrollbar_width = QApplication.style().pixelMetric(
QStyle.PM_ScrollBarExtent)
self.compiler_view.setMaximumWidth(
self.compiler_view.sizeHintForColumn(0) + scrollbar_width + 16)
page = QWidget()
QHBoxLayout(page)
page.layout().setContentsMargins(*(0,) * 4)
source = QTextEdit()
source.setStyleSheet('min-width: 0; min-height: 0')
source.setReadOnly(True)
QVBoxLayout(source)
button = QPushButton('Copy')
button.clicked.connect(functools.partial(self.set_clipboard, source))
page.layout().addWidget(source)
source.layout().addWidget(button, 0, Qt.AlignRight | Qt.AlignBottom)
self.stacked_widget.addWidget(page)
return source
def run_script(self, js):
self.view.page().mainFrame().evaluateJavaScript(js)
#.........这里部分代码省略.........