Skip to content

Why that trash symbol? #34

@beyonlo

Description

@beyonlo

Hello @peterhinch

I'm using micro-gui with the ssd1306 mono display (128 x 64) with three buttons, but the micro-gui is showing in all demos a strange symbol (like as a trash) on the top right side. Why that symbol and how to remove?

Here a screenshot showing that trash symbol inside the green circle using demo/simple.py:
WhatsApp Image 2023-07-10 at 19 55 57

As I'm using a mono display I just changed the simple.py:

  1. All places where has CWriter to Writer
  2. wri = CWriter(ssd, arial10, GREEN, BLACK) to wri = Writer(ssd, arial10)

gui/demos/simple.py:

# simple.py Minimal micro-gui demo.

# Released under the MIT License (MIT). See LICENSE.
# Copyright (c) 2021 Peter Hinch

# hardware_setup must be imported before other modules because of RAM use.
import hardware_setup  # Create a display instance
from gui.core.ugui import Screen, ssd

from gui.widgets import Label, Button, CloseButton
from gui.core.writer import Writer

# Font for CWriter
import gui.fonts.arial10 as arial10
from gui.core.colors import *


class BaseScreen(Screen):

    def __init__(self):

        def my_callback(button, arg):
            print('Button pressed', arg)

        super().__init__()
        # verbose default indicates if fast rendering is enabled
        wri = Writer(ssd, arial10)
        col = 2
        row = 2
        Label(wri, row, col, 'Simple Demo')
        row = 50
        Button(wri, row, col, text='Yes', callback=my_callback, args=('Yes',))
        col += 60
        Button(wri, row, col, text='No', callback=my_callback, args=('No',))
        CloseButton(wri)  # Quit the application

def test():
    print('Simple demo: button presses print to REPL.')
    Screen.change(BaseScreen)  # A class is passed here, not an instance.

test()

Output:

$ mpremote run simple.py 
Using 3 switches.
Simple demo: button presses print to REPL.
Orientation: Horizontal. Reversal: False. Width: 128. Height: 64.
Start row = 0 col = 0
Warning: attempt to create Button outside screen dimensions.
Warning: attempt to create Button outside screen dimensions.

My hardware_setup.py:

from machine import Pin, SPI
import machine
import gc
import time

from ssd1306 import SSD1306_I2C as SSD

WIDTH = const(128)
HEIGHT = const(64)

i2c = machine.SoftI2C(scl=machine.Pin(18), sda=machine.Pin(17))
gc.collect()  # Precaution before instantiating framebuf
ssd = SSD(WIDTH, HEIGHT, i2c)

from gui.core.ugui import Display

# Define control buttons
nxt = Pin(42, Pin.IN, Pin.PULL_UP)  # Move to next control
sel = Pin(12, Pin.IN, Pin.PULL_UP)  # Operate current control
prev = Pin(41, Pin.IN, Pin.PULL_UP)  # Move to previous control
display = Display(ssd, nxt, sel, prev)  # 3-button mode

The ssd1306.py is from official micropython driver.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions