File: pyqt5.py

package info (click to toggle)
python-sfml 2.2~git20150611.196c88%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,816 kB
  • ctags: 1,605
  • sloc: python: 1,125; cpp: 309; makefile: 118
file content (38 lines) | stat: -rw-r--r-- 937 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys

try:
    from PyQt5.Qt import *
except ImportError:
    print("Install PyQt5 from Riverbank.")

from sfml import sf
from qsfml_canvas import QSFMLCanvas


class MyCyanCanvas(QSFMLCanvas):
    def onInit(self):
        self.image = sf.Image.from_file("data/head_kid.png")
        self.texture = sf.Texture.from_image(self.image)
        self.sprite = sf.Sprite(self.texture)
        self.sprite.position = self.texture.size // (2, 2)

    def onUpdate(self):
        self.clear(sf.Color.CYAN)
        self.sprite.rotate(0.05)
        self.sprite.origin = self.texture.size // (2, 2)
        self.draw(self.sprite)

app = QApplication(sys.argv)

# create the main frame
mainFrame = QFrame()
mainFrame.setWindowTitle("pySFML - Qt")
mainFrame.resize(400, 400)
mainFrame.show()

# create a SFML view inside the main frame
SFMLView = MyCyanCanvas(mainFrame, QPoint(20, 20), QSize(360, 360))
SFMLView.show()

app.exec_()
sys.exit()