class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Scale") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) scale = Scale(self, from_=0, to=100, command=self.onScale) scale.place(x=20, y=20) self.var = IntVar() self.label = Label(self, text=0, textvariable=self.var) self.label.place(x=130, y=70) def onScale(self, val): v = int(float(val)) self.var.set(v)
def initUI(self): # Style().configure("TButton", padding=(10, 10, 10, 10), # font='serif 8', weight=1) mri = Image.open("mri.jpg") # mri.resize((w, h), Image.ANTIALIAS) background_image=ImageTk.PhotoImage(mri) background_label = Label(self, image=background_image) background_label.photo=background_image background_label.place(x=0, y=0, relheight=1) self.columnconfigure(0, pad=10, weight=1) self.columnconfigure(1, pad=10, weight=1) self.columnconfigure(2, pad=20, weight=1) self.rowconfigure(0, pad=20, weight=1) self.rowconfigure(1, pad=20, weight=1) self.rowconfigure(2, pad=20, weight=1) self.customFont = tkFont.Font(family="Helvetica", size=15) # Style().configure('green/black.TButton', foreground='yellow', background=tk_rgb, activefill="red",font=self.customFont) entry = Entry(self) #TODO: REMOVE? f = open('games.txt') buttonArray = [] for i, line in enumerate(f): line = line.split(':') filename = line[0].translate(None, ' \n').lower() imagefile = Image.open(filename + "-thumbnail.png") image = ImageTk.PhotoImage(imagefile) label1 = Label(self, image=image) label1.image = image # + "\n" + line[1] tk_rgb = "#%02x%02x%02x" % (100+35*(i%5), 50+100*(i%3), 70+80*(i%2)) button = (Button(self, text=line[0], image=image, compound="bottom", bd=0, bg=tk_rgb, font=self.customFont, command = lambda filename=filename :os.system("python " + filename + ".py"))) button.grid(row=i/3, column=i%3) f.close() self.pack(fill=BOTH, expand=1)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Listbox + Scale + ChkBtn") self.pack(fill=BOTH, expand=1) acts = ['Scarlett Johansson', 'Rachel Weiss', 'Natalie Portman', 'Jessica Alba'] lb = Listbox(self) for i in acts: lb.insert(END, i) lb.bind("<<ListboxSelect>>", self.onSelect) lb.place(x=20, y=20) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.place(x=20, y=190) scale = Scale(self, from_=0, to=100, command=self.onScale) scale.place(x=20, y=220) self.var_scale = IntVar() self.label_scale = Label(self, text=0, textvariable=self.var_scale) self.label_scale.place(x=180, y=220) self.var_chk = IntVar() cb = Checkbutton(self, text="Test", variable=self.var_chk, command=self.onClick) cb.select() cb.place(x=220, y=60) def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value) def onScale(self, val): v = int(float(val)) self.var_scale.set(v) def onClick(self): if self.var_chk.get() == 1: self.var.set("checked") else: self.var.set("unchecked")
def initUI(self): ''' Loades nonograms from Nonogram base.txt file, fills list of nonograms and creates all widgets within GUI ''' self.parent.title("Nonograms") base_nonograms = import_from_file("Nonogram base.txt") self.all_nonograms = [] menubar = tk.Menu(self.parent) self.parent.config(menu=menubar) self.fl = "" fileMenu = tk.Menu(menubar) fileMenu.add_command(label="Export", command=self.export) fileMenu.add_command(label="Open", command=self.onOpen) fileMenu.add_command(label="Exit", command=self.onExit) menubar.add_cascade(label="File", menu=fileMenu) self.pack(fill=tk.BOTH, expand=1) nonos = [] for n in range(len(base_nonograms['unique'])): nonos.append('Nonogram ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['unique'] for n in range(len(base_nonograms['nonunique'])): nonos.append('NUS Nonogram ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['nonunique'] for n in range(len(base_nonograms['hard'])): nonos.append('HARD Nonogram ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['hard'] self.lb = tk.Listbox(self) for i in nonos: self.lb.insert(tk.END, i) self.lb.bind("<<ListboxSelect>>", self.onSelect) self.lb.place(x=20, y=40) info1 = Label(self, text='Select nonogram:') info1.place(x=30, y=10) info2 = Label(self, text='Or choose a file:') info2.place(x=180, y=10) self.browseButton = tk.Button(self, text='Browse...', command=self.onBrowse) self.browseButton.place(x=200, y=30) self.info3 = Label(self, text="") self.info3.place(x=150, y=60) self.info4 = Label(self, text="Rows:") self.ySize = tk.Entry(self, width=5)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Listbox") self.pack(fill=BOTH, expand=1) acts = ['Scarlett Johansson', 'Rachel Weiss', 'Natalie Portman', 'Jessica Alba'] #This is a list of actresses to be shown in the listbox. lb = Listbox(self) for i in acts: lb.insert(END, i) #We create an instance of the Listbox and insert all the items from the above mentioned list. lb.bind("<<ListboxSelect>>", self.onSelect) #When we select an item in the listbox, the <<ListboxSelect>> event is generated. #We bind the onSelect() method to this event. lb.place(x=20, y=20) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) #A label and its value holder is created. #In this label we will display the currently selected item. self.label.place(x=20, y=210) def onSelect(self, val): sender = val.widget #We get the sender of the event. #It is our listbox widget. idx = sender.curselection() #We find out the index of the selected item using the curselection() method. value = sender.get(idx) #The actual value is retrieved with the get() method, which takes the index of the item. self.var.set(value)
class FirstWindow(Frame): def __init__(self, parent, controller, listener): Frame.__init__(self, parent) self.parent = parent self.controller = controller self.listener = listener self.controller.add_listener(self.listener) self.initUI() def initUI(self): self.centerWindow() self.parent.title("Cursor") self.style = Style() self.style.theme_use("clam") self.style.configure("TFrame") self.pack(fill=BOTH, expand=1) self.label = Label(self) self.label.configure(text="Hold your hand above the device for two seconds...") self.label.place(x=50, y=50) quitButton = Button(self, text="Quit", command=self.quit) quitButton.place(x=50, y=100) def update_label(self): self.label.configure(text="You can now use the cursor.") def remove(self): self.controller.remove_listener(self.listener) def centerWindow(self): w, h = 450, 180 sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() x = (sw - w)/2 y = (sh - h)/2 self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
def initUI(self): self.parent.title("Buttons") self.style=Style() self.style.theme_use("default") frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) bard = Image.open("images.jpg") bardejov = ImageTk.PhotoImage(bard) label1 = Label(frame, image=bardejov) label1.image = bardejov label1.place(x=20, y=20) self.pack(fill=BOTH, expand=1) closebutton = Button(self, text="Close") closebutton.pack(side=RIGHT, padx=5, pady=5) okbutton = Button(self, text="OK") okbutton.pack(side=RIGHT)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Listbox") self.pack(fill=BOTH, expand=1) acts = [ 'Scarlett Johansson', 'Rachel Weiss', 'Natalie Portman', 'Jessica Alba' ] lb = Listbox(self) for i in acts: lb.insert(END, i) lb.bind("<<ListboxSelect>>", self.onSelect) lb.place(x=20, y=20) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.place(x=20, y=210) def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Listbox") self.pack(fill=BOTH, expand=1) # put our data in from our global data object lb = Listbox(self) for i in data: lb.insert(END, i) # add event listener with call back to show # when the list object is selected, show visual feedback lb.bind("<<ListboxSelect>>", self.onSelect) # absolute positioning lb.place(x=20, y=20) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.place(x=20, y=210) def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Listbox") self.pack(fill=BOTH, expand=1) acts = ['Scarlett Johansson', 'Rachel Weiss', 'Natalie Portman', 'Jessica Alba'] lb = Listbox(self) for i in acts: lb.insert(END, i) lb.bind("<<ListboxSelect>>", self.onSelect) lb.place(x=20, y=20) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.place(x=20, y=210) def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value)
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 App(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() self.centerWindow() def initUI(self): self.parent.title("Champion Pool Builder") self.parent.iconbitmap("assets/icon.ico") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.buildMode = True self.allPools = "assets/pools/" self.champsLabel = Label(text="Champions") self.champBox = Listbox(self) self.champBoxScrollbar = Scrollbar(self.champBox, orient=VERTICAL) self.champBox.config(yscrollcommand=self.champBoxScrollbar.set) self.champBoxScrollbar.config(command=self.champBox.yview) self.addButton = Button(self, text=">>", command=self.addChampToPool) self.removeButton = Button(self, text="<<", command=self.removeChampFromPool) self.saveButton = Button(self, text="Save champion pool", width=18, command=self.saveChampPool) self.loadButton = Button(self, text="Load champion pool", width=18, command=lambda: self.loadChampPools(1)) self.confirmLoadButton = Button(self, text="Load", width=6, command=self.choosePool) self.getStringButton = Button(self, text="Copy pool to clipboard", width=18, command=self.buildPoolString) self.poolLabel = Label(text="Champion Pool") self.poolBox = Listbox(self) self.poolBoxScrollbar = Scrollbar(self.poolBox, orient=VERTICAL) self.poolBox.config(yscrollcommand=self.poolBoxScrollbar.set) self.poolBoxScrollbar.config(command=self.poolBox.yview) self.champsLabel.place(x=5, y=5) self.champBox.place(x=5, y=30) self.addButton.place(x=150, y=60) self.removeButton.place(x=150, y=100) self.saveButton.place(x=350, y=30) self.loadButton.place(x=350, y=60) self.getStringButton.place(x=350, y=90) self.poolLabel.place(x=200, y=5) self.poolBox.place(x=200, y=30) self.champBox.focus_set() self.loadChampions() def centerWindow(self): w = 500 h = 200 sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() x = (sw - w)/2 y = (sh - h)/2 self.parent.geometry("%dx%d+%d+%d" % (w, h, x, y)) def loadChampions(self, pooled=None): if pooled: with open("assets/Champions.txt", "r") as file: champions = file.read().splitlines() for champ in pooled: champions.remove(champ) for champion in sorted(champions): self.champBox.insert(END, champion) else: with open("assets/Champions.txt", "r") as file: champions = file.read().splitlines() for champion in sorted(champions): self.champBox.insert(END, champion) def choosePool(self): idx = self.poolBox.curselection() chosenPool = self.poolBox.get(idx) self.confirmLoadButton.place_forget() self.loadChampPools(2, chosenPool) def loadChampPools(self, level, pool=None): if level == 1: self.buildMode = False self.champBox.delete(0, END) self.poolBox.delete(0, END) self.saveButton.config(state=DISABLED) self.loadButton.config(state=DISABLED) self.getStringButton.config(state=DISABLED) self.confirmLoadButton.place(x=350, y=120) with open("assets/champpools.txt", "r") as file: champPools = file.read().splitlines() for pool in champPools: self.poolBox.insert(END, pool) elif level == 2: self.poolBox.delete(0, END) self.buildMode = True self.loadButton.config(state=NORMAL) self.saveButton.config(state=NORMAL) self.getStringButton.config(state=NORMAL) fileName = pool + ".txt" with open(self.allPools + fileName, "r") as file: champPool = file.read().splitlines() for champion in sorted(champPool): self.poolBox.insert(END, champion) self.loadChampions(champPool) def addChampToPool(self): idx = self.champBox.curselection() if idx and self.buildMode: name = self.champBox.get(idx) self.poolBox.insert(END, name) self.champBox.delete(idx) def removeChampFromPool(self): idx = self.poolBox.curselection() if idx and self.buildMode: name = self.poolBox.get(idx) self.champBox.insert(END, name) self.poolBox.delete(idx) def checkIfPoolExists(self, title): with open("assets/champpools.txt", "r") as poolFile: pools = poolFile.read().splitlines() for pool in pools: if pool == title: return True return False def saveChampPool(self): championPool = self.poolBox.get(0, END) poolTitle = TitleDialog(self.parent) fileName = self.allPools + poolTitle.title + ".txt" checker = self.checkIfPoolExists(poolTitle.title) if not checker: with open("assets/champpools.txt", "a")as file: file.write(poolTitle.title + "\n") with open(fileName, "w+") as file: for champion in sorted(championPool): file.write(champion + "\n") def buildPoolString(self): clipper = Tk() clipper.withdraw() clipper.clipboard_clear() championPool = self.poolBox.get(0, END) if championPool: championPoolString = "" for champion in championPool: championPoolString += "^" + champion + "$|" clipper.clipboard_append(championPoolString) clipper.destroy()
def __init__(self, root): register_openers() Tkinter.Frame.__init__(self, root) self.root = root self.root.title("GoData Client Module") self.grid() Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10') self.root.columnconfigure(0, pad=3) self.root.columnconfigure(1, pad=3) self.root.columnconfigure(2, pad=3) self.root.columnconfigure(3, pad=3) self.root.columnconfigure(4, pad=3) self.root.rowconfigure(0, pad=3) self.root.rowconfigure(1, pad=3) self.root.rowconfigure(2, pad=3) self.root.rowconfigure(3, pad=3) self.root.rowconfigure(4, pad=3) self.root.rowconfigure(5, pad=3) self.root.rowconfigure(6, pad=3) self.root.rowconfigure(7, pad=3) self.root.rowconfigure(8, pad=3) self.root.rowconfigure(9, pad=3) self.root.rowconfigure(10, pad=3) self.root.rowconfigure(11, pad=3) self.root.rowconfigure(12, pad=3) self.root.rowconfigure(13, pad=3) self.root.rowconfigure(14, pad=3) self.root.rowconfigure(15, pad=3) self.root.rowconfigure(16, pad=3) self.root.rowconfigure(17, pad=3) self.root.rowconfigure(18, pad=3) self.root.rowconfigure(19, pad=3) self.root.rowconfigure(20, pad=3) self.root.rowconfigure(21, pad=3) self.root.rowconfigure(22, pad=3) self.root.rowconfigure(0, weight=1) self.root.columnconfigure(0, weight=1) global e e = Entry(self, width=4) e.grid(row=16, column=4) e.focus_set() #self.button = Button(self, text="Upload", fg="red", command=self.logout) #self.button.pack(side = RIGHT) button_opt = {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5} a = Tkinter.Button(self, text='Browse', command=self.askopenfilename)#.pack(**button_opt) a.grid(row =1 , column =4) b = Tkinter.Button(self, text='Upload', command=self.upload)#.pack(**button_opt) b.grid(row = 3, column =4) f=client.doCmd({"cmd":"view"}) for i in f: FileInfo[i.split(":")[0]].append(i.split(":")[1].split("/")[-1]) print FileInfo t = SimpleTable(self, len(f)/5,5) t.grid(row = 4, column =4) #MyButton1 = Button(self, text="Download 5", width=14, command=self.Download) #MyButton1.grid(row=15, column=4) #MyButton2 = Button(self, text="Download 6", width=14, command=self.Download) #MyButton2.grid(row=15, column=5) #MyButton3 = Button(self, text="Download 7", width=14, command=self.Download) #MyButton3.grid(row=15, column=6) #MyButton4 = Button(self, text="Download 4", width=14, command=self.Download) #MyButton4.grid(row=15, column=3) #MyButton5 = Button(self, text="Download 3", width=14, command=self.Download) #MyButton5.grid(row=15, column=2) #MyButton6 = Button(self, text="Download 2", width=14, command=self.Download) #MyButton6.grid(row=15, column=1) #MyButton7 = Button(self, text="Download 1", width=14, command=self.Download) #MyButton7.grid(row=15, column=0) #MyButton8 = Button(self, text="Download 8", width=14, command=self.Download) #MyButton8.grid(row=15, column=7) MyButton9 = Button(self, text="Download", width=14, command=self.callback) MyButton9.grid(row=17, column=4) creation = tk.Label( self, text = "Created by Kuber, Digvijay, Anahita & Payal", borderwidth =5, width =45) creation.grid(row=50 , column = 4) self.file_opt = options = {} options['defaultextension'] = '.txt' options['filetypes'] = [('all files', '.*'), ('text files', '.txt')] options['initialdir'] = 'C:\\' options['initialfile'] = 'myfile.txt' options['parent'] = root options['title'] = 'Browse' self.dir_opt = options = {} options['initialdir'] = 'C:\\' options['mustexist'] = False options['parent'] = root options['title'] = 'Browse' image = Image.open("./header.png") photo = ImageTk.PhotoImage(image) label = Label(image=photo) label.image = photo # keep a reference! label.place(width=768, height=576) label.grid(row = 0 , column = 0 ) label.pack(side = TOP) self.centerWindow() self.master.columnconfigure(10, weight=1) #Tkinter.Button(self, text='upload file', command=self.Fname).pack(**button_opt) t = self.file_name = Text(self, width=39, height=1, wrap=WORD) t.grid(row = 2, column =4) extra1 = tk.Label(self, text = "please give a file number", borderwidth = 5, width =45) extra1.grid(row =15, column =4)
class FakeDeviceApp(Frame): MIN_X = 0 MAX_X = 50 MIN_Y = 0 MAX_Y = 100 MIN_Z = 0 MAX_Z = 200 def __init__(self, parent): Frame.__init__(self, parent, background='white') self.parent = parent self.init_ui() def init_ui(self): self.parent.title('Fake Device') self.style = Style() self.style.theme_use('default') self.pack(fill=BOTH, expand=1) x_scale = Scale(self, from_=self.MIN_X, to=self.MAX_X, command=self.on_scale_x) x_scale.place(x=0, y=0) y_scale = Scale(self, from_=self.MIN_Y, to=self.MAX_Y, command=self.on_scale_y) y_scale.place(x=0, y=20) z_scale = Scale(self, from_=self.MIN_Z, to=self.MAX_Z, command=self.on_scale_z) z_scale.place(x=0, y=40) angle_scale = Scale(self, from_=0, to=math.pi/2, command=self.on_scale_angle) angle_scale.place(x=0, y=80) self.x_var = IntVar() self.x_label = Label(self, text=0, textvariable=self.x_var) self.x_label.place(x=100, y=0) self.y_var = IntVar() self.y_label = Label(self, text=0, textvariable=self.y_var) self.y_label.place(x=100, y=20) self.z_var = IntVar() self.z_label = Label(self, text=0, textvariable=self.z_var) self.z_label.place(x=100, y=40) self.angle_var = DoubleVar() self.angle_label = Label(self, text=0, textvariable=self.angle_var) self.angle_label.place(x=100, y=80) self.button = Button(self, text='test', command=self.on_button) self.button.place(x=0, y=100) def on_button(self): print('hello') def on_scale_angle(self, val): v = float(val) self.angle_var.set(v) self.update() def on_scale_x(self, val): v = int(float(val)) self.x_var.set(v) self.update() def on_scale_y(self, val): v = int(float(val)) self.y_var.set(v) self.update() def on_scale_z(self, val): v = int(float(val)) self.z_var.set(v) self.update() def update(self): x = self.x_var.get() y = self.y_var.get() z = self.z_var.get() angle = self.angle_var.get() sensor = events.sensor_storage sensor.reset() if not (x == 0 and y == 0 and z == 0): index_pos = [x, y, z] sensor.index_finger_pos = index_pos sensor.cmd_angle = angle
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 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')
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)
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 AppGui(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.init_ui() def run(self): while True: tmpPath = "%s-%05d.png" % (os.path.splitext(self.path)[0], randint(1, 99999)) if not os.path.exists(tmpPath): break mem = int(self.membershipPassScale.scale.get()) ins = int(self.intensifyPassScale.scale.get()) con = self.convolveCheckbutton.instate(['selected']) in2 = int(self.secondIntensifyPassScale.scale.get()) thr = float(int(self.thresholdScale.scale.get())) / 10 pow = int(self.powerScale.scale.get()) process_image(self.path, tmpPath, mem, ins, con, in2, thr, pow) f = pylab.figure() for n, fname in enumerate((tmpPath, self.path)): image = Image.open(fname).convert("L") arr = np.asarray(image) f.add_subplot(1, 2, n) pylab.imshow(arr, cmap=cm.Greys_r) if con: pylab.title("membership passes=%d, 1st intensify passes=%d, convolve=Yes, 2nd intensify passes=%d, " "threshold=%0.1f, power=%d" % (mem, ins, in2, thr, pow)) else: pylab.title("membership passes=%d, 1st intensify passes=%d, convolve=No, " "threshold=%0.1f, power=%d" % (mem, ins, thr, pow)) pylab.show() def open_file(self): self.path = tkFileDialog.askopenfilename(parent=self, filetypes=[("PNG Images", "*.png")]) if self.path != '': self.preview_input_file(self.path) self.runButton.configure(state="normal") else: tkMessageBox.showerror("Error", "Could not open file") def preview_input_file(self, path): self.img = Image.open(path) imgTk = ImageTk.PhotoImage(self.img) self.label = Label(image=imgTk) self.label.image = imgTk self.label.place(x=400, y=50, width=self.img.size[0], height=self.img.size[1]) def center_window(self): w = 1024 h = 600 x = (self.parent.winfo_screenwidth() - w) / 2 y = (self.parent.winfo_screenheight() - h) / 2 self.parent.geometry("%dx%d+%d+%d" % (w, h, x, y)) def init_ui(self): self.parent.title("Image enhancement") self.pack(fill=BOTH, expand=1) self.center_window() openFileButton = Button(self, text="Choose image", command=self.open_file) openFileButton.place(x=50, y=50) self.runButton = Button(self, text="Enhance", command=self.run, state="disabled") self.runButton.place(x=200, y=50) membershipLabel = Label(text="Membership passes:") membershipLabel.place(x=50, y=120) self.membershipPassScale = LabeledScale(self, from_=1, to=10) self.membershipPassScale.place(x=250, y=100) intensifyLabel = Label(text="1st intensify passes:") intensifyLabel.place(x=50, y=170) self.intensifyPassScale = LabeledScale(self, from_=1, to=10) self.intensifyPassScale.place(x=250, y=150) convolveLabel = Label(text="Convolve:") convolveLabel.place(x=50, y=220) self.convolveCheckbutton = Checkbutton(self) self.convolveCheckbutton.place(x=250, y=220) self.convolveCheckbutton.invoke() secondIntensifyLabel = Label(text="2nd intensify passes:") secondIntensifyLabel.place(x=50, y=270) self.secondIntensifyPassScale = LabeledScale(self, from_=1, to=10) self.secondIntensifyPassScale.place(x=250, y=250) thresholdLabel = Label(text="Threshold:") thresholdLabel.place(x=50, y=320) self.thresholdScale = LabeledScale(self, from_=1, to=10) self.thresholdScale.place(x=250, y=300) self.thresholdScale.scale.set(5) powerLabel = Label(text="Power:") powerLabel.place(x=50, y=370) self.powerScale = LabeledScale(self, from_=2, to=5) self.powerScale.place(x=250, y=350)
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)
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)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Listbox") self.pack(fill=BOTH, expand=1) acts = ['mode 1', 'mode 2', 'mode 3', 'mode 4', 'mode 5', 'mode 6'] lb = Listbox(self) for i in acts: lb.insert(END, i) lb.bind("<<ListboxSelect>>", self.onSelect) lb.place(x=400, y=400) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.place(x=20, y=410) abtn = Button(self, image=img[0], command=lambda: helloCallBack(img[0], self.var.get())) abtn.grid(row=0, column=0, pady=5) bbtn = Button(self, image=img[1], command=lambda: helloCallBack(img[1], self.var.get())) bbtn.grid(row=0, column=1, pady=5) cbtn = Button(self, image=img[2], command=lambda: helloCallBack(img[2], self.var.get())) cbtn.grid(row=0, column=2, pady=4) dbtn = Button(self, image=img[3], command=lambda: helloCallBack(img[3], self.var.get())) dbtn.grid(row=1, column=0, pady=4) ebtn = Button(self, image=img[4], command=lambda: helloCallBack(img[4], self.var.get())) ebtn.grid(row=1, column=1, pady=5) fbtn = Button(self, image=img[5], command=lambda: helloCallBack(img[5], self.var.get())) fbtn.grid(row=1, column=2, pady=4) gbtn = Button(self, image=img[6], command=lambda: helloCallBack(img[6], self.var.get())) gbtn.grid(row=3, column=0, pady=5) hbtn = Button(self, image=img[7], command=lambda: helloCallBack(img[7], self.var.get())) hbtn.grid(row=3, column=1, pady=4) ibtn = Button(self, image=img[8], command=lambda: helloCallBack(img[8], self.var.get())) ibtn.grid(row=3, column=2, pady=4) def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value)
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()
class App(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() self.centerWindow() def initUI(self): self.parent.title("Champion Pool Builder") self.parent.iconbitmap("assets/icon.ico") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.buildMode = True self.allPools = "assets/pools/" self.champsLabel = Label(text="Champions") self.champBox = Listbox(self) self.champBoxScrollbar = Scrollbar(self.champBox, orient=VERTICAL) self.champBox.config(yscrollcommand=self.champBoxScrollbar.set) self.champBoxScrollbar.config(command=self.champBox.yview) self.addButton = Button(self, text=">>", command=self.addChampToPool) self.removeButton = Button(self, text="<<", command=self.removeChampFromPool) self.saveButton = Button(self, text="Save champion pool", width=18, command=self.saveChampPool) self.loadButton = Button(self, text="Load champion pool", width=18, command=lambda: self.loadChampPools(1)) self.confirmLoadButton = Button(self, text="Load", width=6, command=self.choosePool) self.getStringButton = Button(self, text="Copy pool to clipboard", width=18, command=self.buildPoolString) self.poolLabel = Label(text="Champion Pool") self.poolBox = Listbox(self) self.poolBoxScrollbar = Scrollbar(self.poolBox, orient=VERTICAL) self.poolBox.config(yscrollcommand=self.poolBoxScrollbar.set) self.poolBoxScrollbar.config(command=self.poolBox.yview) self.champsLabel.place(x=5, y=5) self.champBox.place(x=5, y=30) self.addButton.place(x=150, y=60) self.removeButton.place(x=150, y=100) self.saveButton.place(x=350, y=30) self.loadButton.place(x=350, y=60) self.getStringButton.place(x=350, y=90) self.poolLabel.place(x=200, y=5) self.poolBox.place(x=200, y=30) self.champBox.focus_set() self.loadChampions() def centerWindow(self): w = 500 h = 200 sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() x = (sw - w) / 2 y = (sh - h) / 2 self.parent.geometry("%dx%d+%d+%d" % (w, h, x, y)) def loadChampions(self, pooled=None): if pooled: with open("assets/Champions.txt", "r") as file: champions = file.read().splitlines() for champ in pooled: champions.remove(champ) for champion in sorted(champions): self.champBox.insert(END, champion) else: with open("assets/Champions.txt", "r") as file: champions = file.read().splitlines() for champion in sorted(champions): self.champBox.insert(END, champion) def choosePool(self): idx = self.poolBox.curselection() chosenPool = self.poolBox.get(idx) self.confirmLoadButton.place_forget() self.loadChampPools(2, chosenPool) def loadChampPools(self, level, pool=None): if level == 1: self.buildMode = False self.champBox.delete(0, END) self.poolBox.delete(0, END) self.saveButton.config(state=DISABLED) self.loadButton.config(state=DISABLED) self.getStringButton.config(state=DISABLED) self.confirmLoadButton.place(x=350, y=120) with open("assets/champpools.txt", "r") as file: champPools = file.read().splitlines() for pool in champPools: self.poolBox.insert(END, pool) elif level == 2: self.poolBox.delete(0, END) self.buildMode = True self.loadButton.config(state=NORMAL) self.saveButton.config(state=NORMAL) self.getStringButton.config(state=NORMAL) fileName = pool + ".txt" with open(self.allPools + fileName, "r") as file: champPool = file.read().splitlines() for champion in sorted(champPool): self.poolBox.insert(END, champion) self.loadChampions(champPool) def addChampToPool(self): idx = self.champBox.curselection() if idx and self.buildMode: name = self.champBox.get(idx) self.poolBox.insert(END, name) self.champBox.delete(idx) def removeChampFromPool(self): idx = self.poolBox.curselection() if idx and self.buildMode: name = self.poolBox.get(idx) self.champBox.insert(END, name) self.poolBox.delete(idx) def checkIfPoolExists(self, title): with open("assets/champpools.txt", "r") as poolFile: pools = poolFile.read().splitlines() for pool in pools: if pool == title: return True return False def saveChampPool(self): championPool = self.poolBox.get(0, END) poolTitle = TitleDialog(self.parent) fileName = self.allPools + poolTitle.title + ".txt" checker = self.checkIfPoolExists(poolTitle.title) if not checker: with open("assets/champpools.txt", "a") as file: file.write(poolTitle.title + "\n") with open(fileName, "w+") as file: for champion in sorted(championPool): file.write(champion + "\n") def buildPoolString(self): clipper = Tk() clipper.withdraw() clipper.clipboard_clear() championPool = self.poolBox.get(0, END) if championPool: championPoolString = "" for champion in championPool: championPoolString += "^" + champion + "$|" clipper.clipboard_append(championPoolString) clipper.destroy()
class Nono_Main(Frame): ''' It is GUI for player to choose nonogram, or to import from text file or picture ''' def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): ''' Loades nonograms from Nonogram base.txt file, fills list of nonograms and creates all widgets within GUI ''' self.parent.title("Nonograms") base_nonograms = import_from_file("Nonogram base.txt") self.all_nonograms = [] menubar = tk.Menu(self.parent) self.parent.config(menu=menubar) self.fl = "" fileMenu = tk.Menu(menubar) fileMenu.add_command(label="Export", command=self.export) fileMenu.add_command(label="Open", command=self.onOpen) fileMenu.add_command(label="Exit", command=self.onExit) menubar.add_cascade(label="File", menu=fileMenu) self.pack(fill=tk.BOTH, expand=1) nonos = [] for n in range(len(base_nonograms['unique'])): nonos.append('Nonogram ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['unique'] for n in range(len(base_nonograms['nonunique'])): nonos.append('NUS Nonogram ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['nonunique'] for n in range(len(base_nonograms['hard'])): nonos.append('HARD Nonogram ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['hard'] self.lb = tk.Listbox(self) for i in nonos: self.lb.insert(tk.END, i) self.lb.bind("<<ListboxSelect>>", self.onSelect) self.lb.place(x=20, y=40) info1 = Label(self, text='Select nonogram:') info1.place(x=30, y=10) info2 = Label(self, text='Or choose a file:') info2.place(x=180, y=10) self.browseButton = tk.Button(self, text='Browse...', command=self.onBrowse) self.browseButton.place(x=200, y=30) self.info3 = Label(self, text="") self.info3.place(x=150, y=60) self.info4 = Label(self, text="Rows:") self.ySize = tk.Entry(self, width=5) def onSelect(self, val): ''' When player selects nonogram from list, new window appears with this particular nonogram. ''' sender = val.widget num = sender.curselection()[0] current_nonogram = self.all_nonograms[num] master = tk.Tk() if 'HARD' not in sender.get(sender.curselection())\ and 'Picture' not in sender.get(sender.curselection()): current_nonogram.solve() current_nonogram.full_solve() app = ShowNono(master, current_nonogram.Rows, current_nonogram.Columns, current_nonogram.nonogram_Matrix, current_nonogram.pair) app.mainloop() else: app = ShowNonoHard(master, current_nonogram.Rows, current_nonogram.Columns) app.mainloop() def onBrowse(self): ''' Opens filedialog window, so player can choose text file or picture to add nonograms. In the second case player is asked to give dimensions of picture he wants to solve. WARNING! Image size ratio cannot be changed! So if original picture has resolution 900x900 and players gives X = 10, Y = 100 picture will be converted to X = 100 and Y = 100, to retain size ratio and to match Y. ''' if self.ySize: self.ySize.destroy() if self.info4: self.info4.destroy() ftypes = [('Text files', '*.txt'), ('Pictures', '*.jpg; *.png; *.bmp')] dlg = filedialog.Open(self, filetypes=ftypes) self.fl = dlg.show() sss = self.fl.split("/") self.info3.configure(text=sss[-1]) if self.fl[-3:] == "txt": self.convert = tk.Button(self, text='Convert', command=self.converty) self.convert.place(x=200, y=160) elif self.fl[-3:] in ['jpg', 'png', 'bmp']: self.ySize = tk.Entry(self, width=5) self.ySize.place(x=210, y=100) self.info4 = Label(self, text="Rows:") self.info4.place(x=150, y=100) self.convert = tk.Button(self, text='Convert', command=self.converty) self.convert.place(x=200, y=160) def converty(self): ''' Imports and adds to list nonograms from file, or converts picture to nonogram and adds it to the list. ''' if self.fl[-3:] == "txt": base_nonograms = import_from_file(self.fl) name = self.fl.split("/")[-1].split(".")[0] nonos = [] for n in range(len(base_nonograms['unique'])): nonos.append('My ' + name + ' ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['unique'] for n in range(len(base_nonograms['nonunique'])): nonos.append('My NUS ' + name + ' ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['nonunique'] for n in range(len(base_nonograms['hard'])): nonos.append('HARD ' + name + ' ' + str(len(self.all_nonograms) + n)) self.all_nonograms += base_nonograms['hard'] for i in nonos: self.lb.insert(tk.END, i) elif self.fl[-3:] in ['jpg', 'png', 'bmp']: name = self.fl.split("/")[-1].split(".")[0] rows, cols = import_picture(self.fl, int(self.ySize.get()), int(self.ySize.get())) ngram = nonogram(rows, cols) self.lb.insert( tk.END, "Picture " + name + ' ' + str(len(self.all_nonograms))) self.all_nonograms.append(ngram) self.ySize.destroy() self.info4.destroy() self.convert.destroy() self.info3.configure(text="") def onOpen(self): self.onBrowse() def onExit(self): self.parent.destroy() def export(self): ''' Saves all nonograms from the list to "Nonogram base.txt" so they will be loaded on next opening. ''' text = [ str(nonogram.Rows) + '\n' + str(nonogram.Columns) for nonogram in self.all_nonograms ] new_text = '\n\n'.join(text) f = open('Nonogram base.txt', 'w') f.write(new_text) f.close
def init_ui(self): self.parent.title("Image enhancement") self.pack(fill=BOTH, expand=1) self.center_window() openFileButton = Button(self, text="Choose image", command=self.open_file) openFileButton.place(x=50, y=50) self.runButton = Button(self, text="Enhance", command=self.run, state="disabled") self.runButton.place(x=200, y=50) membershipLabel = Label(text="Membership passes:") membershipLabel.place(x=50, y=120) self.membershipPassScale = LabeledScale(self, from_=1, to=10) self.membershipPassScale.place(x=250, y=100) intensifyLabel = Label(text="1st intensify passes:") intensifyLabel.place(x=50, y=170) self.intensifyPassScale = LabeledScale(self, from_=1, to=10) self.intensifyPassScale.place(x=250, y=150) convolveLabel = Label(text="Convolve:") convolveLabel.place(x=50, y=220) self.convolveCheckbutton = Checkbutton(self) self.convolveCheckbutton.place(x=250, y=220) self.convolveCheckbutton.invoke() secondIntensifyLabel = Label(text="2nd intensify passes:") secondIntensifyLabel.place(x=50, y=270) self.secondIntensifyPassScale = LabeledScale(self, from_=1, to=10) self.secondIntensifyPassScale.place(x=250, y=250) thresholdLabel = Label(text="Threshold:") thresholdLabel.place(x=50, y=320) self.thresholdScale = LabeledScale(self, from_=1, to=10) self.thresholdScale.place(x=250, y=300) self.thresholdScale.scale.set(5) powerLabel = Label(text="Power:") powerLabel.place(x=50, y=370) self.powerScale = LabeledScale(self, from_=2, to=5) self.powerScale.place(x=250, y=350)
class FakeDeviceApp(Frame): MIN_X = 0 MAX_X = 50 MIN_Y = 0 MAX_Y = 100 MIN_Z = 0 MAX_Z = 200 def __init__(self, parent): Frame.__init__(self, parent, background='white') self.parent = parent self.init_ui() def init_ui(self): self.parent.title('Fake Device') self.style = Style() self.style.theme_use('default') self.pack(fill=BOTH, expand=1) x_scale = Scale(self, from_=self.MIN_X, to=self.MAX_X, command=self.on_scale_x) x_scale.place(x=0, y=0) y_scale = Scale(self, from_=self.MIN_Y, to=self.MAX_Y, command=self.on_scale_y) y_scale.place(x=0, y=20) z_scale = Scale(self, from_=self.MIN_Z, to=self.MAX_Z, command=self.on_scale_z) z_scale.place(x=0, y=40) angle_scale = Scale(self, from_=0, to=math.pi / 2, command=self.on_scale_angle) angle_scale.place(x=0, y=80) self.x_var = IntVar() self.x_label = Label(self, text=0, textvariable=self.x_var) self.x_label.place(x=100, y=0) self.y_var = IntVar() self.y_label = Label(self, text=0, textvariable=self.y_var) self.y_label.place(x=100, y=20) self.z_var = IntVar() self.z_label = Label(self, text=0, textvariable=self.z_var) self.z_label.place(x=100, y=40) self.angle_var = DoubleVar() self.angle_label = Label(self, text=0, textvariable=self.angle_var) self.angle_label.place(x=100, y=80) self.button = Button(self, text='test', command=self.on_button) self.button.place(x=0, y=100) def on_button(self): print('hello') def on_scale_angle(self, val): v = float(val) self.angle_var.set(v) self.update() def on_scale_x(self, val): v = int(float(val)) self.x_var.set(v) self.update() def on_scale_y(self, val): v = int(float(val)) self.y_var.set(v) self.update() def on_scale_z(self, val): v = int(float(val)) self.z_var.set(v) self.update() def update(self): x = self.x_var.get() y = self.y_var.get() z = self.z_var.get() angle = self.angle_var.get() sensor = events.sensor_storage sensor.reset() if not (x == 0 and y == 0 and z == 0): index_pos = [x, y, z] sensor.index_finger_pos = index_pos sensor.cmd_angle = angle
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)