Advertisement
Tanas

Window

Sep 30th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.35 KB | None | 0 0
  1. #import context  # Ensures paho is in PYTHONPATH
  2. from tkinter import *
  3. from mqtt_handler import Mqtt_handler
  4.  
  5. # Here, we are creating our class, Window, and inheriting from the Frame
  6. # class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
  7. class Window(Frame):
  8.    
  9.     # Define settings upon initialization. Here you can specify
  10.     def __init__(self, master=None):
  11.         self.mqtt_h = Mqtt_handler()
  12.        
  13.      
  14.         self.textBoxUser = None
  15.         self.textBoxMessage = None
  16.         self.textfield = None
  17.         # parameters that you want to send through the Frame class.
  18.         Frame.__init__(self, master)  
  19.  
  20.         #reference to the master widget, which is the tk window                
  21.         self.master = master
  22.  
  23.         #with that, we want to then run init_window, which doesn't yet exist
  24.         self.init_window()
  25.  
  26.     #Creation of init_window
  27.     def init_window(self):
  28.  
  29.         # changing the title of our master widget      
  30.         self.master.title("HARDCORE VSB CHAT FOR SUPERIOR STUDENTS")
  31.  
  32.         # allowing the widget to take the full space of the root window
  33.         self.pack(fill=BOTH, expand=1)
  34.  
  35.         # creating a button instance
  36.         labelName=Label(self, text="Nickname:", font="Arial 12")
  37.         labelName.pack(padx=20, pady=10)
  38.  
  39.         labelMessage=Label(self, text="Message:", font="Arial 12")
  40.         labelMessage.pack(padx=20, pady=10)
  41.  
  42.         labelLogin=Label(self, text="Login:", font="Arial 12")
  43.         labelLogin.pack(padx=20, pady=10)
  44.  
  45.         labelPassword=Label(self, text="Password:", font="Arial 12")
  46.         labelPassword.pack(padx=20, pady=10)
  47.  
  48.         labelSTATE=Label(self, text="Unknown", font="Arial 30")
  49.         labelSTATE.pack(padx=20, pady=10)
  50.  
  51.         self.textBoxLogin = Entry(self)
  52.         self.textBoxLogin.insert("1","mobilni")
  53.  
  54.         self.textBoxPassword = Entry(self,show="*")
  55.         self.textBoxPassword.insert("1","Systemy")
  56.  
  57.         loginButton = Button(self,text="Log me PLZ", command=mqtt_h.log_me_in)
  58.         #DiscoButton = Button(self,text="LET ME OUT", command=self.call_disconnect)
  59.        
  60.         quitButton = Button(self, text="Exit",command=self.client_exit)
  61.         #SendMessageButton = Button(self, text="Send",command=self.send_message)
  62.    
  63.         self.editArea = tkst.ScrolledText(
  64.             wrap   = WORD,
  65.             width  = 20,
  66.             height = 10
  67.         )
  68.         self.editArea.pack(padx=10, pady=10, fill=BOTH, expand=True)
  69.  
  70.         self.textBoxUser = Entry(self)
  71.         self.textBoxUser.insert("1","killar")
  72.        
  73.         self.textBoxMessage = Entry(self)
  74.         self.textBoxMessage.insert("1","fuck my lief")
  75.        
  76.         # placing the button on my window
  77.         labelName.place(x=0,y=30)
  78.         labelMessage.place(x=0,y=60)
  79.         labelSTATE.place(x=400,y=60)
  80.         labelLogin.place(x=300,y=30)
  81.         labelPassword.place(x=300,y=60)
  82.        
  83.  
  84.         quitButton.place(x=0, y=0)
  85.         loginButton.place (x=300,y=150)
  86.         #DiscoButtonDiscoButton.place(x=400,y=150)
  87.  
  88.         self.textBoxUser.place(x=70,y=25)
  89.         self.textBoxMessage.place(x=70,y=60)
  90.        
  91.         self.textBoxLogin.place(x=400,y=30)
  92.         self.textBoxPassword.place(x=400,y=60)
  93.  
  94.         #textBoxUser.pack()
  95.         #SendMessageButton.place(x=50,y=0)
  96.  
  97.     def client_exit(self):
  98.         exit()
  99.  
  100.     def getPassword(self):
  101.         return str(self.textBoxPassword.get())
  102.    
  103.     def getLogin(self):
  104.         return str(self.textBoxLogin.get())
  105.  
  106.     def getNick(self):
  107.         return str(self.textBoxUser.get())
  108.  
  109. # root window created. Here, that would be the only window, but
  110. # you can later have windows within windows.
  111. root = Tk()
  112.        
  113. root.geometry("800x600")
  114.  
  115. #creation of an instance
  116. app = Window(root)
  117.  
  118.  
  119. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement