pyobjc&iphone app - how make button/set title

Discussion in 'iOS Programming' started by stibi, May 27, 2009.

  1. stibi macrumors newbie

    Joined:
    May 27, 2009
    #1
    Hello. Please i need help with creating button in pyobjc app for iphone.
    I know how create button instance:

    Code:
    button = UIButton.alloc().init()
    But how set title for button ? Original Objective-C code is this:

    Code:
    [button setTitle:@"MyTitle" forState:UIControlStateNormal];
    So pyobjc code is this: (?)

    Code:
    button.setTitle_forState_("MyTitle", UIControlStateNormal)
    Problem is in UIControlStateNormal. This class not exist, only UIControl (in loaded UIKit framework). So how i specify state for title ?

    Sorry for my bad english.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    UIControlStateNormal is not a class: it's a constant (probably an integer). If you can't access the C constants over the Python bridge then substitute the correct integer instead...
     
  3. stibi thread starter macrumors newbie

    Joined:
    May 27, 2009
    #3
    Oh, of course, my bad. Thanks !!
    Code:
    button.setTitle_forState_("MyTitle", 0)
     

Share This Page