Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: PyQt4 + PySFML feedback  (Read 5963 times)

0 Members and 1 Guest are viewing this topic.

Kharyus

  • Newbie
  • *
  • Posts: 7
    • View Profile
PyQt4 + PySFML feedback
« on: July 17, 2015, 02:21:27 pm »
Hello. I have found a little problem in the PyQt4 example in PySFML and thought i'd share just in case. I do not know if this is the suited place so feel free to delete this.

In the PyQt example that can be found here there seems to be a minor issue in the initialization order of things.

# let the derived class do its specific stuff
        self.onInit()
Is inside def showEvent(self, event):, which caused the onUpdate method of the derived class to run once before the onInit step, which in turn caused some errors because things had not been initialized yet. In c++ this would be a bigger problem, but i still thought it was a bother having those errors showing so i found the solution. The onInit call must be inside the base class' constructor, i put mine after
self.__dict__['display'] = self._HandledWindow.display
and things started to run smoothly.

Since i'm already writing this, in the example it was still required for me to figure how to start the program on my own. I suggest that it would be interesting having some code like this available in the example so the user could have a running application from the start
# Main part
app = QApplication(sys.argv)

# Qt Frame
mainframe = QFrame()
mainframe.setWindowTitle("QtPySFML")
mainframe.resize(500, 500)
mainframe.show()

# QSFML Canvas
position = QPoint()
position.setX(0)
position.setY(0)
size = QSize()
size.setHeight(400)
size.setWidth(400)
# this SFMLCanvas class is the derived class that the user must create basing on QSFMLCanvas
sfmlwidget = SFMLCanvas(mainframe, position, size)
sfmlwidget .show()

sys.exit(app.exec_())

I'm not really used to giving feedback so i don't know if i'm being a bother, but thought i'd share this stuff.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: PyQt4 + PySFML feedback
« Reply #1 on: July 22, 2015, 09:15:36 am »
Thanks a bunch for your feedback. :)

Unfortunately PySFML's maintainer Sonkun is currently MIA, so I'm not sure how and when it'll be fixed.