Exemplo n.º 1
0
    def loadModel(self, model):
        self.model = model
        # set size and position based on the position of the node in the tree, also load data comes with model
        if not model.rect:
            if model.isLeaf():
                self.model.rect = QRectF(-NodeGraphicsItem.LEAFSIZE[0] / 2,
                                         -NodeGraphicsItem.LEAFSIZE[1] / 2,
                                         *NodeGraphicsItem.LEAFSIZE)
            else:
                self.model.rect = QRectF(-NodeGraphicsItem.PARENTSIZE[0] / 2,
                                         -NodeGraphicsItem.PARENTSIZE[1] / 2,
                                         *NodeGraphicsItem.PARENTSIZE)
        if model.isLeaf():
            self._resizable = False
        else:
            self._resizable = True
            self.setResizeHandle()

        if model.pos:
            self.setPos(model.pos)
        else:
            self.model.pos = QPointF(0, 0)

        if not model.color:
            self.model.color = QColor(
                qrand() % 256,
                qrand() % 256,
                qrand() % 256) if model.isLeaf() else QColor(Qt.lightGray)

        if not model.isLeaf():
            for child in model.children:
                childitem = NodeGraphicsItem(child, self)
Exemplo n.º 2
0
def generate_password(charcount, charset, seed):
	"""Generate a password for the given charcount, charset and seed
	   using the qsrand() and qrand() functions, just as the KDE
	   paste applet would.
	   Note that this is an example of how NOT to do it."""
	qsrand(seed)
	return "".join([ charset[qrand() % len(charset)] for _ in range(charcount)])
Exemplo n.º 3
0
def generate_password(charcount, charset, seed):
    """Generate a password for the given charcount, charset and seed
	   using the qsrand() and qrand() functions, just as the KDE
	   paste applet would.
	   Note that this is an example of how NOT to do it."""
    qsrand(seed)
    return "".join([charset[qrand() % len(charset)] for _ in range(charcount)])
Exemplo n.º 4
0
    def keyPressEvent(self, event):
        key = event.key()

        if key == Qt.Key_Up:
            self.centerNode.moveBy(0, -20)
        elif key == Qt.Key_Down:
            self.centerNode.moveBy(0, 20)
        elif key == Qt.Key_Left:
            self.centerNode.moveBy(-20, 0)
        elif key == Qt.Key_Right:
            self.centerNode.moveBy(20, 0)
        elif key == Qt.Key_Plus:
            self.scaleView(1.2)
        elif key == Qt.Key_Minus:
            self.scaleView(1 / 1.2)
        elif key == Qt.Key_Space or key == Qt.Key_Enter:
            for item in self.scene().items():
                if isinstance(item, Node):
                    item.setPos(-150 + qrand() % 300, -150 + qrand() % 300)
                else:
                    super(GraphWidget, self).keyPressEvent(event)
Exemplo n.º 5
0
	def random(valA, valB=0):
		"""
		Gibt einen zufälligen Wert zwischen valMin und valMax zurück. [valMin, valMax]
		Sollte valB nicht angegeben werden, wird es als 0 angenommen.
		"""
		
		if (valB < valA):
			valueMin = valB
			valueMax = valA
		else:
			valueMin = valA
			valueMax = valB
			
		return valueMin + (qrand() % (valueMax - valueMin + 1))
Exemplo n.º 6
0
 def createGui(self):
     pNetworkAccessManager.instance().setCacheDirectory(
         qApp.applicationDirPath().append( "/tmp" ) )
     
     self.twPages = QTabWidget( self )
     self.setCentralWidget( self.twPages )
     
     # initialize gui
     self.createMenuBar()
     self.createPlainTextEdit()
     self.createActionsTreeView()
     self.createConsole()
     self.createVersionsTests()
     self.createListEditors()
     self.createEnvironmentVariablesEditor()
     self.createCustomWidgets()
     self.createUpdateChecker()
     
     QTimer.singleShot( 3000, self.ucMkS.silentCheck )
     
     # create fake dock widget for testing
     '''for ( i = 0; i < 10; i++ )        dw = QDockWidget( self )
         dw.setObjectName( QString( "Dock%1" ).arg( i ) )
         dw.toggleViewAction().setObjectName( 
                     QString( "DockViewAction%1" ).arg( i ) )
         self.dockToolBar( Qt.LeftToolBarArea ).addDockWidget( 
                 dw, QString( "Dock %1" ).arg( i ), 
     QIcon( scaledPixmap( 
         ":/fresh/country-flags/ad.png", QSize( 96, 96 ) ) ) )
     }'''
     
     # list dock widgets in the menu
     for dockWidget in self.findChildren(QDockWidget):
         #dockWidget.setAttribute( Qt.WA_DeleteOnClose )
         action = dockWidget.toggleViewAction()
         self.mActionsModel.addAction( "mView/mDockWidgets/%s" % \
                     action.objectName() , action )
         self.mActionsModel.setDefaultShortcut(action, 
             QKeySequence( "Ctrl+%s" % chr( max( 32, qrand() % 127 ) ) ) )
Exemplo n.º 7
0
def randomValue():
    #a number between [ 0.0, 1.0 ]
    return (qrand() % 100000) / 100000.0