Guest User

Untitled

a guest
May 25th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. def invoice_creator_window():
  2. global total_cost, total_cost_list, list_of_items, invoice_created
  3.  
  4. invoice_created = Toplevel()
  5. invoice_created.focus_set()
  6. invoice_created.resizable(width = True, height = False)
  7. invoice_created.title("Invoice Created")
  8. invoice_created.geometry("300x300")
  9. invoice_created.geometry("+400+400")
  10. invoice_created.configure(bg = "limegreen")
  11. currentDisplay = 10
  12.  
  13. print(total_cost, total_cost_list, list_of_items)
  14.  
  15. done = Label(invoice_created, text = "Items have been purchased. Invoice has been created. Please check this program's file location.")
  16. invoice_created = Button(invoice_created, text = "Done", bg = "white", command = close_window)
  17.  
  18. #
  19. done.grid(row = 1, column = 1, padx = 7.5, pady = space_between)
  20. invoice_created.grid(row = 2, column = 1, padx = 7.5, pady = space_between)
  21.  
  22. # This section is for the invoice creation with HTML.
  23. html_formatting_start = """<!DOCTYPE html>
  24. <html>
  25. <head>
  26. <title>Games R Us - Invoice</title>
  27. </head>
  28. <body>
  29.  
  30.  
  31. <style>
  32. body {background-color: #F7D358;}
  33. h1 {color: #775A03;}
  34. p {color: ; border: 1px solid #775A03; padding: 15px; width: 650px}
  35. </style>
  36.  
  37. <center>
  38. <h1>Games R Us - Invoice Document</h1>
  39. """
  40. counter = 0
  41. while len(list_of_items) > 0:
  42. global html_formatting_mid
  43. print(counter)
  44. html_formatting_mid = ("""
  45. <h3>
  46. <p>
  47. <img src="https://steamcdn-a.akamaihd.net/steam/apps/211420/header.jpg?t=1483694369"</img>
  48. <br>""" + str(list_of_items[counter]) + """<br>
  49. <i>$""" + str(total_cost_list[counter]) + """ AUD</i>
  50.  
  51. </p>
  52. </h3>
  53. """)
  54.  
  55. if counter >= len(list_of_items) - 1:
  56. return
  57. else:
  58. counter += 1
  59. html_formatting_end = """
  60. <h2>In Total: $""" + str(total_cost) +""" AUD</h2>
  61. <br>
  62.  
  63. <b>Information Grabbed from These Links: </b>
  64. <a href="https://store.steampowered.com/explore/new/">Steam's New Releases</a> [LIVE] -
  65. <a href="https://store.steampowered.com/search/?filter=topsellers">Steam's Top Sellers</a> [LIVE] -
  66. <a href="https://www.umart.com.au/Headphones_147C.html">Umart's Headphones</a> [PRE-DOWNLOADED] -
  67. <a href="https://www.umart.com.au/Microphones_496C.html">Umart's Microphones</a> [PRE-DOWNLOADED]
  68.  
  69. </center>
  70. </body>
  71. </html>"""
  72.  
  73. invoice_creation = open(invoice_file, "w")
  74.  
  75. invoice_creation.write(html_formatting_start)
  76. invoice_creation.write(html_formatting_mid)
  77. invoice_creation.write(html_formatting_end)
  78.  
  79. invoice_creation.close()
  80.  
  81. #############################################################################
  82.  
  83. button_buy = Button(welcome_window, text = "Buy", fg = "white", bg = "goldenrod", font = gui_font_10,
  84. command = invoice_creator_window)
  85.  
  86. from tkinter import *
  87. import webbrowser
  88. root = Tk ()
  89.  
  90. space_between, invoice_file = 5, "Invoice.html"
  91. total_cost, total_cost_list, list_of_items = 10, [1, 9], ["Something", "Something 2"]
  92.  
  93. def close_window (): root.destroy ()
  94.  
  95. def invoice_creator_window():
  96. global total_cost, total_cost_list, list_of_items, invoice_created
  97.  
  98. invoice_created = Toplevel()
  99. invoice_created.focus_set()
  100. invoice_created.resizable(width = True, height = False)
  101. invoice_created.title("Invoice Created")
  102. invoice_created.geometry("300x300")
  103. invoice_created.geometry("+400+400")
  104. invoice_created.configure(bg = "limegreen")
  105. currentDisplay = 10
  106.  
  107. print(total_cost, total_cost_list, list_of_items)
  108.  
  109. done = Label(invoice_created, text = "Items have been purchased. Invoice has been created.")
  110. invoice_created = Button(invoice_created, text = "Done", bg = "white", command = close_window)
  111.  
  112. #
  113. done.grid(row = 1, column = 1, padx = 7.5, pady = space_between)
  114. invoice_created.grid(row = 2, column = 1, padx = 7.5, pady = space_between)
  115.  
  116. # This section is for the invoice creation with HTML.
  117. html_formatting_start = """<!DOCTYPE html>
  118. <html>
  119. <head>
  120. <title>Games R Us - Invoice</title>
  121. </head>
  122. <body>
  123.  
  124.  
  125. <style>
  126. body {background-color: #F7D358;}
  127. h1 {color: #775A03;}
  128. p {color: ; border: 1px solid #775A03; padding: 15px; width: 650px}
  129. </style>
  130.  
  131. <center>
  132. <h1>Games R Us - Invoice Document</h1>
  133. """
  134. counter = 0
  135. html_formatting_mid = ""
  136. while len(list_of_items) > 0:
  137. print(counter)
  138. html_formatting_mid += """
  139. <h3>
  140. <p>
  141. <img src="https://steamcdn-a.akamaihd.net/steam/apps/211420/header.jpg?t=1483694369"</img>
  142. <br>""" + str(list_of_items[counter]) + """<br>
  143. <i>$""" + str(total_cost_list[counter]) + """ AUD</i>
  144.  
  145. </p>
  146. </h3>
  147. """
  148.  
  149. if counter >= len(list_of_items) - 1:
  150. break
  151. else:
  152. counter += 1
  153. html_formatting_end = """
  154. <h2>In Total: $""" + str(total_cost) +""" AUD</h2>
  155. <br>
  156.  
  157. <b>Information Grabbed from These Links: </b>
  158. <a href="https://store.steampowered.com/explore/new/">Steam's New Releases</a> [LIVE] -
  159. <a href="https://store.steampowered.com/search/?filter=topsellers">Steam's Top Sellers</a> [LIVE] -
  160. <a href="https://www.umart.com.au/Headphones_147C.html">Umart's Headphones</a> [PRE-DOWNLOADED] -
  161. <a href="https://www.umart.com.au/Microphones_496C.html">Umart's Microphones</a> [PRE-DOWNLOADED]
  162.  
  163. </center>
  164. </body>
  165. </html>"""
  166.  
  167. invoice_creation = open(invoice_file, "w")
  168.  
  169. invoice_creation.write (html_formatting_start)
  170. invoice_creation.write (html_formatting_mid)
  171. invoice_creation.write (html_formatting_end)
  172.  
  173. invoice_creation.close ()
  174.  
  175. webbrowser.open (invoice_file)
  176.  
  177. #############################################################################
  178.  
  179. button_buy = Button(root, text = "Buy", fg = "white", bg = "goldenrod",
  180. command = invoice_creator_window).pack ()
  181. root.mainloop ()
Add Comment
Please, Sign In to add comment