GUI Bitmap Button Properties
-
Hello everyone!
I have a few questions.
- How to remove padding between buttons?
- How to change BITMAPBUTTON_BACKCOLOR via the Command? (When pressing on it)
- How to activate fading fading when the back color is activated?
import c4d class test_dialog(c4d.gui.GeDialog): def CreateLayout(self): self.GroupBegin(id=0, flags=c4d.BFH_SCALEFIT, rows=1, title=" ", cols=2, groupflags=0) bc = c4d.BaseContainer() bc[c4d.BITMAPBUTTON_BUTTON] = True bc[c4d.BITMAPBUTTON_ICONID1] = c4d.Ocube bc[c4d.BITMAPBUTTON_BACKCOLOR] = c4d.COLOR_BG_PALETTE bc[c4d.BITMAPBUTTON_DISABLE_FADING] = False self.bitmapButton = self.AddCustomGui(100001, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER | c4d.BFV_CENTER, 0, 0, bc) bc = c4d.BaseContainer() bc[c4d.BITMAPBUTTON_BUTTON] = True bc[c4d.BITMAPBUTTON_ICONID1] = c4d.Osphere bc[c4d.BITMAPBUTTON_BACKCOLOR] = c4d.COLOR_BG_PALETTE bc[c4d.BITMAPBUTTON_DISABLE_FADING] = False self.bitmapButton = self.AddCustomGui(100002, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER | c4d.BFV_CENTER, 0, 0, bc) return True def Command(self, id, msg): if id == 100001: print("Click Detected") #Change BITMAPBUTTON_BACKCOLOR return True def main(): global dialog dialog = test_dialog() dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=-2, defaulth=-2) if __name__ == '__main__': main()
-
Hi @merkvilson
This may not help, I'm not a python coder, but for the padding, it might be worth trying to set the BITMAPBUTTON_NOBORDERDRAW flag. I can't tell from the screen shot if that's happening here, but it might be the button border? See if that helps.
I'll let others help you with your other queries.
WP.
-
Hey @WickedP
Thanks for your answer but unfortunately, that's not the case. -
Hello @merkvilson,
Thank you for reaching out to us. Your thread is still okay, but you are surfing here on the edge of 'too many questions in one topic'. Please note that our Support Procedures require users to ask question(s) on a singular well-defined subject in a thread. This cannot become a 'everything about GeDialog' or 'everything about bitmap buttons' thread.
About your Questions
How to remove padding between buttons?
The padding between elements of a group in a dialog is controlled with
GeDialog.GroupSpace
.How to change BITMAPBUTTON_BACKCOLOR via the Command?
I am not sure if I am understanding your question here correctly. You want to change the background color of a button after
CreateLayout
ran? That is not possible. You can flush layout groups and rebuild them at runtime (with buttons with a new color for example). I showed here once the pattern of a dynamic dialog.How to activate fading fading when the back color is activated?
I do not think that is possible, because for that you would have to define a second color to fade to. And I do not see any option to do this in the settings of this custom GUI.
Cheers,
FerdinandResult:
Code:import c4d class test_dialog(c4d.gui.GeDialog): def CreateLayout(self): """ """ # In a GeDialog, two methods control the spacing of elements, GroupSpace() and # GroupBorderSpace(). Both methods apply to the group context they are called in. When # we do not add a group, they will apply to they outmost and dialog group added by the # dialog itself. self.GroupBegin(id=0, flags=c4d.BFH_SCALEFIT, rows=1, title=" ", cols=2, groupflags=0) self.GroupSpace(0, 0) # The horizontal and vertical spacing between two elements for id=0. self.GroupBorderSpace(10, 10, 10, 10) # The space at borders of the group for id=0. bc = c4d.BaseContainer() bc[c4d.BITMAPBUTTON_BUTTON] = True bc[c4d.BITMAPBUTTON_ICONID1] = c4d.Ocube bc[c4d.BITMAPBUTTON_BACKCOLOR] = c4d.COLOR_BG_PALETTE bc[c4d.BITMAPBUTTON_DISABLE_FADING] = False self.bitmapButton = self.AddCustomGui(100001, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER | c4d.BFV_CENTER, 0, 0, bc) bc = c4d.BaseContainer() bc[c4d.BITMAPBUTTON_BUTTON] = True bc[c4d.BITMAPBUTTON_ICONID1] = c4d.Osphere bc[c4d.BITMAPBUTTON_BACKCOLOR] = c4d.COLOR_BG_PALETTE bc[c4d.BITMAPBUTTON_DISABLE_FADING] = False self.bitmapButton = self.AddCustomGui(100002, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER | c4d.BFV_CENTER, 0, 0, bc) # You were also missing this call, it is important to close groups. self.GroupEnd() return True def main(): # Doing this is dangerous, you create a dangling dialog instance with this. Never use store # dialog in a script module or use the global pattern (which just creates an attribute in the # module). It is fine to do this for development and testing, but production ASYNC dialogs are # not supported by Script Manager scripts. global dialog dialog = test_dialog() dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=-2, defaulth=-2) if __name__ == '__main__': main()
-
@ferdinand said in GUI Bitmap Button Properties:
How to change BITMAPBUTTON_BACKCOLOR via the Command?
I am not sure if I am understanding your question here correctly. You want to change the background color of a button after CreateLayout ran? That is not possible. You can flush layout groups and rebuild them at runtime (with buttons with a new color for example). I showed here once the pattern of a dynamic dialog.
Is it possible to change the background color based on the toggle state?
Thanks for your answers!
-
@merkvilson said in GUI Bitmap Button Properties:
@ferdinand said in GUI Bitmap Button Properties:
How to change BITMAPBUTTON_BACKCOLOR via the Command?
I am not sure if I am understanding your question here correctly. You want to change the background color of a button after CreateLayout ran? That is not possible. You can flush layout groups and rebuild them at runtime (with buttons with a new color for example). I showed here once the pattern of a dynamic dialog.
Is it possible to change the background color based on the toggle state?
Thanks for your answers!
It depends on how you define 'possible'. Dialogs in itself are static GUIs, you cannot change any of the settings you have set in
CreateLayout
after the method ran. It does not matter if it is the spacing of a group, the width of a text field, or the background color of a bitmap toggle button.What you can do in addition to defining the 2nd icon of the toggle button, is flush a layout group and then rebuild that group with a button which has the color you like. So, you wrap all your buttons in a group, and whenever a button is toggled on or off, you change a color in an array of button colors and then flush the buttons and rebuild them using your array of colors to set the background colors (and you also have to reapply the states then). The posting I linked to in my previous example lines out the details of how to do such dynamic dialog GUIs.
Cheers,
Ferdinand