Facebook
From mahdi, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 293
  1. import linecache
  2. import pygame
  3. from datetime import *
  4. from tkinter import *
  5. import os
  6. import random
  7.  
  8.  
  9.  
  10.  
  11.  
  12. time = datetime.today()
  13. w = Tk()
  14. w.title("Million (Beta version v.0.1)")
  15. w.configure(bg="black")
  16. w.resizable(0 , 0)
  17. w.geometry("600x260")
  18. os.system("db23456789.txt")
  19.  
  20.  
  21. #    هاي مال صوت :)
  22. def ps():
  23.    
  24.     pygame.init()
  25.     pygame.mixer.music.load("btn.mp3")            #اسم ملف الصوت يجب ان يكون صيغة
  26.     pygame.mixer.music.play()
  27.  
  28.  
  29.  
  30.  
  31. def sg():
  32.     os.system("db2.txt")
  33.     pygame.init()
  34.     pygame.mixer.music.load("btn.mp3")            #اسم ملف الصوت يجب ان يكون صيغة
  35.     pygame.mixer.music.play()
  36.     o = open("db.txt", "r+")
  37.     o.write("اسم الفريق الاول : " + " "+ "["+e1.get()+ "]\n")
  38.     o.write("اسم الفريق الثاني : " + " "+ "["+e2.get()+ "]")
  39.     o.close()
  40.  
  41.  
  42.     def H():
  43.       pygame.init()
  44.       pygame.mixer.music.load("btn.mp3")            #اسم ملف الصوت يجب ان يكون صيغة
  45.       pygame.mixer.music.play()
  46.       with open ("An.txt", "r") as f:
  47.                  lines = f.readlines()
  48.                  rl1 = random.choice(lines)
  49.                  rl2 = random.choice(lines)
  50.                  rl3 = random.choice(lines)
  51.                  rl4 = random.choice(lines)
  52.  
  53.  
  54.       w2.destroy()
  55.       wh = Tk()
  56.       wh.title("Million (Beta version v.0.1)")
  57.       wh.configure(bg="black")
  58.       wh.resizable(0 , 0)
  59.       wh.geometry("1350x695")
  60.       bt1 = Button(wh, text="1- "+rl1, font="family 25", bg="white")
  61.       bt2 = Button(wh, text="2- "+rl2, font="family 25", bg="white")
  62.       bt3 = Button(wh, text="3- "+rl3, font="family 25", bg="white")
  63.       bt4 = Button(wh, text="4- "+rl4, font="family 25", bg="white")
  64.       get = linecache.getline('db.txt',1)
  65.                            
  66.       lbq = Label(wh, text=get, font="family 25", bg="black", fg="white")
  67.       lbq.grid(sticky=N, pady=10, padx=450)
  68.       bt1.grid(pady=10, padx=200, sticky=N)
  69.       bt2.grid(pady=10, padx=200, sticky=N)
  70.       bt3.grid(pady=10, padx=200, sticky=N)
  71.       bt4.grid(pady=10, padx=200, sticky=N)
  72.      
  73.     def SI():
  74.       pygame.init()
  75.       pygame.mixer.music.load("btn.mp3")            #اسم ملف الصوت يجب ان يكون صيغة
  76.       pygame.mixer.music.play()
  77.       w2.configure(bg="red")
  78.     def SP():
  79.       pygame.init()
  80.       pygame.mixer.music.load("btn.mp3")            #اسم ملف الصوت يجب ان يكون صيغة
  81.       pygame.mixer.music.play()
  82.       w2.configure(bg="blue")
  83.      
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.       #DisAbled
  102.     def B():
  103.       w2.configure(bg="white")
  104.     def C():
  105.       w2.configure(bg="brown")
  106.     def M():
  107.       w2.configure(bg="pink")
  108.  
  109.  
  110.  
  111.  
  112.     w.after(4000)
  113.     w.destroy()
  114.     w2 = Tk()
  115.     w2.title("Million (Beta version v.0.1)")
  116.     w2.configure(bg="black")
  117.     w2.resizable(0 , 0)
  118.     w2.geometry("1350x695")
  119.     B1 = Button(w2, text="التاريخ", height="1", width="80", command=H, font="Times 25")
  120.     B2 = Button(w2, text="العلوم", height="1", width="80", command=SI, font="Times 25")
  121.     B3 = Button(w2, text="الرياضة", height="1", width="80", command=SP, font="Times 25")
  122.     B4 = Button(w2, text=" .. قريباٌ ", height="1", width="80", command=B, font="Times 25")
  123.     B5 = Button(w2, text=" .. قريباٌ ", height="1", width="80", command=C, font="Times 25")
  124.     B6 = Button(w2, text=" .. قريباٌ ", height="1", width="80", command=M, font="Times 25")
  125.     B7 = Button(w2, text=" .. قريباٌ ", height="1", width="80", command=M, font="Times 25")
  126.  
  127.     L = Label(w2, text=": اختر المجال الذي تريد ان تُختبر به ", bg="black", fg="white", font="Times 25")
  128.     L.grid(sticky=N, padx=0, pady=10)        
  129.     B1.grid(sticky=NW, padx=0, pady=5)
  130.     B2.grid(sticky=NW, padx=0, pady=5)
  131.     B3.grid(sticky=N, padx=0, pady=5)
  132.  
  133.  
  134.     B4.grid(sticky=NW, padx=0, pady=5)
  135.     B5.grid(sticky=N, padx=0, pady=5)
  136.     B6.grid(sticky=N, padx=0, pady=5)
  137.     B7.grid(sticky=N, padx=0, pady=5)
  138.    
  139.  
  140.  
  141. #    هاي مال صوت :)
  142. def ps():
  143.    
  144.     pygame.init()
  145.     pygame.mixer.music.load("btn.mp3")            #اسم ملف الصوت يجب ان يكون صيغة
  146.     pygame.mixer.music.play()
  147.  
  148.  
  149.  
  150.  
  151. FN = StringVar()
  152. SN = StringVar()
  153.  
  154.  
  155. e1 = Entry(w, textvariable=FN)
  156. e2 = Entry(w, textvariable=SN)
  157. l1 = Label(w, text=": اسم الفريق الاول ", bg="black", fg="white")
  158. l2 = Label(w, text=": اسم الفريق الثاني", bg="black", fg="white")
  159.  
  160. def SN():
  161.     with open ('file2.txt') as file:
  162.             for i in file:
  163.                 file.write("asdasdas")
  164.  
  165. b2 = Button(w, text="! بدء اللعبة ", height="3", width="16", command=sg)
  166. b3 = Button(w, text="Play a sound", command=ps)
  167. L1 = Label(w, text=time, foreground="white", bg="black")
  168. l1.grid(sticky=N)
  169. e1.grid(sticky=N)
  170. l2.grid(sticky=N)
  171. e2.grid(sticky=N)
  172. b2.grid(pady=50, padx=250)
  173. b3.grid()
  174. L1.grid(sticky=W)
  175.  
  176.  
  177.  
  178.  
  179.  
  180. # matching & names basing:
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  192.  
  193.  
  194.  
  195. w.mainloop()
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.