forked from Guovin/iptv-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscribe.py
64 lines (56 loc) · 2.22 KB
/
subscribe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import tkinter as tk
from tkinter import ttk
from utils.config import config
from tkinter import scrolledtext
class SubscribeUI:
def init_ui(self, root):
"""
Init subscribe UI
"""
frame_subscribe_open_subscribe = tk.Frame(root)
frame_subscribe_open_subscribe.pack(fill=tk.X)
self.open_subscribe_label = tk.Label(
frame_subscribe_open_subscribe, text="开启订阅源:", width=9
)
self.open_subscribe_label.pack(side=tk.LEFT, padx=4, pady=8)
self.open_subscribe_var = tk.BooleanVar(
value=config.getboolean("Settings", "open_subscribe", fallback=True)
)
self.open_subscribe_checkbutton = ttk.Checkbutton(
frame_subscribe_open_subscribe,
variable=self.open_subscribe_var,
onvalue=True,
offvalue=False,
command=self.update_open_subscribe,
)
self.open_subscribe_checkbutton.pack(side=tk.LEFT, padx=4, pady=8)
frame_subscribe_subscribe_urls = tk.Frame(root)
frame_subscribe_subscribe_urls.pack(fill=tk.X)
self.subscribe_urls_label = tk.Label(
frame_subscribe_subscribe_urls, text="订阅源:", width=9
)
self.subscribe_urls_label.pack(side=tk.LEFT, padx=4, pady=8)
self.subscribe_urls_text = scrolledtext.ScrolledText(
frame_subscribe_subscribe_urls, height=5
)
self.subscribe_urls_text.pack(
side=tk.LEFT, padx=4, pady=8, expand=True, fill=tk.BOTH
)
self.subscribe_urls_text.insert(
tk.END, config.get("Settings", "subscribe_urls", fallback="")
)
self.subscribe_urls_text.bind("<KeyRelease>", self.update_subscribe_urls)
def update_open_subscribe(self):
config.set("Settings", "open_subscribe", str(self.open_subscribe_var.get()))
def update_subscribe_urls(self, event):
config.set(
"Settings",
"subscribe_urls",
self.subscribe_urls_text.get(1.0, tk.END),
)
def change_entry_state(self, state):
for entry in [
"open_subscribe_checkbutton",
"subscribe_urls_text",
]:
getattr(self, entry).config(state=state)