• MOD0

    JonB
    I find that I misunderstood Keycommand, so i try to add subview.
    Tkank you for reply my asking.

    posted in Pythonista read more
  • MOD0

    Hi, i wrote code in order to use my program with Bluetooth keyboard.(some part quoted from here)

    I succeeded in some print code(pleases press the D key in your bluetooth-keyboard).
    But when I press A (i expected label show me Pusshed-A)
    only called that message

    AttributeError (Line-35)
    Alabel = sender.superview['Alabel']
    AttributeError: 'int' object has no attribute 'superview'

    How do i use Keycommand with superview?

    code is here(Please make FC.pyui)
    (FC.pyui include label. label name is Alabel)

    from objc_util import *
    import ui
    
    UIKeyCommand = ObjCClass('UIKeyCommand')
    modifiers = {(1<<17): 'Shift', (1<<18): 'Ctrl', (1<<19): 'Alt', (1<<20): 'Cmd', (1<<21): 'NumPad'}
    
    def keyCommands(_self, _cmd):
        cmd_key_flag = (1<<20)
        key_a = UIKeyCommand.keyCommandWithInput_modifierFlags_action_('A', 0,'keyCommandAction:')
        key_s = UIKeyCommand.keyCommandWithInput_modifierFlags_action_('S', 0, 'keyCommandAction:')
        key_d = UIKeyCommand.keyCommandWithInput_modifierFlags_action_('D', 0, 'keyCommandAction:')
        
        commands = ns([key_a, key_s, key_d])
        return commands.ptr
    
    def canBecomeFirstResponder(_self, _cmd):
        return True
        
    def keyCommandAction_(_self, _cmd, sender):
        self = ObjCInstance(_self)
        key_cmd = ObjCInstance(sender)
        flags = key_cmd.modifierFlags()
        modifier_str = ' + '.join(modifiers[m] for m in modifiers.keys() if (m & flags))
        key_input = key_cmd.input()
        print 'Input: "%s" Modifiers: %s' % (key_input, modifier_str)
        if str(key_input) == 'A':
            A(sender)
        elif str(key_input) == 'S':
            S(sender)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
        else:
            D(sender)
                    
    def A(sender):
        Alabel = sender.superview['Alabel']
        Alabel.text = str('Pusshed-A')        
    def S(sender):
        print('pusshed-S') 
           
    def D(sender):
        print('pusshed-D') 
    
    FCCF = create_objc_class('FCCF', UIView, [keyCommands, canBecomeFirstResponder, keyCommandAction_])
    main_view = ui.load_view('FC')
    v = FCCF.alloc().initWithFrame_(((0, 0), (1, 1)))
    v.becomeFirstResponder()
    ObjCInstance(main_view).addSubview_(v)
    main_view.present('sheet')

    posted in Pythonista read more
  • MOD0

    @lachlantula
    Thanks for tell me that add subview with changing bar_color.
    I learned python grammar which i didn't know until now.

    @JonB
    Thanks for tell me the :URL.
    I achieve my objective that changing bar_color when running program without change or add subview.

    for everyone who answered my asking
    Thank you for answering my question, and
    I thank you for reading it through.
    By now, I guess you get used to my funny English writing.

    posted in Pythonista read more
  • MOD0

    @bennr01 said:

    title_bar_color to View.present().

    Tkanks for tell that, I became capable of change default bar_color.
    i pleased.

    but, how can i change "title_bar_color" when running program like when change "background_color" ,(for example label,button,,,).

    for example i want change "title_bar_color" like that

    1. red (when start progrum)

    1. blue ( when "button1 = sender.superview['button1']" pushed)

    ↓↑

    1. green ( when "button2 = sender.superview['button2']" pushed)

    posted in Pythonista read more
  • MOD0

    Hi, I’ve recently started pythonista for iOS.
    And I don't know how i change color of top bar.
    I don't know its bar name exact, so i decided to ask here.
    Please look at the image
    http://i.imgur.com/ru9o49j.png

    I mean I want to change color that space(bar?) , can i do that?

    or Please help me on how to full space when ran myself gui program.
    like this example game program. http://i.imgur.com/lNExnah.png

    Thank you for reading.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!