Package: tkst
tkstAboutPreview projects using the ST7789 spi display (andcorresponding python library) on your desktop with tkinter. Read morehere.jump to...DocUsageExamplesDocDisplaytkst.Display(displayType)main class that provides methods for interacting with a displayparametersdisplayTypea tkstdisplay type(tkst.STortkst.TK)methodstkst.Display().start()starts the display. Fortkst.TKdisplays it calls tkinter'smainloop()function, and fortkst.STit calls ST7789'sbegin()function. Sincemainloop()is blocking,tkst.Display().start()will block regardless of display type to ensure code works with either.tkst.Display().awaitStart()blocks untiltkst.Display().start()has started the display. This is likely unnecessary, as the display starts very quickly, however if you receive atkst.DisplayErrorwhen first callingtkst.Display().display(), then it might be a good idea to use this.tkst.Display().stop()stops the display. Any attempts to update the display after callingtkst.Display().stop()will result in atkst.DisplayError.tkst.Display().display(image)display aPIL.Imageimage on the display.propertiestkst().Display().outputa tkstdisplay type(tkst.STortkst.TK).tkst().Display().widththe width of the display (240px).tkst().Display().hegihtthe height of the display (240px).tkst().Display().isRunninga boolean describing whether the display is currently running or not.tkst().Display().rootthe root window on which any image is drawn. It is of typetkinter.Tk()window iftkst().Display().outputistkst.TK, orST7789.ST7789()iftkst().Display().outputistkst.ST.Display Typestkst.STdisplay type corresponding to a physical ST7789 display. Requires the ST7789 module to be installed; if it is not, atkst.DisplayErrorwill be raised.tkst.TKdisplay type corresponding to a tkinter window. Requires the tkinter module to be installed; if it is not, atkst.DisplayErrorwill be raised.Errorstkst.DisplayErrora general error used by this module, will be raised if methods liketkst.Display().start()are called while the display is active, or iftkst.Display().display()is called after the display is stopped.UsageFirstly import the tkst module (you'll also want to use Pillow and threading)importtkstfromPILimportImage,ImageDraw,ImageFontfromthreadingimportThreadDefine a function to be the target of the thread we're going to createdefupdateDisplay(display):display.awaitStart()img=Image.new('RGB',(display.width,display.height),color=(0,0,0))# the image we're going to displaydraw=ImageDraw.Draw(img)# a way for us to add text etc on top of the imagedraw.text((0,0),"hello, world!",font="/usr/share/fonts/gnu-free/FreeMono.otf",fill=(255,255,255))# add some sample text to our imagedisplay.display(img)# show this image on the displaySet up a main function where we initialise the display and set everything goingdef__main__():d=tkst.Display(tkst.TK)# just change tkst.TK to tkst.ST when you want to display it on the ST7789t=Thread(target=updateDisplay,args=[d,])# thread to set the picture on the display, has to be threaded as tkst.Display().start() is blockingt.start()# start the updater threadd.start()# start the displayif__name__=="__main__":# fancy way of starting the main function__main__()Et vóila! That's your first program that you can easily test on your computer before displaying it on an ST7789.ExamplesCheck out a couple of examples on mygithub repo