Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import context # Ensures paho is in PYTHONPATH
- from tkinter import *
- from mqtt_handler import Mqtt_handler
- # Here, we are creating our class, Window, and inheriting from the Frame
- # class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
- class Window(Frame):
- # Define settings upon initialization. Here you can specify
- def __init__(self, master=None):
- self.mqtt_h = Mqtt_handler()
- self.textBoxUser = None
- self.textBoxMessage = None
- self.textfield = None
- # parameters that you want to send through the Frame class.
- Frame.__init__(self, master)
- #reference to the master widget, which is the tk window
- self.master = master
- #with that, we want to then run init_window, which doesn't yet exist
- self.init_window()
- #Creation of init_window
- def init_window(self):
- # changing the title of our master widget
- self.master.title("HARDCORE VSB CHAT FOR SUPERIOR STUDENTS")
- # allowing the widget to take the full space of the root window
- self.pack(fill=BOTH, expand=1)
- # creating a button instance
- labelName=Label(self, text="Nickname:", font="Arial 12")
- labelName.pack(padx=20, pady=10)
- labelMessage=Label(self, text="Message:", font="Arial 12")
- labelMessage.pack(padx=20, pady=10)
- labelLogin=Label(self, text="Login:", font="Arial 12")
- labelLogin.pack(padx=20, pady=10)
- labelPassword=Label(self, text="Password:", font="Arial 12")
- labelPassword.pack(padx=20, pady=10)
- labelSTATE=Label(self, text="Unknown", font="Arial 30")
- labelSTATE.pack(padx=20, pady=10)
- self.textBoxLogin = Entry(self)
- self.textBoxLogin.insert("1","mobilni")
- self.textBoxPassword = Entry(self,show="*")
- self.textBoxPassword.insert("1","Systemy")
- loginButton = Button(self,text="Log me PLZ", command=mqtt_h.log_me_in)
- #DiscoButton = Button(self,text="LET ME OUT", command=self.call_disconnect)
- quitButton = Button(self, text="Exit",command=self.client_exit)
- #SendMessageButton = Button(self, text="Send",command=self.send_message)
- self.editArea = tkst.ScrolledText(
- wrap = WORD,
- width = 20,
- height = 10
- )
- self.editArea.pack(padx=10, pady=10, fill=BOTH, expand=True)
- self.textBoxUser = Entry(self)
- self.textBoxUser.insert("1","killar")
- self.textBoxMessage = Entry(self)
- self.textBoxMessage.insert("1","fuck my lief")
- # placing the button on my window
- labelName.place(x=0,y=30)
- labelMessage.place(x=0,y=60)
- labelSTATE.place(x=400,y=60)
- labelLogin.place(x=300,y=30)
- labelPassword.place(x=300,y=60)
- quitButton.place(x=0, y=0)
- loginButton.place (x=300,y=150)
- #DiscoButtonDiscoButton.place(x=400,y=150)
- self.textBoxUser.place(x=70,y=25)
- self.textBoxMessage.place(x=70,y=60)
- self.textBoxLogin.place(x=400,y=30)
- self.textBoxPassword.place(x=400,y=60)
- #textBoxUser.pack()
- #SendMessageButton.place(x=50,y=0)
- def client_exit(self):
- exit()
- def getPassword(self):
- return str(self.textBoxPassword.get())
- def getLogin(self):
- return str(self.textBoxLogin.get())
- def getNick(self):
- return str(self.textBoxUser.get())
- # root window created. Here, that would be the only window, but
- # you can later have windows within windows.
- root = Tk()
- root.geometry("800x600")
- #creation of an instance
- app = Window(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement