InnocentScar

Up/Down

Jul 9th, 2022
884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.91 KB | None | 0 0
  1. import tkinter as tk
  2. import tkinter.font as tkFont
  3. from tkinter import Label
  4.  
  5.  
  6. class App:
  7.     def __init__(self, root):
  8.         # setting title
  9.         root.title("TV Control Panel")
  10.         # setting window size
  11.         width = 356
  12.         height = 219
  13.         screenwidth = root.winfo_screenwidth()
  14.         screenheight = root.winfo_screenheight()
  15.         alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
  16.         root.geometry(alignstr)
  17.         root.resizable(width=False, height=False)
  18.  
  19.         GButton_419 = tk.Button(root)
  20.         GButton_419["anchor"] = "center"
  21.         GButton_419["bg"] = "#f0f0f0"
  22.         ft = tkFont.Font(family='Times', size=10)
  23.         GButton_419["font"] = ft
  24.         GButton_419["fg"] = "#000000"
  25.         GButton_419["justify"] = "center"
  26.         GButton_419["text"] = "Up"
  27.         GButton_419.place(x=140, y=110, width=70, height=25)
  28.         GButton_419["command"] = self.GButton_419_command
  29.  
  30.         GButton_928 = tk.Button(root)
  31.         GButton_928["bg"] = "#f0f0f0"
  32.         ft = tkFont.Font(family='Times', size=10)
  33.         GButton_928["font"] = ft
  34.         GButton_928["fg"] = "#000000"
  35.         GButton_928["justify"] = "center"
  36.         GButton_928["text"] = "Down"
  37.         GButton_928.place(x=140, y=150, width=70, height=25)
  38.         GButton_928["command"] = self.GButton_928_command
  39.  
  40.         GLabel_424 = tk.Label(root)
  41.         ft = tkFont.Font(family='Times', size=26)
  42.         GLabel_424["font"] = ft
  43.         GLabel_424["fg"] = "#333333"
  44.         GLabel_424["justify"] = "center"
  45.         GLabel_424["text"] = "TV Control"
  46.         GLabel_424.place(x=90, y=10, width=178, height=51)
  47.  
  48.         GLabel_868: Label = tk.Label(root)
  49.         ft = tkFont.Font(family='Times', size=18)
  50.         GLabel_868["font"] = ft
  51.         GLabel_868["fg"] = "#333333"
  52.         GLabel_868["justify"] = "center"
  53.         GLabel_868["text"] = "Volume:"
  54.         GLabel_868.place(x=130, y=60, width=98, height=33)
  55.  
  56.     def GButton_419_command(self):
  57.         import requests
  58.         import json
  59.  
  60.         x = requests.get(url='http://192.168.178.9:1925/1/audio/volume')
  61.  
  62.         y = json.loads(x.text)
  63.  
  64.         Vol = (y['current'])
  65.         level = Vol + 1
  66.         url = 'http://192.168.178.9:1925/1/audio/volume'
  67.         volume = {'current': level}
  68.         requests.get(url, json=volume)
  69.  
  70.         x = requests.post(url, json=volume)
  71.  
  72.     def GButton_928_command(self):
  73.         import requests
  74.         import json
  75.  
  76.         x = requests.get(url='http://192.168.178.9:1925/1/audio/volume')
  77.  
  78.         y = json.loads(x.text)
  79.  
  80.         Vol = (y['current'])
  81.         level = Vol - 1
  82.         url = 'http://192.168.178.9:1925/1/audio/volume'
  83.         volume = {'current': level}
  84.         requests.get(url, json=volume)
  85.  
  86.         x = requests.post(url, json=volume)
  87.  
  88.  
  89. if __name__ == "__main__":
  90.     root = tk.Tk()
  91.     app = App(root)
  92.     root.mainloop()
  93.  
Advertisement
Add Comment
Please, Sign In to add comment