Advertisement
RoW_Tobi

Untitled

Jun 17th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 23.20 KB | None | 0 0
  1. ### ETModules
  2. import socket
  3. import getpass
  4. import gui
  5. import pickle
  6. import os
  7. from struct import *
  8.  
  9.  
  10. def ClientLogin(Login_Socket):
  11.     login = False
  12.  
  13.     FileExists = os.path.isfile('config.db')
  14.  
  15.     if FileExists:
  16.         pickle_in = open('config.db', 'rb')
  17.         configList = pickle.load(pickle_in)
  18.         pickle_in.close()
  19.  
  20.         ID = configList[0]
  21.         Name = configList[1]
  22.         password = configList[2]
  23.  
  24.     else:
  25.         user_data = gui.Login("First")
  26.         Name = user_data[0]
  27.         password = user_data[1]
  28.  
  29.         ID = 'IDrequest'
  30.  
  31.     userdata = Name + ';' + password
  32.     IDBytes = pickle.dumps(ID)
  33.  
  34.     Login_Socket.sendall(IDBytes)
  35.     Login_Socket.send(bytes(userdata, 'utf8', errors='ignore'))
  36.  
  37.     LoginResult = Login_Socket.recv(2048)
  38.     LoginResult = pickle.loads(LoginResult)
  39.  
  40.     if LoginResult == 'login':
  41.         login = True       
  42.         pass
  43.  
  44.     elif LoginResult == 'unsucsesfull':
  45.         pass
  46.  
  47.     else:
  48.         configList = [LoginResult, Name, password]
  49.  
  50.         pickle_save = open('config.db','wb')
  51.         pickle.dump(configList, pickle_save)
  52.         pickle_save.close()
  53.  
  54.         login = True
  55.  
  56.     return login and ID
  57.  
  58.  
  59. ##### Server
  60. # Imports
  61. import socket
  62. import threading
  63. import sys
  64. import time
  65. import pickle
  66. import os
  67. from struct import *
  68.  
  69. # Userdaten
  70. conns = []
  71. IDs = []
  72.  
  73.  
  74. # Speichern von toSave in PickleName
  75. def SavePickle(toSave, FileName):
  76.  
  77.     pickle_save = open(FileName, 'wb')
  78.     pickle.dump(toSave, pickle_save)
  79.     pickle_save.close()
  80.  
  81.  
  82. # Einlesen und returnen der inhalte von PickleName
  83. def ReadPickle(FileName):
  84.  
  85.     pickle_in = open(FileName, 'rb')
  86.     PickleOut = pickle.load(pickle_in)
  87.     pickle_in.close()
  88.  
  89.     return PickleOut
  90.  
  91.  
  92. # Beliebigen User Einloggen oder Regestrieren
  93. def Login(Requester):
  94.  
  95.     while True:
  96.         login = False
  97.         IDBytes = Requester.recv(2048)    
  98.         ID = pickle.loads(IDBytes)
  99.  
  100.  
  101.         dbList = ReadPickle('users.db')
  102.         IDList = dbList[0]
  103.         NameList = dbList[1]
  104.         PasswordList = dbList[2]
  105.         IDcounter = dbList[3]
  106.         IDprioList = dbList[4]
  107.  
  108.         if ID != 'IDrequest':  
  109.             try:        
  110.                 IDposition = IDList.index(ID)
  111.  
  112.             except:
  113.                 ID = 'IDrequest'
  114.  
  115.         if ID == 'IDrequest':
  116.             # Register
  117.             registerDat = Requester.recv(2048)
  118.             registerDat = str(registerDat, 'utf8', errors='ignore')
  119.  
  120.             registerDatList = registerDat.split(';')
  121.             Name = registerDatList[0]
  122.             Pasword = registerDatList[1]
  123.  
  124.             IDcounter += 1
  125.  
  126.             if IDprioList:
  127.                 ID = IDprioList[0]
  128.                 IDprioList.pop(0)            
  129.                 IDList.append(ID)
  130.  
  131.             else:
  132.                 ID = IDcounter
  133.                 IDList.append(ID)
  134.  
  135.             NameList.append(Name)
  136.             PasswordList.append(Pasword)
  137.  
  138.             dbList = [IDList, NameList, PasswordList, IDcounter, IDprioList]
  139.             SavePickle(dbList, 'users.db')
  140.  
  141.             IDBytes = pickle.dumps(ID)
  142.             Requester.sendall(IDBytes)
  143.             login = True
  144.             break
  145.  
  146.         else:
  147.  
  148.             loginDat = Requester.recv(2048)
  149.             loginDat = str(loginDat, 'utf8', errors='ignore')    
  150.  
  151.             loginList = loginDat.split(';')
  152.             Name = loginList[0]
  153.             Password = loginList[1]
  154.  
  155.             if Name == NameList[IDposition] and Password == PasswordList[IDposition]:
  156.                 login = pickle.dumps('login')
  157.                 Requester.send(login)
  158.  
  159.                 login = True            
  160.                 break
  161.  
  162.             else:
  163.                 unsucsesfull = pickle.dumps('unsucsesfull')
  164.                 Requester.send(unsucsesfull)
  165.                 continue
  166.  
  167.     return login, ID              
  168.  
  169.  
  170. # def Is_Alive():
  171. #    global conns
  172. #    global IDs
  173. #
  174. #    while True:
  175. #        time.sleep(30)
  176. #        
  177. #        for x in range(len(IDs)):
  178. #            
  179. #            try:
  180. #                conns[x].send(bytes('Is_Alive_00', 'utf-8', errors='ignore'))
  181. #            except:
  182. #                try:
  183. #                    print('Reciever '+ IDs[x] +' hat sich disconectet')
  184. #                except:
  185. #                    print('Ein Reciever hat sich disconectet')
  186. #
  187. #                conns.pop(x)
  188. #                IDs.pop(x)
  189.  
  190.  
  191. def RecieverLogin(Reciever):
  192.     global conns
  193.     global IDs
  194.  
  195.     (login, ID) = Login(Reciever)
  196.     print('Empfaenger: '+ str(ID) +' Hat sich Eingeloggt')
  197.  
  198.     if not login:
  199.         pass
  200.     else:
  201.         conns.append(Reciever)
  202.  
  203.         IDs.append(ID)
  204.  
  205.  
  206. def RecieverConnect():
  207.  
  208.     Recever_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  209.     Recever_socket.bind(('', 50500))
  210.     Recever_socket.listen(5)
  211.  
  212.     while True:
  213.         (Reciever, Raddr) = Recever_socket.accept()
  214.         print('\033[42m[Info]\033[40m Empfaenger ' + Raddr[0] + ":" + str(Raddr[1]) + ' hat sich verbunden')
  215.  
  216.         threading.Thread(target=RecieverLogin, daemon=True, args=(Reciever, )).start()
  217.  
  218.  
  219. def Relay(Sender):
  220.     global conns
  221.     global IDs
  222.     IDsend = []
  223.     Namesend = []
  224.  
  225.     (login, ID) = Login(Sender)
  226.     print('Sender: '+ str(ID) +'Hat sich Eingeloggt')
  227.  
  228.     if login:
  229.  
  230.         dbList = ReadPickle('users.db')
  231.         IDList = dbList[0]
  232.         NameList = dbList[1]
  233.  
  234.         while True:
  235.             time.sleep(5)
  236.  
  237.             if IDs:
  238.                 break
  239.             else:
  240.                 continue
  241.        
  242.         for x in range(len(IDs)):  
  243.                  
  244.             position = IDList.index(IDs[x])
  245.  
  246.             IDsend.append(IDs[x])
  247.             Namesend.append(NameList[position])
  248.            
  249.         userList = [IDsend, Namesend]
  250.         userStr = pickle.dumps(userList)
  251.  
  252.         Sender.sendall(userStr)
  253.  
  254.         Selection = Sender.recv(2048)
  255.         Selection = pickle.loads(Selection)
  256.  
  257.         SendToPosition = IDs.index(Selection)        
  258.  
  259.         try:
  260.             FileName = Sender.recv(2048)
  261.             FileSendsBytes = Sender.recv(2048)
  262.  
  263.             conns[SendToPosition].sendall(FileName)
  264.             conns[SendToPosition].sendall(FileSendsBytes)
  265.             FileName = str(FileName, 'utf8', errors='ignore')
  266.             print(FileName)
  267.  
  268.             while True:
  269.                 decision = conns[SendToPosition].recv(2048)
  270.                 Sender.sendall(decision)
  271.                 decision = bool(decision)
  272.                
  273.                 DatListLen = Sender.recv(2048)
  274.                 conns[SendToPosition].send(DatListLen)
  275.  
  276.                 if decision:
  277.                     f = open(FileName, 'wb')
  278.                     FilePart = Sender.recv(2048)
  279.  
  280.                     while(FilePart):
  281.                         conns[SendToPosition].send(FilePart)
  282.  
  283.                         f.write(FilePart)
  284.                         FilePart = Sender.recv(2048)
  285.                     f.close()
  286.  
  287.                     print("Server hat den File an den Reciver gesendet")
  288.                 else:
  289.                     print("File transfer wurde abgebrochen")
  290.  
  291.                     retry = Sender.recv(2048)
  292.                     conns[SendToPosition].sendall(retry)
  293.  
  294.                     retry = bool(retry)
  295.  
  296.                     if retry:
  297.                         continue
  298.                     else:
  299.                         break
  300.         except:
  301.             try:
  302.                 Sender.sendall(bytes('Error: Fehler beim übertragen', 'utf-8', errors='ignore'))
  303.  
  304.                 Sender.close()
  305.                 sys.exit()
  306.             except:
  307.                 Sender.close()
  308.                 sys.exit()
  309.  
  310.  
  311. FileExists = os.path.isfile('users.db')
  312.  
  313. if not FileExists:
  314.     IDList = []
  315.     NameList = []
  316.     PasswordList = []
  317.     IDcounter = 0
  318.     IDprioList = []
  319.  
  320.     dbList = [IDList, NameList, PasswordList, IDcounter, IDprioList]
  321.     SavePickle(dbList, 'users.db')
  322.  
  323. Sender_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  324. Sender_socket.bind(('', 50600))
  325. Sender_socket.listen(2)
  326.  
  327. threading.Thread(target=RecieverConnect, daemon=True).start()
  328. # threading.Thread(target=Is_Alive, daemon=True).start()
  329.  
  330.  
  331. while True:
  332.  
  333.     try:
  334.         (Sender, Caddr) = Sender_socket.accept()
  335.         print('\033[42m[Info]\033[40m Sender ' + Caddr[0] + ":" + str(Caddr[1]) + ' hat sich verbunden')
  336.  
  337.         threading.Thread(target=Relay, daemon=True, args=(Sender, )).start()
  338.     except:
  339.         continue
  340.  
  341.  
  342.  
  343. ###### Client E
  344. # Imports
  345. import getpass
  346. import math
  347. import os
  348. import socket
  349. import sys
  350. import time
  351. from struct import *
  352.  
  353. # Module / intern
  354. import ETModules
  355. import gui
  356.  
  357. # Options
  358. ToolBarWidth = 40
  359. Destination = 'C:\\Users\\'+ getpass.getuser() +'\\Downloads\\'
  360. Host = '134.255.216.31'
  361. Port = 50500
  362. Recv = 2048
  363.  
  364. while True:
  365.     while True:
  366.         try:
  367.             ReceverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  368.             ReceverSocket.connect((Host, Port))
  369.  
  370.             break
  371.         except:
  372.             continue
  373.  
  374.     Login = ETModules.ClientLogin(ReceverSocket)
  375.  
  376.     if Login:
  377.         try:
  378.             FileName = ReceverSocket.recv(Recv)
  379.             print('FileName Empfangen')
  380.             FileSendsBytes = ReceverSocket.recv(Recv)
  381.             print('FileSends Empfangen')
  382.  
  383.             FileName = str(FileName, 'utf8', errors='Ignore')
  384.             print(FileName)
  385.             FileSends = unpack('i', FileSendsBytes)[0]
  386.  
  387.             print(FileSends)
  388.  
  389.             FilePath = Destination + FileName
  390.             SendProzent = int(math.ceil(FileSends / ToolBarWidth))
  391.  
  392.             while True:
  393.                 try:
  394.                     Decision = gui.DownloadAsk()
  395.                     ReceverSocket.send(bytes(Decision))
  396.  
  397.                     print('File: ' + FileName + ' wird heruntergeladen')
  398.  
  399.                     if Decision:
  400.                         f = open(FilePath, 'wb')
  401.                         timer = 0
  402.                         counter = 0
  403.  
  404.                         sys.stdout.write("[%s]" % (" " * ToolBarWidth))
  405.                         sys.stdout.flush()
  406.                         sys.stdout.write("\b" * ToolBarWidth)
  407.  
  408.                         FilePart = ReceverSocket.recv(1024)
  409.  
  410.                         while FilePart:
  411.                             timer = timer + 1
  412.                             counter = counter + 1
  413.  
  414.                             if timer == SendProzent:
  415.                                 sys.stdout.write("▰")
  416.                                 sys.stdout.flush()
  417.                                 timer = 0
  418.  
  419.                             f.write(FilePart)
  420.                             FilePart = ReceverSocket.recv(1024)
  421.  
  422.                             time.sleep(0.01)
  423.  
  424.                         sys.stdout.write("\n")
  425.                         f.close()
  426.  
  427.                         print("Datentransfer abgeschlossen")
  428.                         time.sleep(0.5)
  429.                         os.system("cls")
  430.                         break
  431.  
  432.                     else:
  433.                         Retry = ReceverSocket.recv(Recv)
  434.                         Retry = bool(Retry)
  435.  
  436.                         if Retry:
  437.                             continue
  438.  
  439.                         else:
  440.                             break
  441.  
  442.                 except:
  443.                     pass
  444.  
  445.                 break
  446.  
  447.             break
  448.  
  449.         except:
  450.             pass
  451.  
  452.  
  453. ### Client S
  454. # Imports
  455. import getpass
  456. import math
  457. import os
  458. import socket
  459. import pickle
  460. import sys
  461. import time
  462. from struct import *
  463.  
  464. # Module / intern
  465. import ETModules
  466. import gui
  467.  
  468. # Options
  469. ToolBarWidth = 40
  470. Destination = 'C:\\Users\\'+ getpass.getuser() +'\\Downloads\\'
  471. Host = '134.255.216.31'
  472. Port = 50600
  473. Recv = 2048
  474.  
  475. while True:
  476.     try:
  477.         SenderSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  478.         SenderSocket.connect((Host, Port))
  479.         break
  480.  
  481.     except:
  482.         continue
  483.  
  484. Login = ETModules.ClientLogin(SenderSocket)
  485.  
  486. if Login:
  487.     UserStr = SenderSocket.recv(Recv)
  488.     UserList = pickle.loads(UserStr)
  489.     IDList = UserList[0]
  490.     NameList = UserList[1]
  491.  
  492.     IDSelection = gui.SendToSelect(IDList, NameList)
  493.  
  494.     IDSelection = pickle.dumps(IDSelection)
  495.     SenderSocket.send(IDSelection)
  496.  
  497.     FilePath = input('Bitte die Datei einfügen: ')
  498.  
  499.     FileInfo = os.stat(FilePath)
  500.     FileSize = FileInfo.st_size
  501.     FileSends = int(math.ceil(FileSize / 1024))
  502.     SendProzent = int(math.ceil(FileSends / ToolBarWidth))
  503.  
  504.     FileSendsBytes = pack('i', FileSends)
  505.  
  506.     FileList = FilePath.split('\\')
  507.     FileName = FileList[-1]
  508.  
  509.     try:
  510.         SenderSocket.sendall(bytes(FileName, 'utf8', errors='ignore'))
  511.         SenderSocket.send(FileSendsBytes)
  512.  
  513.     except:
  514.         print(FileName + 'konnte nicht gesendet werden')
  515.         sys.exit()
  516.  
  517.     while True:
  518.         try:
  519.             Decision = SenderSocket.recv(Recv)
  520.             Decision = bool(Decision)
  521.  
  522.             if Decision:
  523.                 timer = 0
  524.                 sys.stdout.write("[%s]" % (" " * ToolBarWidth))
  525.                 sys.stdout.flush()
  526.                 sys.stdout.write("\b" * (ToolBarWidth + 1))
  527.  
  528.                 i = open('Debug\\backup.jpg', 'wb')
  529.                 f = open(FilePath, 'rb')
  530.  
  531.                 FilePart = f.read(1024)
  532.  
  533.                 while FilePart:
  534.                     timer = timer + 1
  535.  
  536.                     if timer == SendProzent:
  537.                         sys.stdout.write("▰")
  538.                         sys.stdout.flush()
  539.                         timer = 0
  540.  
  541.                     SenderSocket.send(FilePart)
  542.                     i.write(FilePart)
  543.  
  544.                     FilePart = f.read(1024)
  545.                     time.sleep(0.01)
  546.  
  547.                 sys.stdout.write("\n")
  548.                 f.close()
  549.                 i.close()
  550.                 SenderSocket.close()
  551.  
  552.                 print(FileName + '\n wurde erfolgreich gesendet')
  553.                 break
  554.  
  555.             else:              
  556.                 Retry = gui.SendAsk()
  557.                 SenderSocket.send(bytes(Retry))
  558.                 if Retry:
  559.                     continue
  560.  
  561.                 else:
  562.                     SenderSocket.close()
  563.                     break
  564.  
  565.         except:
  566.             print(FileName + ' konnte nicht gesendet werden')
  567.  
  568.  
  569. ##### gui
  570. # Imports
  571. from tkinter import *
  572. import time
  573. import threading
  574.  
  575.  
  576. def Error(error=404):
  577.     window = Tk()
  578.     window.title("EasyTransfer")
  579.     window.geometry("200x80")
  580.     window.resizable(False, False)
  581.     window.iconbitmap('Icon.ico')
  582.     centerWindow(window)
  583.  
  584.     def no():
  585.         pass
  586.  
  587.     # X Button
  588.     window.protocol("WM_DELETE_WINDOW", no)
  589.  
  590.     Label(window, text='Es ist ein Fehler aufgetreten ( ' + str(error) + ' ) !', fg="red", font="Times 10 bold").place(x=0, y=10)
  591.     # progressbar(0.2, 10, 10, 40, 20, "▰", window, True)
  592.     window.mainloop()
  593.  
  594.  
  595. def progressbar(timer=None, max=None, x=0, y=0, width=None, zeichen="▰", window=None, destroy=True):
  596.  
  597.     def bar(x=0, y=0, state=0, width=None, zeichen="▰", window=None):
  598.         status = ""
  599.         for x in range(state):
  600.             status = status + zeichen
  601.  
  602.         Label(window, width=width, text=status).place(x=x, y=y)
  603.  
  604.     def Dtimer(timer=None, max=None, z=0, y=0, width=None, zeichen="▰", window=None, destroy=None):
  605.  
  606.         for x in range((max + 1)):
  607.             x = max - x
  608.             bar(z, y, x, width, zeichen, window)
  609.             window.update()
  610.             time.sleep(timer)
  611.         if destroy:
  612.             window.destroy()
  613.  
  614.     threading.Thread(target=Dtimer, daemon=True, args=(timer, max, x, y, width, zeichen, window, destroy)).start()
  615.  
  616.  
  617. def centerWindow(window=None):
  618.     window.update_idletasks()
  619.  
  620.     x = (window.winfo_screenwidth() - window.winfo_reqwidth()) / 2
  621.     y = (window.winfo_screenheight() - window.winfo_reqheight()) / 2
  622.     window.geometry("+%d+%d" % ((x - 170), (y - 50)))
  623.     window.deiconify()
  624.  
  625.  
  626. def DownloadAsk():
  627.     window = Tk()
  628.     window.title("EasyTransfer")
  629.     window.geometry("400x150")
  630.     window.resizable(False, False)
  631.     window.iconbitmap('Icon.ico')
  632.     centerWindow(window)
  633.  
  634.     global download
  635.     download = False
  636.  
  637.     def yes():
  638.         window.destroy()
  639.         global download
  640.         download = True
  641.  
  642.     def no():
  643.         window.destroy()
  644.         global download
  645.         download = False
  646.  
  647.     # X Button
  648.     window.protocol("WM_DELETE_WINDOW", no)
  649.  
  650.     Label(window, text="Warnung: Downloaden sie nur Datein von jemanden, ").place(x=5, y=10)
  651.     Label(window, text="den sie kennen!").place(x=5, y=30)
  652.     Label(window, text="▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁").place(x=5, y=50)
  653.     Label(window, text="Info: Der Download beeinträchtigt ihre Internetgeschwindigkeit").place(x=5, y=70)
  654.  
  655.     Button(window, text="Ja", width=12, command=yes).place(x=190, y=110)
  656.     Button(window, text="Nein", width=12, command=no).place(x=290, y=110)
  657.  
  658.     # progressbar(1, 10, 0, 110, 25, "▰", window, True)
  659.  
  660.     window.mainloop()
  661.     try:
  662.         return download
  663.     except:
  664.         pass
  665.  
  666.  
  667. def SendAsk():
  668.     window = Tk()
  669.     window.title("EasyTransfer")
  670.     window.geometry("400x150")
  671.     window.resizable(False, False)
  672.     window.iconbitmap('Icon.ico')
  673.     centerWindow(window)
  674.  
  675.     global download
  676.     download = False
  677.  
  678.     def AskAgain():
  679.         window.destroy()
  680.         global ask
  681.         ask = True
  682.  
  683.     def end():
  684.         window.destroy()
  685.         global ask
  686.         ask = False
  687.  
  688.     def ResendButton():
  689.         time.sleep(10)
  690.         Button(window, text="Erneut anfragen", width=12, command=AskAgain).place(x=190, y=110)
  691.  
  692.     # X Button
  693.     window.protocol("WM_DELETE_WINDOW", end)
  694.  
  695.     Label(window, text="Warnung: Senden sie die Datei nur an jemanden, ").place(x=5, y=10)
  696.     Label(window, text="den sie kennen!").place(x=5, y=30)
  697.     Label(window, text="▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁").place(x=5, y=50)
  698.     Label(window, text="Info: Der Upload beeinträchtigt ihre Internetgeschwindigkeit").place(x=5, y=70)
  699.  
  700.     Button(window, text="Abbrechen", width=12, command=end).place(x=290, y=110)
  701.  
  702.     # progressbar(1, 10, 0, 110, 25, "▰", window, False)
  703.     threading.Thread(target=ResendButton, daemon=True,).start()
  704.  
  705.     window.mainloop()
  706.     try:
  707.         return ask
  708.     except:
  709.         pass
  710.  
  711.  
  712. # flIDs = ID des Freundes | flName Name des Freundes
  713. def SendToSelect(flIDs=None, flNames=None):
  714.     window = Tk()
  715.     window.title("EasyTransfer")
  716.     window.geometry("500x400")
  717.     window.resizable(False, False)
  718.     window.iconbitmap('Icon.ico')
  719.     centerWindow(window)
  720.  
  721.     global state
  722.     state = None
  723.  
  724.     def onClickOnFriend(friend=None):
  725.         global state
  726.         state = friend
  727.         window.destroy()
  728.  
  729.     def FriendLine(x, multiplikator, flID, flName):
  730.         # Send
  731.         Button(window, text="Senden", width=10, image="", command=lambda x=x: onClickOnFriend(flIDs[x])).place(x=400, y=(multiplikator + 10))
  732.         Label(window, text="ID: " + str(flID), font="Times 15 bold").place(x=290, y=(multiplikator + 10))
  733.         Label(window, text=flName, font="Times 15 bold").place(x=200, y=(multiplikator + 10))
  734.  
  735.         # Pb (comming soon)
  736.         try:
  737.             image = PhotoImage(file=flID + ".png")
  738.             pb = Label(window, image=image, width=10, height=10).place(x=10, y=(multiplikator + 10))
  739.         except:
  740.             Label(window, text="Kein Pb vorhanden |", font="Times 15 bold").place(x=10, y=(multiplikator + 10))
  741.  
  742.         window.update()
  743.  
  744.     multiplikator = 0
  745.     for x in range(len(flIDs)):
  746.         multiplikator = multiplikator + 30
  747.  
  748.         Label(window, text="Es wurden " + str(x + 1) + " Freunde gefunden :)", font="Times 15 bold").place(x=10, y=10)
  749.  
  750.         FriendLine(x, multiplikator, flIDs[x], flNames[x])
  751.  
  752.         window.update()
  753.  
  754.     window.mainloop()
  755.     return state
  756.  
  757.  
  758. def DatenWerdenUebertragen(time=10):
  759.     window = Tk()
  760.     window.title("EasyTransfer")
  761.     window.geometry("150x100")
  762.     window.resizable(False, False)
  763.     window.iconbitmap('Icon.ico')
  764.     centerWindow(window)
  765.  
  766.     time = time / 10
  767.  
  768.     Label(window, text=' Daten werden übertragen!', font="Times 10 bold").place(x=0, y=10)
  769.     # progressbar(time, 10, 0, 40, 15, "▰", window, True)
  770.  
  771.     window.mainloop()
  772.  
  773.  
  774. def DownloadOrUploadFinish():
  775.     window = Tk()
  776.     window.title("EasyTransfer")
  777.     window.geometry("255x100")
  778.     window.resizable(False, False)
  779.     window.iconbitmap('Icon.ico')
  780.     centerWindow(window)
  781.  
  782.     Label(window, text=' Fertig Daten wurden erfolgreich übertragen!', font="Times 10 bold").place(x=0, y=10)
  783.     # progressbar(0.5, 20, 0, 40, 30, "▰", window, True)
  784.  
  785.     window.mainloop()
  786.  
  787.  
  788. def Login(state="First"):
  789.     window = Tk()
  790.     window.title("EasyTransfer")
  791.     window.geometry("500x200")
  792.     window.resizable(False, False)
  793.     window.iconbitmap('Icon.ico')
  794.     centerWindow(window)
  795.  
  796.     if state == "First":
  797.         pass
  798.     elif state == "Second":
  799.         Label(window, text='Passwort oder Benutzername ist falsch!', fg="red").place(x=0, y=10)
  800.     else:
  801.         Error(0)
  802.  
  803.     global user
  804.     global pw
  805.  
  806.     global User
  807.     global Pw
  808.  
  809.     user = None
  810.     pw = None
  811.  
  812.     def send():
  813.         global user
  814.         global pw
  815.  
  816.         global User
  817.         global Pw
  818.  
  819.         user = User.get()
  820.         pw = Pw.get()
  821.  
  822.         window.destroy()
  823.  
  824.     User = Entry(window)
  825.     User.place(x=100, y=50)
  826.  
  827.     Pw = Entry(window)
  828.     Pw.place(x=100, y=90)
  829.  
  830.     Label(window, text='Username: ').place(x=10, y=50)
  831.     Label(window, text='Password: ').place(x=10, y=90)
  832.  
  833.     Button(window, text="Login", width=12, command=send).place(x=10, y=120)
  834.     Button(window, text="Abbrechen", width=12, command=window.quit).place(x=130, y=120)
  835.  
  836.     window.mainloop()
  837.     return user, pw
  838.  
  839.  
  840. def LoginRight():
  841.     window = Tk()
  842.     window.title("EasyTransfer")
  843.     window.geometry("100x80")
  844.     window.resizable(False, False)
  845.     window.iconbitmap('Icon.ico')
  846.     centerWindow(window)
  847.  
  848.     def no():
  849.         pass
  850.  
  851.     # X Button
  852.     window.protocol("WM_DELETE_WINDOW", no)
  853.  
  854.     Label(window, text=' Login erfolgreich!', font="Times 10 bold").place(x=0, y=10)
  855.     # progressbar(0.2, 10, 0, 40, 15, "▰", window, True)
  856.  
  857.     window.mainloop()
  858.  
  859.  
  860. def Update(state=False):
  861.     window = Tk()
  862.     window.title("EasyTransfer")
  863.     window.resizable(False, False)
  864.     window.iconbitmap('Icon.ico')
  865.     centerWindow(window)
  866.  
  867.     def YesUpdate():
  868.         window.geometry("10x80")
  869.  
  870.         def no():
  871.             pass
  872.  
  873.         # X Button
  874.         window.protocol("WM_DELETE_WINDOW", no)
  875.  
  876.         Label(window, text='Update erfolgreich!', font="Times 10 bold").place(x=0, y=10)
  877.         # progressbar(0.2, 10, 0, 40, 15, "▰", window, True)
  878.  
  879.         window.mainloop()
  880.  
  881.     def NoUpdate():
  882.         window.geometry("130x80")
  883.  
  884.         def no():
  885.             pass
  886.  
  887.         # X Button
  888.         window.protocol("WM_DELETE_WINDOW", no)
  889.  
  890.         Label(window, text='Kein Update verfügbar!', font="Times 10 bold").place(x=0, y=10)
  891.         # progressbar(0.2, 10, 0, 40, 15, "▰", window, True)
  892.  
  893.         window.mainloop()
  894.  
  895.     if state:
  896.         YesUpdate()
  897.     elif not state:
  898.         NoUpdate()
  899.  
  900.  
  901. def Options():
  902.     window = Tk()
  903.     window.title("EasyTransfer")
  904.     window.geometry("600x600")
  905.     window.resizable(False, False)
  906.     window.iconbitmap('Icon.ico')
  907.     centerWindow(window)
  908.  
  909.     window.mainloop()
  910.  
  911.  
  912. def Menue():
  913.     pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement