Exemplo n.º 1
0
    def __init__(self):
        self.invert = False
        self.EChooser = TestEmbeddedChooserClass("E1", flags=Choose.CH_MULTI)
        Form.__init__(self, r"""STARTITEM {id:rNormal}
BUTTON YES* Yeah
BUTTON NO Nope
BUTTON CANCEL Nevermind
Form Test

{FormChangeCb}
This is a string:  |+{cStr1}+
This is an address:|+{cAddr1}+
This is some HTML: |+{cHtml1}+
This is a number:  |+{cVal1}+

<#Hint1#Enter text  :{iStr1}>
<#Hint2#Select color:{iColor1}>
Browse test
<#Select a file to open#Browse to open:{iFileOpen}>
<#Select a file to save#Browse to save:{iFileSave}>
<#Select dir#Browse for dir:{iDir}>
Misc
<##Enter a selector value:{iSegment}>
<##Enter a raw hex       :{iRawHex}>
<##Enter a character     :{iChar}>
<##Enter an address      :{iAddr}>
<##Write a type name     :{iType}>
Button test: <##Button1:{iButton1}> <##Button2:{iButton2}>

<##Check boxes##Error output:{rError}> | <##Radio boxes##Green:{rGreen}>
<Normal output:{rNormal}>              | <Red:{rRed}>
<Warnings:{rWarnings}>{cGroup1}>       | <Blue:{rBlue}>{cGroup2}>

<Embedded chooser:{cEChooser}>
The end!
""", {
            'cStr1': Form.StringLabel("Hello"),
            'cHtml1': Form.StringLabel("<span style='color: red'>Is this red?<span>", tp=Form.FT_HTML_LABEL),
            'cAddr1': Form.NumericLabel(0x401000, Form.FT_ADDR),
            'cVal1' : Form.NumericLabel(99, Form.FT_HEX),
            'iStr1': Form.StringInput(),
            'iColor1': Form.ColorInput(),
            'iFileOpen': Form.FileInput(open=True),
            'iFileSave': Form.FileInput(save=True),
            'iDir': Form.DirInput(),
            'iType': Form.StringInput(tp=Form.FT_TYPE),
            'iSegment': Form.NumericInput(tp=Form.FT_SEG),
            'iRawHex': Form.NumericInput(tp=Form.FT_RAWHEX),
            'iAddr': Form.NumericInput(tp=Form.FT_ADDR),
            'iChar': Form.NumericInput(tp=Form.FT_CHAR),
            'iButton1': Form.ButtonInput(self.OnButton1),
            'iButton2': Form.ButtonInput(self.OnButton2),
            'cGroup1': Form.ChkGroupControl(("rNormal", "rError", "rWarnings")),
            'cGroup2': Form.RadGroupControl(("rRed", "rGreen", "rBlue")),
            'FormChangeCb': Form.FormChangeCb(self.OnFormChange),
            'cEChooser' : Form.EmbeddedChooserControl(self.EChooser)
        })
    def __init__(self, manager):
        self.cnn = manager.connector
        self.configuration = manager.configuration
        self.listView = ConnectionListView(manager)

        apps = self.configuration['apps'].keys()
        app_default = self.configuration['default-app']

        if app_default is not None:
            default_index = apps.index(app_default)

        else:
            default_index = 0

        # indent matters:
        Form.__init__(
            self, r"""BUTTON YES* OK 
BUTTON CANCEL NONE 
Kam1n0 - Manage connections
{FormChangeCb}
Manage Connections:
<(Click to edit):{fvChooser}>
<Remove :{btnRemove}> Remove selected connection.
<App URL  :{txtServer}>
Login Info:
<User     :{txtUser}>
<Password :{txtPw}>
<Update / Add:{btnUpdate}>
<Threshold:{txtSim}>
<Top-K    :{txtTopK}>
<Avoid Same Binary  :{chkSameBin}>{chkGroup}>
<Connector:{dpCnn}>
""", {
                'fvChooser':
                Form.EmbeddedChooserControl(self.listView),
                'FormChangeCb':
                Form.FormChangeCb(self.OnFormChange),
                'txtServer':
                Form.StringInput(swidth=60, tp=Form.FT_ASCII),
                'txtUser':
                Form.StringInput(swidth=60, tp=Form.FT_ASCII),
                'txtPw':
                Form.StringInput(swidth=60, tp=Form.FT_ASCII),
                'btnRemove':
                Form.ButtonInput(self.OnButtonRemove),
                'btnUpdate':
                Form.ButtonInput(self.OnButtonUpdate),
                'txtSim':
                Form.StringInput(swidth=45,
                                 tp=Form.FT_ASCII,
                                 value=str(
                                     self.configuration['default-threshold'])),
                'txtTopK':
                Form.StringInput(swidth=45,
                                 tp=Form.FT_ASCII,
                                 value=str(
                                     self.configuration['default-topk'])),
                'chkGroup':
                Form.ChkGroupControl(("chkSameBin", "")),
                'dpCnn':
                Form.DropdownListControl(swidth=60,
                                         width=60,
                                         selval=default_index,
                                         items=apps,
                                         readonly=True)
            })
        self.Compile()