Advertisement
gregwa

FCM 134 - mqttclient.py

May 22nd, 2018
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.09 KB | None | 0 0
  1. #! /usr/bin/env python
  2. #  -*- coding: utf-8 -*-
  3. #
  4. # GUI module generated by PAGE version 4.13
  5. # In conjunction with Tcl version 8.6
  6. #    May 22, 2018 07:56:33 AM
  7. # ======================================================
  8. #             mqttclient.py
  9. # ------------------------------------------------------
  10. # Written by G.D. Walters for Full Circle Magazine #134
  11. # Python in the REAL World # 84 June 2018
  12. # ======================================================
  13. import sys
  14.  
  15. try:
  16.     from Tkinter import *
  17. except ImportError:
  18.     from tkinter import *
  19.  
  20. try:
  21.     import ttk
  22.     py3 = False
  23. except ImportError:
  24.     import tkinter.ttk as ttk
  25.     py3 = True
  26.  
  27. import mqttclient_support
  28.  
  29. def vp_start_gui():
  30.     '''Starting point when module is the main routine.'''
  31.     global val, w, root
  32.     root = Tk()
  33.     mqttclient_support.set_Tk_var()
  34.     top = MQTT_Client (root)
  35.     mqttclient_support.init(root, top)
  36.     root.mainloop()
  37.  
  38. w = None
  39. def create_MQTT_Client(root, *args, **kwargs):
  40.     '''Starting point when module is imported by another program.'''
  41.     global w, w_win, rt
  42.     rt = root
  43.     w = Toplevel (root)
  44.     mqttclient_support.set_Tk_var()
  45.     top = MQTT_Client (w)
  46.     mqttclient_support.init(w, top, *args, **kwargs)
  47.     return (w, top)
  48.  
  49. def destroy_MQTT_Client():
  50.     global w
  51.     w.destroy()
  52.     w = None
  53.  
  54.  
  55. class MQTT_Client:
  56.     def __init__(self, top=None):
  57.         '''This class configures and populates the toplevel window.
  58.           top is the toplevel containing window.'''
  59.         _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
  60.         _fgcolor = '#000000'  # X11 color: 'black'
  61.         _compcolor = '#d9d9d9' # X11 color: 'gray85'
  62.         _ana1color = '#d9d9d9' # X11 color: 'gray85'
  63.         _ana2color = '#d9d9d9' # X11 color: 'gray85'
  64.  
  65.         top.geometry("495x227+347+264")
  66.         top.title("MQTT Client")
  67.  
  68.  
  69.  
  70.         self.Frame1 = Frame(top)
  71.         self.Frame1.place(relx=0.02, rely=0.04, relheight=0.9, relwidth=0.96)
  72.         self.Frame1.configure(relief=GROOVE)
  73.         self.Frame1.configure(borderwidth="2")
  74.         self.Frame1.configure(relief=GROOVE)
  75.         self.Frame1.configure(width=475)
  76.  
  77.         self.Label1 = Label(self.Frame1)
  78.         self.Label1.place(relx=0.04, rely=0.17, height=18, width=146)
  79.         self.Label1.configure(text='''Last Message Received:''')
  80.  
  81.         self.lblLastMessage = Label(self.Frame1)
  82.         self.lblLastMessage.place(relx=0.36, rely=0.15, height=28, width=256)
  83.         self.lblLastMessage.configure(relief=SUNKEN)
  84.         self.lblLastMessage.configure(text='''Label''')
  85.         self.lblLastMessage.configure(textvariable=mqttclient_support.LastMessage)
  86.         self.lblLastMessage.configure(width=256)
  87.  
  88.         self.Label3 = Label(self.Frame1)
  89.         self.Label3.place(relx=0.19, rely=0.36, height=18, width=67)
  90.         self.Label3.configure(text='''Humidity:''')
  91.  
  92.         self.lblHumidity = Label(self.Frame1)
  93.         self.lblHumidity.place(relx=0.36, rely=0.34, height=28, width=116)
  94.         self.lblHumidity.configure(relief=SUNKEN)
  95.         self.lblHumidity.configure(text='''Label''')
  96.         self.lblHumidity.configure(textvariable=mqttclient_support.HumidityValue)
  97.         self.lblHumidity.configure(width=116)
  98.  
  99.         self.Label5 = Label(self.Frame1)
  100.         self.Label5.place(relx=0.15, rely=0.55, height=18, width=90)
  101.         self.Label5.configure(text='''Temperature:''')
  102.  
  103.         self.lblTemp = Label(self.Frame1)
  104.         self.lblTemp.place(relx=0.36, rely=0.54, height=28, width=116)
  105.         self.lblTemp.configure(relief=SUNKEN)
  106.         self.lblTemp.configure(text='''Label''')
  107.         self.lblTemp.configure(textvariable=mqttclient_support.TempValue)
  108.         self.lblTemp.configure(width=116)
  109.  
  110.         self.btnQuit = Button(self.Frame1)
  111.         self.btnQuit.place(relx=0.69, rely=0.78, height=26, width=87)
  112.         self.btnQuit.configure(activebackground="#d9d9d9")
  113.         self.btnQuit.configure(command=mqttclient_support.on_btnQuit)
  114.         self.btnQuit.configure(text='''Quit''')
  115.         self.btnQuit.configure(width=87)
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122. if __name__ == '__main__':
  123.     vp_start_gui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement