Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added javascript interface and pdf save

  • Loading branch information...
commit 0715b61afd10c325046b4da2550ce063678afebb 1 parent dce7ce9
@victordiaz authored
Showing with 41 additions and 11 deletions.
  1. +40 −10 mikado.py
  2. +1 −1  settings.conf
View
50 mikado.py
@@ -35,6 +35,14 @@ def paintEvent(self, event):
p.end()
+class ConsolePrinter(QObject):
+ def __init__(self, parent=None):
+ super(ConsolePrinter, self).__init__(parent)
+
+ @Slot(str)
+ def text(self, message):
+ print message
+
class MBrowser(QWebPage):
def __init__(self):
@@ -83,9 +91,12 @@ class Miniwini(QWidget):
def __init__(self, conf):
super(Miniwini, self).__init__()
self.activated = False
-
+ self.createActions()
+ shortcut = QShortcut(QKeySequence(self.tr("Alt+M", "File|Open")),self)
+ QObject.connect(shortcut, SIGNAL('activated()'), self.printqq)
+
+
if (conf['docked'] == "yes"):
- self.createActions()
self.createTrayIcon()
self.trayIcon.activated.connect(self.iconActivated)
@@ -112,9 +123,10 @@ def __init__(self, conf):
self.setGeometry(self.x, self.y, self.w, self.h)
-
-
+
self.webView = MyWebView()
+ #self.webView.settings().setAttribute(QWebSettings.WebAttribute.DeveloperExtrasEnabled, True)
+
#self.webView.setStyleSheet("background-color: black; padding: 12px; margin:12px");
page = MBrowser()
@@ -163,9 +175,7 @@ def __init__(self, conf):
#self.connect(self.webView, SIGNAL("titleChanged(const QString&)"),
# self.setWindowTitle)
-
- #self.webView.settings().setAttribute(QWebSettings.WebAttribute.DeveloperExtrasEnabled, True)
-
+
#cambiar esto de sitio
inspect = QWebInspector()
inspect.setPage(self.webView.page())
@@ -177,12 +187,31 @@ def __init__(self, conf):
#self.resize(350, 480)
if (conf['fullscreen'] == "yes"):
self.showFullScreen()
+
+
+ frame = self.webView.page().mainFrame()
+ printer = ConsolePrinter()
+
+ frame.addToJavaScriptWindowObject('printer', printer)
+ frame.evaluateJavaScript("alert('Hello');")
+ frame.evaluateJavaScript("printer.text('Goooooooooo!');")
+
+ printer = QPrinter()
+ printer.setPageSize(QPrinter.A4)
+ printer.setOutputFormat(QPrinter.PdfFormat)
+ printer.setOutputFileName("qq.pdf")
+ self.webView.print_(printer)
+
+
+
+ def printqq(self):
+ print "qq"
def createActions(self):
- self.minimizeAction = QAction("Mi&nimize", self,
- triggered=self.hide)
+ self.minimizeAction = QAction("Mi&nimize", self, shortcut="Alt+B",
+ triggered=self.printqq)
- self.maximizeAction = QAction("Ma&ximize", self,
+ self.maximizeAction = QAction("Ma&ximize", self, shortcut="Ctrl+M",
triggered=self.showMaximized)
self.restoreAction = QAction("&Restore", self,
@@ -219,6 +248,7 @@ def iconActivated(self, reason):
if (self.activated == False):
self.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint)
self.show()
+
else:
self.hide();
View
2  settings.conf
@@ -9,7 +9,7 @@ fullscreen = no
[meneame]
icon = arrow.png
-url = http://www.meneame.net
+url = http://www.google.es
border = no
transparency = no
docked = no
Please sign in to comment.
Something went wrong with that request. Please try again.