Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    [python] PySide for gui

    General Discussion
    0
    9
    2.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 29/10/2015 at 00:05, xxxxxxxx wrote:

      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
      _

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 29/10/2015 at 10:30, xxxxxxxx wrote:

        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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 29/10/2015 at 10:49, xxxxxxxx wrote:

          Scott, i tried before, got different glitches and crashes - probably i had a few amount  of experience or wrong python/pyside*😉. 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, 🤢
          but can be to create more complex qt dialog.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 29/10/2015 at 11:28, xxxxxxxx wrote:

            Scott, have you try to build widgets, for windows os? Example(macos or linux) https://github.com/fabric-engine/FabricUI/blob/pablo/PySideBuild.sh

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 29/10/2015 at 11:29, xxxxxxxx wrote:

              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

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 29/10/2015 at 11:44, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                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 xxxxxxxx

                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

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  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

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 29/10/2015 at 12:00, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    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 😠 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()
                    
                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 29/10/2015 at 12:07, xxxxxxxx wrote:

                      I'm sorry that made such topic and content. Maybe python, qt and etc.  will be one of topics at future developer kitchens

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post