Help Needed !!! Browsing and Selecting More Than One File

Kilicaslan Fatih fkaslan at yahoo.com
Fri Jul 7 04:01:57 EDT 2006


Thank you very much for your indications. I've just
subscribed for the group and even I don't know how to
reply directly through mailing list. I will try to
answer some of the questions you have asked about my
program.

Question:
What has it to do with running your program with
several file names as arguments? Is it two different
ways to select several files in your application? Or
do you want one or the other?

Answer:
I want to browse, and want to select all of the "*.c"
files in a folder and than run CCCC code analyzer
program for all of these files. The syntax to run CCCC
on multiple files on DOS is:

cccc file1.c file2.c file3.c

I want to have 2 options on my GUI, one for only to
select one file, the other is to select multiple files
in a project(folder). 

I didn't yet change the code according to your
indications, there are still basic mistakes but I will
send the whole code, to be more clear. When I run this
code: 
I can browse a file and 
than open a file through the browser, 
assign it to "cccc" as parameter
and able to analyse one C file through a GUI

I can't select more than one file. I want to do this
because I will need to analyze the total project which
is composed of 8-15 "*.c" files.  

Source Code:

from Tkinter import *
from tkFileDialog import *
import tkMessageBox
import os


class App:

#Function for browsing a file
    def browseFile(self):
        global file
        file = askopenfilename(filetypes = [("C source
code", "*.c"), ("All Files", "*.*")])
       
#Function for running CCCC                 
    def runCCCC(self, event):
        if type(file)==str:
            dosya = file            
            cmd = 'cccc ' + dosya
            print cmd
            return os.system(cmd)
        else:
            message = tkMessageBox.showinfo("Window
Text", "Please Browse a File Firstly")
      
    def __init__(self, master):

        frame = Frame(master)
        frame.pack(fill="both")   
        
        self.menubar = Menu(master)
        self.menubar.add_command(label="Browse File",
command=self.browseFile)
        master.config(menu=self.menubar)
        
        self.ccccRun = Button(frame, text="Run CCCC",
fg="red")
        self.ccccRun.bind("<Button-1>", self.runCCCC)
        self.ccccRun.pack(side=LEFT, padx=10, pady=20)

        self.close = Button(frame, text="QUIT",
fg="red", command=frame.quit)
        self.close.pack(side=LEFT, padx=10, pady=20)
        
     
root = Tk()
app=App(root)
root.mainloop()

Best Regards,
Fatih K.




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Python-list mailing list