示例#1
0
 def text(self, value):
     if self.autohotkey and (value != None):
         from singularity.code.g import hotkey
         parsed_hotkey = hotkey(value)
         self.hotkey = parsed_hotkey['key']
         text.Text.text.fset(self, parsed_hotkey['text'])
     else:
         text.Text.text.fset(self, value)
示例#2
0
def test_hotkeys(input_text, hotkey_chars, cleaned_text):
    hotkey_data = g.hotkey(input_text)
    actual_hotkey_chars = ''.join(x[0] for x in hotkey_data['keys'])
    actual_cleaned_text = hotkey_data['text']
    actual_hotkey_char = hotkey_data['key'][0] if hotkey_data['key'] else ''
    expected_hotkey = hotkey_chars[0] if hotkey_chars else ''

    print(("input: %s - %s" % (input_text, str(hotkey_data['keys']))))
    assert actual_hotkey_chars == hotkey_chars
    assert actual_cleaned_text == cleaned_text
    assert actual_hotkey_char == expected_hotkey
示例#3
0
 def text(self, value):
     # Updates language-dependent data
     try:
         hotkey = g.hotkey(value)
     except AttributeError:
         # g.hotkey() wasn't declared yet, mimic its defaults
         hotkey = dict(text= value,
                       key = value[0:1],
                       pos = 0,)
     self._text  = value
     self.label  = hotkey['text'] # "Friendly" name for screens and buttons
     self.hotkey = hotkey['key']  # Hotkey char
     self.pos    = hotkey['pos']  # Hotkey index in Label
示例#4
0
def load_buttons_defs():
    buttons = {
        "yes": g.hotkey(_("&YES")),
        "no": g.hotkey(_("&NO")),
        "ok": g.hotkey(_("&OK")),
        "cancel": g.hotkey(_("&CANCEL")),
        "destroy": g.hotkey(_("&DESTROY")),
        "build": g.hotkey(_("&BUILD")),
        "back": g.hotkey(_("&BACK")),
        "pause": g.hotkey(_("&PAUSE")),
        "load": g.hotkey(_("&LOAD")),
        "continue": g.hotkey(_("&CONTINUE")),
        "skip": g.hotkey(_("&SKIP")),
        "quit": g.hotkey(_("&QUIT")),
    }
    gg.buttons.update(buttons)
示例#5
0
 def _extract_and_set_hotkey(self, text_value):
     from singularity.code.g import hotkey
     parsed_hotkey = hotkey(text_value)
     self._new_hotkey(parsed_hotkey['key'])
     return parsed_hotkey['text']