def sort_by_name(): """Create input window for tkinter""" def get_name(): by_name(ask_name.get()) ask_window = Tk() ask_window.title("batchful") ask_window.geometry("200x200") title = Label(ask_window, text="Enter A Phrase") title.grid(column=1, row=0) ask_name = Entry(ask_window, width=10) ask_name.focus() ask_name.grid(column=1, row=1) ask_button = Button(ask_window, text="Search", command=combine_funcs(get_name, ask_window.destroy)) ask_button.grid(column=1, row=2) quit_button = Button(ask_window, text="Go Back", command=ask_window.destroy) quit_button.grid(column=0, row=3)
def help(): """Creates help window for tkinter""" help_window = Tk() help_window.title("batchful - help") help_text = Label(help_window, text="HOW TO USE BATCHFUL:", font=("Ariel Bold", 25)) help_text2 = Label( help_window, text="In the main screen, choose a method of organization.\n\ Currently, there are 2 methods of organization: \n\ 1. By file extension: creates a directory for every filetype \n\ and sorts the files accordingly. \n\ 2. By file name: creates a directory for a spacefic phrase and moves \n\ all of the files containing the phrase to the directory. \n\ \n\ You will also be presented with the option to sort through subfolders. \n\ This process deletes the unnecessary folders after it's done sorting. \n\ \n\ To run the program, just press the desired button. \n\ you can make sub-folders search active by checking the checkbox", font=("Ariel", 15)) back_button = Button(help_window, text="Go Back", command=help_window.destroy) current_location_label = Label(help_window, text="Current location: " + str(currentLocation), font=("Ariel 12")) help_text.grid(column=0, row=0) help_text2.grid(column=0, row=1) current_location_label.grid(column=0, row=3) back_button.grid(column=0, row=4) place_holder = Label(help_window).grid(column=0, row=2)
def check_loaddata(self): global patient global Kinect global IMU global valid_graphs valid_graphs = [] nameGood = False dateGood = False if self.ids["Patient_Name"].text != "" and self.ids["Date"].text != "": # self.manager.current = 'Dataanalysis' nameGood = True if len(self.ids["Patient_Name"].text) > 0: # self.manager.current = 'Dataanalysis' pass else: ctypes.windll.user32.MessageBoxW(0, u"Enter Patient Name!", u"Error", 16) # self.manager.current = 'olddata' date = self.ids["Date"].text furtherCheck = False if self.ids["Date"].text.isdigit() and len(date) == 8: m = date[0:2] d = date[2:4] y = date[4:8] furtherCheck = True else: ctypes.windll.user32.MessageBoxW(0, u"Date must be numbers (mmddyyyy)!", u"Error", 16) # self.manager.current = 'olddata' if furtherCheck: if int(m) >= 1 and int(m) <= 12 and int(d) >= 1 and int(d) <= 31 and int(y) >= 2018 and int(y) <= 3000: # self.manager.current = 'Dataanalysis' dateGood = True else: ctypes.windll.user32.MessageBoxW(0, u"Enter Valid Date.", u"Error", 16) # self.manager.current = 'olddata' if nameGood and dateGood: global selected_t global t patient = self.ids["Patient_Name"].text.lower() t = y + "-" + m + '-' + d possible_times = glob.glob(default_path + '/' + patient + '/*/') if len(possible_times) >= 1: times = [] for pt in possible_times: pt = pt.split('\\') pt = pt[len(pt)-2] pt = pt.split('-') times.append(pt[len(pt)-1]) if len(times) > 1: root = Tk() root.title("Drop-down boxes for option selections.") var = StringVar(root) var.set("Select a Time and Close") def grab_and_assign(event): global selected_t chosen_option = var.get() label_chosen_variable= Label(root, text=chosen_option) label_chosen_variable.grid(row=1, column=2) selected_t = chosen_option drop_menu = OptionMenu(root, var, *tuple(times), command=grab_and_assign) drop_menu.grid(row=0, column=0) label_left=Label(root, text="chosen variable= ") label_left.grid(row=1, column=0) root.mainloop() t = t + '-' + selected_t else: t = t + '-' + times[0] files_available = glob.glob(default_path + '\\' + patient + '\\' + t + '\\*') if default_path + '\\' + patient + '\\' + t + '\\' + 'kinect.csv' in files_available: Kinect = True valid_graphs.append('Left Elbow Angles') valid_graphs.append('Right Elbow Angles') valid_graphs.append('Shoulder Angles') if default_path + '\\' + patient + '\\' + t + '\\' + 'imu.csv' in files_available: IMU = True valid_graphs.append('QX') valid_graphs.append('QY') valid_graphs.append('QZ') valid_graphs.append('Q0') # print(t) # print(valid_graphs) self.manager.current = 'Dataanalysis' else: ctypes.windll.user32.MessageBoxW(0, u"No sessions exist for this date.", u"Error", 16)
def grab_and_assign(event): global selected_t chosen_option = var.get() label_chosen_variable= Label(root, text=chosen_option) label_chosen_variable.grid(row=1, column=2) selected_t = chosen_option
# endregion # endregion # region main loop if usingKivy: batchfulApp().run() elif usingTkinter: window = Tk() window.title("batchful") window.geometry(xSize + "x" + ySize) # window.wm_iconbitmap("Logo.ico") # window.tk_setPalette("black") title = Label(window, text="batchful", font=("Ariel Bold", 50)) title.grid(column=1, row=0) extensionButton = Button(window, text="Sort By Extension", command=by_ext) extensionButton.grid(column=0, row=1) nameButton = Button(window, text="Sort By Name", command=sort_by_name) nameButton.grid(column=1, row=1) sortSubFolders = IntVar() sortSubFoldersCheckBox = Checkbutton(window, text="Search Sub-Folders", var=sortSubFolders) sortSubFoldersCheckBox.grid(column=2, row=1) helpButton = Button(window, text="Help", command=help) helpButton.grid(column=0, row=3)