From ben.lucato at gmail.com Sat Nov 1 13:09:57 2014 From: ben.lucato at gmail.com (Ben Lucato) Date: Sat, 1 Nov 2014 23:09:57 +1100 Subject: [PySide] Thanks for making PySide easy to build on Windows Message-ID: Hi everyone, I apologise if this is spam but a big thankyou is in order for making PySide the first package I have been able to build on Windows. I was totally shocked when your guide at http://pyside.readthedocs.org/en/latest/building/windows.html *actually worked*. I am so used to compilation not working and having to resort to downloading already-compiled versions from http://www.lfd.uci.edu/~gohlke/pythonlibs/. I had an easier time installing PySide on Windows than I did trying to install PyQt on Ubuntu (which I failed to do after several hours and gave up). Whoever wrote this page is awesome because all the necessary steps were documented and I didn't have to do anything extra. Once again, sorry for the spam but I think it's always nice to receive thanks and I didn't see a better place. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tmassimi at gmail.com Sun Nov 2 18:24:16 2014 From: tmassimi at gmail.com (Tommaso Massimi) Date: Sun, 2 Nov 2014 18:24:16 +0100 Subject: [PySide] PySide for QT 5.x In-Reply-To: References: Message-ID: On Tue, Oct 28, 2014 at 6:18 PM, Jonathan Nabozny wrote: > Hello All, > > I've been using both QT in c++ at work for a while now and python for > several years for my own projects and academia. I'd like to get involved in > helping bring QT 5.x support to PySide. Is there anyone else currently > working towards this goal that I can aid / any information I should know > before beginning to look at what's there currently? Hi Jonathan, I'd like to help this project, have you found any useful information? > > Thanks, > -- > Widmo > Software Engineer > > > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside > From bjelge at nefines.com Mon Nov 3 14:06:34 2014 From: bjelge at nefines.com (=?windows-1252?Q?Bj=F8rn_Helge_Kj=F8snes?=) Date: Mon, 03 Nov 2014 14:06:34 +0100 Subject: [PySide] PySide for QT 5.x In-Reply-To: References: Message-ID: <54577DDA.2030505@nefines.com> Hi I do also want to help. I do work on Windows, programming both in C++ and Python (mainly 2.7). My interest is to get at least core, gui and webkit2 up and running for QT 5.x at the Windows platform as these are the parts I am using in PySide at the moment. I have not had a look at it since QT 5.0 was released, but to me the main problem seams to be that core has been split out in it's own module and that we need a new set of XLM files for QT 5.x? If somebody takes the lead, I can help to get this done as well. Thanks, Bjorn On 02.11.2014 18:24, Tommaso Massimi wrote: > On Tue, Oct 28, 2014 at 6:18 PM, Jonathan Nabozny wrote: >> Hello All, >> >> I've been using both QT in c++ at work for a while now and python for >> several years for my own projects and academia. I'd like to get involved in >> helping bring QT 5.x support to PySide. Is there anyone else currently >> working towards this goal that I can aid / any information I should know >> before beginning to look at what's there currently? > Hi Jonathan, > I'd like to help this project, > have you found any useful information? > >> Thanks, >> -- >> Widmo >> Software Engineer >> >> >> _______________________________________________ >> PySide mailing list >> PySide at qt-project.org >> http://lists.qt-project.org/mailman/listinfo/pyside >> > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside > From elcorreo at deshackra.com Wed Nov 5 07:31:06 2014 From: elcorreo at deshackra.com (Jorge Araya Navarro) Date: Wed, 05 Nov 2014 00:31:06 -0600 Subject: [PySide] It is possible design Custom Controls with PySide (as in this example with PyQt)? Message-ID: <87h9yef8l8.fsf@deshackra.com> Hello! I'm looking to add a custom widget I starting from a QWebView, into Qt Designer. I've been looking how to do this and seems like this is possible but with PyQt[1], I also read[2] that it is better to use the Qt Designer from PyQt. So, it is possible and I just have to follow that guide but with some tweaks proper of PySide? if not, what options do I have? [1]: http://doc.qt.digia.com/qq/qq26-pyqtdesigner.html [2]: http://stackoverflow.com/questions/16030170/custom-qt-widgets-with-python-for-qt-designer#comment36579670_23771502 -- Pax et bonum. Jorge Araya Navarro. ES: Diseñador Publicitario, Programador Python y colaborador en Parabola GNU/Linux-libre EN: Ads Designer, Python programmer and contributor Parabola GNU/Linux-libre EO: Anonco grafikisto, Pitino programalingvo programisto kai kontribuanto en Parabola GNU/Linux-libre https://es.gravatar.com/shackra From elcorreo at deshackra.com Thu Nov 6 06:04:41 2014 From: elcorreo at deshackra.com (Jorge Araya Navarro) Date: Wed, 05 Nov 2014 23:04:41 -0600 Subject: [PySide] Internal C++ object (PySide.QtWebKit.QWebFrame) already deleted; but I'm saving it as an attribute to avoid this exact issue Message-ID: <877fz8lxtx.fsf@deshackra.com> I need some help figuring out how to solve this error. As I described it on SO[1]: I'm working on a project where I use a modified `QWebView`. I'm getting this error: Traceback (most recent call last): File "/home/jorge/coders/universal-scraper/src/customwebview.py", line 63, in mouseMoveEvent hittestresult = self.currentframe.hitTestContent(event.pos()) RuntimeError: Internal C++ object (PySide.QtWebKit.QWebFrame) already deleted. I have read about [PySide pitfalls](http://qt-project.org/wiki/PySide_Pitfalls) already, and I've been saving that `QtWebKit.QWebFrame` as an attribute of my modified `QWebView` **from the beggining of the project** with the method `setframeafterloadfinished` which is called when the page finishes loading, the problem raised after some majors changes on my modified `QWebView`. Here is the source code showing what I changed: diff -r 916f0091fee8 src/customwebview.py --- a/src/customwebview.py Thu Oct 30 19:54:57 2014 -0600 +++ b/src/customwebview.py Mon Nov 03 20:22:51 2014 -0600 @@ -4,6 +4,7 @@ from PySide.QtWebKit import QWebView from PySide import QtCore, QtGui +from . import webelementinfo class CustomQWebView(QWebView): @@ -12,19 +13,16 @@ """ Init the custom class """ super(CustomQWebView, self).__init__(*args, **kwargs) - self.colors = {0: QtGui.QColor(255, 165, 0), - 1: QtGui.QColor(135, 206, 235), - 2: QtGui.QColor(135, 235, 164), - 3: QtGui.QColor(235, 135, 206), - 4: QtGui.QColor(235, 164, 135)} - self.colorfill = None + self.colors = {0: QtGui.QColor(255, 165, 0, 127), + 1: QtGui.QColor(135, 206, 235, 127), + 2: QtGui.QColor(135, 235, 164, 127), + 3: QtGui.QColor(235, 135, 206, 127), + 4: QtGui.QColor(235, 164, 135, 127)} + self.color = None self.currentframe = None - self.lastelement = None - self.lastelementboundingrect = None + self.element = None self.loadFinished.connect(self.setframeafterloadfinished) - self.pen = QtGui.QPen() - self.pen.setWidth(2) - self.drawrects = False + self.selectCommentsArea() @QtCore.Slot() def selectCommentsArea(self): @@ -63,11 +61,15 @@ if self.drawrects: if self.currentframe: hittestresult = self.currentframe.hitTestContent(event.pos()) - element = hittestresult.element() - if self.lastelement != element: - self.lastelement = element - self.lastelementboundingrect = hittestresult.boundingRect() - self.update() + element = webelementinfo.WebElement( + hittestresult, self.color, self) + if not self.element: + self.element = element + elif self.element != element: + self.element = element + + # FIXME: self.update should draw rects from WebElements too. + self.update() @QtCore.Slot(QtGui.QPaintEvent) def paintEvent(self, event): @@ -76,22 +78,8 @@ if self.drawrects: # then the rectangle - if self.lastelementboundingrect: - painter = QtGui.QPainter(self) - painter.setPen(self.defaultpen) - # This rectangles takes into account any offset of the scroll - # bar so the rectangle can be drawn correctly - rect = QtCore.QRect() - rect.setRect(self.lastelementboundingrect.x() - - self.currentframe.scrollPosition().x(), - self.lastelementboundingrect.y() - - self.currentframe.scrollPosition().y(), - self.lastelementboundingrect.width(), - self.lastelementboundingrect.height()) - # painter.drawRect(QtCore.QRectF(self.lastelementcurrectrect)) - painter.drawRect(QtCore.QRectF(rect)) - painter.fillRect( - QtCore.QRectF(rect), self.colorfill) + if self.element: + self.element.update() def setframeafterloadfinished(self): self.currentframe = self.page().mainFrame() @@ -109,15 +97,7 @@ commentary text. """ self.drawrects = True - self.colorfill = self.colors[forarea] - self.colorfill.setAlpha(128) - - colorborder = self.colors[forarea] - self.pen.setColor(colorborder) + self.color = self.colors[forarea] # defines what we are looking to select self.selecttype = forarea and here it is again but complete, **and functional** (just be sure to put the file `webelementinfo.py` in the same directory as this code before running a test): #!/usr/bin/env python2 # coding: utf-8 # VENI, SANCTE SPIRITUS from PySide.QtWebKit import QWebView from PySide import QtCore, QtGui try: from . import webelementinfo except ValueError: import webelementinfo class CustomQWebView(QWebView): def __init__(self, *args, **kwargs): """ Init the custom class """ super(CustomQWebView, self).__init__(*args, **kwargs) self.colors = {0: QtGui.QColor(255, 165, 0, 127), 1: QtGui.QColor(135, 206, 235, 127), 2: QtGui.QColor(135, 235, 164, 127), 3: QtGui.QColor(235, 135, 206, 127), 4: QtGui.QColor(235, 164, 135, 127)} self.color = None self.currentframe = None self.element = None self.loadFinished.connect(self.setframeafterloadfinished) self.selectCommentsArea() @QtCore.Slot() def selectCommentsArea(self): """ For selecting the comment area """ self.setup_rectcolor_area(0) @QtCore.Slot(QtGui.QMouseEvent) def mouseMoveEvent(self, event): super(CustomQWebView, self).mouseMoveEvent(event) if self.drawrects: if self.currentframe: hittestresult = self.currentframe.hitTestContent(event.pos()) element = webelementinfo.WebElement( hittestresult, self.color, self) if not self.element: self.element = element elif self.element != element: self.element = element # FIXME: self.update should draw rects from WebElements too. self.update() @QtCore.Slot(QtGui.QPaintEvent) def paintEvent(self, event): # draw the content first super(CustomQWebView, self).paintEvent(event) if self.drawrects: # then the rectangle if self.element: self.element.update() def setframeafterloadfinished(self): self.currentframe = self.page().mainFrame() def setup_rectcolor_area(self, forarea): """Called when we want to select certain area of a web site This method set-up the painter to a giving color so web elements are drawn with a rect on top. Also activates the flag to allow painting inside CustomQWebView. :param int forarea: For which area we are going to set the painter\\ valid values are: 0 for Comments area, 1 for comment box, 2 for\\ commentator's user name, 3 for comment date and time, 4 for\\ commentary text. """ self.drawrects = True self.color = self.colors[forarea] # defines what we are looking to select self.selecttype = forarea if __name__ == "__main__": app = QtGui.QApplication([]) mainwn = QtGui.QMainWindow() mainwn.resize(800, 696) centralwidget = QtGui.QWidget(mainwn) centralwidget.resize(800, 600) gridlayout = QtGui.QGridLayout(centralwidget) web = CustomQWebView(parent=centralwidget) gridlayout.addWidget(web, 0, 0, 1) web.setUrl(QtCore.QUrl("http://duckduckgo.com")) mainwn.show() app.exec_() Here is the other file that have the definition of that new class `WebElement` that I write and start to use: #!/usr/bin/env python2 # coding: utf-8 # VENI, SANCTE SPIRITUS from PySide.QtWebKit import QWebElement, QWebHitTestResult from PySide import QtGui from PySide import QtCore class WebElement(QtCore.QObject): """ Holds information of webelements """ def __eq__(self, other): if isinstance(other, WebElement): return (self.web_element == other.web_element and self.getrect() == other.getrect()) else: raise ValueError("Not same objects") def __ne__(self, other): if isinstance(other, WebElement): return (self.web_element != other.web_element and self.getrect() != other.getrect()) else: raise ValueError("Not same objects") def __init__(self, hittestresult, color, parent=None): super(WebElement, self).__init__(parent) if (not isinstance(hittestresult, QWebHitTestResult) and not isinstance(hittestresult, QWebElement)): raise ValueError( "Argument passed for 'hittestresult' is not" " QtWebkit.QWenHitTestResult or QtWebkit.QWebElement instance" ) if not isinstance(color, QtGui.QColor): raise ValueError( "Argument passed for 'color' is not QtGui.QColor instance" ) try: self.frame = hittestresult.frame() except AttributeError: self.frame = hittestresult.webFrame() self.frame_scroll_x = self.frame.scrollPosition().x() self.frame_scroll_y = self.frame.scrollPosition().y() try: rect = hittestresult.boundingRect() except AttributeError: rect = hittestresult.geometry() self.element_rect_x = rect.x() self.element_rect_y = rect.y() self.element_rect_w = rect.width() self.element_rect_h = rect.height() try: self.web_element = hittestresult.element() except AttributeError: self.web_element = hittestresult self.color = color self.color_darker = color.darker() self.color_darker.setAlpha(255) self.pen = QtGui.QPen(self.color_darker) self.pen.setWidth(2) #self.painter = QtGui.QPainter(self.parent) self.painter = QtGui.QPainter() self.painter.setPen(self.pen) def update(self): """ draw the rect for this element in the CustomQWebView """ rect = self.getrect() rectf = QtCore.QRectF(rect) self.painter.fillRect(rectf, self.color) self.painter.drawRect(rectf) def getrect(self): """ Return the rect for this WebElement """ self.frame_scroll_x = self.frame.scrollPosition().x() self.frame_scroll_y = self.frame.scrollPosition().y() rect = QtCore.QRect() rect.setRect(self.element_rect_x - self.frame_scroll_x, self.element_rect_y - self.frame_scroll_y, self.element_rect_w, self.element_rect_h) return rect My project should work right as if I didn't change anything, however, with these changes it doesn't. What am I doing wrong? Am I missing something about `QWebFrame`s? [1]: http://stackoverflow.com/q/26726878/2020214 -- Pax et bonum. Jorge Araya Navarro. ES: Diseñador Publicitario, Programador Python y colaborador en Parabola GNU/Linux-libre EN: Ads Designer, Python programmer and contributor Parabola GNU/Linux-libre EO: Anonco grafikisto, Pitino programalingvo programisto kai kontribuanto en Parabola GNU/Linux-libre https://es.gravatar.com/shackra From schampailler at skynet.be Thu Nov 6 20:31:32 2014 From: schampailler at skynet.be (Stefan Champailler) Date: Thu, 6 Nov 2014 20:31:32 +0100 Subject: [PySide] Internal C++ object (PySide.QtWebKit.QWebFrame) already deleted; but I'm saving it as an attribute to avoid this exact issue In-Reply-To: <877fz8lxtx.fsf@deshackra.com> References: <877fz8lxtx.fsf@deshackra.com> Message-ID: <20141106203132.4f73929f@debian> Hi Jorge, Would you care to send a shorter version of the code (with the bug, that is) ? It'd help us to reproduce it (and it'd help you to better understand it) Stefan On Wed, 05 Nov 2014 23:04:41 -0600 Jorge Araya Navarro wrote: > > I need some help figuring out how to solve this error. As I described it on SO[1]: > > I'm working on a project where I use a modified `QWebView`. I'm getting this error: > > Traceback (most recent call last): > File "/home/jorge/coders/universal-scraper/src/customwebview.py", line 63, in mouseMoveEvent > hittestresult = self.currentframe.hitTestContent(event.pos()) > RuntimeError: Internal C++ object (PySide.QtWebKit.QWebFrame) already deleted. > > I have read about [PySide pitfalls](http://qt-project.org/wiki/PySide_Pitfalls) already, and I've been > saving that `QtWebKit.QWebFrame` as an attribute of my modified `QWebView` **from the beggining of the > project** with the method `setframeafterloadfinished` which is called when the page finishes loading, > the problem raised after some majors changes on my modified `QWebView`. > > Here is the source code showing what I changed: > > diff -r 916f0091fee8 src/customwebview.py > --- a/src/customwebview.py Thu Oct 30 19:54:57 2014 -0600 > +++ b/src/customwebview.py Mon Nov 03 20:22:51 2014 -0600 > @@ -4,6 +4,7 @@ > > from PySide.QtWebKit import QWebView > from PySide import QtCore, QtGui > +from . import webelementinfo > > > class CustomQWebView(QWebView): > @@ -12,19 +13,16 @@ > """ Init the custom class > """ > super(CustomQWebView, self).__init__(*args, **kwargs) > - self.colors = {0: QtGui.QColor(255, 165, 0), > - 1: QtGui.QColor(135, 206, 235), > - 2: QtGui.QColor(135, 235, 164), > - 3: QtGui.QColor(235, 135, 206), > - 4: QtGui.QColor(235, 164, 135)} > - self.colorfill = None > + self.colors = {0: QtGui.QColor(255, 165, 0, 127), > + 1: QtGui.QColor(135, 206, 235, 127), > + 2: QtGui.QColor(135, 235, 164, 127), > + 3: QtGui.QColor(235, 135, 206, 127), > + 4: QtGui.QColor(235, 164, 135, 127)} > + self.color = None > self.currentframe = None > - self.lastelement = None > - self.lastelementboundingrect = None > + self.element = None > self.loadFinished.connect(self.setframeafterloadfinished) > - self.pen = QtGui.QPen() > - self.pen.setWidth(2) > - self.drawrects = False > + self.selectCommentsArea() > > @QtCore.Slot() > def selectCommentsArea(self): > @@ -63,11 +61,15 @@ > if self.drawrects: > if self.currentframe: > hittestresult = self.currentframe.hitTestContent(event.pos()) > - element = hittestresult.element() > - if self.lastelement != element: > - self.lastelement = element > - self.lastelementboundingrect = hittestresult.boundingRect() > - self.update() > + element = webelementinfo.WebElement( > + hittestresult, self.color, self) > + if not self.element: > + self.element = element > + elif self.element != element: > + self.element = element > + > + # FIXME: self.update should draw rects from WebElements too. > + self.update() > > @QtCore.Slot(QtGui.QPaintEvent) > def paintEvent(self, event): > @@ -76,22 +78,8 @@ > > if self.drawrects: > # then the rectangle > - if self.lastelementboundingrect: > - painter = QtGui.QPainter(self) > - painter.setPen(self.defaultpen) > - # This rectangles takes into account any offset of the scroll > - # bar so the rectangle can be drawn correctly > - rect = QtCore.QRect() > - rect.setRect(self.lastelementboundingrect.x() - > - self.currentframe.scrollPosition().x(), > - self.lastelementboundingrect.y() - > - self.currentframe.scrollPosition().y(), > - self.lastelementboundingrect.width(), > - self.lastelementboundingrect.height()) > - # painter.drawRect(QtCore.QRectF(self.lastelementcurrectrect)) > - painter.drawRect(QtCore.QRectF(rect)) > - painter.fillRect( > - QtCore.QRectF(rect), self.colorfill) > + if self.element: > + self.element.update() > > def setframeafterloadfinished(self): > self.currentframe = self.page().mainFrame() > @@ -109,15 +97,7 @@ > commentary text. > """ > self.drawrects = True > - self.colorfill = self.colors[forarea] > - self.colorfill.setAlpha(128) > - > - colorborder = self.colors[forarea] > - self.pen.setColor(colorborder) > + self.color = self.colors[forarea] > > # defines what we are looking to select > self.selecttype = forarea > > and here it is again but complete, **and functional** (just be sure to put the file > `webelementinfo.py` in the same directory as this code before running a test): > > #!/usr/bin/env python2 > # coding: utf-8 > # VENI, SANCTE SPIRITUS > > from PySide.QtWebKit import QWebView > from PySide import QtCore, QtGui > try: > from . import webelementinfo > except ValueError: > import webelementinfo > > > class CustomQWebView(QWebView): > > def __init__(self, *args, **kwargs): > """ Init the custom class > """ > super(CustomQWebView, self).__init__(*args, **kwargs) > self.colors = {0: QtGui.QColor(255, 165, 0, 127), > 1: QtGui.QColor(135, 206, 235, 127), > 2: QtGui.QColor(135, 235, 164, 127), > 3: QtGui.QColor(235, 135, 206, 127), > 4: QtGui.QColor(235, 164, 135, 127)} > self.color = None > self.currentframe = None > self.element = None > self.loadFinished.connect(self.setframeafterloadfinished) > self.selectCommentsArea() > > @QtCore.Slot() > def selectCommentsArea(self): > """ For selecting the comment area > """ > self.setup_rectcolor_area(0) > > @QtCore.Slot(QtGui.QMouseEvent) > def mouseMoveEvent(self, event): > super(CustomQWebView, self).mouseMoveEvent(event) > > if self.drawrects: > if self.currentframe: > hittestresult = self.currentframe.hitTestContent(event.pos()) > element = webelementinfo.WebElement( > hittestresult, self.color, self) > if not self.element: > self.element = element > elif self.element != element: > self.element = element > > # FIXME: self.update should draw rects from WebElements too. > self.update() > > @QtCore.Slot(QtGui.QPaintEvent) > def paintEvent(self, event): > # draw the content first > super(CustomQWebView, self).paintEvent(event) > > if self.drawrects: > # then the rectangle > if self.element: > self.element.update() > > def setframeafterloadfinished(self): > self.currentframe = self.page().mainFrame() > > def setup_rectcolor_area(self, forarea): > """Called when we want to select certain area of a web site > > This method set-up the painter to a giving color so web elements are > drawn with a rect on top. Also activates the flag to allow painting > inside CustomQWebView. > > :param int forarea: For which area we are going to set the painter\\ > valid values are: 0 for Comments area, 1 for comment box, 2 for\\ > commentator's user name, 3 for comment date and time, 4 for\\ > commentary text. > """ > self.drawrects = True > self.color = self.colors[forarea] > > # defines what we are looking to select > self.selecttype = forarea > > if __name__ == "__main__": > app = QtGui.QApplication([]) > mainwn = QtGui.QMainWindow() > mainwn.resize(800, 696) > centralwidget = QtGui.QWidget(mainwn) > centralwidget.resize(800, 600) > gridlayout = QtGui.QGridLayout(centralwidget) > web = CustomQWebView(parent=centralwidget) > gridlayout.addWidget(web, 0, 0, 1) > web.setUrl(QtCore.QUrl("http://duckduckgo.com")) > mainwn.show() > > app.exec_() > > Here is the other file that have the definition of that new class `WebElement` that I write and start > to use: > > #!/usr/bin/env python2 > # coding: utf-8 > # VENI, SANCTE SPIRITUS > > from PySide.QtWebKit import QWebElement, QWebHitTestResult > from PySide import QtGui > from PySide import QtCore > > > class WebElement(QtCore.QObject): > > """ Holds information of webelements > """ > > def __eq__(self, other): > if isinstance(other, WebElement): > return (self.web_element == other.web_element and > self.getrect() == other.getrect()) > else: > raise ValueError("Not same objects") > > def __ne__(self, other): > if isinstance(other, WebElement): > return (self.web_element != other.web_element and > self.getrect() != other.getrect()) > else: > raise ValueError("Not same objects") > > def __init__(self, hittestresult, color, parent=None): > super(WebElement, self).__init__(parent) > > if (not isinstance(hittestresult, QWebHitTestResult) and > not isinstance(hittestresult, QWebElement)): > raise ValueError( > "Argument passed for 'hittestresult' is not" > " QtWebkit.QWenHitTestResult or QtWebkit.QWebElement instance" > ) > if not isinstance(color, QtGui.QColor): > raise ValueError( > "Argument passed for 'color' is not QtGui.QColor instance" > ) > > try: > self.frame = hittestresult.frame() > except AttributeError: > self.frame = hittestresult.webFrame() > > self.frame_scroll_x = self.frame.scrollPosition().x() > self.frame_scroll_y = self.frame.scrollPosition().y() > > try: > rect = hittestresult.boundingRect() > except AttributeError: > rect = hittestresult.geometry() > > self.element_rect_x = rect.x() > self.element_rect_y = rect.y() > self.element_rect_w = rect.width() > self.element_rect_h = rect.height() > > try: > self.web_element = hittestresult.element() > except AttributeError: > self.web_element = hittestresult > > self.color = color > self.color_darker = color.darker() > self.color_darker.setAlpha(255) > self.pen = QtGui.QPen(self.color_darker) > self.pen.setWidth(2) > #self.painter = QtGui.QPainter(self.parent) > self.painter = QtGui.QPainter() > self.painter.setPen(self.pen) > > def update(self): > """ draw the rect for this element in the CustomQWebView > """ > rect = self.getrect() > rectf = QtCore.QRectF(rect) > self.painter.fillRect(rectf, self.color) > self.painter.drawRect(rectf) > > def getrect(self): > """ Return the rect for this WebElement > """ > self.frame_scroll_x = self.frame.scrollPosition().x() > self.frame_scroll_y = self.frame.scrollPosition().y() > rect = QtCore.QRect() > rect.setRect(self.element_rect_x - self.frame_scroll_x, > self.element_rect_y - self.frame_scroll_y, > self.element_rect_w, self.element_rect_h) > return rect > > My project should work right as if I didn't change anything, however, with these changes it > doesn't. What am I doing wrong? Am I missing something about `QWebFrame`s? > > [1]: http://stackoverflow.com/q/26726878/2020214 > > -- > Pax et bonum. > Jorge Araya Navarro. > ES: Diseñador Publicitario, Programador Python y colaborador en Parabola GNU/Linux-libre > EN: Ads Designer, Python programmer and contributor Parabola GNU/Linux-libre > EO: Anonco grafikisto, Pitino programalingvo programisto kai kontribuanto en Parabola GNU/Linux-libre > https://es.gravatar.com/shackra > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside -- Timeo Danaos et dona ferentes Twitter : @Arakowa1 From elcorreo at deshackra.com Thu Nov 6 23:07:05 2014 From: elcorreo at deshackra.com (Jorge Araya Navarro) Date: Thu, 06 Nov 2014 16:07:05 -0600 Subject: [PySide] Internal C++ object (PySide.QtWebKit.QWebFrame) already deleted; but I'm saving it as an attribute to avoid this exact issue In-Reply-To: <20141106203132.4f73929f@debian> References: <877fz8lxtx.fsf@deshackra.com> <20141106203132.4f73929f@debian> Message-ID: <877fz8j7pv.fsf@deshackra.com> Stefan Champailler writes: > Hi Jorge, > > Would you care to send a shorter version of the code (with the bug, that is) ? It'd help us to reproduce it (and it'd help you to better understand it) > > Stefan > Sure, for a minimal example that you can run, you will require to download the file attached. -------------- next part -------------- A non-text attachment was scrubbed... Name: webelementinfo.py Type: text/x-python Size: 3730 bytes Desc: code that defines WebElement class URL: -------------- next part -------------- Here is the code that displays the issue, after starting it, just move the mouse over the web site, here is the code: --8<---------------cut here---------------start------------->8--- #!/usr/bin/env python2 # coding: utf-8 # VENI, SANCTE SPIRITUS from PySide.QtWebKit import QWebView from PySide import QtCore, QtGui try: from . import webelementinfo except ValueError: import webelementinfo class CustomQWebView(QWebView): def __init__(self, *args, **kwargs): """ Init the custom class """ super(CustomQWebView, self).__init__(*args, **kwargs) self.colors = {0: QtGui.QColor(255, 165, 0, 127), 1: QtGui.QColor(135, 206, 235, 127), 2: QtGui.QColor(135, 235, 164, 127), 3: QtGui.QColor(235, 135, 206, 127), 4: QtGui.QColor(235, 164, 135, 127)} self.color = None self.currentframe = None self.element = None self.loadFinished.connect(self.setframeafterloadfinished) self.selectCommentsArea() @QtCore.Slot() def selectCommentsArea(self): """ For selecting the comment area """ self.setup_rectcolor_area(0) @QtCore.Slot(QtGui.QMouseEvent) def mouseMoveEvent(self, event): super(CustomQWebView, self).mouseMoveEvent(event) if self.drawrects: if self.currentframe: hittestresult = self.currentframe.hitTestContent(event.pos()) element = webelementinfo.WebElement( hittestresult, self.color, self) if not self.element: self.element = element elif self.element != element: self.element = element # FIXME: self.update should draw rects from WebElements too. self.update() @QtCore.Slot(QtGui.QPaintEvent) def paintEvent(self, event): # draw the content first super(CustomQWebView, self).paintEvent(event) if self.drawrects: # then the rectangle if self.element: self.element.update() def setframeafterloadfinished(self): self.currentframe = self.page().mainFrame() def setup_rectcolor_area(self, forarea): """Called when we want to select certain area of a web site This method set-up the painter to a giving color so web elements are drawn with a rect on top. Also activates the flag to allow painting inside CustomQWebView. :param int forarea: For which area we are going to set the painter\\ valid values are: 0 for Comments area, 1 for comment box, 2 for\\ commentator's user name, 3 for comment date and time, 4 for\\ commentary text. """ self.drawrects = True self.color = self.colors[forarea] # defines what we are looking to select self.selecttype = forarea if __name__ == "__main__": app = QtGui.QApplication([]) mainwn = QtGui.QMainWindow() mainwn.resize(800, 696) centralwidget = QtGui.QWidget(mainwn) centralwidget.resize(800, 600) gridlayout = QtGui.QGridLayout(centralwidget) web = CustomQWebView(parent=centralwidget) # I do this too in my main interface code gridlayout.addWidget(web, 0, 0, 1) # but wasn't a problem before adding my class WebElement web.setUrl(QtCore.QUrl("http://duckduckgo.com")) mainwn.show() app.exec_() --8<---------------cut here---------------end--------------->8--- -- Pax et bonum. Jorge Araya Navarro. ES: Diseñador Publicitario, Programador Python y colaborador en Parabola GNU/Linux-libre EN: Ads Designer, Python programmer and contributor Parabola GNU/Linux-libre EO: Anonco grafikisto, Pitino programalingvo programisto kai kontribuanto en Parabola GNU/Linux-libre https://es.gravatar.com/shackra From sergey.komissarov at datadvance.net Mon Nov 10 16:05:33 2014 From: sergey.komissarov at datadvance.net (Sergey A. Komissarov) Date: Mon, 10 Nov 2014 18:05:33 +0300 (MSK) Subject: [PySide] Translating 4-bytes unicode symbols from cpp to python In-Reply-To: <2128329163.173607.1415628811915.JavaMail.zimbra@datadvance.net> Message-ID: <1955401690.174487.1415631933328.JavaMail.zimbra@datadvance.net> Hello, We have 64bit linux cpp application with embeded python and pyside. Recently we encountered problem with more than 2-bytes long unicode symbols: >from PySide import QtCore >QtCore.QUrl(u"\U0001F431").toString() # using u"\uD83D\uDC31" instead of u"\U0001F431" leads to the same result >u'\U0001f431\u7f74' # 2 symbols string instead of one last symbol is different each application run (it's some randomly filled memory). our exact environment is python 2.7.7 with Py_UNICODE_SIZE = 2, pyside 1.1.2 and qt 4.8.3 where sizeof(wchar_t) = 4. Look in the QString converter-function at PySide/QtCore/typesystem_core_common.xml:195 The source of problem is QString::toWCharArray function, which traslates 2 characters QString into single character wchar_t array and python PyUnicode_FromWideChar doesn't set proper unicode string length to resulting object when argument array have internal zeros. I attached patch which seems to fix this problem. If patch is not appropriate could someone tell me how to fix this properly? -------------- next part -------------- A non-text attachment was scrubbed... Name: pyside-qstring.patch Type: text/x-patch Size: 2451 bytes Desc: not available URL: From elcorreo at deshackra.com Mon Nov 17 23:09:33 2014 From: elcorreo at deshackra.com (Jorge Araya Navarro) Date: Mon, 17 Nov 2014 16:09:33 -0600 Subject: [PySide] QFont::setPixelSize: Pixel size <= 0 (0) Message-ID: <87vbmdiijq.fsf@deshackra.com> Hello! I have notice this message from Qt `QFont::setPixelSize: Pixel size <= 0 (0)` appearing while my application runs. I'm using QtWebKit in my project. Is there a way to suppress it? -- Pax et bonum. Jorge Araya Navarro. ES: Diseñador Publicitario, Programador Python y colaborador en Parabola GNU/Linux-libre EN: Ads Designer, Python programmer and contributor Parabola GNU/Linux-libre EO: Anonco grafikisto, Pitino programalingvo programisto kai kontribuanto en Parabola GNU/Linux-libre https://es.gravatar.com/shackra From me at the-compiler.org Tue Nov 18 12:10:57 2014 From: me at the-compiler.org (Florian Bruhin) Date: Tue, 18 Nov 2014 12:10:57 +0100 Subject: [PySide] QFont::setPixelSize: Pixel size <= 0 (0) In-Reply-To: <87vbmdiijq.fsf@deshackra.com> References: <87vbmdiijq.fsf@deshackra.com> Message-ID: <20141118111057.GG32338@tonks> * Jorge Araya Navarro [2014-11-17 16:09:33 -0600]: > Hello! > > I have notice this message from Qt `QFont::setPixelSize: Pixel size <= 0 (0)` appearing while my application > runs. I'm using QtWebKit in my project. Hah, I just noticed the same yesterday as well when trying some Qt4 browser. It seems it's gone in Qt5. Probably it's fixed by [1]. [1] https://bugs.webkit.org/show_bug.cgi?id=49759 > Is there a way to suppress it? You could use qInstallMsgHandler[2] to install a message handler and then filter this message, e.g. using regex. [2] http://qt-project.org/doc/qt-4.8/qtglobal.html#qInstallMsgHandler Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From elcorreo at deshackra.com Tue Nov 18 20:17:58 2014 From: elcorreo at deshackra.com (Jorge Araya Navarro) Date: Tue, 18 Nov 2014 13:17:58 -0600 Subject: [PySide] QFont::setPixelSize: Pixel size <= 0 (0) In-Reply-To: <20141118111057.GG32338@tonks> References: <87vbmdiijq.fsf@deshackra.com> <20141118111057.GG32338@tonks> Message-ID: <87ppck71wc.fsf@deshackra.com> Florian Bruhin writes: > * Jorge Araya Navarro [2014-11-17 16:09:33 -0600]: >> Hello! >> >> I have notice this message from Qt `QFont::setPixelSize: Pixel size <= 0 (0)` appearing while my application >> runs. I'm using QtWebKit in my project. > > Hah, I just noticed the same yesterday as well when trying some Qt4 > browser. It seems it's gone in Qt5. Probably it's fixed by [1]. > > [1] https://bugs.webkit.org/show_bug.cgi?id=49759 > >> Is there a way to suppress it? > > You could use qInstallMsgHandler[2] to install a message handler and > then filter this message, e.g. using regex. > > [2] http://qt-project.org/doc/qt-4.8/qtglobal.html#qInstallMsgHandler > > Florian I have noticed that there isn't documentation in PySide about such solution... -- Pax et bonum. Jorge Araya Navarro. ES: Diseñador Publicitario, Programador Python y colaborador en Parabola GNU/Linux-libre EN: Ads Designer, Python programmer and contributor Parabola GNU/Linux-libre EO: Anonco grafikisto, Pitino programalingvo programisto kai kontribuanto en Parabola GNU/Linux-libre https://es.gravatar.com/shackra From juan0christian at gmail.com Wed Nov 26 02:21:10 2014 From: juan0christian at gmail.com (Juan Christian) Date: Wed, 26 Nov 2014 01:21:10 +0000 Subject: [PySide] Question about QThred and QObject (Signal/Slot) Message-ID: Python 3.4.2 PySide 1.2.2 The code: http://pastebin.com/piR42XzQ Main module: http://pastebin.com/CE2GN3nM The 'main.ui' only have a QVBoxLayout and it's OK. Traceback (most recent call last): File "D:/.../main.py", line 44, in output_slot outpost = Outpost('76561198077080978') File "D:\...\outpost.py", line 29, in __init__ self.finished.emit() TypeError: finished(QThread*) only accepts 1 arguments, 1 given! Didn't understood the error... Anyway, is this a good approach regarding threads and signal/slot? -------------- next part -------------- An HTML attachment was scrubbed... URL: