Vanilla set.text to TextBox



  • I know this is a vanilla question but probably it will be easy to answer by someone.
    I want to set the text to a TextBox (for a progressbar, to follow what's going on) but I can't get it updated. Any help?

    from vanilla import *
    from time import sleep
    
    class Test():
    
        def __init__ (self):
            self.w = Window((200, 100), 'a W')
            self.w.text = TextBox((10, 10, -10, -10), 'start')
            self.w.open()
            
            # set text
            self.counter = 0
            while self.counter < 10:
                print self.counter
                self.w.text.set(self.counter)
                sleep(1)
                self.counter += 2
            else:
                print 'finished counting'
                
    Test()
    

  • admin

    can you use the defconAppKit progressWindow?

    see http://code.typesupply.com/browser/packages/defconAppKit/trunk/Lib/defconAppKit/windows/progressWindow.py

    Cocoa is build up rather smart so it checks when a view is been updated frequently before redrawing it on screen.

    Although you can force a redraw:

    self.w.text.getNSTextField().display()
    

    after setting a string into the TextBox