Python Forum

Full Version: help with showing wifi symbol when connected
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ive got a pi zero w and a ssd1306 128x64 screen and have managed to eventually get something showing up on the screen for examples (yey)

ive got a little project on doing various things which i'll try to learn along the way but ive never done anything in python before at the mo im trying to have the screen show in the top right a wifi symbol when its connected to wifi (and maybe a logo with a diagonal line through the symbol when its disconnected)

can anyone help or point me in the right direction with some simple instructions?

thanks
Here is everything what you need: https://github.com/rm-hull/luma.oled

Everything is linked on the page, also the Documentation: https://luma-oled.readthedocs.io/en/latest/
You can use PIL for the Images. If you're using Python3 (you should), use instead Pillow.
One way would be to print the unicode for "Antenna with bars" (\u1f4f6), the drawback is: good luck finding a font that will print it. If you do, other users most likely won't have that font. The other way would be to copy the image itself, then try and print it:

print("?")
again, though, no guarantees it will work. For example, both with the same font, using Pycharm the out put is:

Output:
C:\Python36\python.exe C:/Python/scratch.py ? Process finished with exit code 0
 

whilst in the Windows terminal it is two blank boxes.  Not sure how or if the situation be the same on a Linux, Mac or *nix terminal.

The final solution that comes to mind, is to create you own symbol using ASCII art, though that might turn out to be rather large.

My suggestion would be to use a library like "colorama" (which can be installed with 'pip' and is cross platform), map a cursor position, make it green for connected and red for disconnected.

EDIT: Oops, apparently the editor will not allow my to display the icon so it just shows up as a question mark. Sorry. So where you see the "?" just picture in your mind the actual emoji. :-)
Do you mean this symbol: 🖧?

print('\N{THREE NETWORKED COMPUTERS}')

Hint to post this in a forum:

msg = 'Do you mean this symbol: \N{THREE NETWORKED COMPUTERS}?'.encode('ascii', 'xmlcharrefreplace')
print(msg.decode())
Thanks all,
i'll have a look at the suggestions and see where i get to.

the 3 networked pc's oould work but would prefer the wifi symbol as im using a pi zero w. i think i definately need to get my head around python beings the Pi's and projects ive seen tend to use it a lot
Actually, it would be then

msg = 'Do you mean this symbol: \N{ANTENNA WITH BARS}?'.encode('ascii', 'xmlcharrefreplace')
print(msg.decode())
Don't know how you got your little computers where able to show up in the reply  Think
https://github.com/rm-hull/luma.examples...erminal.py

You need a font which supports the the unicode symbol. They are processed wit PIL. But you can also use a graphic.
I am using unicode symbols to see the battery status in the panel or if the laptop power cable is plugged in
DeaD_EyE, I was referring more to your actual post. I've tried "pasting" the icon for "ANTENNA WITH BARS", using the emoji method :signal_strength: and using the html code & #128246; (without the space between the "&" and "#"). They all show the icon (except the emoji method) in the preview post, but change to "?" as soon as I "Post" the reply.  I may have to bring this up in the "Board" forum, so's not to hijack this thread.