Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.60 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import filedialog
  3. from tkinter import messagebox
  4.  
  5. import tkinter as tk, sys, os
  6.  
  7. def koniec():
  8.     sys.exit()
  9.  
  10. def scan_files(): #skanowanie w poszukiwaniu danego pliku
  11.     cash_file = open('cash_file.txt', 'w')
  12.     print("scaning...\n")
  13.     for root, dirs, files in os.walk('D:/a_phyton_skrypt/test'):
  14.         for file in files:
  15.             if file.endswith('.txt'):
  16.                 print(os.path.join('['+file+']    -->    '+root, file))
  17.                 cash_file.write(os.path.join('['+file+']    -->    '+root, file)+'\n')
  18.     print("\nscanned successful!")
  19.     cash_file.close()
  20.  
  21. def click():
  22.     entered_text = textentry.get() #Pobieranie danych z pola tekstowego
  23.     print(entered_text)
  24.  
  25. def load_list(): #Ładowanie z listy i uruchomienie programu z przycisku
  26.     f = open("cash_file.txt","r")
  27.  
  28.     tablica = []
  29.  
  30.     for line in f.readlines():
  31.         tablica.append(line.strip())
  32.  
  33.     for y in tablica:
  34.         def tst():
  35.             os.popen(y)
  36.         b = tk.Button(main, text = y, command=tst)
  37.         b.pack()
  38.  
  39.     f.close()
  40.  
  41. main  = tk.Tk() #GUI
  42. main.title("Application for Jacob")
  43.  
  44. '''
  45. dir = filedialog.askdirectory()
  46. print(dir)
  47. '''
  48. textentry = tk.Entry(main, width=20, bg="white")
  49.  
  50. button4 = tk.Button(main, text="Load List", command=load_list)
  51.  
  52. button3 = tk.Button(main, text="Submit", command=click)
  53.  
  54. button2 = tk.Button(main, text = "Scan Files", command = scan_files)
  55.  
  56. button1 = tk.Button(main, text = "Exit", command = koniec)
  57.  
  58. textentry.pack()
  59. button4.pack()
  60. button3.pack()
  61. button2.pack()
  62. button1.pack()
  63.  
  64. main.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement