Example #1
0
def demo_drag_toolcorner_expr_maker(world):  #070106 improving the above
    # given an instance of World, return an expr for the "toolcorner" for use along with GraphDrawDemo_FixedToolOnArg1 (on the same World)
    expr = SimpleColumn(
        checkbox_pref(kluge_dragtool_state_prefs_key,
                      "drag new nodes?",
                      dflt=kluge_dragtool_state_prefs_default),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla",
                      "make polyline?",
                      dflt=False),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla2",
                      "(make it closed?)",
                      dflt=False),
        ## ActionButton( world._cmd_Clear, "button: clear") # works
        # 070108: try this variant which uses _cmd_Clear_nontrivial: will the If work as an Expr?? If_kluge should tell us #####k
        ####k also will the type tests inside ActionButton work with an If? Probably not -- that's a ###BUG but I'll put it off.
        ## 1. make this work later: ActionButton( world._cmd_Clear, If_kluge( world._cmd_Clear_nontrivial, "button: clear", "button (disabled): clear"))
        ##          2. this too: If_kluge( world._cmd_Clear_nontrivial,
        ##                  ActionButton( world._cmd_Clear, "button: clear"),
        ##                  ActionButton( world._cmd_Clear, "button (disabled): clear")
        ##         )
        If_kluge(
            getattr_Expr(world, '_cmd_Clear_nontrivial'),
            ActionButton(world._cmd_Clear, "button: clear"),
            ActionButton(world._cmd_Clear,
                         "button (disabled): clear",
                         enabled=False)
        )  # works, though text change is so slow I suspect there's actually a highlighting or update bug making it appear even slower...
        # update 070109: the bug seems to be that as long as the mouse stays on the button, it remains highlighted with the old highlight form.
    )
    return expr
Example #2
0
def demo_drag_toolcorner_expr_maker(world): #070106 improving the above
    # given an instance of World, return an expr for the "toolcorner" for use along with GraphDrawDemo_FixedToolOnArg1 (on the same World)
    expr = SimpleColumn(
        checkbox_pref(kluge_dragtool_state_prefs_key,         "drag new nodes?", dflt = kluge_dragtool_state_prefs_default),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla", "make polyline?", dflt = False),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla2", "(make it closed?)", dflt = False),
        ## ActionButton( world._cmd_Clear, "button: clear") # works
        # 070108: try this variant which uses _cmd_Clear_nontrivial: will the If work as an Expr?? If_kluge should tell us #####k
        ####k also will the type tests inside ActionButton work with an If? Probably not -- that's a ###BUG but I'll put it off.
        ## 1. make this work later: ActionButton( world._cmd_Clear, If_kluge( world._cmd_Clear_nontrivial, "button: clear", "button (disabled): clear"))
##          2. this too: If_kluge( world._cmd_Clear_nontrivial,
##                  ActionButton( world._cmd_Clear, "button: clear"),
##                  ActionButton( world._cmd_Clear, "button (disabled): clear")
##         )
        If_kluge( getattr_Expr( world, '_cmd_Clear_nontrivial'),
                  ActionButton( world._cmd_Clear, "button: clear"),
                  ActionButton( world._cmd_Clear, "button (disabled): clear", enabled = False)
         ) # works, though text change is so slow I suspect there's actually a highlighting or update bug making it appear even slower...
          # update 070109: the bug seems to be that as long as the mouse stays on the button, it remains highlighted with the old highlight form.
     )
    return expr
Example #3
0
class make_polyline3d_PG(
        PropertyGroup
):  ###e call me ###e revise -- not clear it should refer to a pref
    #e rename? this name means "PG for the command make_<class>"
    ###e who supplies this? the command? i guess so. is it a local class inside it? or at least the value of an attr inside it?
    "contents of property manager group for a polyline3d which is being made"
    ###e needs some args that let it find that polyline3d or the making-command!
    ##    arg = Arg()
    #e someday be able to automake this from higher-level contents... but returning a widget is always going to be a possibility
    # (see also comments in PM_from_groups about this)
    title = "Polyline Properties"  ###e USE ME in PM_from_groups
    delegate = SimpleColumn(
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla2",
                      "closed loop?",
                      dflt=False),  # only gets closed when done -- ok??
    )
    pass
Example #4
0
    # so automatically we can get code-specific control panels just to control display & behavior that affects what's now on screen,
    # organized in std hierarchy but filtered for whether they are "in use". For now do this by hand, but later we'll want some way
    # to find out what's in use in that sense, and usage-tracking might be enough unless prefs get bundled into single tracked objs
    # of which then only some parts get used. We can probably avoid that well enough by convention.
    import foundation.env as env
    polyline = env.prefs.get(kluge_dragtool_state_prefs_key + "bla", False)#070223 new hack
    if polyline:
        return "polyline"
    # for this kluge, let the stored value be False or True for whether it's drag
    drag = env.prefs.get(kluge_dragtool_state_prefs_key, kluge_dragtool_state_prefs_default)
    return drag and 'drag' or 'draw'

kluge_dragtool_state() # set the default val

kluge_dragtool_state_checkbox_expr = SimpleColumn( # note, on 061215 late, checkbox_pref was replaced with a better version, same name
    checkbox_pref(kluge_dragtool_state_prefs_key,         "drag new nodes?", dflt = kluge_dragtool_state_prefs_default),
    checkbox_pref(kluge_dragtool_state_prefs_key + "bla", "some other pref"),
 )

def demo_drag_toolcorner_expr_maker(world): #070106 improving the above
    # given an instance of World, return an expr for the "toolcorner" for use along with GraphDrawDemo_FixedToolOnArg1 (on the same World)
    expr = SimpleColumn(
        checkbox_pref(kluge_dragtool_state_prefs_key,         "drag new nodes?", dflt = kluge_dragtool_state_prefs_default),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla", "make polyline?", dflt = False),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla2", "(make it closed?)", dflt = False),
        ## ActionButton( world._cmd_Clear, "button: clear") # works
        # 070108: try this variant which uses _cmd_Clear_nontrivial: will the If work as an Expr?? If_kluge should tell us #####k
        ####k also will the type tests inside ActionButton work with an If? Probably not -- that's a ###BUG but I'll put it off.
        ## 1. make this work later: ActionButton( world._cmd_Clear, If_kluge( world._cmd_Clear_nontrivial, "button: clear", "button (disabled): clear"))
##          2. this too: If_kluge( world._cmd_Clear_nontrivial,
##                  ActionButton( world._cmd_Clear, "button: clear"),
Example #5
0
    import foundation.env as env
    polyline = env.prefs.get(kluge_dragtool_state_prefs_key + "bla",
                             False)  #070223 new hack
    if polyline:
        return "polyline"
    # for this kluge, let the stored value be False or True for whether it's drag
    drag = env.prefs.get(kluge_dragtool_state_prefs_key,
                         kluge_dragtool_state_prefs_default)
    return drag and 'drag' or 'draw'


kluge_dragtool_state()  # set the default val

kluge_dragtool_state_checkbox_expr = SimpleColumn(  # note, on 061215 late, checkbox_pref was replaced with a better version, same name
    checkbox_pref(kluge_dragtool_state_prefs_key,
                  "drag new nodes?",
                  dflt=kluge_dragtool_state_prefs_default),
    checkbox_pref(kluge_dragtool_state_prefs_key + "bla", "some other pref"),
)


def demo_drag_toolcorner_expr_maker(world):  #070106 improving the above
    # given an instance of World, return an expr for the "toolcorner" for use along with GraphDrawDemo_FixedToolOnArg1 (on the same World)
    expr = SimpleColumn(
        checkbox_pref(kluge_dragtool_state_prefs_key,
                      "drag new nodes?",
                      dflt=kluge_dragtool_state_prefs_default),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla",
                      "make polyline?",
                      dflt=False),
        checkbox_pref(kluge_dragtool_state_prefs_key + "bla2",