Help Needed !!! Browsing and Selecting More Than One File(ProblemSolved)

Discussion in 'Python' started by Kilicaslan Fatih, Jul 10, 2006.

  1. Special Thanks to Diez B. Roggisch and Eric Brunel.

    Last week on Friday I solved the problems I
    encountered thanks to your helpful indications.

    I think I covered all the ambiguity in my code. Here's
    the code:

    # executing CCCC with Python

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

    # Creating App Class
    class App:

    b_file = ""

    # Function to browse files, the files selected
    will be the items of
    a tuple
    # This tuple is assigned to the instance of App
    class
    # browseFile Function is triggered by a label in
    Menu
    def browseFile(self):
    App.b_file
    App.b_file = askopenfilename(filetypes = [("C
    Source Code",
    "*.c"), ("C Header Files", "*.h"), ("All Files",
    "*.*")], multiple=1)

    # Function to Run CCCC Code Analyzer
    def runCCCC(self, event):

    # Controls if a file is browsed and selected
    # If a selection is done the code continues
    from here
    if App.b_file != "":
    cmd_tup = ""
    for i in range(len(App.b_file)):
    cmd_tup += App.b_file+' ' # The
    type of the a
    tuple's items are all strings, here parameter for CCCC
    are arranged
    cmd = 'cccc ' + cmd_tup
    #according to the
    #command prompt syntax, command is created
    return os.system(cmd)
    # command is executed
    else:
    tkMessageBox.showinfo("Window Text",
    "Please Firstly Browse
    and Select A File")
    # if no file is selected a warning pop-ups



    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()


    __________________________________________________
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
     
    Kilicaslan Fatih, Jul 10, 2006
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.