Tkinter Apps
for python 3+
client.py on your machine:
import tkinter import http.client myWindow = tkinter.Tk() #replace your server IP:port here: httpServ = http.client.HTTPConnection("192.168.0.19", 5000) httpServ.connect() def sendData(event): httpServ.request("GET", "/listen?message=blah%20blah") response = httpServ.getresponse() resultLabel.configure(text=response.read()) httpServ.close() btnGo = tkinter.Button(myWindow, text="waiting", fg="magenta") btnGo.bind("<ButtonPress>",sendData) btnGo.pack(side="top") resultLabel = tkinter.Label(text="...") resultLabel.pack(side="top") myWindow.title("client app") myWindow.geometry("300x300") myWindow.configure(background='salmon') myWindow.mainloop()server.py on your server:
from flask import Flask from flask import request app = Flask(__name__) @app.route("/listen", methods=["GET"]) def connectionWithClient(): message = request.args.get("message") return "received " + message + " ok" app.run(host="0.0.0.0", port=5000, debug=True)
Challenges
- make a Tkinter app that returns me the school days notices (located on a server) based on what day of the week i ask for