Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

Multiple SubDialogs

Page  <12
Author
Message
  Topic Search Topic Search
ShawnFrueh View Drop Down
Member
Member
Avatar

Joined: 2013 Jan 26
Location: Minneapolis
Online Status: Offline
Posts: 136
Direct Link To This Post Posted: 2014 Apr 08 at 2:14pm
Figured it out! After typing it out above I realized RestoreLayout() was misspelled. Thank you guys for all the help!

*Edit there is a new problem the setup: 

    def Restore(self, pluginid, secref):
        if secref['subid'] == 1:
            print "Color"
            return self.RB_ColorDLG.Restore(pluginid,secref)
        if secref['subid'] == 2:
            print "Temp"
            return self.RB_TempDLG.Restore(pluginid,secref)
        else:
            print "Main"
            return super(BuddyDialog, self).Restore(pluginid,secref)

This causes cinema to crash. I will restore the layout but if you launch the sub dialog again everything locks up. This happens with the Example as well. Confused


Edited by ShawnFrueh - 2014 Apr 08 at 2:25pm
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Posted: 2014 Apr 08 at 4:01pm
Hi Shawn, I can reproduce the problems you have described. The Example I posted worked though,
but funnily broke after a few more times testing it. I'll have to talk to a developer on this, I am pretty
sure this is a bug. Especially this message is

Traceback (most recent call last):
  File "'restore-sub-dialog.pyp'", line 57, in CreateLayout
SystemError: error return without exception set

Best,
-Niklas
Back to Top
ShawnFrueh View Drop Down
Member
Member
Avatar

Joined: 2013 Jan 26
Location: Minneapolis
Online Status: Offline
Posts: 136
Direct Link To This Post Posted: 2014 Apr 08 at 4:19pm
Thank you Niklas.

-Shawn
Back to Top
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Direct Link To This Post Posted: 2014 Apr 08 at 7:28pm
It seems to work just fine for me. No errors or problems at all.
Maybe you're trying to do something different than I'm doing?

Here is a complete example that works fine for me in R13.
Save it as a .pyp file and put it in your plugins folder.
The main dialog has buttons to open two other dialogs. And a button that will change the checkbox gizmo in dilaog1.
All three dialogs can be docked into the UI and saved in a custom layout.
#This is an example of a GeDialog plugin that opens three dialogs
#It also allows all three dialogs to be docked and saved in a custom layout

import c4d, os
from c4d import gui, plugins, bitmaps

PLUGIN_ID  = 1000004 #Testing ID
SUBDLG_ID1  = 1000005 #Testing ID
SUBDLG_ID2 = 1000006 #Testing ID

MAINDLG_BUTTON1_ID = 1000
MAINDLG_BUTTON2_ID = 1001
MAINDLG_BUTTON3_ID = 1002
SUBDLG_TEXT_ID     = 1003
SUBDLG_CHKBOX_ID   = 1004
SUBDLG_RESET_ID    = 1005

############################
#The first sub dialog           
class SubDialog1(c4d.gui.GeDialog):

    def CreateLayout(self):
        self.SetTitle('Sub-Dialog1')   
       
        self.GroupBeginInMenuLine() 
        self.AddCheckbox(SUBDLG_RESET_ID, c4d.BFH_RIGHT, 100, 20, name="Reset")
        self.GroupEnd()       
       
        self.GroupBegin(0, c4d.BFH_SCALEFIT, 2, 0, "MyGroup")
        self.GroupBorderSpace(5, 5, 5, 5)
        self.GroupBorder(c4d.BORDER_BLACK)
        self.AddStaticText(SUBDLG_TEXT_ID, c4d.BFH_LEFT, 200, 20, "This is the sub-dialog1")
        self.AddCheckbox(SUBDLG_CHKBOX_ID, c4d.BFH_LEFT, 20, 20, "myChkbox")
        self.GroupEnd()
       
        return True       
       
    def Command(self, id, msg):
        if id == SUBDLG_RESET_ID:
            self.SetBool(SUBDLG_CHKBOX_ID, False)
            self.SetBool(SUBDLG_RESET_ID, False)  
           
        return True      
       
       
############################
#The second sub dialog           
class SubDialog2(c4d.gui.GeDialog):

    def CreateLayout(self):
        self.SetTitle('Sub-Dialog2')   
       
        self.GroupBeginInMenuLine() 
        self.AddCheckbox(SUBDLG_RESET_ID, c4d.BFH_RIGHT, 100, 20, name="Reset")
        self.GroupEnd()       
       
        self.GroupBegin(0, c4d.BFH_SCALEFIT, 2, 0, "MyGroup")
        self.GroupBorderSpace(5, 5, 5, 5)
        self.GroupBorder(c4d.BORDER_BLACK)
        self.AddStaticText(SUBDLG_TEXT_ID, c4d.BFH_LEFT, 200, 20, "This is the sub-dialog2")
        self.AddCheckbox(SUBDLG_CHKBOX_ID, c4d.BFH_LEFT, 20, 20, "myChkbox")
        self.GroupEnd()
       
        return True       
       
    def Command(self, id, msg):
        if id == SUBDLG_RESET_ID:
            self.SetBool(SUBDLG_CHKBOX_ID, False)
            self.SetBool(SUBDLG_RESET_ID, False)  
           
        return True       
       


############################
#The main dialog
class MainDialog(c4d.gui.GeDialog):

    sub_dialog1 = SubDialog1()
    sub_dialog2 = SubDialog2()       

    def CreateLayout(self):
        self.SetTitle('Main Dialog')
        self.AddButton(MAINDLG_BUTTON1_ID, 0, name="Open Sub-Dialog1")
        self.AddButton(MAINDLG_BUTTON2_ID, 0, name="Open Sub-Dialog2")
        self.AddButton(MAINDLG_BUTTON3_ID, 0, name="Change Sub-Dialog1")
        return True

    def Command(self, id, msg):
        if id == MAINDLG_BUTTON1_ID:
            self.sub_dialog1.Open(c4d.DLG_TYPE_ASYNC, PLUGIN_ID, subid=SUBDLG_ID1)
           
        if id == MAINDLG_BUTTON2_ID:
            self.sub_dialog2.Open(c4d.DLG_TYPE_ASYNC, PLUGIN_ID, subid=SUBDLG_ID2)           
           
        if id == MAINDLG_BUTTON3_ID:
            self.sub_dialog1.SetBool(SUBDLG_CHKBOX_ID, True)           
           
        return True
       
    #Restore the subdialog and the main dialog in the layout
    def Restore(self, pluginid, secref):
        if secref['subid'] == SUBDLG_ID1:
            return self.sub_dialog1.Restore(pluginid, secref)
           
        if secref['subid'] == SUBDLG_ID2:
            return self.sub_dialog2.Restore(pluginid, secref)           
           
        else:
            return super(MainDialog, self).Restore(pluginid, secref)
       
############################
#The Command Data section
class MainDialog_CD(c4d.plugins.CommandData):

    @property
    def dialog(self):
        if not hasattr(self, '_dialog'):
            self._dialog = MainDialog()
        return self._dialog

    def Execute(self, doc):
        return self.dialog.Open(c4d.DLG_TYPE_ASYNC, PLUGIN_ID)

    def RestoreLayout(self, secref):
        return self.dialog.Restore(PLUGIN_ID, secref)

if __name__ == "__main__":

    bmp = bitmaps.BaseBitmap()
    dir, file = os.path.split(__file__)
    fn = os.path.join(dir, "res", "icon.png")
    bmp.InitWith(fn)
    plugins.RegisterCommandPlugin(PLUGIN_ID, "Sub-Dialog Docking",0, bmp, "re-open", MainDialog_CD())



-ScottA
Back to Top
Page  <12

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.