BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Python Blynk Library GUI

python

#1

Hello!
Using a raspberry pi, I am trying to make a GUI using Blynk’s python library and Tkinter’s GUI library. When running them together (see code below), the loop, [blynk.run()] overrides the GUI. :frowning: Is there a way to run the Blynk library using this GUI? I’m kind of new to all this so sorry if I said anything wrong.

Thanks in advance

Edit: Using python 3.5.3 on Raspberry Pi B+

import BlynkLib
import time
import requests
from tkinter import *
from tkinter import font

blynk = BlynkLib.Blynk('MY AUTH TOKEN')

win = Tk()

myFont = font.Font(family = 'Helvetica', size = 36, weight = 'bold')
font.families()

win.title("Changing V1 Blynk")
win.geometry('400x400')

def changeV1():
    print("Button was pressed")
    blynk.virtual_write(1, 1)

changeV1 = Button(win, text = "Change V1", font = myFont, command = changeV1, height = 2, width 
=10 )

changeV1.pack()

win.update()
blynk.run()

#2

There is not a lot of info on Blynk Python as I think it is still in Alpha. But what there is, is fairly easy to search for wthi the simple keyword Python :wink:

You may need to run your win.update() or perhaps blynk.run() in a thread?


#3

There was a change in the Python Blynk library that requires blynk.run() to be put in an (infinite) loop:

while True:
    blynk.run()
    work_function_for_gui()

I don’t know what the work function would be for the gui. Is it win.update() ?


#4

blynk-library-python 0.2.0 is released, please check it out.