0 Members and 1 Guest are viewing this topic.
from Tkinter import *import osimport tkFileDialogroot = Tk()tn = Label(root, text="gcc C++ Compiler GUI")tn.grid(row=0, column=1, columnspan=3, sticky=N+S+E+W)pathn = Label(root, text="Path to source:")pathn.grid(row=1, column=1, sticky=N+S+E+W)namen = Label(root, text="Name of compiled file:")namen.grid(row=2, column=1, sticky=N+S+E+W)path = Entry(root)path.grid(row=1, column=2, columnspan=2, sticky=N+S+E+W)path.delete(0, END)path.insert(0, "")name = Entry(root)name.grid(row=2, column=2, columnspan=3, sticky=N+S+E+W)name.delete(0, END)name.insert(0, "")quitbtn = Button(root, text="Exit", fg="red", command=exit)quitbtn.grid(row=3, column=3, sticky=N+S+E+W)compilebtn = Button(root, text="Compile!", fg="blue", command=quit)compilebtn.grid(row=3, column=2, sticky=N+S+E+W)spyro = Label(root, text="By Spyro543")spyro.grid(row=3, column=1, sticky=N+S+E+W)def fopen(): cformats = [('C++ source file','*.cpp'),('Plain text file','*.txt'),('Any File','*.*')] filenm = tkFileDialog.askopenfile(parent=root,filetypes=cformats ,title='Select the cpp source file') path.insert(0, filenm)browsebtn = Button(root, text="Browse", fg="black", command=fopen())browsebtn.grid(row=1, column=4, sticky=N+S+E+W)root.mainloop()
def fopen(): cformats = [('C++ source file','*.cpp'),('Plain text file','*.txt'),('Any File','*.*')] filenm = tkFileDialog.askopenfile(parent=root,filetypes=cformats ,title='Select the cpp source file') path.insert(0, filenm)
browsebtn = Button(root, text="Browse", fg="black", command=fopen())
browsebtn = Button(root, text="Browse", fg="black", command=lambda:fopen())