def __init__(self, title): self.title = title self.width, self.height = 600, 600 self.master = tk.Tk(screenName=self.title) self.master.geometry("950x700") self.version = '1.0' self.navbar = None self.home = None self.scan_frame = None self.history = None # Initialization Spider self.spider = None # Get UI Entry Information self.location_entry = None self.type_options = None self.options_var = None # Labels self.location_label = None self.number_list_label = None self.thread = None # Button Images self.home_button_image = tk.PhotoImage( file=fileutil.get_project_file('Spider', 'assets/Home.png')) self.scan_button_image = tk.PhotoImage( file=fileutil.get_project_file('Spider', 'assets/Scan.png')) self.history_button_image = tk.PhotoImage( file=fileutil.get_project_file('Spider', 'assets/History.png')) # Background image self.background_image = tk.PhotoImage(file=fileutil.get_project_file( 'Spider', 'assets/starbackground.png')) # Create frames self.create_navbar() self.create_home_frame() self.create_scan_frame() # Configure grid self.master.rowconfigure(0, weight=1) self.master.columnconfigure(0, weight=1) self.master.columnconfigure(1, weight=4) # Other self.create_labels() self.scan_buttons() self.create_entries() self.create_options_menu() self.thread = threading.Thread(target=self.start_scan) # Starts the TKinter GUI self.master.mainloop()
def add_last_row(row): with open(fileutil.get_project_file("Spider", "settings.yaml")) as f: doc = yaml.safe_load(f) # Set the last row to the current row + new rows - 1 for the header doc['excel']["lastRow"] = int(doc['excel']['lastRow']) + int(row) - 1 with open(fileutil.get_project_file("Spider", "settings.yaml"), 'w') as f: yaml.dump(doc, f)
def update_key(path, key, value): with open(fileutil.get_project_file("Spider", "settings.yaml")) as f: doc = yaml.safe_load(f) # Set the last row to the current row + new rows - 1 for the header doc[path][key] = str(value) with open(fileutil.get_project_file("Spider", "settings.yaml"), 'w') as f: yaml.safe_dump(doc, f)
def get_last_row(): try: with open(fileutil.get_project_file("Spider", "settings.yaml")) as fs: config = yaml.safe_load(fs) fs.close() return int(config['excel']['lastRow']) except yaml.YAMLError as exc: print(exc)
def get_value(path, key): with open(fileutil.get_project_file('Spider', 'settings.yaml')) as f: config = yaml.safe_load(f) f.close() value = config[path][key] if str(value).isdigit(): return int(value) else: return value
def __init__(self): self.excel_path = fileutil.get_project_file("Spider", "info.xlsx") # Create workbook self.wb = openpyxl.load_workbook(self.excel_path) # Fetches the current active workbook self.ws = self.wb.active self.headers = ["Email", "First Name", "Last Name", "Phone Number", "Type"] self.add_headers() self.col = 1 self.row = configutil.get_last_row()
import fileutil # TODO Is this memory Intensive? Can' it be made easier. company_file = fileutil.get_project_file('Spider', 'companies.txt') def create_new_line_with_text(text): with open(company_file, 'a') as a: a.write("\n") a.write(text) a.close() def append_company_safe(text): with open(company_file) as r: lines = r.readlines() if len(lines) == 0: append_company(text) return if not lines[-1].endswith("\n"): create_new_line_with_text(text) r.close() else: print("nothing in file") def append_company(text): with open(company_file, 'a') as a: a.write(text) a.close()