peterhinch/micropython-micro-gui

Having error File "gui/core/ugui.py", line 420, in __init__ AttributeError: 'NoneType' object has no attribute 'height'

Closed this issue · 4 comments

import hardware_setup  
from gui.core.ugui import Screen,ssd

from gui.widgets import CloseButton, Checkbox, LED
from gui.core.writer import Writer


import gui.fonts.arial10 as arial10
from gui.core.colors import *


class BaseScreen(Screen):

    def __init__(self):

        super().__init__()
        wri = Writer(ssd, arial10, verbose=False)
        col = 2
        row = 2
        self.cb = Checkbox(wri, row, col, callback=self.cbcb)
        col+= 40
        self.led = LED(wri, row, col, color=YELLOW, bdcolor=GREEN)
        CloseButton(wri)

    def cbcb(self, cb):
        self.led.value(cb.value())

def test():
    print('Checkbox demo.')
    Screen.change(BaseScreen)

test()

while running this code I am getting an error:

Traceback (most recent call last):
File "", line 38, in
File "", line 36, in test
File "gui/core/ugui.py", line 328, in change
File "", line 22, in init
File "gui/core/ugui.py", line 420, in init
AttributeError: 'NoneType' object has no attribute 'height'

Please show me your hardware_setup.py.

I am using ssd1306 oled display therefore i used this code for hardware_setup.py

from machine import Pin, SoftI2C
import gc

from drivers.ssd1306.ssd1306 import SSD1306_I2C as SSD


i2c = SoftI2C(scl=Pin(22), sda=Pin(21))

oled_width = 128
oled_height = 64
gc.collect()  # Precaution before instantiating framebuf
ssd = SSD(oled_width, oled_height, i2c)


Your setup file appears to be designed for nanogui.

In microgui you need to define your control buttons and create a display object. Please study the docs and the microgui setup examples.

Closing due to inactivity.