-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnew_topic.py
35 lines (28 loc) · 1.27 KB
/
new_topic.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
"""
MQTT Client GUI - New Topic Creation Window
Author: Sahin MERSIN - electrocoder <[email protected]>
"""
import tkinter as tk
from tkinter import ttk
from config_file import ConfigFile
class NewTopic(tk.Toplevel):
def __init__(self, main_window):
super().__init__(main_window)
self.main_window = main_window
self.title("Add New Topic")
self.geometry("300x150")
self.transient(main_window)
self.grab_set()
font = ("Helvetica", 12)
frame = ttk.Frame(self, padding="10")
frame.pack(fill="both", expand=True)
ttk.Label(frame, text="Topic:").grid(row=0, column=0, padx=5, pady=5, sticky="e")
self.entry_topic = ttk.Entry(frame, font=font)
self.entry_topic.grid(row=0, column=1, padx=5, pady=5, sticky="ew")
ttk.Button(frame, text="Save", command=self.save_topic).grid(row=1, column=1, pady=10, sticky="e")
ttk.Button(frame, text="Cancel", command=self.destroy).grid(row=1, column=0, pady=10, sticky="w")
def save_topic(self):
topic = ConfigFile().create_topic(self.main_window.entry_broker_text.get(), self.entry_topic.get())
self.main_window.refresh_subscribe_list()
self.main_window.entry_subscribe_topic_text.set(topic)
self.destroy()