Forum Archive

Custom font for ui.SegmentedControl

rb

Hi how can I set a custom font for ui.SegmentedControl instance?
Objective C hackery?

Cheers!
Rich

cvp

@rb this works

import ui
from objc_util import *

v = ui.SegmentedControl()
v.frame =(0,0,300,50)
v.segments = ['one','two']

UIFont = ObjCClass('UIFont').fontWithName_size_('Menlo', 32)
#UIFont = ObjCClass('UIFont').systemFontOfSize(32)
red = UIColor.redColor()
attributes = {'NSFont': UIFont, 'NSColor': red}

vo= ObjCInstance(v).segmentedControl()
vo.setTitleTextAttributes_forState_(attributes, 0)
v.present('sheet')
rb

Thanks works perfectly:)