Vanilla TextBox .set()

RoboFont Forums Help / General Vanilla TextBox .set()

This topic contains 4 replies, has 2 voices, and was last updated by  frederik 6 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5819

    Jeremie
    Member

    Hello,

    I am using a TextBox in a FloatingWindow:

    def __init__(self):
    		self.w = FloatingWindow((200, 75))
    		self.w.textBox = TextBox((10, 30, -10, 20), "test", sizeStyle = "small")
    		self.w.button = Button((10, -20, -10, 15), "Go!", sizeStyle = "mini", callback=self.showProgress)
    

    The Button here is used to start an action (self.defineGlyphsToMake), and I want the TextBox content text to be updated just before.

    def showProgress(self, sender):
    	    self.w.textBox.set("Checking UFO...")
    	    glyphsToMake = self.defineGlyphsToMake(f, extrasL)
    

    The strange thing is that the textBox content is updated only _after_ the self.defineGlyphsToMake is finished.
    Is there something I am doing wrong or is it a flaw in Vanilla ?

    #5820

    frederik
    Keymaster

    Cocoa is rather smart in updating views and this is a good example: it prevents the update while there is something else running.

    You could force to update the view but maybe a better way is to use the defconAppKit base window and use the a progress from there.

    from defconAppKit.windows.baseWindow import BaseWindowController
    from vanilla import *
    
    from time import sleep
    
    class Test(BaseWindowController):
        
        def __init__(self):
            
            self.w = Window((200, 40))
            self.w.b = Button((10, 10, -10, 22), "Push", callback=self.buttonCallback)
            self.w.open()
            
        def buttonCallback(self, sender):
            progress = self.startProgress("Doing it...")
            
            for v in ["he", "I'm", "almost", "done"]:
                progress.update(v)
                sleep(0.5)
            
            progress.close()
    
    Test()
    

    good luck

    #5821

    Jeremie
    Member

    great thanks !
    is there a doc for BaseWindowController ? the .startProgress for example?
    I would like to use a determinate progress bar…

    #5824

    Jeremie
    Member

    OK I found my way reading the sources of defconAppKit:

    https://github.com/typesupply/defconAppKit/blob/master/Lib/defconAppKit/windows/progressWindow.py

    self.progress.setTickCount(len(extrasDict.keys()))
    for i in extrasDict.keys():
    self.progress.update()

    thanks for your help Frederik :)

    #5825

    frederik
    Keymaster

    source code is the best documentation :)

    otherwise use:

    from defconAppKit.windows.baseWindow import BaseWindowController
    from defconAppKit.windows.progressWindow import ProgressWindow
    
    help(BaseWindowController)
    help(ProgressWindow)
    
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.