GUI basic problem

Hello:)
I am writing small script. If there was no Gui it would be really easy. Unfortunatelly I need to add gui.I have never do it before so I have got small problem.

import bpyclass DS_Panel(bpy.types.Panel):
    bl_idname = "VIEW3D_SD"
    bl_label = "SD_Panel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
                
    def draw(self, context):
        layout=self.layout
        layout.label("Also Small Class")
        layout.label("Choose export type")
        
        col = layout.column(align=1)
        row = col.row()
        row.operator("DS_TF") 
        row.operator("DS_T")
        
class DS_FF(bpy.types.Panel):
    bl_idname = "DS_F"    
    def execute(self,context):
        n=0
        for n in range(len(bpy.data.objects)):
            if(bpy.data.objects[n].type=="MESH"):
                bpy.data.objects[n].data.show_double_sided=False
        return {'FINISHED'}
      
      
class DS_TF(bpy.types.Panel):
    bl_idname = "DS_T"
    bl_label = "TRUE"                          
    def execute(self,context):
        n=0
        for n in range(len(bpy.data.objects)):
            if(bpy.data.objects[n].type=="MESH"):
                bpy.data.objects[n].data.show_double_sided=True  
        return {'FINISHED'}      


def register():
    bpy.utils.register_class( DS_Panel )        
    bpy.utils.register_class(DS_FF)
    bpy.utils.register_class(DS_TF)


if __name__ == "__main__":
    register()

I used 3 class. Functions are in 2 class.
Id is different that class name

Error is in line

 row.operator("DS_TF") 

        row.operator("DS_T")

I do not know why it doesn’t work. Maybe someone know what is wrong…Thanks for any reply:)

should be
col = layout.column(align=True) # True instead of 1

these operators probably don’t exist, if their bl_idname was e.g. “mesh.ds_tf”, then you’d have to do:
row.operator(“mesh.ds_tf”)
row.operator(“mesh.ds_t”)

should be
col = layout.column(align=True) # True instead of 1

1 or 0 can be instead of True/False
If You don’t belive You can try for example

bpy.data.objects[2].data.show_double_sided=0

in Console.
Anyway if there was problem error will be showed in that moment, not in

row.operator("DS_TF") 
ow.operator("DS_T")

these operators probably don’t exist,

Yes, I think so too. But i do not know any idea why.

if their bl_idname was e.g. “mesh.ds_tf”, then you’d have to do:
row.operator(“mesh.ds_tf”)

Yes it is true.
I have class which bl_idname = “DS_T” and i use row.operator(“DS_T”) and that doesn’t work.My question is why?

Hi alex6000

Afaik operator bl id_names need to be lowercase aaaaaaaaa.bbbbbbbbbb

You need to make your DS_TF DS_FF classes operators not panels.

You only need one of these operators as you can setup a property and pass it to the operator from the panel. You can also set up a toggle.


    col = layout.column()
    opt = col.operator("mesh.set_double_sided")
    opt.is_double_sided  = True
    opf = col.operator("mesh.set_double_sided")
    opf.is_double_sided = False



class DS_TF(bpy.types.Operator):
   bl_idname = "mesh.set_double_sided" 
   bl_label = "Set double sided mesh" 
   is_double_sided = BoolProperty()

   def execute(self,context):
        meshes = [obj.data for obj in context.scene.objects if obj.type == 'MESH']
        for mesh in meshes:
            mesh.show_double_sided = self.is_double_sided
        return {'FINISHED'}  


Hey.thanks fo reply:)
So You are right I need only one class.
Everything would be OK if i do not have another error.

name BoolProperty() is not defined

When I change it to True or False. It always has got that value
//Edit
Sorry for really basic question. As I said i am new in this topic.

BoolProperty()

is property that I must add earlier?
RNA properties or something similar?

Either add

 from bpy.props import (BoolProperty)

to the top of your code or write it

is_double_sided = bpy.props.BoolProperty()

Thanks a lot!

1 or 0 can be instead of True/False

Yeah, but it’s bad style