Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PySide.QtCore import *
- from PySide.QtGui import *
- import PySide.QtGui as QtGui
- import PySide.QtCore as QtCore
- import maya.OpenMayaUI as omu
- import maya.cmds as mc
- from shiboken import wrapInstance
- from functools import partial
- import random
- from functools import partial
- import math
- class CustomButtom(QtGui.QPushButton):
- def __init__(self):
- super(CustomButtom, self).__init__()
- def closeWindow(self, windowsToClose):
- for w in windowsToClose:
- w.resize(55,55)
- w.deleteLater()
- def mouseMoveEvent(self, event):
- print("in focus")
- def enterEvent(self, event):
- print("Enter")
- #button.setStyleSheet("background-color:#45b545;")
- def leaveEvent(self, event):
- #button.setStyleSheet("background-color:yellow;")
- print("Leave")
- def buttonCreator(self, parentWindow, buttonName, windowsList):
- #create buttons function
- self.icon = QtGui.QIcon(":/clusterHandle.svg")
- self.buttonTest = QtGui.QPushButton(parent = parentWindow)
- self.buttonTest.setObjectName(buttonName)
- self.buttonTest.setGeometry(QtCore.QRect(0, 0, 50, 50))
- self.buttonTest.setIconSize(QSize(50, 50))
- self.buttonTest.setText("test")
- self.buttonTest.clicked.connect(partial(self.closeWindow, windowsList))
- self.buttonTest.setMouseTracking(1)
- self.buttonTest.pressed.connect(PrintTestClass)
- self.buttonTest.setStyleSheet("hover: background-color:blue;")
- class PrintTestClass(object):
- def __init__(self):
- print("this a test")
- class RadialMenuWindow(object):
- def __init__(self):
- self.mousePos = QtGui.QCursor().pos()
- self.mayaMainWindowPtr = omu.MQtUtil.mainWindow()
- self.mayaMainWindow= wrapInstance(long(self.mayaMainWindowPtr), QWidget)
- self.windowsList = []
- def menuLikeWindow(self, windowName):
- self.windowName = QtGui.QMainWindow(parent = self.mayaMainWindow, flags=QtCore.Qt.FramelessWindowHint)
- self.windowName.setWindowTitle(str(windowName))
- self.windowName.setObjectName(str(windowName))
- #self.windowName.setAttribute(QtCore.Qt.WA_TranslucentBackground)
- #self.windowName.setStyleSheet("background:transparent;")
- self.windowName.resize(80,80)
- if not self.windowName in self.windowsList:
- self.windowsList.append(self.windowName)
- return self.windowName
- def createWindowsFunction(self):
- buttonCreatorInstance = CustomButtom()
- #create a window with its button
- self.windowNorth = self.menuLikeWindow("windowNorth")
- self.windowNorthButton = buttonCreatorInstance.buttonCreator(self.windowNorth, "buttonWindNorth",
- self.windowsList)
- #self.windowNorthButton.setMouse
- #position windows based on the windows len
- angleIncrease = 360 / len(self.windowsList)
- radius = 100
- angle = -90
- for i in self.windowsList:
- x = radius * math.cos(math.radians(angle)) + self.mousePos.x()- 25
- y = radius * math.sin(math.radians(angle)) + self.mousePos.y()- 25
- i.move(x, y)
- i.show()
- angle += angleIncrease
Advertisement
Add Comment
Please, Sign In to add comment