Advertisement
DogPl

tkinter clicker

Feb 24th, 2020
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.99 KB | None | 0 0
  1. from tkinter import *
  2. import sys
  3. from PIL import ImageTk, Image
  4. import json
  5. import winsound
  6. import random as rd
  7.  
  8. winsound.PlaySound("Gabe the dog - End Game.wav", winsound.SND_LOOP+winsound.SND_ASYNC)
  9.  
  10. try:
  11. with open("player_stats.json", "r") as player_stats:
  12. player_stats = json.load(player_stats)
  13. except FileNotFoundError:
  14. player_stats = {"dogecoins": 0, "power": 1}
  15.  
  16. screen = Tk()
  17. screen.title("Clicker")
  18. screen.iconbitmap("DogDolanOdPajczaka1.ico")
  19. screen.config(bg="black")
  20.  
  21. button_image = ImageTk.PhotoImage(Image.open("DogDolanOdPajczaka1.png").resize((220, 220)))
  22.  
  23. wasy_image = ImageTk.PhotoImage(Image.open("wasy.png").resize((100, 100)))
  24. kapelusz_image = ImageTk.PhotoImage(Image.open("kapelusz.png").resize((100, 100)))
  25. puszka_image = ImageTk.PhotoImage(Image.open("puszka.jpg").resize((100, 100)))
  26. przysmak_image = ImageTk.PhotoImage(Image.open("przysmak.png").resize((100, 100)))
  27. kosc_image = ImageTk.PhotoImage(Image.open("kosc.jpg").resize((100, 100)))
  28. korona_image = ImageTk.PhotoImage(Image.open("korona.jpg").resize((100, 100)))
  29. piwo_image = ImageTk.PhotoImage(Image.open("piwo.jpg").resize((100, 100)))
  30. komputer_image = ImageTk.PhotoImage(Image.open("komputer.jpg").resize((100, 100)))
  31. rozdzka_image = ImageTk.PhotoImage(Image.open("rozdzka.jpg").resize((100, 100)))
  32. willa_image = ImageTk.PhotoImage(Image.open("willa.jpg").resize((100, 100)))
  33. wodka_image = ImageTk.PhotoImage(Image.open("wodka.jpg").resize((100, 100)))
  34. auto_image = ImageTk.PhotoImage(Image.open("auto.jpg").resize((100, 100)))
  35. wiedzmin_image = ImageTk.PhotoImage(Image.open("wiedzmin.jpg").resize((100, 100)))
  36. shiba_image = ImageTk.PhotoImage(Image.open("shiba.jpg").resize((100, 100)))
  37. marihuana_image = ImageTk.PhotoImage(Image.open("marihuana.jpg").resize((100, 100)))
  38.  
  39. brazowa_skrzynia_image = ImageTk.PhotoImage(Image.open("brazowa_skrzynia.jpg").resize((150, 150)))
  40. zlota_skrzynia_image = ImageTk.PhotoImage(Image.open("zlota_skrzynia.jpg").resize((150, 150)))
  41. diamentowa_skrzynia_image = ImageTk.PhotoImage(Image.open("diamentowa_skrzynia.jpg").resize((150, 150)))
  42.  
  43. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',', ' ')} DogeCoins", bg="darkblue", font="white", fg="white")
  44. label.grid(row=0, column=0)
  45. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  46. label2.grid(row=0, column=1)
  47.  
  48.  
  49. def on_clicked():
  50. global label
  51. global player_stats
  52.  
  53. label.destroy()
  54. player_stats["dogecoins"] += player_stats["power"]
  55. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',', ' ')} DogeCoins",bg="darkblue", font="white", fg="white")
  56. label.grid(row=0, column=0)
  57.  
  58.  
  59. def exit_and_save():
  60.  
  61. with open("player_stats.json", "w") as saving_file:
  62. json.dump(player_stats, saving_file)
  63. sys.exit()
  64.  
  65.  
  66. def brazowa_skrzynia_command():
  67. global label
  68.  
  69. if player_stats["dogecoins"] < 50000:
  70. pass
  71. else:
  72. player_stats["dogecoins"] -= 50000
  73. prize = rd.randint(25000, 75000)
  74. player_stats["dogecoins"] += prize
  75. label.destroy()
  76. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  77. label.grid(row=0, column=0)
  78.  
  79.  
  80. def zlota_skrzynia_command():
  81. global label
  82.  
  83. if player_stats["dogecoins"] < 10000000:
  84. pass
  85. else:
  86. player_stats["dogecoins"] -= 10000000
  87. prize = rd.randint(2500000, 17500000)
  88. player_stats["dogecoins"] += prize
  89. label.destroy()
  90. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  91. label.grid(row=0, column=0)
  92.  
  93.  
  94. def diamentowa_skrzynia_command():
  95. global label
  96.  
  97. if player_stats["dogecoins"] < 1000000000:
  98. pass
  99. else:
  100. player_stats["dogecoins"] -= 1000000000
  101. prize = rd.randint(100000000, 1900000000)
  102. player_stats["dogecoins"] += prize
  103. label.destroy()
  104. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  105. label.grid(row=0, column=0)
  106.  
  107.  
  108. def wasy_command():
  109. global label
  110. global label2
  111.  
  112. if player_stats["dogecoins"] < 500:
  113. pass
  114. else:
  115. player_stats["dogecoins"] -= 500
  116. player_stats["power"] += 1
  117. label.destroy()
  118. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  119. label.grid(row=0, column=0)
  120. label2.destroy()
  121. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  122. label2.grid(row=0, column=1)
  123.  
  124.  
  125. def kapelusz_command():
  126. global label
  127. global label2
  128.  
  129. if player_stats["dogecoins"] < 1400:
  130. pass
  131. else:
  132. player_stats["dogecoins"] -= 1400
  133. player_stats["power"] += 3
  134. label.destroy()
  135. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  136. label.grid(row=0, column=0)
  137. label2.destroy()
  138. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  139. label2.grid(row=0, column=1)
  140.  
  141.  
  142. def puszka_command():
  143. global label
  144. global label2
  145.  
  146. if player_stats["dogecoins"] < 3000:
  147. pass
  148. else:
  149. player_stats["dogecoins"] -= 3000
  150. player_stats["power"] += 7
  151. label.destroy()
  152. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  153. label.grid(row=0, column=0)
  154. label2.destroy()
  155. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  156. label2.grid(row=0, column=1)
  157.  
  158.  
  159. def przysmak_command():
  160. global label
  161. global label2
  162.  
  163. if player_stats["dogecoins"] < 10000:
  164. pass
  165. else:
  166. player_stats["dogecoins"] -= 10000
  167. player_stats["power"] += 23
  168. label.destroy()
  169. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  170. label.grid(row=0, column=0)
  171. label2.destroy()
  172. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  173. label2.grid(row=0, column=1)
  174.  
  175.  
  176. def kosc_command():
  177. global label
  178. global label2
  179.  
  180. if player_stats["dogecoins"] < 30000:
  181. pass
  182. else:
  183. player_stats["dogecoins"] -= 30000
  184. player_stats["power"] += 71
  185. label.destroy()
  186. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  187. label.grid(row=0, column=0)
  188. label2.destroy()
  189. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  190. label2.grid(row=0, column=1)
  191.  
  192.  
  193. def korona_command():
  194. global label
  195. global label2
  196.  
  197. if player_stats["dogecoins"] < 100000:
  198. pass
  199. else:
  200. player_stats["dogecoins"] -= 100000
  201. player_stats["power"] += 250
  202. label.destroy()
  203. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  204. label.grid(row=0, column=0)
  205. label2.destroy()
  206. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  207. label2.grid(row=0, column=1)
  208.  
  209.  
  210. def piwo_command():
  211. global label
  212. global label2
  213.  
  214. if player_stats["dogecoins"] < 250000:
  215. pass
  216. else:
  217. player_stats["dogecoins"] -= 250000
  218. player_stats["power"] += 650
  219. label.destroy()
  220. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  221. label.grid(row=0, column=0)
  222. label2.destroy()
  223. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  224. label2.grid(row=0, column=1)
  225.  
  226.  
  227. def komputer_command():
  228. global label
  229. global label2
  230.  
  231. if player_stats["dogecoins"] < 750000:
  232. pass
  233. else:
  234. player_stats["dogecoins"] -= 750000
  235. player_stats["power"] += 1960
  236. label.destroy()
  237. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  238. label.grid(row=0, column=0)
  239. label2.destroy()
  240. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  241. label2.grid(row=0, column=1)
  242.  
  243.  
  244. def rozdzka_command():
  245. global label
  246. global label2
  247.  
  248. if player_stats["dogecoins"] < 1500000:
  249. pass
  250. else:
  251. player_stats["dogecoins"] -= 1500000
  252. player_stats["power"] += 3930
  253. label.destroy()
  254. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  255. label.grid(row=0, column=0)
  256. label2.destroy()
  257. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  258. label2.grid(row=0, column=1)
  259.  
  260.  
  261. def wila_comand():
  262.  
  263. global label
  264. global label2
  265.  
  266. if player_stats["dogecoins"] < 4500000:
  267. pass
  268. else:
  269. player_stats["dogecoins"] -= 4500000
  270. player_stats["power"] += 11800
  271. label.destroy()
  272. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  273. label.grid(row=0, column=0)
  274. label2.destroy()
  275. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  276. label2.grid(row=0, column=1)
  277.  
  278.  
  279. def wodka_command():
  280. global label
  281. global label2
  282.  
  283. if player_stats["dogecoins"] < 10000000:
  284. pass
  285. else:
  286. player_stats["dogecoins"] -= 10000000
  287. player_stats["power"] += 25000
  288. label.destroy()
  289. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  290. label.grid(row=0, column=0)
  291. label2.destroy()
  292. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  293. label2.grid(row=0, column=1)
  294.  
  295.  
  296. def auto_command():
  297. global label
  298. global label2
  299.  
  300. if player_stats["dogecoins"] < 25000000:
  301. pass
  302. else:
  303. player_stats["dogecoins"] -= 25000000
  304. player_stats["power"] += 62515
  305. label.destroy()
  306. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  307. label.grid(row=0, column=0)
  308. label2.destroy()
  309. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  310. label2.grid(row=0, column=1)
  311.  
  312.  
  313. def wiedzmin_command():
  314. global label
  315. global label2
  316.  
  317. if player_stats["dogecoins"] < 75000000:
  318. pass
  319. else:
  320. player_stats["dogecoins"] -= 75000000
  321. player_stats["power"] += 187850
  322. label.destroy()
  323. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  324. label.grid(row=0, column=0)
  325. label2.destroy()
  326. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  327. label2.grid(row=0, column=1)
  328.  
  329.  
  330. def shiba_command():
  331. global label
  332. global label2
  333.  
  334. if player_stats["dogecoins"] < 150000000:
  335. pass
  336. else:
  337. player_stats["dogecoins"] -= 150000000
  338. player_stats["power"] += 375715
  339. label.destroy()
  340. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  341. label.grid(row=0, column=0)
  342. label2.destroy()
  343. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  344. label2.grid(row=0, column=1)
  345.  
  346.  
  347. def marihuana_command():
  348. global label
  349. global label2
  350.  
  351. if player_stats["dogecoins"] < 500000000:
  352. pass
  353. else:
  354. player_stats["dogecoins"] -= 500000000
  355. player_stats["power"] += 1500000
  356.  
  357. label.destroy()
  358. label = Label(screen, text=f"You have {str('{:,}'.format(player_stats['dogecoins'])).replace(',',' ' )} DogeCoins", bg="darkblue", font="white", fg="white")
  359. label.grid(row=0, column=0)
  360. label2.destroy()
  361. label2 = Label(screen, text=f"Your click power = {str('{:,}'.format(player_stats['power'])).replace(',', ' ')}", bg="darkblue", font="white", fg="white")
  362. label2.grid(row=0, column=1)
  363.  
  364.  
  365. button = Button(screen, command=on_clicked, image=button_image)
  366. exit_button = Button(screen, text="Exit\nand\nsave", command=exit_and_save, bg="darkred", height=5, width=10)
  367. wasy_button = Button(screen, image=wasy_image, command=wasy_command)
  368. wasy_cost = Label(screen, text="Cost: -500\nClick power: +1", bg="darkgreen")
  369. kapelusz_button = Button(screen, image=kapelusz_image, command=kapelusz_command)
  370. kapelusz_cost = Label(screen, text="Cost: -1400\nClick power: +3", bg="darkgreen")
  371. puszka_button = Button(screen, image=puszka_image, command=puszka_command)
  372. puszka_cost = Label(screen, text="Cost: -3000\nClick power: +7", bg="darkgreen")
  373. przysmak_button = Button(screen, image=przysmak_image, command=przysmak_command)
  374. przysmak_cost = Label(screen, text="Cost: -10 000\nClick power: +23", bg="darkgreen")
  375. kosc_button = Button(screen, image=kosc_image, command=kosc_command)
  376. kosc_cost = Label(screen, text="Cost: -30 000\nClick power: +71", bg="darkgreen")
  377. korona_button = Button(screen, image=korona_image, command=korona_command)
  378. korona_cost = Label(screen, text="Cost: -100 000\nClick power: +250", bg="darkgreen")
  379. piwo_button = Button(screen, image=piwo_image, command=piwo_command)
  380. piwo_cost = Label(screen, text="Cost: -250 000\nClick power: +650", bg="darkgreen")
  381. komputer_button = Button(screen, image=komputer_image, command=komputer_command)
  382. komputer_cost = Label(screen, text="Cost: -750 000\nClick power: +1960", bg="darkgreen")
  383. rozdzka_button = Button(screen, image=rozdzka_image, command=rozdzka_command)
  384. rozdzka_cost = Label(screen, text="Cost: -1 500 000\nClick power: +3930", bg="darkgreen")
  385. willa_button = Button(screen, image=willa_image, command=wila_comand)
  386. will_cost = Label(screen, text="Cost: -4 500 000\nClick power: +11 800", bg="darkgreen")
  387. wodka_button = Button(screen, image=wodka_image, command=wodka_command)
  388. wodka_cost = Label(screen, text="Cost: -10 000 000\nClick power: +25 000", bg="darkgreen")
  389. auto_button = Button(screen, image=auto_image, command=auto_command)
  390. auto_cost = Label(screen, text="Cost: -25 000 000\nClick power: +62 615", bg="darkgreen")
  391. wiedzmin_button = Button(screen, image=wiedzmin_image, command=wiedzmin_command)
  392. wiedzmin_cost = Label(screen, text="Cost: -75 000 000\nClick power: +187 850", bg="darkgreen")
  393. shiba_button = Button(screen, image=shiba_image, command=shiba_command)
  394. shiba_cost = Label(screen, text="Cost: -150 000 000\nClick power: +375 715", bg="darkgreen")
  395. marihuana_button = Button(screen, image=marihuana_image, command=marihuana_command)
  396. marihuana_cost = Label(screen, text="Cost: -500 000 000\nClick power: +1 500 000", bg="darkgreen")
  397.  
  398. brazowa_skrzynia_button = Button(screen, image=brazowa_skrzynia_image, command=brazowa_skrzynia_command)
  399. brazowa_skrzynia_cost = Label(screen, text="Bronze Box\nCost: -50 000\nPrize: from 25 000 to 75 000 dogecoins", bg="brown")
  400. zlota_skrzynia_button = Button(screen, image=zlota_skrzynia_image, command=zlota_skrzynia_command)
  401. zlota_skrzynia_cost = Label(screen, text="Gold Box\nCost: -10 000 000\nPrize: from 2 500 000 to 17 500 000 dogecoins", bg="gold")
  402. diamentowa_skrzynia_button = Button(screen, image=diamentowa_skrzynia_image, command=diamentowa_skrzynia_command)
  403. diamentowa_skrzynia_cost = Label(screen, text="Diamond Box\nCost: -1 000 000 000\nPrize: from 100 000 000 to 1 900 000 000 dogecoins", bg="blue")
  404.  
  405.  
  406. button.grid(row=1, column=0)
  407. exit_button.grid(row=1, column=1)
  408. brazowa_skrzynia_button.grid(row=1, column=3)
  409. brazowa_skrzynia_cost.grid(row=0, column=3)
  410. zlota_skrzynia_button.grid(row=1, column=4)
  411. zlota_skrzynia_cost.grid(row=0, column=4)
  412. diamentowa_skrzynia_button.grid(row=1, column=5)
  413. diamentowa_skrzynia_cost.grid(row=0, column=5)
  414.  
  415. wasy_button.grid(row=2, column=0)
  416. wasy_cost.grid(row=3, column=0)
  417. kapelusz_button.grid(row=4, column=0)
  418. kapelusz_cost.grid(row=5, column=0)
  419. puszka_button.grid(row=6, column=0)
  420. puszka_cost.grid(row=7, column=0)
  421.  
  422. przysmak_button.grid(row=2, column=1)
  423. przysmak_cost.grid(row=3, column=1)
  424. kosc_button.grid(row=4, column=1)
  425. kosc_cost.grid(row=5, column=1)
  426. korona_button.grid(row=6, column=1)
  427. korona_cost.grid(row=7, column=1)
  428.  
  429. piwo_button.grid(row=2, column=3)
  430. piwo_cost.grid(row=3, column=3)
  431. komputer_button.grid(row=4, column=3)
  432. komputer_cost.grid(row=5, column=3)
  433. rozdzka_button.grid(row=6, column=3)
  434. rozdzka_cost.grid(row=7, column=3)
  435.  
  436. willa_button.grid(row=2, column=4)
  437. will_cost.grid(row=3, column=4)
  438. wodka_button.grid(row=4, column=4)
  439. wodka_cost.grid(row=5, column=4)
  440. auto_button.grid(row=6, column=4)
  441. auto_cost.grid(row=7, column=4)
  442.  
  443. wiedzmin_button.grid(row=2, column=5)
  444. wiedzmin_cost.grid(row=3, column=5)
  445. shiba_button.grid(row=4, column=5)
  446. shiba_cost.grid(row=5, column=5)
  447. marihuana_button.grid(row=6, column=5)
  448. marihuana_cost.grid(row=7, column=5)
  449.  
  450. if __name__ == '__main__':
  451. screen.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement