changeset 45:8a52263d67c4

Fixed width of library
author windel
date Sat, 18 Feb 2012 17:09:21 +0100
parents cbf199e007c2
children 7964065400b7
files applications/lab/diagrameditor.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/applications/lab/diagrameditor.py	Sat Feb 18 16:42:23 2012 +0100
+++ b/applications/lab/diagrameditor.py	Sat Feb 18 17:09:21 2012 +0100
@@ -96,7 +96,7 @@
       self.setFlag(self.ItemSendsScenePositionChanges, True)
    def itemChange(self, change, value):
       if change == self.ItemScenePositionHasChanged:
-         value = value.toPointF() # Required!
+         #value = value.toPointF() # Required in python2??!
          for cb in self.posCallbacks:
             cb(value)
          return value
@@ -117,7 +117,7 @@
 
    def itemChange(self, change, value):
       if change == self.ItemPositionChange:
-         value = value.toPointF()
+         #value = value.toPointF()
          x, y = value.x(), value.y()
          # TODO: make this a signal?
          # This cannot be a signal because this is not a QObject
@@ -244,7 +244,8 @@
       mimedata = QMimeData()
       for idx in idxs:
          if idx.isValid():
-            txt = self.data(idx, Qt.DisplayRole).toByteArray()
+            #txt = self.data(idx, Qt.DisplayRole).toByteArray() # python2
+            txt = self.data(idx, Qt.DisplayRole) # python 3
             mimedata.setData('component/name', txt)
       return mimedata
 
@@ -266,6 +267,7 @@
       # Widget layout and child widgets:
       self.horizontalLayout = QtGui.QHBoxLayout(self)
       self.libraryBrowserView = QtGui.QListView(self)
+      self.libraryBrowserView.setMaximumWidth(160)
       self.libraryModel = LibraryModel(self)
       self.libraryModel.setColumnCount(1)
       # Create an icon with an icon:
@@ -326,6 +328,10 @@
          self.startedConnection = None
 
 if __name__ == '__main__':
+   if sys.version_info.major != 3:
+      print('Please use python 3.x')
+      sys.exit(1)
+
    app = QtGui.QApplication(sys.argv)
    global editor
    editor = DiagramEditor()