Exemple #1
0
 def _settext(self, text):
     text = _string2dialog(text)
     h = self._dlg.GetDialogItemAsControl(ITEM_INPUT_TEXT)
     if self._is_passwd_dialog:
         ControlAccessor.SetControlData(
             h, Controls.kControlEditTextPart,
             Controls.kControlEditTextPasswordTag, text)
         Ctl.SetKeyboardFocus(self._onscreen_wid, h,
                              Controls.kControlEditTextPart)
     else:
         Dlg.SetDialogItemText(h, text)
         self._dlg.SelectDialogItemText(ITEM_INPUT_TEXT, 0, 32767)
def AskPassword(prompt, default='', id=264, ok=None, cancel=None):
    """Display a PROMPT string and a text entry field with a DEFAULT string.
    The string is displayed as bullets only.
    
    Return the contents of the text entry field when the user clicks the
    OK button or presses Return.
    Return None when the user clicks the Cancel button.
    
    If omitted, DEFAULT is empty.
    
    The PROMPT and DEFAULT strings, as well as the return value,
    can be at most 255 characters long.
    """
    _initialize()
    _interact()
    d = GetNewDialog(id, -1)
    if not d:
        print "EasyDialogs: Can't get DLOG resource with id =", id, ' (missing resource file?)'
        return
    else:
        h = d.GetDialogItemAsControl(3)
        SetDialogItemText(h, lf2cr(prompt))
        pwd = d.GetDialogItemAsControl(4)
        bullets = '\xa5' * len(default)
        SetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag,
                       default)
        d.SelectDialogItemText(4, 0, 999)
        Ctl.SetKeyboardFocus(d.GetDialogWindow(), pwd, kControlEditTextPart)
        if ok is not None:
            h = d.GetDialogItemAsControl(1)
            h.SetControlTitle(ok)
        if cancel is not None:
            h = d.GetDialogItemAsControl(2)
            h.SetControlTitle(cancel)
        d.SetDialogDefaultItem(Dialogs.ok)
        d.SetDialogCancelItem(Dialogs.cancel)
        d.AutoSizeDialog()
        d.GetDialogWindow().ShowWindow()
        while 1:
            n = ModalDialog(None)
            if n == 1:
                h = d.GetDialogItemAsControl(4)
                return cr2lf(
                    GetControlData(pwd, kControlEditTextPart,
                                   kControlEditTextPasswordTag))
            if n == 2:
                return

        return
def AskPassword(prompt, default='', id=264, ok=None, cancel=None):
    _initialize()
    _interact()
    d = GetNewDialog(id, -1)
    if not d:
        print "EasyDialogs: Can't get DLOG resource with id =", id, ' (missing resource file?)'
        return
    else:
        h = d.GetDialogItemAsControl(3)
        SetDialogItemText(h, lf2cr(prompt))
        pwd = d.GetDialogItemAsControl(4)
        bullets = '\xa5' * len(default)
        SetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag,
                       default)
        d.SelectDialogItemText(4, 0, 999)
        Ctl.SetKeyboardFocus(d.GetDialogWindow(), pwd, kControlEditTextPart)
        if ok is not None:
            h = d.GetDialogItemAsControl(1)
            h.SetControlTitle(ok)
        if cancel is not None:
            h = d.GetDialogItemAsControl(2)
            h.SetControlTitle(cancel)
        d.SetDialogDefaultItem(Dialogs.ok)
        d.SetDialogCancelItem(Dialogs.cancel)
        d.AutoSizeDialog()
        d.GetDialogWindow().ShowWindow()
        while 1:
            n = ModalDialog(None)
            if n == 1:
                h = d.GetDialogItemAsControl(4)
                return cr2lf(
                    GetControlData(pwd, kControlEditTextPart,
                                   kControlEditTextPasswordTag))
            if n == 2:
                return

        return
Exemple #4
0
"""Easy to use dialogs.
Exemple #5
0
 def setkeyboardfocus(self):
     Ctl.SetKeyboardFocus(self.wid, self.control,
                          Controls.kControlListBoxPart)