def initUI(self): self.parent.title("Software Activation") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) if(self.needsActivated()): idEntry = Entry(self, width=36) idEntry.place(x=175, y=20) idEntry.delete(0, END) idEntry.insert(0, "Enter a product id") keyEntry = Entry(self, width=36) keyEntry.place(x=175, y=40) keyEntry.delete(0, END) keyEntry.insert(0, "Enter your license key") activateButton = Button(self, text="Activate", command=lambda:self.activate( idEntry.get(), keyEntry.get())) activateButton.place(x=250, y=65) else: label = Label(self, text="Product has already been activated") label.pack()
class Window(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.style = Style() self.style.theme_use("clam") self.pack(fill=BOTH,expand=5) self.parent.title("Document Similarity Checker") self.dir = "Choose a directory" self.setupInputs() self.setButton() def setupInputs(self): self.chooseDir = Button(self, text="Choose",command=self.getDir) self.chooseDir.place(x=10, y=10) self.selpath = Label(self, text=self.dir, font=("Helvetica", 12)) self.selpath.place(x=150, y=10) self.aLabel = Label(self, text="Alpha", font=("Helvetica", 12)) self.aLabel.place(x=10, y=50) self.aEntry = Entry() self.aEntry.place(x=200,y=50,width=400,height=30) self.bLabel = Label(self, text="Beta", font=("Helvetica", 12)) self.bLabel.place(x=10, y=100) self.bEntry = Entry() self.bEntry.place(x=200,y=100,width=400,height=30) def setButton(self): self.quitButton = Button(self, text="Close",command=self.quit) self.quitButton.place(x=520, y=250) self.browserButton = Button(self, text="Open Browser",command=self.browser) self.browserButton.place(x=400, y=250) self.browserButton.config(state=DISABLED) self.generate = Button(self, text="Generate Data",command=self.genData) self.generate.place(x=10, y=250) def browser(self): import webbrowser webbrowser.get('firefox').open('data/index.html') self.browserButton.config(state=DISABLED) def getDir(self): globals.dir = tkFileDialog.askdirectory(parent=self.parent,initialdir="/",title='Select a directory') self.selpath['text'] = globals.dir #print globals.dir #validate and process data def genData(self): valid = True try: globals.alpha = float(self.aEntry.get()) except ValueError: globals.alpha = 0.0 valid = False try: globals.beta = float(self.bEntry.get()) except ValueError: globals.beta = 0.0 valid = False if not os.path.isdir(globals.dir) or globals.alpha>=1.0 or globals.beta>=1.0: valid = False if valid: self.generate.config(state=DISABLED) from compute import main as computeMain computeMain() from jsonutil import main as jsonMain jsonMain() self.browserButton.config(state=NORMAL) self.generate.config(state=NORMAL)
class Application(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack(fill=BOTH, expand=1) self.initUI() self.setGeometry() self.component = NewComponent() def setGeometry(self): x = 300 y = 100 self.master.geometry("400x300+%d+%d" % (x, y)) self.master.update() def initUI(self): #setup title self.master.title("Component Creator") self.style = Style() self.style.theme_use("clam") #indicator label self.labelName = Label(self, text="Component Name:") self.labelName.place(x=10, y=10) self.master.update() # create variable and namefield for input of component name sv = StringVar() sv.trace("w", lambda name, index, mode, sv=sv: self.nameChanged(sv)) self.nameField = Entry(self, textvariable=sv) self.nameField.place(x=10+self.labelName.winfo_width() + 10, y=10) self.master.update() # label for image name that will show img name for a given component name self.imgNameVar = StringVar() self.imgNameVar.set('imageName:') self.labelImageName = Label(self, textvariable=self.imgNameVar) self.labelImageName.place(x=10+self.labelName.winfo_width()+10,y=40) # checkbox for visible component or not self.cbVar = IntVar() self.cb = Checkbutton(self, text="Visible Component", variable=self.cbVar) self.cb.place(x=10, y=70) # dropdown list for category self.labelCategory = Label(self, text="Category:") self.labelCategory.place(x=10, y=110) self.master.update() acts = ['UserInterface', 'Layout', 'Media', 'Animation', 'Sensors', 'Social', 'Storage', 'Connectivity', 'LegoMindStorms', 'Experimental', 'Internal', 'Uninitialized'] self.catBox = Combobox(self, values=acts) self.catBox.place(x=10+self.labelCategory.winfo_width()+10, y=110) # button to select icon image self.getImageButton = Button(self, text="Select icon", command=self.getImage) self.getImageButton.place(x=10, y=150) self.master.update() # explanation for resizing self.resizeVar = IntVar() self.resizeCB = Checkbutton(self, text="ON=Resize Image (Requires PIL)\nOFF=Provide 16x16 Image", variable=self.resizeVar) self.resizeCB.place(x=10+self.getImageButton.winfo_width()+10, y=150) # create button self.createButton = Button(self, text="Create", command=self.create) self.createButton.place(x=10, y=230) #cancel button self.cancelButton = Button(self, text="Cancel", command=self.quit) self.cancelButton.place(x=200, y=230) # open file picker for selecting an icon def getImage(self): ftypes = [('All Picture Files', ('*.jpg', '*.png', '*.jpeg', '*.bmp')), ('All files', '*')] self.component.imgFile = askopenfilename(filetypes=ftypes, title="Select an Icon file") # update component name and image name for component by lowercasing first letter def nameChanged(self, sv): s = sv.get() self.component.compName = s self.component.compImgName = s[:1].lower() + s[1:] if s else '' self.imgNameVar.set('imageName: %s' % self.component.compImgName) # tries to create component def create(self): # sets parameters for new component based on input values self.component.visibleComponent = bool(self.cbVar.get()) self.component.resizeImage = bool(self.resizeVar.get()) self.component.category = self.catBox.get().upper() self.component.compName = self.nameField.get() try: # check if component already exists try: open('../../components/src/com/google/appinentor/components/runtime/%s.java', 'r') tkMessageBox.showerror("Duplicate Component","%s already exists" % self.component.compName) # if doesnt exist will raise error except IOError: # check for name input if not self.component.compImgName: tkMessageBox.showerror("Missing Name","Please enter component name") return #check for category selection if not self.component.category: tkMessageBox.showerror("Missing Category","Please select a category") return # check if selected an icon if not self.component.imgFile: tkMessageBox.showerror("Missing Icon","Please select an icon image") return # copy image file to folder, can get error if user checked resize and doest have PIL installed try: self.component.copyImageToFolder() except ImportError, e: tkMessageBox.showerror("Unable to import PIL","Please install PIL or unselect checkbox") return # add references to the image file, can get error if component already exists try: self.component.addImageReference() except DuplicateError, e: tkMessageBox.showerror("Duplicate Component","%s already exists" % self.component.compName) return # will create mock component if is visible and add references to SimpleComponentDescriptor self.component.createMockComponent() # will create the actual component file self.component.createComponent() tkMessageBox.showinfo('Success', 'Component created successfully')
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Append Data") self.pack(fill=BOTH, expand=True) labelfont20 = ('Roboto', 15, 'bold') labelfont10 = ('Roboto', 10, 'bold') labelfont8 = ('Roboto', 8, 'bold') frame0 = Frame(self) frame0.pack() lbl0 = Label(frame0, text="Hi Nakul") lbl0.config(font=labelfont20) lbl0.pack(padx=5, pady=5) lbl00 = Label(frame0, text="Fill the data here") lbl00.config(font=labelfont10) lbl00.pack(padx=5, pady=5) #################################### frame1 = Frame(self) frame1.pack() frame1.place(x=50, y=100) lbl1 = Label(frame1, text="Name", width=15) lbl1.pack(side=LEFT, padx=7, pady=5) self.entry1 = Entry(frame1, width=20) self.entry1.pack(padx=5, expand=True) #################################### frame2 = Frame(self) frame2.pack() frame2.place(x=50, y=130) lbl2 = Label(frame2, text="F Name", width=15) lbl2.pack(side=LEFT, padx=7, pady=5) self.entry2 = Entry(frame2) self.entry2.pack(fill=X, padx=5, expand=True) ###################################### frame3 = Frame(self) frame3.pack() frame3.place(x=50, y=160) lbl3 = Label(frame3, text="DOB(D/M/Y)", width=15) lbl3.pack(side=LEFT, padx=7, pady=5) self.entry3 = Entry(frame3) self.entry3.pack(fill=X, padx=5, expand=True) ####################################### frame4 = Frame(self) frame4.pack() frame4.place(x=50, y=190) lbl4 = Label(frame4, text="Medium(H/E)", width=15) lbl4.pack(side=LEFT, padx=7, pady=5) self.entry4 = Entry(frame4) self.entry4.pack(fill=X, padx=5, expand=True) ########################################## frame5 = Frame(self) frame5.pack() frame5.place(x=50, y=225) MODES = [ ("M", "Male"), ("F", "Female"), ] lbl5 = Label(frame5, text="Gender", width=15) lbl5.pack(side=LEFT, padx=7, pady=5) global v v = StringVar() v.set("Male") # initialize for text, mode in MODES: b = Radiobutton(frame5, text=text, variable=v, value=mode) b.pack(side=LEFT, padx=10) ############################################ #####printing line lbl5a = Label( text="___________________________________________________") lbl5a.pack() lbl5a.place(x=45, y=255) ############################################ frame6 = Frame(self) frame6.pack() frame6.place(x=50, y=290) lbl6 = Label(frame6, text="Phone No:", width=15) lbl6.pack(side=LEFT, padx=7, pady=5) self.entry6 = Entry(frame6) self.entry6.pack(fill=X, padx=5, expand=True) ################################################ frame7 = Frame(self) frame7.pack() frame7.place(x=50, y=320) lbl7 = Label(frame7, text="Landline No:", width=15) lbl7.pack(side=LEFT, padx=7, pady=5) self.entry7 = Entry(frame7) self.entry7.pack(fill=X, padx=5, expand=True) ############################################### frame8 = Frame(self) frame8.pack() frame8.place(x=50, y=350) lbl8 = Label(frame8, text="Email:", width=15) lbl8.pack(side=LEFT, padx=7, pady=5) self.entry8 = Entry(frame8) self.entry8.pack(fill=X, padx=5, expand=True) ############################################# frame9 = Frame(self) frame9.pack() frame9.place(x=50, y=380) lbl9 = Label(frame9, text="HomeTown:", width=15) lbl9.pack(side=LEFT, padx=7, pady=5) self.entry9 = Entry(frame9) self.entry9.pack(fill=X, padx=5, expand=True) ############################################### frame10 = Frame(self) frame10.pack() frame10.place(x=60, y=415) lbl10 = Label(frame10, text="Address:") lbl10.pack(padx=5, pady=5) self.entry10 = Text(frame10, height=5, width=28) self.entry10.pack(padx=5, expand=True) ############################################## ############################################# frame11 = Frame(self) frame11.pack() frame11.place(x=350, y=100) lbl11x = Label(frame11, text="_______Class 10th Data_______") lbl11x.pack(padx=0, pady=0) lbl11 = Label(text="%", width=15) lbl11.pack(side=LEFT, padx=0, pady=0) lbl11.place(x=350, y=130) self.entry11 = Entry(width=12) self.entry11.pack(padx=1, expand=True) self.entry11.place(x=420, y=130) lbl11a = Label(text="Passing Year", width=15) lbl11a.pack(padx=0, pady=2) lbl11a.place(x=350, y=160) self.entry11a = Entry(width=12) self.entry11a.pack(padx=1, expand=True) self.entry11a.place(x=420, y=160) lbl11b = Label(text="Board Name", width=15) lbl11b.pack(padx=0, pady=2) lbl11b.place(x=350, y=190) self.entry11b = Entry(width=12) self.entry11b.pack(padx=1, expand=True) self.entry11b.place(x=420, y=190) #################################################### frame12 = Frame(self) frame12.pack() frame12.place(x=510, y=100) lbl12x = Label(frame12, text="_______Class 12th Data_______") lbl12x.pack(padx=0, pady=0) lbl12 = Label(text="%", width=15) lbl12.pack(side=LEFT, padx=0, pady=0) lbl12.place(x=510, y=130) self.entry12 = Entry(width=12) self.entry12.pack(padx=1, expand=True) self.entry12.place(x=580, y=130) lbl12a = Label(text="Passing Year", width=15) lbl12a.pack(padx=0, pady=2) lbl12a.place(x=510, y=160) self.entry12a = Entry(width=12) self.entry12a.pack(padx=1, expand=True) self.entry12a.place(x=580, y=160) lbl12b = Label(text="Board Name", width=15) lbl12b.pack(padx=0, pady=2) lbl12b.place(x=510, y=190) self.entry12b = Entry(width=12) self.entry12b.pack(padx=1, expand=True) self.entry12b.place(x=580, y=190) ##################################################### frame13 = Frame(self) frame13.pack() frame13.place(x=670, y=100) lbl13x = Label(frame13, text="________B.Tech Data_________") lbl13x.pack(padx=0, pady=0) lbl13 = Label(text="%", width=15) lbl13.pack(side=LEFT, padx=0, pady=0) lbl13.place(x=670, y=130) self.entry13 = Entry(width=12) self.entry13.pack(padx=1, expand=True) self.entry13.place(x=740, y=130) lbl13a = Label(text="Passing Year", width=15) lbl13a.pack(padx=0, pady=2) lbl13a.place(x=670, y=160) self.entry13a = Entry(width=12) self.entry13a.pack(padx=1, expand=True) self.entry13a.place(x=740, y=160) lbl13b = Label(text="College", width=15) lbl13b.pack(padx=0, pady=2) lbl13b.place(x=670, y=190) self.entry13b = Entry(width=12) self.entry13b.pack(padx=1, expand=True) self.entry13b.place(x=740, y=190) #################################################### frame14 = Frame(self) frame14.pack() frame14.place(x=380, y=255) lbl14 = Label(frame14, text="Any Other Info:") lbl14.pack(padx=5, pady=5) self.entry14 = Text(frame14, height=5, width=28) self.entry14.pack(padx=5, expand=True) frame15 = Frame(self) frame15.pack() frame15.place(x=650, y=290) openButton = Button(frame15, text="Attatch Resume", width=15, command=self.openResume) openButton.pack(padx=5, pady=5) self.entry15 = Entry(frame15) self.entry15.pack(fill=X, padx=4, expand=True) ############################################################# frame16 = Frame(self) frame16.pack() frame16.place(x=450, y=500) closeButton = Button(frame16, text="SUBMIT", width=35, command=self.getDatax) closeButton.pack(padx=5, pady=5) ####################################### framexxx = Frame(self) framexxx.pack() framexxx.place(x=700, y=600) self.xxx = Label(framexxx, text="Recent Changes Will Appear Here") self.xxx.config(font=labelfont8) self.xxx.pack() ####################################### frame000 = Frame(self) frame000.pack() frame000.place(x=50, y=600) self.lbl000 = Label(frame000, text="Beta/Sample2.0 | (c) Nakul Rathore") self.lbl000.config(font=labelfont8) self.lbl000.pack(padx=5, pady=5) def openResume(self): ftypes = [('All files', '*')] dlg = tkFileDialog.Open(self, filetypes=ftypes, initialdir='C:/Users/') global x15 fl = dlg.show() #file name x15 = fl temp1 = os.path.basename(fl) global temp2 temp2 = os.path.splitext(temp1)[0] self.entry15.delete(0, 'end') self.entry15.insert(0, temp2) ##################### def getDatax(self): x1 = self.entry1.get() x2 = self.entry2.get() x3 = self.entry3.get() x4 = self.entry4.get() x5 = v.get() x6 = int(self.entry6.get()) x7 = int(self.entry7.get()) x8 = self.entry8.get() x9 = self.entry9.get() x10 = self.entry10.get('1.0', 'end') x11 = int(self.entry11.get()) x11a = int(self.entry11a.get()) x11b = self.entry11b.get() x12 = int(self.entry12.get()) x12a = int(self.entry12a.get()) x12b = self.entry12b.get() x13 = int(self.entry13.get()) x13a = int(self.entry13a.get()) x13b = self.entry13b.get() x14 = self.entry14.get('1.0', 'end') list1 = [ x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x11a, x11b, x12, x12a, x12b, x13, x13a, x13b, x14, "=HYPERLINK(" + "\"" + x15 + "\"" + "," + "\"" + temp2 + "\"" + ")" ] wb = openpyxl.load_workbook('..\database\database.xlsx') ws = wb.active print(wb.get_sheet_names()) max_row = ws.get_highest_row() #max_col = ws.get_highest_column() max_col = 21 print max_row for i in xrange(1, max_col + 1): #print list1[i] ws.cell(row=max_row + 1, column=i).value = list1[i - 1] ws.cell(row=max_row + 1, column=max_col).font = Font(color="0000FF", underline='single') ws.cell(row=max_row + 1, column=max_col).alignment = Alignment(horizontal='center') wb.save('..\database\database.xlsx') self.entry1.delete(0, 'end') self.entry2.delete(0, 'end') self.entry3.delete(0, 'end') self.entry4.delete(0, 'end') self.entry6.delete(0, 'end') self.entry7.delete(0, 'end') self.entry8.delete(0, 'end') self.entry9.delete(0, 'end') self.entry10.delete('1.0', '2.0') self.entry11.delete(0, 'end') self.entry11a.delete(0, 'end') self.entry11b.delete(0, 'end') self.entry12.delete(0, 'end') self.entry12a.delete(0, 'end') self.entry12b.delete(0, 'end') self.entry13.delete(0, 'end') self.entry13a.delete(0, 'end') self.entry13b.delete(0, 'end') self.entry14.delete('1.0', '2.0') self.xxx.config(text="Recent Changes Made For : " + x1)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Append Data") self.pack(fill=BOTH, expand=True) labelfont20 = ('Roboto', 15, 'bold') labelfont10 = ('Roboto', 10, 'bold') labelfont8 = ('Roboto', 8, 'bold') frame0 = Frame(self) frame0.pack() lbl0 = Label(frame0, text="Hi Nakul") lbl0.config(font=labelfont20) lbl0.pack( padx=5, pady=5) lbl00 = Label(frame0, text="Fill the data here") lbl00.config(font=labelfont10) lbl00.pack( padx=5, pady=5) #################################### frame1 = Frame(self) frame1.pack() frame1.place(x=50, y=100) lbl1 = Label(frame1, text="Name", width=15) lbl1.pack(side=LEFT,padx=7, pady=5) self.entry1 = Entry(frame1,width=20) self.entry1.pack(padx=5, expand=True) #################################### frame2 = Frame(self) frame2.pack() frame2.place(x=50, y=130) lbl2 = Label(frame2, text="F Name", width=15) lbl2.pack(side=LEFT, padx=7, pady=5) self.entry2 = Entry(frame2) self.entry2.pack(fill=X, padx=5, expand=True) ###################################### frame3 = Frame(self) frame3.pack() frame3.place(x=50, y=160) lbl3 = Label(frame3, text="DOB(D/M/Y)", width=15) lbl3.pack(side=LEFT, padx=7, pady=5) self.entry3 = Entry(frame3) self.entry3.pack(fill=X, padx=5, expand=True) ####################################### frame4 = Frame(self) frame4.pack() frame4.place(x=50, y=190) lbl4 = Label(frame4, text="Medium(H/E)", width=15) lbl4.pack(side=LEFT, padx=7, pady=5) self.entry4 = Entry(frame4) self.entry4.pack(fill=X, padx=5, expand=True) ########################################## frame5 = Frame(self) frame5.pack() frame5.place(x=50, y=225) MODES = [ ("M", "Male"), ("F", "Female"), ] lbl5 = Label(frame5, text="Gender", width=15) lbl5.pack(side=LEFT, padx=7, pady=5) global v v = StringVar() v.set("Male") # initialize for text, mode in MODES: b = Radiobutton(frame5, text=text,variable=v, value=mode) b.pack(side=LEFT,padx=10) ############################################ #####printing line lbl5a = Label(text="___________________________________________________") lbl5a.pack() lbl5a.place(x=45, y=255) ############################################ frame6 = Frame(self) frame6.pack() frame6.place(x=50, y=290) lbl6 = Label(frame6, text="Phone No:", width=15) lbl6.pack(side=LEFT, padx=7, pady=5) self.entry6 = Entry(frame6) self.entry6.pack(fill=X, padx=5, expand=True) ################################################ frame7 = Frame(self) frame7.pack() frame7.place(x=50, y=320) lbl7 = Label(frame7, text="Landline No:", width=15) lbl7.pack(side=LEFT, padx=7, pady=5) self.entry7 = Entry(frame7) self.entry7.pack(fill=X, padx=5, expand=True) ############################################### frame8 = Frame(self) frame8.pack() frame8.place(x=50, y=350) lbl8 = Label(frame8, text="Email:", width=15) lbl8.pack(side=LEFT, padx=7, pady=5) self.entry8 = Entry(frame8) self.entry8.pack(fill=X, padx=5, expand=True) ############################################# frame9 = Frame(self) frame9.pack() frame9.place(x=50, y=380) lbl9 = Label(frame9, text="HomeTown:", width=15) lbl9.pack(side=LEFT, padx=7, pady=5) self.entry9 = Entry(frame9) self.entry9.pack(fill=X, padx=5, expand=True) ############################################### frame10 = Frame(self) frame10.pack() frame10.place(x=60, y=415) lbl10 = Label(frame10, text="Address:") lbl10.pack( padx=5, pady=5) self.entry10 = Text(frame10,height=5, width=28) self.entry10.pack(padx=5, expand=True) ############################################## ############################################# frame11 = Frame(self) frame11.pack() frame11.place(x=350, y=100) lbl11x = Label(frame11,text="_______Class 10th Data_______") lbl11x.pack(padx=0, pady=0) lbl11 = Label(text="%",width=15) lbl11.pack(side=LEFT,padx=0, pady=0) lbl11.place(x=350, y=130) self.entry11 = Entry(width=12) self.entry11.pack(padx=1, expand=True) self.entry11.place(x=420, y=130) lbl11a = Label(text="Passing Year",width=15) lbl11a.pack(padx=0, pady=2) lbl11a.place(x=350, y=160) self.entry11a = Entry(width=12) self.entry11a.pack(padx=1, expand=True) self.entry11a.place(x=420, y=160) lbl11b = Label(text="Board Name",width=15) lbl11b.pack(padx=0, pady=2) lbl11b.place(x=350, y=190) self.entry11b = Entry(width=12) self.entry11b.pack(padx=1, expand=True) self.entry11b.place(x=420, y=190) #################################################### frame12 = Frame(self) frame12.pack() frame12.place(x=510, y=100) lbl12x = Label(frame12,text="_______Class 12th Data_______") lbl12x.pack(padx=0, pady=0) lbl12 = Label(text="%",width=15) lbl12.pack(side=LEFT,padx=0, pady=0) lbl12.place(x=510, y=130) self.entry12 = Entry(width=12) self.entry12.pack(padx=1, expand=True) self.entry12.place(x=580, y=130) lbl12a = Label(text="Passing Year",width=15) lbl12a.pack(padx=0, pady=2) lbl12a.place(x=510, y=160) self.entry12a = Entry(width=12) self.entry12a.pack(padx=1, expand=True) self.entry12a.place(x=580, y=160) lbl12b = Label(text="Board Name",width=15) lbl12b.pack(padx=0, pady=2) lbl12b.place(x=510, y=190) self.entry12b = Entry(width=12) self.entry12b.pack(padx=1, expand=True) self.entry12b.place(x=580, y=190) ##################################################### frame13 = Frame(self) frame13.pack() frame13.place(x=670, y=100) lbl13x = Label(frame13,text="________B.Tech Data_________") lbl13x.pack(padx=0, pady=0) lbl13 = Label(text="%",width=15) lbl13.pack(side=LEFT,padx=0, pady=0) lbl13.place(x=670, y=130) self.entry13 = Entry(width=12) self.entry13.pack(padx=1, expand=True) self.entry13.place(x=740, y=130) lbl13a = Label(text="Passing Year",width=15) lbl13a.pack(padx=0, pady=2) lbl13a.place(x=670, y=160) self.entry13a = Entry(width=12) self.entry13a.pack(padx=1, expand=True) self.entry13a.place(x=740, y=160) lbl13b = Label(text="College",width=15) lbl13b.pack(padx=0, pady=2) lbl13b.place(x=670, y=190) self.entry13b = Entry(width=12) self.entry13b.pack(padx=1, expand=True) self.entry13b.place(x=740, y=190) #################################################### frame14 = Frame(self) frame14.pack() frame14.place(x=380, y=255) lbl14 = Label(frame14, text="Any Other Info:") lbl14.pack( padx=5, pady=5) self.entry14 = Text(frame14,height=5, width=28) self.entry14.pack(padx=5, expand=True) frame15 = Frame(self) frame15.pack() frame15.place(x=650, y=290) openButton = Button(frame15, text="Attatch Resume",width=15,command=self.openResume) openButton.pack(padx=5, pady=5) self.entry15 = Entry(frame15) self.entry15.pack(fill=X, padx=4, expand=True) ############################################################# frame16 = Frame(self) frame16.pack() frame16.place(x=450, y=500) closeButton = Button(frame16, text="SUBMIT",width=35,command=self.getDatax) closeButton.pack(padx=5, pady=5) ####################################### framexxx = Frame(self) framexxx.pack() framexxx.place(x=700, y=600) self.xxx = Label(framexxx,text="Recent Changes Will Appear Here") self.xxx.config(font=labelfont8) self.xxx.pack() ####################################### frame000 = Frame(self) frame000.pack() frame000.place(x=50, y=600) self.lbl000= Label(frame000, text="Beta/Sample2.0 | (c) Nakul Rathore") self.lbl000.config(font=labelfont8) self.lbl000.pack( padx=5, pady=5) def openResume(self): ftypes = [('All files', '*')] dlg = tkFileDialog.Open(self, filetypes = ftypes,initialdir='C:/Users/') global x15 fl = dlg.show() #file name x15 = fl temp1 = os.path.basename(fl) global temp2 temp2 = os.path.splitext(temp1)[0] self.entry15.delete(0, 'end') self.entry15.insert(0,temp2) ##################### def getDatax(self): x1 = self.entry1.get() x2 = self.entry2.get() x3 = self.entry3.get() x4 = self.entry4.get() x5 = v.get() x6 = int(self.entry6.get()) x7 = int(self.entry7.get()) x8 = self.entry8.get() x9 = self.entry9.get() x10 = self.entry10.get('1.0', 'end') x11 = int(self.entry11.get()) x11a = int(self.entry11a.get()) x11b = self.entry11b.get() x12 = int(self.entry12.get()) x12a = int(self.entry12a.get()) x12b = self.entry12b.get() x13 = int(self.entry13.get()) x13a = int(self.entry13a.get()) x13b = self.entry13b.get() x14 = self.entry14.get('1.0', 'end') list1=[x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x11a,x11b,x12,x12a,x12b,x13,x13a,x13b,x14,"=HYPERLINK("+"\""+x15+"\""+","+"\""+temp2+"\""+")"] wb = openpyxl.load_workbook('..\database\database.xlsx') ws = wb.active print(wb.get_sheet_names()) max_row = ws.get_highest_row() #max_col = ws.get_highest_column() max_col = 21 print max_row for i in xrange(1,max_col+1): #print list1[i] ws.cell(row = max_row+1, column = i).value = list1[i-1] ws.cell(row = max_row+1, column = max_col).font = Font(color="0000FF", underline='single') ws.cell(row = max_row+1, column = max_col).alignment = Alignment(horizontal='center') wb.save('..\database\database.xlsx') self.entry1.delete(0, 'end') self.entry2.delete(0, 'end') self.entry3.delete(0, 'end') self.entry4.delete(0, 'end') self.entry6.delete(0, 'end') self.entry7.delete(0, 'end') self.entry8.delete(0, 'end') self.entry9.delete(0, 'end') self.entry10.delete('1.0', '2.0') self.entry11.delete(0, 'end') self.entry11a.delete(0, 'end') self.entry11b.delete(0, 'end') self.entry12.delete(0, 'end') self.entry12a.delete(0, 'end') self.entry12b.delete(0, 'end') self.entry13.delete(0, 'end') self.entry13a.delete(0, 'end') self.entry13b.delete(0, 'end') self.entry14.delete('1.0', '2.0') self.xxx.config(text="Recent Changes Made For : "+x1)
class Downloader(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.doGUI() def downloadvid(self): try: #Get video link from textbox self.yt = YouTube(self.yt_linkbox.get()) print self.yt.videos #Download video at specified location in specified resolution and format self.ST_text.set("Downloading...") self.vid = self.yt.get(self.formatselect, self.resolutionselect) self.vid.download("/home") self.ST_text.set("Done.") except: self.ST_text.set("Error!") def option(self, val): #Get the selected option from listbox self.idx = self.resolutionlistbox.curselection() self.resolutionselect = self.resolutionlistbox.get(self.idx) #Set the format for the resolutions if self.resolutionselect == "144p": self.formatselect = "3gp" if self.resolutionselect == "240p": self.formatselect = "3gp" if self.resolutionselect == "360p": self.formatselect = "mp4" if self.resolutionselect == "480p": self.formatselect = "mp4" if self.resolutionselect == "720p": self.formatselect = "mp4" def doGUI(self): #Setup some stuff self.pack(fill=BOTH, expand=1) self.parent.title("Snail YouTube") #Textbox for entering YouTube link self.yt_linkbox = Entry(self, width=30) self.yt_linkbox.place(x=100, y=10) #Button for downloading video self.downloadbutton = Button(self, text="Download!", command=self.downloadvid) self.downloadbutton.place(x=262, y=60) #List of resolutions self.resolutionlist = ["144p", "240p", "360p", "480p", "720p"] #Resolution listbox self.resolutionlistbox = Listbox(self) for i in self.resolutionlist: self.resolutionlistbox.insert(END, i) self.resolutionlistbox.bind("<<ListboxSelect>>", self.option) self.resolutionlistbox.pack(pady=35) #Adress text self.AT = Label(self, text="YouTube link:") self.AT.place(x=10, y=10) #Resolution text self.RT = Label(self, text="""Choose video resolution:""") self.RT.place(x=10, y=50) #Status text self.ST_text = StringVar() self.ST_text.set("") self.ST = Label(self, textvariable=self.ST_text) self.ST.place(x=125, y=120)
class Application(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack(fill=BOTH, expand=1) self.initUI() self.setGeometry() self.component = NewComponent() def setGeometry(self): x = 300 y = 100 self.master.geometry("400x300+%d+%d" % (x, y)) self.master.update() def initUI(self): #setup title self.master.title("Component Creator") self.style = Style() self.style.theme_use("clam") #indicator label self.labelName = Label(self, text="Component Name:") self.labelName.place(x=10, y=10) self.master.update() # create variable and namefield for input of component name sv = StringVar() sv.trace("w", lambda name, index, mode, sv=sv: self.nameChanged(sv)) self.nameField = Entry(self, textvariable=sv) self.nameField.place(x=10 + self.labelName.winfo_width() + 10, y=10) self.master.update() # label for image name that will show img name for a given component name self.imgNameVar = StringVar() self.imgNameVar.set('imageName:') self.labelImageName = Label(self, textvariable=self.imgNameVar) self.labelImageName.place(x=10 + self.labelName.winfo_width() + 10, y=40) # checkbox for visible component or not self.cbVar = IntVar() self.cb = Checkbutton(self, text="Visible Component", variable=self.cbVar) self.cb.place(x=10, y=70) # dropdown list for category self.labelCategory = Label(self, text="Category:") self.labelCategory.place(x=10, y=110) self.master.update() acts = [ 'UserInterface', 'Layout', 'Media', 'Animation', 'Sensors', 'Social', 'Storage', 'Connectivity', 'LegoMindStorms', 'Experimental', 'Internal', 'Uninitialized' ] self.catBox = Combobox(self, values=acts) self.catBox.place(x=10 + self.labelCategory.winfo_width() + 10, y=110) # button to select icon image self.getImageButton = Button(self, text="Select icon", command=self.getImage) self.getImageButton.place(x=10, y=150) self.master.update() # explanation for resizing self.resizeVar = IntVar() self.resizeCB = Checkbutton( self, text="ON=Resize Image (Requires PIL)\nOFF=Provide 16x16 Image", variable=self.resizeVar) self.resizeCB.place(x=10 + self.getImageButton.winfo_width() + 10, y=150) # create button self.createButton = Button(self, text="Create", command=self.create) self.createButton.place(x=10, y=230) #cancel button self.cancelButton = Button(self, text="Cancel", command=self.quit) self.cancelButton.place(x=200, y=230) # open file picker for selecting an icon def getImage(self): ftypes = [('All Picture Files', ('*.jpg', '*.png', '*.jpeg', '*.bmp')), ('All files', '*')] self.component.imgFile = askopenfilename(filetypes=ftypes, title="Select an Icon file") # update component name and image name for component by lowercasing first letter def nameChanged(self, sv): s = sv.get() self.component.compName = s self.component.compImgName = s[:1].lower() + s[1:] if s else '' self.imgNameVar.set('imageName: %s' % self.component.compImgName) # tries to create component def create(self): # sets parameters for new component based on input values self.component.visibleComponent = bool(self.cbVar.get()) self.component.resizeImage = bool(self.resizeVar.get()) self.component.category = self.catBox.get().upper() self.component.compName = self.nameField.get() try: # check if component already exists try: open( '../../components/src/com/google/appinentor/components/runtime/%s.java', 'r') tkMessageBox.showerror( "Duplicate Component", "%s already exists" % self.component.compName) # if doesnt exist will raise error except IOError: # check for name input if not self.component.compImgName: tkMessageBox.showerror("Missing Name", "Please enter component name") return #check for category selection if not self.component.category: tkMessageBox.showerror("Missing Category", "Please select a category") return # check if selected an icon if not self.component.imgFile: tkMessageBox.showerror("Missing Icon", "Please select an icon image") return # copy image file to folder, can get error if user checked resize and doest have PIL installed try: self.component.copyImageToFolder() except ImportError, e: tkMessageBox.showerror( "Unable to import PIL", "Please install PIL or unselect checkbox") return # add references to the image file, can get error if component already exists try: self.component.addImageReference() except DuplicateError, e: tkMessageBox.showerror( "Duplicate Component", "%s already exists" % self.component.compName) return # will create mock component if is visible and add references to SimpleComponentDescriptor self.component.createMockComponent() # will create the actual component file self.component.createComponent() tkMessageBox.showinfo('Success', 'Component created successfully')
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Filter Data") self.pack(fill=BOTH, expand=True) labelfont20 = ('Roboto', 15, 'bold') labelfont10 = ('Roboto', 10, 'bold') labelfont8 = ('Roboto', 8, 'bold') frame0 = Frame(self) frame0.pack() lbl0 = Label(frame0, text="Hi Nakul") lbl0.config(font=labelfont20) lbl0.pack( padx=5, pady=5) lbl00 = Label(frame0, text="Filter Data") lbl00.config(font=labelfont10) lbl00.pack( padx=5, pady=5) #################################### ########################################## ############################################ #####printing line lbl5a = Label(text="__________________________________") lbl5a.pack() lbl5a.place(x=170, y=300) lbl5b = Label(text="__________________________________") lbl5b.pack() lbl5b.place(x=480, y=300) self.lbl5c = Label(text="Search Result Will Appear Here") self.lbl5c.pack() self.lbl5c.place(x=170, y=320) self.lbl5d = Label(text="File Name Will Appear Here") self.lbl5d.pack() self.lbl5d.place(x=480, y=320) ############################################ ############################################# ############################################### ############################################## ############################################# frame11 = Frame(self) frame11.pack() frame11.place(x=200, y=100) lbl11x = Label(frame11,text="Class 10th %") lbl11x.pack(padx=0, pady=0) self.entry11 = Entry(width=12) self.entry11.pack(padx=1, expand=True) self.entry11.place(x=200, y=120) #################################################### frame12 = Frame(self) frame12.pack() frame12.place(x=380, y=100) lbl12x = Label(frame12,text="Class 12th %") lbl12x.pack(padx=0, pady=0) self.entry12 = Entry(width=12) self.entry12.pack(padx=1, expand=True) self.entry12.place(x=380, y=120) ##################################################### frame13 = Frame(self) frame13.pack() frame13.place(x=550, y=100) lbl13x = Label(frame13,text="B.Tech %") lbl13x.pack(padx=0, pady=0) self.entry13 = Entry(width=12) self.entry13.pack(padx=1, expand=True) self.entry13.place(x=550, y=120) #################################################### frame9 = Frame(self) frame9.pack() frame9.place(x=350, y=160) lbl9 = Label(frame9, text="HomeTown:") lbl9.pack() self.entry9 = Entry(frame9) self.entry9.pack(fill=X, padx=5, expand=True) ############################################################# frame16 = Frame(self) frame16.pack() frame16.place(x=190, y=250) closeButton = Button(frame16, text="Filter",width=20,command=self.getDatax2) closeButton.pack(padx=5, pady=5) ####################################### frame17 = Frame(self) frame17.pack() frame17.place(x=500, y=250) closeButton = Button(frame17, text="Save & Open",width=20,command=self.getDatax3) closeButton.pack(padx=5, pady=5) ####################################### frame000 = Frame(self) frame000.pack() frame000.place(x=50, y=600) self.lbl000= Label(frame000, text="Beta/Sample2.0 | (c) Nakul Rathore") self.lbl000.config(font=labelfont8) self.lbl000.pack( padx=5, pady=5) def getDatax2(self): x1 = self.entry11.get() if x1 != "": x1 = int(x1) x2 = self.entry12.get() if x2 != "": x2 = int(x2) x3 = self.entry13.get() if x3 != "": x3 = int(x3) x4 = self.entry9.get() list1=[x1,x2,x3,x4] wb = openpyxl.load_workbook('..\database\database.xlsx') ws = wb.active print(wb.get_sheet_names()) max_row = ws.get_highest_row() max_col = ws.get_highest_column() global temp global tempx temp = [] tempx = [] for i in xrange(2,max_row+1): temp.append(i) #print temp if isinstance(x1, int): for i in temp: if ws.cell(row = i, column = 11).value >= x1: tempx.append(i) temp = tempx tempx = [] print temp if isinstance(x2, int): for i in temp: if ws.cell(row = i, column = 14).value >= x2: tempx.append(i) temp = tempx tempx = [] print temp if isinstance(x3, int): for i in temp: if ws.cell(row = i, column = 17).value >= x3: tempx.append(i) temp = tempx tempx = [] print temp if isinstance(x3, str) and x3 != "": for i in temp: if ws.cell(row = i, column = 9).value == x4: tempx.append(i) temp = tempx tempx = [] print temp self.lbl5c.config(text=""+str(len(temp))+" result(s) found") def getDatax3(self): import datetime now = datetime.datetime.now() now = now.replace(microsecond=0,second = 0) now = now.strftime("%d_%B_%y,%I-%M_%p") now = now+".xlsx" if len(temp) != 0: wb1 = openpyxl.load_workbook('..\database\database.xlsx') ws1 = wb1.active wb2 = openpyxl.load_workbook('..\_frame\_frame.xlsx') ws2 = wb2.active for i in xrange(2,len(temp)+2): for j in xrange(1,22): ws2.cell(row = i, column = j).value = ws1.cell(row = temp[i-2], column = j).value wb2.save('..\Result\\'+now) tempstart = '..\Result\\'+now self.lbl5d.config(text="File is :: "+"\""+now+"\"") os.system("start "+tempstart) self.entry11.delete(0, 'end') self.entry12.delete(0, 'end') self.entry13.delete(0, 'end') self.entry9.delete(0, 'end')
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.parent.title("Jo Ion Picker") self.pack(fill=BOTH, expand=1) self.compounds = deisotope(filename=input_file) self.error_label = Label(self, text="Error in ppm") self.error_label.place(x=20, y=730) self.entry = Entry(self, text='error in ppm') self.entry.place(x=20, y=750) self.entry.insert(10,'5') self.b = Button(self, text="ReCalc Error", width=15, \ command=self.callback) self.b.place(x=20, y=770) self.b_output = Button(self, text="Export", width=10, command=self.write_output) self.b_output.place(x=20, y=800) #self.b_output = Button(self, text="Allowed", width=10, command=self.only_allowed_ions) #self.b_output.place(x=20, y=830) self.gaps=IntVar() self.check_gaps = Checkbutton(self, text='Remove Gaps', variable=self.gaps,onvalue=1, offvalue=0, command=self.remove_gaps_call) #self.check.pack() self.check_gaps.place(x=20, y=830) self.scrollbar = Scrollbar(self, orient=VERTICAL) self.lb = Listbox(self, height=46, yscrollcommand=self.scrollbar.set) self.scrollbar.config(command=self.lb.yview) self.scrollbar.pack(side=LEFT, fill=Y) for compound in self.compounds: print "found", compound.get_base_peak() mzs = compound.get_mz_list() num_mzs = len(mzs) entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) self.lb.bind("<<ListboxSelect>>", self.onSelect) self.lb.place(x=20, y=20) self.var = StringVar() #self.label = Label(self, text=0, textvariable=self.var) #self.label.place(x=20, y=710) self.mz_label = Label(self, text="M/Z Num Ions") self.mz_label.place(x=20, y=0) f = Figure(figsize=(8,11), dpi=100) self.ax = f.add_subplot(111) mass_list = self.compounds[0].get_mz_list() print mass_list intensity_list = self.compounds[0].get_intensity_list() mass_spec_plot = self.ax.bar(mass_list, intensity_list,\ width=0.05) min_mz = mass_list[0] max_mz = mass_list[-1] self.ax.set_xlim([min_mz-1, max_mz+1]) self.ax.set_ylim([0, 1.1*max(intensity_list)]) self.ax.set_xticks(mass_list) self.ax.set_xticklabels(mass_list, rotation=45) self.ax.set_title("Base Ion:" + str(mass_list[0])) self.canvas = FigureCanvasTkAgg(f, master=self) self.canvas.show() self.canvas.get_tk_widget().pack(side=RIGHT) def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value) mz_to_search = value.split()[0] self.ax.clear() for i, compound in enumerate(self.compounds): if float(mz_to_search) == compound.get_base_peak(): index = i mass_list = self.compounds[index].get_mz_list() print mass_list intensity_list = self.compounds[index].get_intensity_list() mass_spec_plot = self.ax.bar(mass_list, intensity_list,\ width=0.05) min_mz = mass_list[0] max_mz = mass_list[-1] self.ax.set_xlim([min_mz-1, max_mz+1]) self.ax.set_ylim([0, 1.1*max(intensity_list)]) self.ax.set_xticks(mass_list) self.ax.set_xticklabels([str(mass) for mass in mass_list], rotation=45) self.ax.set_title("Base Ion:" + str(mass_list[0])) self.canvas.draw() def only_allowed_ions(self): ion_list = [] fp = open('ions.csv', 'r') lines = fp.readlines() for line in lines: ion_list.append(float(line)) #print ion_list self.compounds = deisotope(filename=input_file,max_error = float(self.entry.get())) new_compound_list = [] for compound in self.compounds: for ion in ion_list: error_Da = float(self.entry.get())*compound.get_base_peak()/1e6 if compound.get_base_peak() > ion-error_Da \ and compound.get_base_peak() < ion + error_Da: new_compound_list.append(compound) for compound in new_compound_list: print "compound:",compound.get_base_peak() self.lb.delete(0, END) for compound in new_compound_list: mzs = compound.get_mz_list() num_mzs = len(mzs) entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) def callback(self): self.compounds = deisotope(filename=input_file, max_error = float(self.entry.get())) self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() num_mzs = len(mzs) entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) print self.entry.get() def remove_gaps_call(self): self.compounds = deisotope(filename=input_file,max_error = float(self.entry.get())) check_for_gaps(self.compounds) self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() num_mzs = len(mzs) entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) print self.entry.get() def do_list_update(self): l_multi = self.multi.get() l_missing = self.missing.get() l_m1gtm2 = self.m1gtm2.get() # possible situations: 000, 001,010,100, 011,101, 110, 111 if l_multi == 0 and l_missing == 0 and l_m1gtm2 ==0: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() num_mzs = len(mzs) entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) elif l_multi == 0 and l_missing == 0 and l_m1gtm2 ==1: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() num_mzs = len(mzs) intensities = compound.get_intensity_list() if intensities[-1] <= intensities[0]: entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) elif l_multi == 0 and l_missing == 1 and l_m1gtm2 ==0: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() num_mzs = len(mzs) if mzs[-1] - mzs[0] <1.75: # margin of error allowed here entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) elif l_multi == 1 and l_missing == 0 and l_m1gtm2 ==0: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() num_mzs = len(mzs) if num_mzs >1: entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) elif l_multi == 0 and l_missing == 1 and l_m1gtm2 ==1: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() intensities = compound.get_intensity_list() num_mzs = len(mzs) if mzs[-1] - mzs[0] <1.75 and intensities[-1] <= intensities[0]: entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) elif l_multi == 1 and l_missing == 0 and l_m1gtm2 ==1: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() intensities = compound.get_intensity_list() num_mzs = len(mzs) if num_mzs >1 and intensities[-1] <= intensities[0]: entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) elif l_multi == 1 and l_missing == 1 and l_m1gtm2 ==0: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() num_mzs = len(mzs) if num_mzs >1 and mzs[-1] - mzs[0] <1.75: entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) elif l_multi == 1 and l_missing == 1 and l_m1gtm2 ==1: self.lb.delete(0, END) for compound in self.compounds: mzs = compound.get_mz_list() intensities = compound.get_intensity_list() num_mzs = len(mzs) if num_mzs >1 and mzs[-1] - mzs[0] <1.75 and \ intensities[1] <= intensities[0]: entry = str(mzs[0]) + " " + str(num_mzs) self.lb.insert(END, entry) else: pass # error! def write_output(self): op = open('edited_output.csv', 'w') op.write('mz, intensity, mz, intensity, mz, intensity\n') items = self.lb.get(0,END) output_list = [] for item in items: mz_val = item.split(' ')[0] for compound in self.compounds: if float(mz_val) == compound.get_base_peak(): mzs = compound.get_mz_list() intensities = compound.get_intensity_list() for i, mz in enumerate(mzs): op.write(str(mz) + ',' + str(intensities[i]) + ',') op.write('\n') op.close()