Exemplo n.º 1
0
 def load_file(self):
     ftypes = [('Mov files', '*.mov'), ('Mp4 files', '*.mp4'), ('Avi files', '*.avi'), ('All files', '*.*')]
     dlg = tkFileDialog.Open(self.parent, filetypes=ftypes)
     fl = dlg.show()
     if fl != '':
         self.e2.delete(0, END)
         self.e2.insert(0, fl)
def myLoadImage():
    dlg = tkFileDialog.Open(filetypes=[('image files',
                                        '*.jpg'), ('All files', '*')])
    fl = dlg.show()
    if fl != '':
        print fl
        imageCanvas.delete('all')
        fls = unicodedata.normalize('NFKD', fl).encode('ascii', 'ignore')
        img[0] = Image.open(fl)
        img[0] = img[0].resize((600, 600), Image.ANTIALIAS)
        tkimg[0] = ImageTk.PhotoImage(img[0])
        imageCanvas.create_image((0, 0), anchor=NW, image=tkimg[0])
        for i in range(21):  # Number of distortion pictures created
            par = np.float64(i - 10) / 10
            tempImage = UF.myDistort(fls, par)
            tempImage = tempImage[:, :, ::-1]
            tempFileName = 'tempFile.jpg'
            cv2.imwrite(tempFileName, tempImage)
            cvimgTemp[i] = tempImage.copy()

            imgTemp = Image.open(tempFileName)
            imgTemp = imgTemp.resize((600, 600), Image.ANTIALIAS)
            tkimgTemp[i] = ImageTk.PhotoImage(imgTemp)
            print 'Finished image with param: ' + str(par)
        UF.os.remove('tempFile.jpg')
        tkMessageBox.showinfo('Loading Image Process',
                              'Loading Cache Memory: \n STATUS - DONE')
    def open_file(self):
        """Opens dialog to select a file, reads data from file and plots the data"""
        ftypes = [('Text files', '*.txt'), ('All files', '*')]
        dlg = tkFileDialog.Open(root, filetypes = ftypes)
        fl = dlg.show()
        if fl != '':
            # Open file for reading
            arch = open(fl, "r")
            datos_arch = arch.read()
            # Searches for every channel, delimited by L1, L2 and L3 tags.
            canal_1 = extraer_int_tag(datos_arch, 'L1')
            canal_2 = extraer_int_tag(datos_arch, 'L2')
            canal_3 = extraer_int_tag(datos_arch, 'L3')

            print("Amount of samples in channel 1: %s" %len(canal_1))
            print("Amount of samples on channel 2: %s" %len(canal_2))
            print("Amount of samples on channel 3: %s" %len(canal_3))
            message_string = "Amount of samples channel 1: {0} \n".format(len(canal_1))
            message_string += "Amount of samples channel 2: {0} \n".format(len(canal_2))
            message_string += "Amount of samples channel 3: {0} \n".format(len(canal_3))
            self.show_message(self.text_message, message_string)

            global g_canal_1, g_canal_2, g_canal_3
            #Keep a copy of the original values
            g_canal_1 = canal_1[:]            #Copy list by value not by reference
            g_canal_2 = canal_2[:]
            g_canal_3 = canal_3[:]

            self.window_var.set(1)        #Option rectangular window
            self.plot(self.tab1, self.tab2, canal_1, canal_2, canal_3, win_var=1)
Exemplo n.º 4
0
def get_pcb_data():
    global display  #this needs to be global for PCB image to show

    # Dialog box for selecting PCB image file
    ftypes = [('GIF', '*.gif')]
    dlg = tkFileDialog.Open(filetypes=ftypes, initialdir=dir)
    image = dlg.show()
    pcb_root_name = image.split('.')[0]

    get_fab_file_data(pcb_root_name)
    pcb_dimensions = get_pcb_dimensions()
    pcb_image = Image.open(image)
    pcb_image = pcb_image.resize((pcb_dimensions['x'], pcb_dimensions['y']),
                                 Image.ANTIALIAS)
    width, height = pcb_image.size

    yscrollbar = Scrollbar(top)
    Pcb.config(bg="white",
               height=pcb_dimensions['y'],
               width=pcb_dimensions['x'],
               yscrollcommand=yscrollbar.set,
               scrollregion=(0, 0, width, height))
    yscrollbar.pack(side=RIGHT, fill=Y)
    yscrollbar.config(command=Pcb.yview)
    display = ImageTk.PhotoImage(pcb_image)
    Pcb.create_image(0, 0, image=display, anchor=NW)
    Pcb.pack(side=LEFT)
Exemplo n.º 5
0
def createNewPreset():
    global root

    tkMessageBox.showinfo(
        "For Making New Preset",
        "To make a new preset please open a blank omr sheet.")

    #Reading The File
    ftype = [('JPEG', '*.jpg'), ('PNG', '*.png')]
    dlg = tkFileDialog.Open(filetypes=ftype)
    fp = dlg.show()  #Gives path of the open file
    fn = filename(fp)  #Returns File Name

    #Creating temp Folder For opencv access
    try:
        os.mkdir(".temp")
    except OSError:
        print("Failed to make temp folder")

    #Copying Image to the temp folder
    destination = os.getcwd() + "/.temp/" + fn
    try:
        dest = shutil.copyfile(fp, destination)
        #Final File Path
        image_path = ".temp/" + str(fn)

        # Load an color image
        img = cv2.imread(image_path)

        root.destroy()
        presetBuilder.main(img)
    except Exception as e:
        print("failed to copy file into temp : " + str(e))
Exemplo n.º 6
0
    def __init__(self):
        self.__root = Tkinter.Tk()  # open the main window
        self.__root.title('Split & Join')  # give it a name
        self.__root.resizable(False, False)  # disable resizing

        # starts the splitter engine
        split = Tkinter.Button(self.__root,
                               text='Split',
                               font='Courier 8',
                               command=self.split)
        split.grid(row=0, column=0, padx=15, pady=5)

        # starts the joiner engine
        join = Tkinter.Button(self.__root,
                              text='Join',
                              font='Courier 8',
                              command=self.join)
        join.grid(row=0, column=1, padx=15, pady=5)

        # used for saving / opening files
        self.__open = tkFileDialog.Open()
        self.__save = tkFileDialog.Directory()

        # don't forget to execute!
        self.__root.mainloop()
Exemplo n.º 7
0
	def onFileProjectOpen(self):
		ftypes = [('JSON Files', '*.json')]
		dlg = fd.Open(self, filetypes=ftypes)
		fl = dlg.show()
		
		if fl != '':
			# read file contents, load project
			prj = os.path.basename(fl)
			prj = os.path.splitext(prj)[0]
			self.g.currentProject.load(prj)
			
			# get file list
			lst = self.g.currentProject.getFilesInArchive()
			
			# set label text
			self.updateLabels("Project: " + self.g.currentProject.project["name"],
							  "Current Version: " + str(self.g.currentProject.project["latestVersion"]),
							  "Author: " + self.g.currentProject.project["author"])
			
			# set text area text
			self.descriptionTxt.config(state=NORMAL)
			self.descriptionTxt.insert(END, self.g.currentProject.project["description"])
			self.descriptionTxt.config(state=DISABLED)
			
			# set list box text
			for l in range(len(lst)):
				self.fileList.insert(END, lst[l])
Exemplo n.º 8
0
Arquivo: read.py Projeto: Abhi551/GUIs
    def onOpen(self):

        ## to read different types of file give argument here
        ftypes = [('all files', '*')]
        dlg = tkFileDialog.Open(self, filetypes=ftypes)
        fl_name = dlg.show()

        print(fl_name)
        ## to return the output
        'call the python file passed in the subprocess argument, with additinal argument required to be passed'

        ## subprocess.call(['./abc.py', arg1, arg2])

        call(["python", str(fl_name)])

        ## to print the final answer by the another program
        ## file to be executed is passed in check_output
        return_value = subprocess.check_output(
            [sys.executable, "add.py",
             str("4"), str("8"), fl_name])

        print(return_value)
        if fl_name != '':
            ## file can be displayed here
            self.txt.insert(END, str(fl_name))
        else:
            self.txt.insert(END, "program not evaluated")
Exemplo n.º 9
0
 def selectFileOpen(self):
     #Open file dialog
     dlg = tkFileDialog.Open(self, filetypes = [('Excel spreadsheet', '*.xlsx')])
     openName = dlg.show()
     if openName != "":
         self.ifPathText.set(openName)
         self.findPRS(openName)#find phosphRS column
Exemplo n.º 10
0
 def command(self):
     filename = tkFileDialog.Open().show()
     if filename:
         filename = filename.replace('/', '\\')
         self.widget.shortcut = filename
         self.entry.delete(0, END)
         self.entry.insert(0, filename)
Exemplo n.º 11
0
def insert_input():
    print "I-M-pressed"
    ftypes = [('JPG files', '*.jpg'), ('PNG files', '*.png'), ('All files', '*')]
    dlg = tkFileDialog.Open(root, filetypes = ftypes)
    global photo_path
    photo_path = dlg.show()
    if photo_path != '':
            print "ok"  
            print photo_path
            global image
            image = Image.open(photo_path)
            image.thumbnail(size, Image.ANTIALIAS)
            #img = img.resize((basewidth,hsize), PIL.Image.ANTIALIAS)
            global data
            data = ImageTk.PhotoImage(image)
            explanation=photo_path
            global photo_info
            photo_info.destroy()
            photo_info = Label(input_frame, 
                               justify=LEFT,
                               padx = 10, 
                               fg='green',
                               text='świeżo wczytany obraz')
            photo_info.grid(row=1, column=0)
            global photo_display
            photo_display.destroy()
            photo_display = Label(input_frame, image=data)
            photo_display.configure(image = data)
            photo_display.image=data
            photo_display.grid(row=0, column=0)
Exemplo n.º 12
0
    def onOpen(self):
        #displays .txt files in browser window
        #only reads time domain data files
        ftypes = [('binary files', '*.trc'), ('txt files', '*.txt')]
        dlg = tkFileDialog.Open(self, filetypes=ftypes)
        fl = dlg.show()

        if fl != '':
            if fl[-3:] == 'trc':
                self.time, self.intensity = read_lecroy_binary.read_timetrace(
                    fl)
            elif fl[-3:] == 'txt':
                data = self.readFile(fl)
                self.time = data[0]
                self.intensity = data[1]
            #plots data in time domain
            self.time_domain()
            #self.labelButton.config(state=NORMAL)
            #self.deletelabelButton.config(state=NORMAL)
            #allows for smoothing of data
            self.smoothButton.config(state=NORMAL)
            #allows for resetting of plotting environment
            self.resetButton.config(state=NORMAL)
            self.wavenumberButton.config(state=NORMAL)
            self.wavelengthButton.config(state=NORMAL)
Exemplo n.º 13
0
    def _openImage(self):
        FileTypes = [('JPG Image Files', '*.jpg'), ('All files', '*')]
        Dialog = tkFileDialog.Open(self._ControlFrame, filetypes=FileTypes)
        FileName = Dialog.show()

        if not FileName == '' and not FileName == ():
            print("Open file: " + str(FileName))

            if self._IsVideoRunnung:
                self._pressPause()

            Image = image.open(FileName)
            Image = Image.resize(
                self._getLabelSize(self._VideoLabel,
                                   Image.width / Image.height),
                image.ANTIALIAS)
            Image = imagetk.PhotoImage(Image)
            self._VideoLabel.imgtk = Image
            self._VideoLabel.configure(image=Image)

            self._OutputText.delete('1.0', tk.END)

            File = tf.gfile.GFile(FileName, "r")
            Captions = self._CaptionFunc(File.read())

            for i, Caption in enumerate(Captions):
                self._OutputText.insert(tk.END,
                                        str(i + 1) + ") " + Caption + "\n")
    def evt_popup_file_window(self):
        if self.generating_file_list_flg == 1: return
        dialog_icon = tkFileDialog.Open(master=self.parent.control_frame2,
                                        filetypes=pub_controls.filetypes,
                                        title='File Open Selection')
        dirfilename = dialog_icon.show(initialdir=os.getcwd())
        if dirfilename in [(), '']: return

        # Set up the thread to do asynchronous I/O
        self.stop_listing_flg = 0

        self.parent.parent.busyCursor = 'watch'
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane('EditPaneTop')
        ]

        # Note: this busy cursor is reset in open_text_file
        pub_busy.busyStart(self.parent.parent)

        # Remove the old list
        if self.parent.parent.file_counter > 0:
            self.parent.parent.pub_editorviewer.sf.destroy()
            self.parent.parent.pub_editorviewer = pub_editorviewer.create_publisher_editor_viewer(
                self.parent.parent)

        self.parent.parent.log_window.appendtext("Creating the file list...\n")
        self.generating_file_list_flg = 1
        lock = thread.allocate_lock()
        thread.start_new_thread(self.open_text_file, (dirfilename, lock))
Exemplo n.º 15
0
    def onOpen(self):
        #displays .txt files in browser window
        #only reads time domain data files
        ftypes = [('txt files', '*.txt'), ('binary files', '*.trc')]
        dlg = tkFileDialog.Open(self, filetypes=ftypes)
        fl = dlg.show()

        if fl != '':
            if fl[-3:] == 'trc':
                self.time, self.intensity = read_lecroy_binary.read_timetrace(
                    fl)
                #plots data in time domain
                if self.time_mass_flag == 0:
                    self.time_domain()
                #plots data in mass domain
                elif self.time_mass_flag == 1:
                    self.mass_domain()

            elif fl[-3:] == 'txt':
                data = self.readFile(fl)
                self.intensity = data[1]
                #self.intensity = [x+0.00075 for x in data[1]]
                if self.time_mass_flag == 0:
                    self.time = data[0]
                    self.time_domain()
                elif self.time_mass_flag == 1:
                    self.mass = data[0]
                    self.mass_domain()
            self.labelButton.config(state=NORMAL)
            self.deletelabelButton.config(state=NORMAL)
            #allows for smoothing of data
            self.smoothButton.config(state=NORMAL)
            #allows for calibration
            self.calMenu.entryconfig("MS Calibration", state=NORMAL)
            self.calMenu.entryconfig("MSMS Calibration", state=NORMAL)
Exemplo n.º 16
0
 def open_conf_file(self):
     ftypes = [('conf files', '*.conf'), ('All files', '*')]
     dlg = tkFileDialog.Open(self, filetypes=ftypes)
     fl = dlg.show()
     if fl != '':
         self.manager.read_config_file(fl)
         self.configured.set(1)
Exemplo n.º 17
0
    def onMSMSOpenCal(self):
        #display .txt files in browser window
        ftypes = [('txt files', '*.txt')]
        dlg = tkFileDialog.Open(self, filetypes=ftypes)
        filename = dlg.show()

        if filename != '':
            #list with time calibration value
            calt_read = []
            #list with mass calibration value
            calm_read = []
            file = open(filename, 'r')
            #header=file.readline()
            for line in file:
                #read each row - store data in columns
                temp = line.split(' ')
                calt_read.append(float(temp[0]))
                calm_read.append(float(temp[1].rstrip('/n')))
            #store values in calibration lists
            self.cal_time = calt_read
            self.cal_mass = calm_read
        #sets MSMS flag for finish_calibrate routine
        self.MSMS_flag = 1
        #call finish_MSMScalibrate method to calibrate and plot data in mass domain
        self.finish_calibrate()
    def openDialog(self,emotion):
        ftypes = [('Audio files','*.mp3 *wav')]
        dialog = tkFileDialog.Open(self,filetypes=ftypes)
        fl = dialog.show()

        if fl != '':
           self.importFile(fl,emotion)
Exemplo n.º 19
0
def pickMDA():
    """
    pickMDA() - This fuction let user to use file selection dialog to pick desired mda file,
    then passed the selected file to the readMDA function 
    it returns the MDA data sturcture constructed

    e.g.

    from readMDA import *
    d = pickMDA()
    """
    root = Tkinter.Tk()
    if len(sys.argv) < 2:
        fname = tkFileDialog.Open().show()
    elif sys.argv[1] == '?' or sys.argv[1] == "help" or sys.argv[1][:2] == "-h":
        print "usage: %s [filename [maxdim [verbose]]]" % sys.argv[0]
        print "   maxdim defaults to 2; verbose defaults to 1"
        return ()
    else:
        fname = sys.argv[1]
    if fname == (): return

    maxdim = 2
    verbose = 1
    if len(sys.argv) > 1:
        maxdim = int(sys.argv[2])
    if len(sys.argv) > 2:
        verbose = int(sys.argv[3])
    if len(sys.argv) > 3:
        help = int(sys.argv[4])
    else:
        help = 0

    dim = readMDA(fname, maxdim, verbose, help)
    return dim
Exemplo n.º 20
0
def set_data_file():
	if os.path.isfile(dir_path+'\data.xlsx'):
		os.remove(dir_path+'\data.xlsx')    
	global output_variables,numpy_input,numpy_data,number_of_threads
	tf = tkFileDialog.Open()
	fl = tf.show()
	E2.delete(0,END)
	E2.insert(0,fl)
	src_excel_file=E2.get()
	
	copyfile(src_excel_file, dir_path+'/data.xlsx')
	book = xlrd.open_workbook('data.xlsx')
	outputs_sheet = book.sheet_by_name('Outputs')
	output_variables = [[outputs_sheet.cell_value(r, c) for r in range(1,outputs_sheet.nrows)] for c in range(outputs_sheet.ncols)]
	C1["values"] = output_variables[0]
	C2["values"] = output_variables[0]
	C3["values"] = output_variables[0]
	C1.current(0)
	C2.current(0)
	C3.current(0)
	C1["state"] = "readonly"
	C2["state"] = "readonly"
	C3["state"] = "readonly"
	G1["values"] = output_variables[0]
	G2["values"] = output_variables[0]
	G3["values"] = output_variables[0]
	G1.current(0)
	G2.current(0)
	G3.current(0)
Exemplo n.º 21
0
def rename():
    directory = current_dir
    opts = {}
    opts['title'] = "Select File to be replaced"
    orgfilename = tkFileDialog.Open(**opts).show()
    newfilename = tkSimpleDialog.askstring("Replace", "New File name?")
    os.rename(orgfilename, directory + "/" + newfilename)
Exemplo n.º 22
0
 def load_letter(self): 
     fn = tkFileDialog.Open(self.tk, filetypes = [('*.txt files', '.txt')]).show()
     if fn == '':
         return
     self.textbox.delete('1.0', 'end') 
     self.textbox.insert('1.0', open(fn, 'rt').read())
     self.lb6["text"] = "Loading letter complete... "
Exemplo n.º 23
0
 def onOpen(self):
     ftypes = [('Python files', '*.py'), ('All files', '*')]
     dlg = tkFileDialog.Open(self, filetypes=ftypes)
     fl = dlg.show()
     global input_file
     input_file = fl
     self.hi_there["text"] = ntpath.basename(fl)
Exemplo n.º 24
0
    def loadFile(self):
        load_dialog = tkFileDialog.Open(self, filetypes = self.file_type)
        f = load_dialog.show()

        if f != '':
            loadable = self.readFile(f)
            print loadable
            # Loop splits file characters into the list

            for n in range(0,1560):
                self.type_list[n] = int(loadable[n])
            
            # Sets tile/button states
            count = 1
            col = 0
            for n in range(0,1560):
                print str(self.type_list[n])
                if not (col == 5 or col == 19 or col == 34):
                    if self.type_list[n] == 1:
                        self.change_image = self.photo1
                    elif self.type_list[n] == 3:
                        self.change_image = self.photo2
                    elif self.type_list[n] == 4:
                        self.change_image = self.photo3
                    elif self.type_list[n] == 5:
                        self.change_image = self.photo4

                    self.button_array[n].configure(image = self.change_image)
                    self.button_array[n].image = self.change_image
                col += 1

                if count==40:
                    col = 0
                    count = 0
                count += 1
Exemplo n.º 25
0
def Open(event):
    """
	action, that loads image, calls network function, that generates caption
	and shows image and caption in the box
	"""
    ftypes = [('JPEG files', '*.jpg'), ('All files', '*')]
    dlg = tkFileDialog.Open(filetypes=ftypes)
    fl = dlg.show()
    img_op = Image.open(fl)
    img_op = resizeimage.resize_contain(img_op, [400, 400])
    img = ImageTk.PhotoImage(img_op)
    outp = Net.make_caption(fl)
    label1 = Label(root, image=img)
    label1.image = img
    label2 = Label(root, font="helvetica 18")
    label3 = Label(root, font="helvetica 15")
    label4 = Label(root, font="helvetica 15")
    label5 = Label(root, font="helvetica 15")
    label2["text"] = "Captions:"
    label3["text"] = outp[0]
    label4["text"] = outp[1]
    label5["text"] = outp[2]
    label1.place(x=10, y=50)
    label2.place(x=450, y=150)
    label3.place(x=450, y=200)
    label4.place(x=450, y=250)
    label5.place(x=450, y=300)
Exemplo n.º 26
0
 def test1(self):
     ftypes = [('Python files', '*.py'), ('All files', '*')]
     dlg = tkFileDialog.Open(self, filetypes = ftypes)
     fl = dlg.show()
     if fl != '':
         text = self.readFile(fl) # get "text"
         self.labelVariable.set(text) # display in label
Exemplo n.º 27
0
 def open_file(self):
     dialog = tkFileDialog.Open(self.window)
     filename = dialog.show()
     if filename != '':
         self.filename = filename
         filename = self.filename.split('/')[-1]
         self.LabelEntrada.config(text=filename)
Exemplo n.º 28
0
    def onOpen(self):
        ftypes = [('Fna files', '*.fna')]
        dlg = filedialog.Open(self, filetypes=ftypes)
        fl = dlg.show()
        n = len(fl.split('/')[-1]) + 1
        path = fl[:-n]
        start = timeit.default_timer()

        onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]
        message = "Liste des genomes charges: \n"
        self.sequences = {}
        for f in onlyfiles:
            s = path + '/' + f
            name, genome = lireSeq(s)
            self.sequences[name] = genome
            message = message + name + '\n'
        stop = timeit.default_timer()
        time_total = stop - start

        message += '\n'
        message += ' --> Time reading : ' + str(time_total) + '\n\n'
        self.area.configure(state="normal")
        self.area.insert(END, message)

        self.area.configure(state="disabled")
        self.btn2.configure(state="normal")
        self.e1.configure(state="normal")
    def onFilePicker(self):

        ftypes = [('PNG Files', '*.png'), ('All files', '*')]
        dlg = tkFileDialog.Open(self, initialdir='../testcase_image/', filetypes = ftypes)
        choosedFile = dlg.show()

        if choosedFile != '':
            print choosedFile
            self.imageName = str(choosedFile).split("/")[-1]
            self.imagePath = str(choosedFile).replace(self.imageName, '')

            self.textBoxFile.config(state='normal')
            self.textBoxFile.delete('1.0', END)
            self.textBoxFile.insert(END, choosedFile)
            self.textBoxFile.config(state='disabled')

            newImageLeft = Image.open(choosedFile)
            imageLeftLabel = ImageTk.PhotoImage(newImageLeft)
            self.labelLeft = Label(self, image=imageLeftLabel)
            self.labelLeft.image = imageLeftLabel
            self.labelLeft.place(x=5, y=100)

            imageRight = Image.open("resource/empty.png")
            imageRightLabel = ImageTk.PhotoImage(imageRight)
            self.labelRight = Label(self, image=imageRightLabel)
            self.labelRight.image = imageRightLabel
            self.labelRight.place(x=525, y=100)

        pass
Exemplo n.º 30
0
def openF():
    global fileopen, nchannels, sampwidth, framerate, nframes, comptype, compname, x_vec, y_vec, seconds, windowlength, cursor
    fileopen = 1  #is a file open?
    dialog = tkFileDialog.Open(filetypes=[('wave', '*.wav')])
    filenameStr = str(dialog.show())
    l['text'] = '%s' % filenameStr  #displays the file being viewed
    WAV = wave.open(filenameStr, 'rb')  #open the wave file sprecified by user
    (nchannels, sampwidth, framerate, nframes, comptype,
     compname) = WAV.getparams()
    WAVstring = WAV.readframes(WAV.getnframes())

    #mono
    if sampwidth == 1:
        y_vec = struct.unpack('%dB' % (nchannels * nframes), WAVstring)
    #stereo
    elif sampwidth == 2:
        y_vec = struct.unpack('%dh' % (nchannels * nframes), WAVstring)

    ywindow = y_vec[
        0:
        framerate]  #ywindow = the first window to being viewed by user(0-->60 seconds)
    cursor = 0
    seconds = 0
    windowlength = len(ywindow)
    PlotGraph(ywindow)