Advertisement
Guest User

Untitled

a guest
Jun 24th, 2021
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3.  
  4. class Application(tk.Frame):
  5.  
  6.     def __init__(self, master=None):  # Моля за обяснение, защо self не е повече метод, а променлива? Къде бъркам?
  7.         super().__init__(master)
  8.  
  9.         self.pack()
  10.         self.create_widgets()
  11.  
  12.     def create_widgets(self):
  13.         # create widgets
  14.         self.firstNumberEntry = tk.Entry()
  15.         self.plusSigh = tk.Label(text="+")
  16.         self.secondNumberEntry = tk.Entry()
  17.         self.equalSign = tk.Label(text="=")
  18.         self.resultLabel = tk.Label(text="Result...", bg="green", fg="white")
  19.         self.calculateButton = tk.Button(text="Calculate")
  20.  
  21.         # place widgets
  22.         self.firstNumberEntry.pack(side="left")
  23.         self.plusSigh.pack(side="left")
  24.         self.secondNumberEntry.pack(side="left")
  25.         self.equalSign.pack(side="left")
  26.         self.resultLabel.pack(side="left")
  27.         self.calculateButton.pack(side="left")
  28.  
  29.  
  30. # create the application
  31. app = Application()
  32. app.master.title("Sumator")
  33. app.master.minsize(width=100, height=50)
  34.  
  35. # start the program
  36. app.mainloop()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement