On 29/10/2015 at 11:46, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Scott, have you try to build widgets, for windows os? Example(macos or linux) https://github.com/fabric-engine/FabricUI/blob/pablo/PySideBuild.sh
Yes. Although I just remembered that I used PyQt. Not PySide.
Here's one of the examples I wrote.
This code creates floating windowless Qt widgets that can interact with things in C4D.
#This code creates various gizmos without a visible dialog window (a SplashScreen)
#Then closes it after 5 seconds
import c4d,sys,time
from PyQt4 import QtGui, QtCore, uic
from os import path
QtCore.QCoreApplication.addLibraryPath(path.join(path.dirname(QtCore.__file__), "plugins"))
def handleButton() :
print "Button Clicked"
def handleSlider(value) :
for i in xrange(0,101) :
if value == i: print i
def handleCHKBOX(state) :
if state == QtCore.Qt.Checked: print "on"
else: print "off"
def main() :
app = QtGui.QApplication(sys.argv)
curTime = QtCore.QTime.currentTime()
print curTime
#Creates a gizmo with no dialog and forces it to be the topmost window
#Also puts an icon on the button
button = QtGui.QPushButton('Test')
button.move(700, 400) #Screen X,Y position
icon = QtGui.QIcon("C:/Users/user/Desktop/myimage.jpg")
button.setIconSize(QtCore.QSize(64,64))
button.setIcon(icon)
button.setWindowFlags(QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint)
button.show()
button.clicked.connect(handleButton)
#Creates a gizmo with no dialog and forces it to be the topmost window
labelText = "Hello"
myLabel = QtGui.QLabel("<font color=red size=72>" + labelText + "</font>")
myLabel.move(700, 350) #Screen X,Y position
myLabel.setWindowFlags(QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint)
myLabel.show()
#Creates a label gizmo that is used to display an image
image = QtGui.QPixmap( "C:/Users/user/Desktop/myimage.jpg" )
myLabel = QtGui.QLabel()
myLabel.setPixmap(image)
myLabel.move(700, 350) #Screen X,Y position
myLabel.setWindowFlags(QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint)
myLabel.show()
#Creates a slider gizmo
sld = QtGui.QSlider(QtCore.Qt.Horizontal)
sld.setFocusPolicy(QtCore.Qt.NoFocus)
sld.setMinimum(0)
sld.setMaximum(101)
sld.setWindowFlags(QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint)
sld.setGeometry( 700, 300, 100, 20) #Screen X,Y position, width&height
sld.valueChanged[int].connect(handleSlider)
sld.show()
#Creates a checkbox gizmo
cb = QtGui.QCheckBox('My checkbox')
cb.setWindowFlags(QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint)
cb.toggle()
cb.stateChanged.connect(handleCHKBOX)
cb.setGeometry(700, 250, 85, 15) #Screen X,Y position, width&height
cb.show()
#Close the gizmos after 5 seconds
QtCore.QTimer.singleShot(5000, app.quit)
app.exec_()
if __name__=='__main__':
main()
To be honest I toyed around for this for like one day. Said to myself...heck this is simple...Made some examples and some notes...And then never used it again.
I don't use Python very much other than for quickly testing things in C4D. And I never install custom python modules like this.
I stay mostly in C++.
-ScottA