SHARE
TWEET

Untitled

a guest Oct 17th, 2017 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from tkinter import ttk
  3.  
  4. import tkinter as tk
  5.  
  6. LARGE_FONT= ("Arial", 16)
  7. SMALL_FONT= ("Arial", 12)
  8. current_tariff = None
  9.  
  10.  
  11. def tariff_A():
  12.     global current_tariff
  13.     current_tariff= "A"
  14.  
  15. def tariff_B():
  16.     global current_tariff
  17.     current_tariff= "B"
  18.  
  19. def tariff_C():
  20.     global current_tariff
  21.     current_tariff= "C"
  22.  
  23.  
  24. class PhoneCompany(tk.Tk):
  25.  
  26.     def __init__(self, *args, **kwargs):
  27.  
  28.         tk.Tk.__init__(self, *args, **kwargs)
  29.         container = tk.Frame(self)
  30.  
  31.         container.pack(side="top", fill="both", expand = True)
  32.  
  33.         container.grid_rowconfigure(0, weight=1)
  34.         container.grid_columnconfigure(0, weight=1)
  35.  
  36.         self.frames = {}
  37.  
  38.         for F in (StartPage, PageOne, PageTwo, PageThree, PageFour, PageFive, LogIn):
  39.  
  40.             frame = F(container, self)
  41.  
  42.             self.frames[F] = frame
  43.  
  44.             frame.grid(row=0, column=0, sticky="nsew")
  45.  
  46.         self.show_frame(LogIn)
  47.  
  48.     def show_frame(self, cont):
  49.  
  50.         frame = self.frames[cont]
  51.         frame.tkraise()
  52.    
  53. class LogIn(tk.Frame):
  54.  
  55.     def LogInCheck(self):
  56.         global actEntry
  57.         global pinEntry
  58.  
  59.         act = "james"
  60.         pin = "Python123"
  61.  
  62.         actNum = actEntry.get()
  63.         pinNum = pinEntry.get()
  64.  
  65.         print("FUNCTION RUN")
  66.         if actNum == act and pinNum == pin:
  67.             print("CORRECT")
  68.             self.show_frame(StartPage)
  69.         elif actNum != act or pinNum != pin:
  70.             print("INCORRECT")
  71.             self.show_frame(LogIn)
  72.  
  73.     def __init__(self, parent, controller):
  74.  
  75.         global actEntry
  76.         global pinEntry
  77.         self.controller = controller
  78.  
  79.         tk.Frame.__init__(self, parent)
  80.  
  81.         logLabel = ttk.Label(self, text = "Login With Your Username and
  82. Password", font = LARGE_FONT)
  83.         logLabel.pack(side = TOP, anchor = N, expand = YES)
  84.  
  85.  
  86.         actLabel = Label(self, text = 'Username:')
  87.         actEntry = Entry(self)
  88.  
  89.         pinLabel = Label(self, text = 'Password: ')
  90.         pinEntry = Entry(self, show ="*")
  91.  
  92.         actLabel.pack(pady =10, padx = 10, side = TOP, anchor = N)
  93.         pinLabel.pack(pady =5, padx = 10, side = TOP, anchor  = S)
  94.  
  95.         actEntry.pack(pady =10, padx = 10, side = TOP, anchor = N)
  96.         pinEntry.pack(pady =5, padx = 10, side = TOP, anchor  = S)
  97.  
  98.         logInButton = tk.Button(self, text = "Login",
  99.                              command = self.LogInCheck)
  100.         logInButton.pack(side = TOP, anchor = S)
  101.  
  102.         quitButton = tk.Button(self, text = "Quit", command = quit)
  103.         quitButton.pack(side = BOTTOM, anchor = S)
  104.  
  105.  
  106. if __name__ == "__main__":
  107.     app = PhoneCompany()
  108.     app.mainloop()
  109.    
  110. from tkinter import *
  111. from tkinter import ttk
  112.  
  113. import tkinter as tk
  114.  
  115. LARGE_FONT= ("Arial", 16)
  116. SMALL_FONT= ("Arial", 12)
  117. current_tariff = None
  118.  
  119.  
  120. def tariff_A():
  121.     global current_tariff
  122.     current_tariff= "A"
  123.  
  124. def tariff_B():
  125.     global current_tariff
  126.     current_tariff= "B"
  127.  
  128. def tariff_C():
  129.     global current_tariff
  130.     current_tariff= "C"
  131.  
  132.  
  133. class PhoneCompany(tk.Tk):
  134.  
  135.     def __init__(self, *args, **kwargs):
  136.  
  137.         tk.Tk.__init__(self, *args, **kwargs)
  138.         container = tk.Frame(self)
  139.  
  140.         container.pack(side="top", fill="both", expand = True)
  141.  
  142.         container.grid_rowconfigure(0, weight=1)
  143.         container.grid_columnconfigure(0, weight=1)
  144.  
  145.         self.frames = {}
  146.  
  147.         for F in (StartPage, PageOne, PageTwo, PageThree, PageFour, PageFive, LogIn):
  148.  
  149.             frame = F(container, self)
  150.  
  151.             self.frames[F] = frame
  152.  
  153.             frame.grid(row=0, column=0, sticky="nsew")
  154.  
  155.         self.show_frame(LogIn)
  156.  
  157.     def show_frame(self, cont):
  158.  
  159.         frame = self.frames[cont]
  160.         frame.tkraise()
  161.  
  162.  
  163. class StartPage(tk.Frame):
  164.  
  165.  
  166.     def __init__(self, parent, controller):
  167.         tk.Frame.__init__(self,parent)
  168.         label = tk.Label(self, text="MENU", font=LARGE_FONT)
  169.         label.pack(pady=10,padx=10)
  170.  
  171.         button = tk.Button(self, text="View Account Balance",
  172.                             command=lambda: controller.show_frame(PageOne))
  173.         button.pack()
  174.  
  175.         button2 = tk.Button(self, text="Display Current Tariff",
  176.                             command=lambda: controller.show_frame(PageTwo))
  177.         button2.pack()
  178.  
  179.         button3 = tk.Button(self, text="View List of Rates",
  180.                            command=lambda: controller.show_frame(PageThree))
  181.         button3.pack()
  182.  
  183.         button4 = tk.Button(self, text="View Latest Bill",
  184.                             command=lambda: controller.show_frame(PageFour))
  185.         button4.pack()
  186.  
  187.  
  188. class PageOne(tk.Frame):
  189.  
  190.     def __init__(self, parent, controller):
  191.         tk.Frame.__init__(self, parent)
  192.         label = tk.Label(self, text="Account Balance", font=LARGE_FONT)
  193.         label.pack(pady=10,padx=10)
  194.  
  195.         sublabel = tk.Label(self, text="Your current account balance is £230", font=SMALL_FONT)
  196.         sublabel.pack(pady=10,padx=10)
  197.  
  198.         button1 = tk.Button(self, text="Back to Menu",
  199.                            command=lambda: controller.show_frame(StartPage))
  200.         button1.pack()
  201.  
  202. class PageTwo(tk.Frame):
  203.  
  204.     def __init__(self, parent, controller):
  205.         global current_tariff
  206.         tk.Frame.__init__(self, parent)
  207.         label = tk.Label(self, text="Current Tariff", font=LARGE_FONT)
  208.         label.pack(pady=10,padx=10)
  209.  
  210.         sublabel = tk.Label(self, text="Your current tariff is "+str(current_tariff), font=SMALL_FONT)
  211.         sublabel.pack(pady=10,padx=10)
  212.  
  213.         button1 = tk.Button(self, text="Change Tariff",
  214.                             command=lambda: controller.show_frame(PageFive))
  215.         button1.pack()
  216.  
  217.         button2 = tk.Button(self, text="Back to Home",
  218.                            command=lambda: controller.show_frame(StartPage))
  219.         button2.pack()
  220.  
  221. class PageThree(tk.Frame):
  222.  
  223.     def __init__(self, parent, controller):
  224.         tk.Frame.__init__(self, parent)
  225.         label = tk.Label(self, text="Tariff Rates", font=LARGE_FONT)
  226.         label.pack(pady=10,padx=10)
  227.  
  228.         sublabel = tk.Label(self, text="Peak Rates: A: £0.30 | B: £0.10 | C: £0.90", anchor="w", font=SMALL_FONT)
  229.         sublabel.pack(pady=10,padx=10)
  230.  
  231.         sublabel2 = tk.Label(self, text="Off Peak: A: £0.05 | B: £0.02 | C: -", anchor="w", font=SMALL_FONT)
  232.         sublabel2.pack(pady=10,padx=10)
  233.  
  234.         sublabel3 = tk.Label(self, text="Line Rental: A: £15.00 | B: £20.00 | C: £30.00", anchor="w", font=SMALL_FONT)
  235.         sublabel3.pack(pady=10,padx=10)
  236.  
  237.         button1 = tk.Button(self, text="Back to Home",
  238.                            command=lambda: controller.show_frame(StartPage))
  239.         button1.pack()
  240.  
  241. class PageFour(tk.Frame):
  242.  
  243.     def __init__(self, parent, controller):
  244.         tk.Frame.__init__(self, parent)
  245.         label = tk.Label(self, text="Latest Bill", font=LARGE_FONT)
  246.         label.pack(pady=10,padx=10)
  247.  
  248.         button1 = tk.Button(self, text="Back to Home",
  249.                            command=lambda: controller.show_frame(StartPage))
  250.         button1.pack()
  251.  
  252. class PageFive(tk.Frame):
  253.  
  254.     def __init__(self, parent, controller):
  255.         global current_tariff
  256.         tk.Frame.__init__(self, parent)
  257.         label = tk.Label(self, text="Change Tariff", font=LARGE_FONT)
  258.         label.pack(pady=10,padx=10)
  259.  
  260.         sublabel = tk.Label(self, text="Select new tariffnView list of tariff rates on the main menu to see the prices.", font=SMALL_FONT)
  261.         sublabel.pack(pady=10,padx=10)
  262.  
  263.         button1 = tk.Button(self, text="A",
  264.                             command=lambda:[controller.show_frame(StartPage),tariff_A])
  265.         button1.pack()
  266.  
  267.         button2 = tk.Button(self, text="B",
  268.                             command=lambda:[controller.show_frame(StartPage),tariff_B])
  269.         button2.pack()
  270.  
  271.         button3 = tk.Button(self, text="C",
  272.                             command=lambda:[controller.show_frame(StartPage),tariff_C])
  273.         button3.pack()
  274.  
  275.         button4 = tk.Button(self, text="Back to Home",
  276.                             command=lambda: controller.show_frame(StartPage))
  277.         button4.pack()
  278.  
  279. class LogIn(tk.Frame):
  280.  
  281.     def LogInCheck(self):
  282.         global actEntry
  283.         global pinEntry
  284.  
  285.         act = "james"
  286.         pin = "Python123"
  287.  
  288.         actNum = actEntry.get()
  289.         pinNum = pinEntry.get()
  290.  
  291.         print("FUNCTION RUN")
  292.         if actNum == act and pinNum == pin:
  293.             print("CORRECT")
  294.             self.show_frame(StartPage)
  295.         elif actNum != act or pinNum != pin:
  296.             print("INCORRECT")
  297.             self.show_frame(LogIn)
  298.  
  299.     def __init__(self, parent, controller):
  300.  
  301.         global actEntry
  302.         global pinEntry
  303.         self.controller = controller
  304.  
  305.         tk.Frame.__init__(self, parent)
  306.  
  307.         logLabel = ttk.Label(self, text = "Login With Your Username and Password", font = LARGE_FONT)
  308.         logLabel.pack(side = TOP, anchor = N, expand = YES)
  309.  
  310.  
  311.         actLabel = Label(self, text = 'Username:')
  312.         actEntry = Entry(self)
  313.  
  314.         pinLabel = Label(self, text = 'Password: ')
  315.         pinEntry = Entry(self, show ="*")
  316.  
  317.         actLabel.pack(pady =10, padx = 10, side = TOP, anchor = N)
  318.         pinLabel.pack(pady =5, padx = 10, side = TOP, anchor  = S)
  319.  
  320.         actEntry.pack(pady =10, padx = 10, side = TOP, anchor = N)
  321.         pinEntry.pack(pady =5, padx = 10, side = TOP, anchor  = S)
  322.  
  323.         #  runs the 'LoginCheck' function
  324.  
  325.         logInButton = tk.Button(self, text = "Login",
  326.                                  command = self.LogInCheck)
  327.         logInButton.pack(side = TOP, anchor = S)
  328.  
  329.         quitButton = tk.Button(self, text = "Quit", command = quit)
  330.         quitButton.pack(side = BOTTOM, anchor = S)
  331.  
  332.  
  333. if __name__ == "__main__":
  334.     app = PhoneCompany()
  335.     app.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top