Gui Dialog in Python not respecting the dimensions
-
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()
-
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 -
hello,
After diving into the code, strange enough, I've seen that adding a
pluginid
as a parameter to theopen
function does make it work as expected.
So you can retrieve a pluginID on this forum (top bar) and add it to yourOpen
commandNow i can asked the devs why it need that.
Cheers,
Manuel -
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 -
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?
-
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 -
@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 -
hello,
Ok now i got it. But there's not pictures attached to your post.
Are you using Windows or OSX ?Cheers,
Manuel -
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:
Cheers
-
hello,
i can see that one, thanks, I added it to the bug entry.
Cheers,
Manuel -
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.