small improvements to make textbox non-editable

This commit is contained in:
2023-12-30 11:00:16 +01:00
parent 52ec8a20d9
commit 45f0a3cfeb
3 changed files with 8 additions and 10 deletions
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 94 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 41 KiB

+8 -10
View File
@@ -9,21 +9,19 @@ import urllib
class RadioParadise(object): class RadioParadise(object):
def __init__(self): def __init__(self):
rp_dict=self.load_api() self.load_api()
def load_api(self):
respons=requests.get("https://api.radioparadise.com/api/now_playing")
rp_dict=respons.json()
self.title=rp_dict["title"] self.title=rp_dict["title"]
self.artist=rp_dict["artist"] self.artist=rp_dict["artist"]
self.album=rp_dict["album"] self.album=rp_dict["album"]
self.year=rp_dict["year"] self.year=rp_dict["year"]
self.time=rp_dict["time"] self.time=rp_dict["time"]
self.jpg_path=rp_dict["cover"] self.jpg_path=rp_dict["cover"]
print(self.album)
def load_api(self):
respons=requests.get("https://api.radioparadise.com/api/now_playing")
rp_dict=respons.json()
return rp_dict return rp_dict
def get_list(self): def get_list(self):
result=(self.title, self.artist, self.album, self.year, self.time) result=(self.title, self.artist, self.album, self.year, self.time)
return result return result
@@ -58,21 +56,21 @@ class RPViewer(Tk):
self.font=Font(family="Arial", size=14) self.font=Font(family="Arial", size=14)
self.textbox=Text(self, height=6, width=50, font=self.font) self.textbox=Text(self, height=6, width=50, font=self.font)
self.textbox.insert("1.0", self.rp.get_list()) self.textbox.insert("1.0", self.rp.get_list())
self.textbox.config(state=DISABLED)
self.textbox.pack() self.textbox.pack()
def quit(self): def quit(self):
exit() exit()
def refresh_textbox(self): def refresh_textbox(self):
self.textbox.config(state=NORMAL)
self.textbox.delete("1.0", "end") self.textbox.delete("1.0", "end")
self.textbox.insert("1.0", self.rp.get_list()) self.textbox.insert("1.0", self.rp.get_list())
self.textbox.config(state=DISABLED)
def main(): def main():
rp_play=RadioParadise() rp_play=RadioParadise()
print (rp_play.title)
print(rp_play.artist)
print (rp_play.time)
app=RPViewer(rp_play) app=RPViewer(rp_play)
app.mainloop() app.mainloop()