Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

newbie: GeDialog example?

 Post Reply Post Reply
Author
Message
Jops View Drop Down
Member
Member


Joined: 2005 Apr 25
Online Status: Offline
Posts: 50
Post Options Post Options   Quote Jops Quote  Post ReplyReply Direct Link To This Post Topic: newbie: GeDialog example?
    Posted: 2010 Oct 28 at 4:58am

User Information:

Cinema 4D Version:   12 
Platform:   Windows  ;   
Language(s):       PYTHON  ; 

---------

Hello there,

I am trying to get a grip on GUI interfaces within Python for C4D.
Unfortunately just now learning python (and coding) so I still am not able to understand the SDK in a way that I can code right away.

Is there a example somwhere over making a simple GeDialog with lets say one input value? so that I understand the structure that is nessesary?

thanks a lot

Jops
(who is trying not to flood this nice forum with newbie questions)
Back to Top
s_rath View Drop Down
Member
Member


Joined: 2010 May 04
Location: Ne / Düsseldorf
Online Status: Offline
Posts: 319
Post Options Post Options   Quote s_rath Quote  Post ReplyReply Direct Link To This Post Posted: 2010 Oct 28 at 5:09am
Hi Jops,

here is a small example for you. I hope this helps:

import c4d
from c4d import gui
#Welcome to the world of Python

GROUP_ID1=1000
TEXTBOX=1001
BUTTON1=1002
BUTTON2=1003

class ExampleDlg(gui.GeDialog):
    
    def CreateLayout(self):
        #creat the layout of the dialog
        self.GroupBegin(GROUP_ID1, c4d.BFH_SCALEFIT, 3, 1)
        self.AddEditText(TEXTBOX, c4d.BFH_SCALEFIT)
        self.AddButton(BUTTON1, c4d.BFH_SCALE, name="MessadeDialog")
        self.AddButton(BUTTON2, c4d.BFH_SCALE, name="Close")
        self.GroupEnd()
        return True

    def InitValues(self):
        #initiate the gadgets with values
        self.SetString(TEXTBOX, "Hello World!")
        return True

    def Command(self, id, msg):
        #handle user input
        if id==BUTTON1:
            gui.MessageDialog(self.GetString(TEXTBOX))
        elif id==BUTTON2:
            self.Close()
        return True


dlg = ExampleDlg()
dlg.Open(c4d.DLG_TYPE_MODAL, defaultw=300, defaulth=50)

Cheers, Sebastian
Back to Top
Jops View Drop Down
Member
Member


Joined: 2005 Apr 25
Online Status: Offline
Posts: 50
Post Options Post Options   Quote Jops Quote  Post ReplyReply Direct Link To This Post Posted: 2010 Oct 28 at 5:52am
Hello Sebastian,

that is great, thanks a lot!!!
may I put you example in Per-Anders Python Wiki?


all The best
Jops
Back to Top
s_rath View Drop Down
Member
Member


Joined: 2010 May 04
Location: Ne / Düsseldorf
Online Status: Offline
Posts: 319
Post Options Post Options   Quote s_rath Quote  Post ReplyReply Direct Link To This Post Posted: 2010 Oct 28 at 6:05am
Sure, do with the code what ever you want.
Back to Top
Jops View Drop Down
Member
Member


Joined: 2005 Apr 25
Online Status: Offline
Posts: 50
Post Options Post Options   Quote Jops Quote  Post ReplyReply Direct Link To This Post Posted: 2010 Oct 28 at 6:28am
if you have time you might answer me one more question:

if I define the dialog as a async dialog it just pops up and closes again. even if I put it into the mail loop.

Is there a trick or is there more to it?

thanks again
Jops
Back to Top
s_rath View Drop Down
Member
Member


Joined: 2010 May 04
Location: Ne / Düsseldorf
Online Status: Offline
Posts: 319
Post Options Post Options   Quote s_rath Quote  Post ReplyReply Direct Link To This Post Posted: 2010 Oct 28 at 7:20am
Asynchronous dialogs can just be used in plugins (in combination with CommandData).
Back to Top
Jops View Drop Down
Member
Member


Joined: 2005 Apr 25
Online Status: Offline
Posts: 50
Post Options Post Options   Quote Jops Quote  Post ReplyReply Direct Link To This Post Posted: 2010 Oct 28 at 2:54pm
is it on principle possible to code a python plugin with plug ID and Asynchronous dialogs?
Back to Top
Matthias Bober View Drop Down
Forum Moderator
Forum Moderator


Joined: 2006 Oct 16
Location: Germany
Online Status: Offline
Posts: 2204
Post Options Post Options   Quote Matthias Bober Quote  Post ReplyReply Direct Link To This Post Posted: 2010 Nov 03 at 3:13am
Originally posted by Jops

is it on principle possible to code a python plugin with plug ID and Asynchronous dialogs?


Yes, that's possible.

cheers,
Matthias

MAXON
developer support
Back to Top
sbaden View Drop Down
Member
Member
Avatar

Joined: 2017 Nov 01
Location: United States
Online Status: Offline
Posts: 1
Post Options Post Options   Quote sbaden Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 01 at 12:43pm
Originally posted by s_rath



    def Command(self, id, msg):
        #handle user input
        if id==BUTTON1:
            gui.MessageDialog(self.GetString(TEXTBOX))
        elif id==BUTTON2:
            self.Close()
        return True


The buttons aren't working for me. Nothing happens when I click on them.


Edited by sbaden - 2017 Nov 01 at 12:44pm
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1540
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 02 at 10:29am
Hi,

welcome to the Plugin Café forums Smile

I think, you'd need to post a bit more of your code, the Command() function doesn't look wrong to me.

We have a few examples making use of GeDialog in our GitHub repository.
The simplest, basically with two buttons in a GeDialog (just like the example above) is Py-TextureBaker.pyp.

Cheers,
Andreas
SDK Support Engineer
Back to Top
 Post Reply Post Reply

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.109 seconds.