Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > General Discussion
  New Posts New Posts
  FAQ FAQ  Forum Search

[python] PySide for gui

Author
Message
  Topic Search Topic Search
Ilya View Drop Down
Member
Member
Avatar

Joined: 2009 Nov 04
Location: Russia
Online Status: Offline
Posts: 245
Direct Link To This Post Topic: [python] PySide for gui
    Posted: 2015 Oct 29 at 12:05am
Hi
I wanna say thanks to maxon, for recent enhancements for python bridge.

Alternative ide for ui - qtdesigner, transferring of data to python by pyside-uic

a few recent tests with pyside 1.2.4

in c4d

or kraken by Hybride Technologies for FE

upd.
i remove pic from dead image hoster


Edited by Ilya - 2015 Nov 22 at 4:44am
(sorry for my English)
Back to Top
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Direct Link To This Post Posted: 2015 Oct 29 at 10:30am
What new enhancements?
I've been using PySide ( and also C++ Qt gui code ) in my plugins for this same kind of thing in R13 for a while now.
I'm even launching Qt based dialogs from C4D plugins that can interact with the scene objects.
Of course they can't be docked like a GeDialog.

What new enhancements have they added for Qt since R13?


-ScottA
Back to Top
Ilya View Drop Down
Member
Member
Avatar

Joined: 2009 Nov 04
Location: Russia
Online Status: Offline
Posts: 245
Direct Link To This Post Posted: 2015 Oct 29 at 10:49am
Scott, i tried before, got different glitches and crashes - probably i had a few amount  of experience or wrong python/pyside*Wink. I'm studying qt/pyside

* - even today, i post issue at kraken's git, about wrong display of node body(rounded rectangle)... resolved by new pyside v.1.2.4... before was same as for houdini or maya - 1.2.2
-----

so even, i create such topic

Of course they can't be docked like a GeDialog.

yes, Dead
but can be to create more complex qt dialog.
(sorry for my English)
Back to Top
Ilya View Drop Down
Member
Member
Avatar

Joined: 2009 Nov 04
Location: Russia
Online Status: Offline
Posts: 245
Direct Link To This Post Posted: 2015 Oct 29 at 11:28am
Scott, have you try to build widgets, for windows os? Example(macos or linux) https://github.com/fabric-engine/FabricUI/blob/pablo/PySideBuild.sh
(sorry for my English)
Back to Top
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Direct Link To This Post Posted: 2015 Oct 29 at 11:29am
Ok.
I just wanted to make sure Maxon didn't actually do anything new to make Qt stuff integrate with C4D.
I've asked for this many times over the years. And the replies from the Maxon devs has always been negative about Qt. So it surprised me to see you saying "new stuff" for handling Qt.

I've had to figure out how to integrate Qt with C4D on my own. The same way I had to figure out how to use Win32 code and Win32 dialogs with C4D.
PySide is dead simple to use in C4D due to python itself (nothing Maxon did). Even in R13.
But C++ is a bit harder because you need to create a Custom Build Tool for moc'ing it to generate the signals & slots code in VS.

I had considered doing Qt<-->C4D YouTube tutorials for both PySide & C++.
But since I'm using R13. I have to use VS2010 with it.
And I figured those programs were too outdated to use for tutorials.


-ScottA
Back to Top
Ilya View Drop Down
Member
Member
Avatar

Joined: 2009 Nov 04
Location: Russia
Online Status: Offline
Posts: 245
Direct Link To This Post Posted: 2015 Oct 29 at 11:44am
Originally posted by ScottA

Ok.
I just wanted to make sure Maxon didn't actually do anything new to make Qt stuff integrate with C4D.
I've asked for this many times over the years. And the replies from the Maxon devs has always been negative about Qt. So it surprised me to see you saying "new stuff" for handling Qt.

argh, sorry, that bring false info what maxon done. i only point that moving to vfx platform concept(2015 - http://www.vfxplatform.com ) - change to pyhon 2.7 > make a few pluses for maxon

yes, this also stopped me to learn pyside or pyQT

Originally posted by ScottA

But C++ is a bit harder because you need to create a Custom Build Tool for moc'ing it to generate the signals & slots code in VS.

oh yes, i made qtport of Fabric Engine(it's canvas is qt app gui) to one cad tool. Sdk of this cad is tiny(early bird), so it was easy


Edited by Ilya - 2015 Oct 29 at 11:45am
(sorry for my English)
Back to Top
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Direct Link To This Post Posted: 2015 Oct 29 at 11:46am
Originally posted by Ilya

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><b>" + labelText + "</b></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
Back to Top
Ilya View Drop Down
Member
Member
Avatar

Joined: 2009 Nov 04
Location: Russia
Online Status: Offline
Posts: 245
Direct Link To This Post Posted: 2015 Oct 29 at 12:00pm
Originally posted by ScottA


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

Interesting sample, for example i spent a week or more to understand how assembly their widget python-module-of-fabricui Ouch still no luck - i feel that it not finished. I use "hybrid" - c/c++ extensions and scripting

your example, i moved from such declaration of QtGui.QApplication, make like in maya or hou

import c4d
import sys

from PySide import QtCore, QtGui, shiboken
from PySide.QtCore import *
from PySide.QtGui import *

class Window(QtGui.QMainWindow):
  def __init__(self):
    super(Window,self).__init__()
    self.initUI()
  def initUI(self):
    self.setGeometry(200,500,400,400)
    self.setWindowTitle("Test")

    centralWidget = QtGui.QWidget()
    self.setCentralWidget(centralWidget)
   
def main():
   
    app = QtGui.QApplication.instance() # checks if QApplication already exists    
    if not app: # create QApplication if it doesnt exist
          app = QtGui.QApplication([])
          print "qt app"
    app.aboutToQuit.connect(app.deleteLater)
    print "qt app ins"   
    win = Window()
    win.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
    win.setProperty("saveWindowPref", True )
    if win.isVisible() == False:
        win.show()
        app.exec_()
        while (win.isVisible()):
            app.processEvents()
        if win.isVisible() == False:
            print "exit"
            win.close()   

if __name__ == "__main__":
  main()




Edited by Ilya - 2015 Oct 29 at 12:04pm
(sorry for my English)
Back to Top
Ilya View Drop Down
Member
Member
Avatar

Joined: 2009 Nov 04
Location: Russia
Online Status: Offline
Posts: 245
Direct Link To This Post Posted: 2015 Oct 29 at 12:07pm
I'm sorry that made such topic and content. Maybe python, qt and etc.  will be one of topics at future developer kitchens


Edited by Ilya - 2015 Oct 29 at 12:07pm
(sorry for my English)
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.125 seconds.