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
    • Register
    • Register
    • Login

    Gui Dialog in Python not respecting the dimensions

    Cinema 4D SDK
    python
    3
    11
    1.8k
    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.
    • D
      danielsian
      last edited by Manuel

      Hi there

      I'm setting up the dimensions of a dialog in Python, but the result is not correct as you can see on the image below.

      Is this way the right way to do this or there is a better one?

      import c4d
      from c4d import gui
      
      class OptionsDialog(gui.GeDialog):
          def CreateLayout(self):
              self.SetTitle('Dummy Dialog 700x200px')
              self.AddMultiLineEditText(1000, c4d.BFH_SCALEFIT, inith=50, initw=500, style=c4d.DR_MULTILINE_READONLY)
              self.SetString(1000, "Hello World!")
              if self.GroupBegin(1001, c4d.BFH_CENTER, 2, 1):
                  self.AddDlgGroup(c4d.DLG_CANCEL|c4d.DLG_OK)
              self.GroupEnd()
              self.ok = False
              return True
          
          def Command(self, id, msg):
              if id==c4d.DLG_CANCEL:
                  self.Close()
                  return False
              elif id==c4d.DLG_OK:
                  self.ok = True
                  self.Close()
              return True
      
      def main():
          dlg = OptionsDialog()
          dlg.Open(c4d.DLG_TYPE_MODAL, xpos=-2, ypos=-2, defaultw=700, defaulth=200)
      
      if __name__=='__main__':
          main()
      
      

      dummy_dialog_700x200.jpg

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        Hello,

        For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

        • Q&A New Functionality.
        • How to Post Questions especially the tagging part.

        I've added the tags and marked this thread as a question so when you considered it as solved, please change the state 🙂

        About your question : I can confirm that.

        It's working perfectly with a plugin. (even with a DLG_TYPE_MODAL)

        Within a script the dialog box get the minimal size of its gadget.
        You can set the size of your MultiLineEdtiText gadget to the size you want using c4d.gui.SizePix()

        I'll have a look to the code to see if it's done on purpose or not.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by Manuel

          hello,

          After diving into the code, strange enough, I've seen that adding a pluginid as a parameter to the open function does make it work as expected.
          So you can retrieve a pluginID on this forum (top bar) and add it to your Open command

          Now i can asked the devs why it need that. 🙂

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • D
            danielsian
            last edited by

            Hey Manuel, how are you?

            I'm sorry for the mess!
            Could you please provide an example on how this PluginID should be used so we have the function working as expected?

            I am still learning and I appreciate any help.

            Thanks for your time!
            Cheers

            1 Reply Last reply Reply Quote 0
            • D
              danielsian
              last edited by danielsian

              Hi Manuel

              I think I did it correctly and now I have R21 rendering the dialog exactly like R19 and R20 is doing.
              But I'm struggling to understand why the dialog is being created with slightly smaller dimension than the specified.

              Why is this happening?

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by

                hello,

                ok you never specified it was working as expected in R19/R20.

                So this look like a bug/regression. I'll open a bug entry.

                for now you can use my workaround using the pluginID parameter like so

                # where 123456 is a unique ID retrieve in plugincafe.maxon.net
                dlg.Open(c4d.DLG_TYPE_MODAL,pluginid=123456, xpos=-2, ypos=-2, defaultw=1920, defaulth=200)
                

                Cheers,
                Manuel

                MAXON SDK Specialist

                MAXON Registered Developer

                D 1 Reply Last reply Reply Quote 0
                • D
                  danielsian @Manuel
                  last edited by

                  @m_magalhaes said in Gui Dialog in Python not respecting the dimensions:

                  you never specified it was working as expected in R19/R20.

                  Hi Manuel

                  My fault in not being clear enough, I should have been more specific.

                  The problem was implicit, where on the image attached we see "Dialog 700x200px" (defaultw=700, defaulth=200), but with different numbers in red.
                  By deduction we can read something as not correct. But again, my fault in not being clear enough, sorry about that.

                  So, just to confirm, the issue is about the dimension in pixels not matching what was expected from the code.

                  I was expecting a dialog with 700x200 pixels, and was getting 686x193 in R19/20 and 333x146 in R21.

                  After your workaround, R21 is working better, but still not matching the 700x200 pixels.

                  Thank you again for your time!
                  Cheers

                  1 Reply Last reply Reply Quote 0
                  • ManuelM
                    Manuel
                    last edited by

                    hello,

                    Ok now i got it. But there's not pictures attached to your post.
                    Are you using Windows or OSX ?

                    Cheers,
                    Manuel

                    MAXON SDK Specialist

                    MAXON Registered Developer

                    1 Reply Last reply Reply Quote 0
                    • D
                      danielsian
                      last edited by

                      Hi Manuel

                      I've used the "Upload Image" button, don't know why the image is not visible for you.

                      I'm using Windows 10.

                      I hope you are able to see this one:

                      alt text

                      Cheers

                      1 Reply Last reply Reply Quote 0
                      • ManuelM
                        Manuel
                        last edited by

                        hello,

                        i can see that one, thanks, I added it to the bug entry.

                        Cheers,
                        Manuel

                        MAXON SDK Specialist

                        MAXON Registered Developer

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

                          I know this is an old topic, but just for the record...

                          The same thing seems to happen on macOS as well (Cinema 4D R21.207, macOS Catalina 10.15.3).

                          If xpos and ypos are -2 (i.e. show the dialog in the middle of the screen), and pluginID is not given as parameter, the dialog dimensions are about half of what they're supposed to be. If a pluginID is given, dialog dimensions are correct.

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