{Python} [BGUI] missing 1 required positional argument: 'textlib'

Hello again,
I’m working on implementing a HUD for my game and can’t get past one annoying error.

Python module can't be imported - object 'DynamCamera', controller 'Python2':
Traceback (most recent call last):
  File "F:\Documents\school\3d_modelling\Private\BGE\PHYS\12060.blend~\HUD.py",
line 11, in <module>
TypeError: __init__() missing 1 required positional argument: 'textlib'

I’ve looked this up all over the place with no success.
here is my code:

import sys


# So we can find the bgui module
sys.path.append('../..')


import bgui
import bge
import time
from bge import logic as g


bsys = bgui.System()


class MySys(bgui.System):
    """
    A subclass to handle our game specific gui
    """


    def __init__(self):
        # Initialize the system
        bsys.__init__(self)
        
        # Create the button
        self.fps = bgui.Label(self, 'fps', text='', pos=[0.03, 0.95], font="FanHeitiStd.otf", pt_size=24)


        self.progresstxt = bgui.Label(self, 'progresstxt', text='Health', pos=[0.8, 0.96], font="FanHeitiStd.otf", pt_size=26)
        self.progress = bgui.Label(self, 'progress', text='', pos=[0.8, 0.9], font="FanHeitiStd.otf", pt_size=54)
        self.progressbar = bgui.ProgressBar(self, 'progressbar', percent=100.0,size=[0.1,0.015], pos=[0.8,0.87])
        #items = ["One", "Two", 4, 4.6]
        #self.lb = bgui.ListBox(self, "lb", items=items, padding=0.02, size=[0.9, 0.9], pos=[0.05, 0.05])
        #self.racer = bgui.Label(self, 'racer', text='racer', pos=[0.5, 0.5], font="FanHeitiStd.otf", pt_size=20)


    def main(self):
        """A high-level method to be run every frame"""
        # Now setup the scene callback so we can draw
        bge.logic.getCurrentScene().post_draw = [self.render]


def main(cont):
    own = cont.owner
    scene = g.getCurrentScene()
    camera = scene.active_camera
    fps = g.getAverageFrameRate()
    own["fps"] = fps
    
    own["framerate"] = str("%s%s"%(round(1)," FPS"))
    own["HP"] = str("%s%s"%(round(1)," %"))
    if 'sys' not in own:
        # Create our system and show the mouse
        own['sys'] = MySys()
    else:
        own['sys'].main()


    own['sys'].fps.text = own['framerate']
    own['sys'].progress.text = own['HP']
    own['sys'].progressbar.percent = own['caru']/100

It seems that you use an old example?
The initialising looks quit different to the examples from moguri.
https://bgui.readthedocs.org/en/latest/tutorials/getting_started.html

I would suggest to use the actual API.


import sys

# So we can find the bgui module
sys.path.append('../..')

import bgui
import bgui.bge_utils
import bge


class SimpleLayout(bgui.bge_utils.Layout):
    """A layout showcasing various Bgui features"""

    def __init__(self, sys, data):
        super().__init__(sys, data)
        
        # Use a frame to store all of our widgets
        self.frame = bgui.Frame(self, border=0)
        self.frame.colors = [(0, 0, 0, 0) for i in range(4)]

        # A themed frame
        self.win = bgui.Frame(self, size=[0.6, 0.8],
            options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)
            
        # Create an image to display
        self.win.img = bgui.Image(self.win, 'img.jpg', size=[.92, .7], pos=[.01, .24],
            options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)
        
        # A button
        self.button = bgui.FrameButton(self.win, text='Click Me!', size=[.14, .09], pos=[.815, .03],
            options = bgui.BGUI_DEFAULT)
        self.audio_button = bgui.ImageButton(self.win, sub_theme='Audio',
                                        size=[0.05, 0.05], pos=[0.75, 0.05])
        # Setup an on_click callback for the image
        self.button.on_click = self.on_img_click

        # Add a label
        self.lbl = bgui.Label(self, text="I'm a label!", pos=[0, 0.9],
            sub_theme='Large', options = bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
        
        # A couple of progress bars to demonstrate sub themes
        self.progress = bgui.ProgressBar(self.win, percent=0.0, size=[0.92, 0.06], pos=[.2, 0.17],
                                            sub_theme="Progress", options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
                                            
        self.health = bgui.ProgressBar(self.win, percent=0.5, size=[0.92, 0.02], pos=[0, 0.14],
                                            sub_theme="Health",    options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX)
            
        # A few TextInput widgets
        self.input = bgui.TextInput(self.win, text="I'm active.", font="myfont.otf", size=[.4, .04], pos=[.04, 0.02],
            input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT)
        self.input.activate()
        self.input.on_enter_key = self.on_input_enter
        
        self.input2 = bgui.TextInput(self.win, text="I select all when activated.", size=[.4, .04], pos=[.04, 0.08],
            input_options = bgui.BGUI_INPUT_SELECT_ALL, options = bgui.BGUI_DEFAULT)
        
        # A counter property used for the on_img_click() method
        self.counter = 0

    def on_input_enter(self, widget):
        self.lbl.text = "You've entered: " + widget.text
        widget.text = "You've locked this widget."
        widget.deactivate()
        widget.frozen = 1
        
    def on_img_click(self, widget):
        self.counter += 1
        self.lbl.text = "You've clicked me %d times" % self.counter
        self.progress.percent += .1
        if self.counter % 2 == 1:
            self.win.img.texco = [(1,0), (0,0), (0,1), (1,1)]
        else:
            self.win.img.texco = [(0,0), (1,0), (1,1), (0,1)]


def main(cont):
    own = cont.owner
    mouse = bge.logic.mouse

    if 'sys' not in own:
        # Create our system and show the mouse
        own['sys'] = bgui.bge_utils.System('../../themes/default')
        own['sys'].load_layout(SimpleLayout, None)
        mouse.visible = True

    else:
        own['sys'].run()