Module ida_kernwin :: Class Form
[frames] | no frames]

Class Form

object --+
         |
        Form

Nested Classes
  ButtonInput
Button control.
  ChkGroupControl
Checkbox group control class.
  ChkGroupItemControl
Checkbox group item control
  ColorInput
Color button input control
  Control
  DirInput
Directory browsing control
  DropdownListControl
Dropdown control This control allows manipulating a dropdown control
  EmbeddedChooserControl
Embedded chooser control.
  FileInput
File Open/Save input control
  FormChangeCb
Form change handler.
  GroupControl
Base class for group controls
  GroupItemControl
Base class for group control items
  InputControl
Generic form input control.
  LabelControl
Base class for static label control
  MultiLineTextControl
Multi line text control.
  NumericArgument
Argument representing various integer arguments (ushort, uint32, uint64, etc...)
  NumericInput
A composite class serving as a base numeric input control class
  NumericLabel
Numeric label control
  RadGroupControl
Radiobox group control class.
  RadGroupItemControl
Radiobox group item control
  StringArgument
Argument representing a character buffer
  StringInput
Base string input control class.
  StringLabel
String label control
Instance Methods
 
Add(self, name, ctrl, mkattr=True)
Low level function.
 
AddControls(self, controls, mkattr=True)
Adds controls from a dictionary.
 
Close(self, close_normally)
Close the form
 
Compile(self)
Compiles a form and returns the form object (self) and the argument list.
 
CompileEx(self, form)
Low level function.
 
Compiled(self)
Checks if the form has already been compiled
 
EnableField(self, ctrl, enable)
Enable or disable an input field
 
Execute(self)
Displays a modal dialog containing the compiled form.
 
FindControlById(self, id)
Finds a control instance given its id
 
Free(self)
Frees all resources associated with a compiled form.
 
GetControlValue(self, ctrl)
Returns the control's value depending on its type
 
GetFocusedField(self)
Get currently focused input field.
 
MoveField(self, ctrl, x, y, w, h)
Move/resize an input field
 
Open(self)
Opens a widget containing the compiled form.
 
RefreshField(self, ctrl)
Refresh a field
 
SetControlValue(self, ctrl, value)
Set the control's value depending on its type
 
SetFocusedField(self, ctrl)
Set currently focused input field
 
ShowField(self, ctrl, show)
Show or hide an input field
 
__getitem__(self, name)
Returns a control object by name
 
__init__(self, form, controls)
Contruct a Form class.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
 
ControlToFieldTypeIdAndSize(ctrl)
Converts a control object to a tuple containing the field id and the associated buffer size
 
create_string_buffer(value, size=None)
 
fieldtype_to_ctype(tp, i64=False)
Factory method returning a ctype class corresponding to the field type string
Class Variables
  FT_ADDR = '$'
  FT_ASCII = 'A'
  FT_BIN = 'Y'
  FT_BUTTON = 'B'
  FT_CHAR = 'H'
  FT_CHKGRP = 'C'
  FT_CHKGRP2 = 'c'
  FT_COLOR = 'K'
  FT_DEC = 'D'
  FT_DIR = 'F'
  FT_DROPDOWN_LIST = 'b'
  FT_ECHOOSER = 'E'
  FT_FILE = 'f'
  FT_FORMCHG = '%/'
  FT_HEX = 'N'
  FT_HTML_LABEL = 'h'
  FT_IDENT = 'I'
  FT_INT64 = 'l'
  FT_MULTI_LINE_TEXT = 't'
  FT_OCT = 'O'
  FT_RADGRP = 'R'
  FT_RADGRP2 = 'r'
  FT_RAWHEX = 'M'
  FT_SEG = 'S'
  FT_SHEX = 'n'
  FT_TYPE = 'T'
  FT_UINT64 = 'L'
Properties

Inherited from object: __class__

Method Details

Add(self, name, ctrl, mkattr=True)

 

Low level function. Prefer AddControls() to this function. This function adds one control to the form.

Parameters:
  • name - Control name
  • ctrl - Control object
  • mkattr - Create control name / control object as a form attribute

AddControls(self, controls, mkattr=True)

 

Adds controls from a dictionary. The dictionary key is the control name and the value is a Form.Control object

Parameters:
  • controls - The control dictionary

Close(self, close_normally)

 

Close the form

Parameters:
  • close_normally - 1: form is closed normally as if the user pressed Enter 0: form is closed abnormally as if the user pressed Esc
Returns:
None

Compile(self)

 

Compiles a form and returns the form object (self) and the argument list. The form object will contain object names corresponding to the form elements

Returns:
It will raise an exception on failure. Otherwise the return value is ignored

CompileEx(self, form)

 

Low level function. Compiles (parses the form syntax and adds the control) the form string and returns the argument list to be passed the argument list to ask_form().

The form controls are wrapped inside curly braces: {ControlName}.

A special operator can be used to return the index of a given control by its name: {id:ControlName}. This is useful when you use the STARTITEM form keyword to set the initially focused control. (note that, technically, the index is not the same as the ID; that's because STARTITEM uses raw, 0-based indexes rather than control IDs to determine the focused widget.)

Parameters:
  • form - Compiles the form and returns the arguments needed to be passed to ask_form()

Compiled(self)

 

Checks if the form has already been compiled

Returns:
Boolean

EnableField(self, ctrl, enable)

 

Enable or disable an input field

Returns:
False - no such control

Execute(self)

 

Displays a modal dialog containing the compiled form.

Returns:
1 - ok ; 0 - cancel

Free(self)

 

Frees all resources associated with a compiled form. Make sure you call this function when you finish using the form.

GetControlValue(self, ctrl)

 

Returns the control's value depending on its type

Parameters:
  • ctrl - Form control instance
Returns:
  • color button, radio controls: integer
  • file/dir input, string input and string label: string
  • embedded chooser control (0-based indices of selected items): integer list
  • for multilinetext control: textctrl_info_t
  • dropdown list controls: string (when editable) or index (when readonly)
  • None: on failure

GetFocusedField(self)

 

Get currently focused input field.

Returns:
None if no field is selected otherwise the control ID

MoveField(self, ctrl, x, y, w, h)

 

Move/resize an input field

Returns:
False - no such fiel

RefreshField(self, ctrl)

 

Refresh a field

Returns:
False - no such control

SetControlValue(self, ctrl, value)

 

Set the control's value depending on its type

Parameters:
  • ctrl - Form control instance
  • value -
    • embedded chooser: a 0-base indices list to select embedded chooser items
    • multilinetext: a textctrl_info_t
    • dropdown list: an integer designating the selection index if readonly a string designating the edit control value if not readonly
Returns:
Boolean true on success

SetFocusedField(self, ctrl)

 

Set currently focused input field

Returns:
False - no such control

ShowField(self, ctrl, show)

 

Show or hide an input field

Returns:
False - no such control

__init__(self, form, controls)
(Constructor)

 

Contruct a Form class. This class wraps around ask_form() or open_form() and provides an easier / alternative syntax for describing forms. The form control names are wrapped inside the opening and closing curly braces and the control themselves are defined and instantiated via various form controls (subclasses of Form).

Parameters:
  • form - The form string
  • controls - A dictionary containing the control name as a _key_ and control object as _value_
Overrides: object.__init__