Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PySide import QtCore, QtGui
- import sys
- class Ui_fi(object):
- '''
- UI, auto-generated by using QtDesigner, do not change anything here,
- but only in the .ui file with QtDesigner.
- '''
- def setupUi(self, fi):
- fi.setObjectName("fi")
- fi.resize(603, 361)
- self.zoneDessin = QtGui.QGraphicsView(fi)
- self.zoneDessin.setGeometry(QtCore.QRect(80, 80, 421, 231))
- self.zoneDessin.setObjectName("zoneDessin")
- self.retranslateUi(fi)
- QtCore.QMetaObject.connectSlotsByName(fi)
- def retranslateUi(self, fi):
- fi.setWindowTitle(QtGui.QApplication.translate("fi", "Essai de dessin", None, QtGui.QApplication.UnicodeUTF8))
- class Gui(QtGui.QMainWindow, Ui_fi):
- '''Graphical user interface, without any logic'''
- def __init__(self):
- super(Gui, self).__init__()
- self.setupUi(self)
- def customPaint(self):
- '''Example to draw some text and lines in the graphicsview'''
- scene = QtGui.QGraphicsScene(0, 0, 200, 200)
- scene.addText("Hello Georges!")
- # Draw a box around the text
- width = 110
- height = 40
- downX = width / 2
- downY = height + 20
- scene.addLine(0, 0, 0, height)
- scene.addLine(width, height, downX, downY)
- scene.addLine(0, height, downX, downY)
- scene.addLine(width, 0, width, height)
- scene.addLine(0, 0, width, 0)
- self.zoneDessin.setScene(scene)
- class Controller(object):
- '''Controls interaction between view and logic'''
- def __init__(self):
- self.view = Gui()
- def start(self):
- '''Start the application'''
- self.view.customPaint()
- self.view.show()
- if __name__== "__main__":
- app = QtGui.QApplication(sys.argv)
- controller = Controller()
- controller.start()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment