def initUI(self): self.parent.title("Buttons") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=GROOVE, borderwidth=5) frame.pack(fill=BOTH, expand=1) self.pack(fill = BOTH, expand = 1) self.imageLabel = Label(frame, image = "") self.imageLabel.pack(fill=BOTH, expand=1) closeButton = Button(self, text="Close") closeButton.pack(side=RIGHT) okButton = Button(self, text="OK") okButton.pack(side=RIGHT) options = [item for item in dir(cv2.cv) if item.startswith("CV_CAP_PROP")] option = OptionMenu(self, self.key, *options) self.key.set(options[0]) option.pack(side="left") spin = Spinbox(self, from_=0, to=1, increment=0.05) self.val = spin.get() spin.pack(side="left")
class binaryErosionApp: def __init__(self, parent): self.parent = parent self.frame = Frame(self.parent) self.parent.title("Binary Erosion") self.initUI() def initUI(self): #Create 3x3 Grid for columns in range(0, 3): self.parent.columnconfigure(columns, pad = 14) for rows in range(0, 3): self.parent.rowconfigure(rows, pad = 14) #Add Noise Options binaryErosion1 = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Binary Erosion 1", command = self.binaryErosion1Clicked) binaryErosion2 = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Binary Erosion 2", command = self.binaryErosion2Clicked) binaryErosion1.grid(row = 1, column = 1, padx = 10, pady = 10, sticky = 'w') binaryErosion2.grid(row = 1, column = 2, padx = 10, pady = 10, sticky = 'w') self.frame.pack() def binaryErosion1Clicked(self): global _img, red, green, blue structure = zeros((20, 20)) structure[range(20), range(20)] = 1.0 red = where(red[:,:] > 255.0 * 0.6, 1.0, 0.0) green = where(green[:,:] > 255.0 * 0.6, 1.0, 0.0) blue = where(blue[:,:] > 255.0 * 0.6, 1.0, 0.0) for a in range(0, _img.shape[0]): for b in range(0, _img.shape[1]): _img[a, b, 0] = (red[a, b] * 255.0).astype('uint8') _img[a, b, 1] = (green[a, b] * 255.0).astype('uint8') _img[a, b, 2] = (blue[a, b] * 255.0).astype('uint8') updateImage() def binaryErosion2Clicked(self): global _img, red, green, blue structure = zeros((20, 20)) structure[range(20), range(20)] = 1.0 red = where(red[:,:] > 255.0 * 0.6, 1.0, 0.0) green = where(green[:,:] > 255.0 * 0.6, 1.0, 0.0) blue = where(blue[:,:] > 255.0 * 0.6, 1.0, 0.0) red = ndimage.binary_erosion(red, structure) green = ndimage.binary_erosion(green, structure) blue = ndimage.binary_erosion(blue, structure) for a in range(0, _img.shape[0]): for b in range(0, _img.shape[1]): _img[a, b, 0] = (red[a, b] * 255.0).astype('uint8') _img[a, b, 1] = (green[a, b] * 255.0).astype('uint8') _img[a, b, 2] = (blue[a, b] * 255.0).astype('uint8') updateImage()
def populate(self): """ Renders form :return: """ row = 0 group = LabelFrame(self.scrolledFrame, padx=5, pady=5) group.pack(fill=X, padx=10, pady=10) for field_name, value in self.data.iteritems(): frame = Frame(group) frame.pack(anchor=N, fill=X) # Render label lab = Label(frame, width=15, text=field_name) lab.pack(anchor='w', side=LEFT, padx=2, pady=2) # Guess the entry type entry, var_type = self.get_type(value) # Convert list to comma separated string if var_type == 'list': value = ','.join(str(e) for e in value) # Build input if var_type == 'bool': self.checkbox(entry, value, options=[True, False], group=frame) else: self.input(entry, group=frame, value=value) if field_name in self.entries: self.entries[field_name] = (field_name, entry, var_type) else: self.entries.update( {field_name: (field_name, entry, var_type)}) row += 1
def initUI(self): #some aesthetic definitions self.parent.title("Message Responder") self.style = Style() self.style.theme_use("classic") #building frame frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) self.pack(fill=BOTH, expand=True) #adding some widgets label = Label(frame, text=self.text, wraplength=495, justify=LEFT) label.pack() self.textBox = Text(frame, height=2, width=495) self.textBox.pack(side=BOTTOM) #self.textBox.insert(END, '#enter ye comments here') labelBox = Label(frame, text="Actual Results:") labelBox.pack(anchor=W, side=BOTTOM) passButton = Button(self, text="PASS", command=self.btnClickedPass) passButton.pack(side=RIGHT, padx=5, pady=5) failButton = Button(self, text="FAIL", command=self.btnClickedFail) failButton.pack(side=RIGHT)
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) #We create another Frame widget. #This widget takes the bulk of the area. #We change the border of the frame so that the frame is visible. #By default it is flat. self.pack(fill=BOTH, expand=1) closeButton = Button(self, text="Close") closeButton.pack(side=RIGHT, padx=5, pady=5) #A closeButton is created. #It is put into a horizontal box. #The side parameter will create a horizontal box layout, in which the button is placed to the right of the box. #The padx and the pady parameters will put some space between the widgets. #The padx puts some space between the button widgets and between the closeButton and the right border of the root window. #The pady puts some space between the button widgets and the borders of the frame and the root window. okButton = Button(self, text="OK") okButton.pack(side=RIGHT)
def __init__(self, master, customers, payments, refresh): Toplevel.__init__(self,master) self.root = master self.refresh = refresh self.title("Check In") self.iconname = "Check In" self.name = StringVar() # variable for customer self.customers = customers # customers object self.payments = payments self.names = [] self.workout = StringVar() self.workouts = [] self.workouts_form = [] self.date = StringVar() self.date.set(strftime("%m/%d/%Y")) self.refresh_time = 15 # in minutes self.output = '' # for the output label at the bottom self.schedule = Schedule() self.logger = Logger() #throws IOError if file is open inf = Frame(self) inf.pack(padx=10,pady=10,side='top') Label(inf, text="Name:").grid(row=0,column=0,sticky=E,ipady=2,pady=2,padx=10) Label(inf, text='Date:').grid(row=1,column=0,sticky=E,ipady=2,pady=2,padx=10) Label(inf, text="Workout:").grid(row=2,column=0,sticky=E,ipady=2,pady=2,padx=10) self.name_cb = Combobox(inf, textvariable=self.name, width=30, values=self.names) self.name_cb.grid(row=0,column=1,sticky=W,columnspan=2) self.date_ent = Entry(inf, textvariable=self.date) self.date_ent.grid(row=1,column=1,sticky=W) self.date_ent.bind('<FocusOut>', self.update_workouts) Button(inf,text='Edit', command=self.enable_date_ent).grid(row=1,column=2,sticky=E) self.workout_cb = Combobox(inf, textvariable=self.workout, width=30, values=self.workouts_form,state='readonly') self.workout_cb.grid(row=2,column=1,sticky=W,columnspan=2) self.log_btn=Button(inf,text="Log Workout",command=self.log,width=12) self.log_btn.grid(row=3,column=1,columnspan=2,pady=4,sticky='ew') stf = Frame(self) stf.pack(padx=10,pady=10,fill='x',side='top') self.scrolled_text = ScrolledText(stf,height=15,width=50,wrap='word',state='disabled') self.scrolled_text.pack(expand=True,fill='both') self.update_workouts() self.update_names() self.bind('<Return>',self.log) self.name_cb.focus_set() # set the focus here when created #disable the date field self.disable_date_ent() #start time caller self.time_caller()
def initUI(self): self.parent.title("Example") self.pack(fill=BOTH, expand=1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) #okButton = Button(self, text = "OK") #okButton.place(x = self.width - 200, y = self.height - 100) #quitButton = Button(self.parent, text = "QUIT", command = self.endCommand) #quitButton.place(x = self.width - 100, y = self.height - 100) scale = 0.75 self.wow_pic = Image.open("hd_1.jpg") self.wow_pic = self.wow_pic.resize((self.width, self.height)) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image=self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x=0, y=0) info_x = int(self.width * scale) + 20
def initUI(self): #some aesthetic definitions self.parent.title("Message Responder") self.style = Style() self.style.theme_use("classic") #building frame frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) self.pack(fill=BOTH, expand=True) #adding some widgets label = Label(frame, text = self.text, wraplength = 495, justify = LEFT) label.pack() self.textBox = Text(frame, height = 2, width = 495) self.textBox.pack(side = BOTTOM) #self.textBox.insert(END, '#enter ye comments here') labelBox = Label(frame, text = "Actual Results:") labelBox.pack(anchor = W, side = BOTTOM) passButton = Button(self, text="PASS", command=self.btnClickedPass) passButton.pack(side=RIGHT, padx=5, pady=5) failButton = Button(self, text="FAIL", command=self.btnClickedFail) failButton.pack(side=RIGHT)
def initUI(self): self.parent.title("Example") self.pack(fill=BOTH, expand = 1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) okButton = Button(self, text = "OK") okButton.place(x = self.width - 200, y = self.height - 100) quitButton = Button(self.parent, text = "QUIT") quitButton.place(x = self.width - 100, y = self.height - 100) scale = 0.75 self.wow_pic = Image.open("hd_1.jpg") self.wow_pic = self.wow_pic.resize((int(self.width*scale), int(self.height*scale))) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image = self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x = 10, y = 10) info_x = int(self.width*scale) + 20 label_text_area = Tkinter.Label(self, text = "Message received:") label_text_area.place(x = info_x, y = 10) self.text_area = Tkinter.Text(self, height = 10, width = 40) self.text_area.place(x = info_x, y = 30)
def initUI(self): self.pack(fill=BOTH, expand=1) #create special frame for buttons at the top frame = Frame(self) frame.pack(fill=X) search = Entry(frame) def callback(): #create new window main(Search.SearchFrontPage(search.get())) b = Button(frame, text="Search", width=5, command=callback) b.pack(side=RIGHT) search.pack(side=RIGHT) def login(): #change login credentials self.credentials = reddituserpass.main() self.parent.destroy() login = Button(frame, text="Login", width=5, command=login) login.pack(side=LEFT) self.drawWindow()
def initUI(self): self.parent.title("MyStock") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) menubar = Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Menu(menubar) fileMenu.add_command(label="Exit", command=self.onExit) menubar.add_cascade(label="File", menu=fileMenu) submenu= Menu(fileMenu) submenu.add_command(label="New feed") submenu.add_command(label="Bookmarks") submenu.add_command(label="Mail") fileMenu.add_cascade(label='Import', menu=submenu, underline=0) fileMenu.add_separator() closeButton = Button(self, text="Close", command=self.quit) closeButton.pack(side=RIGHT, padx=5, pady=5) okButton = Button(self, text="OK") okButton.pack(side=RIGHT) self.pack(fill=BOTH, expand=1) self.centerWindow()
def documentation(version, w, h): def _setdoc(evt): w = evt.widget index = int(w.curselection()[0]) doc = w.get(index) textfield.config(state=NORMAL) textfield.delete('1.0', END) textfield.insert('1.0', docdic[doc]) textfield.config(state=DISABLED) r = Toplevel() w = int(w/2) h = int(h/2) r.geometry('{}x{}+{}+{}'.format(w, h, int(w/2), int(h/2))) r.wm_title('Documentation accpy version {}'.format(version)) lf = Frame(r) lf.pack(side=LEFT, fill=BOTH, expand=False) rf = Frame(r) rf.pack(side=RIGHT, fill=BOTH, expand=True) docmenuopts = ['General', 'Lattice editor', 'Citation'] docmenu = Listbox(lf) for entry in docmenuopts: docmenu.insert(END, entry) docmenu.pack(fill=BOTH, expand=True) docmenu.bind('<<ListboxSelect>>', _setdoc) scrollbar = Scrollbar(orient="vertical") textfield = Text(rf, xscrollcommand=scrollbar.set) textfield.pack(fill=BOTH, expand=True)
def initUI(self): self.parent.title("Pycollect") self.pack(fill=BOTH) menubar = Menu(self.parent) self.parent.config(menu=menubar) filemenu = Menu(menubar) filemenu.add_command(label="Open", command=self.open_database) filemenu.add_command(label="Exit", command=self.on_exit) menubar.add_cascade(label="File", menu=filemenu) frame1 = Frame(self) frame1.pack(fill=X) self.game_count = StringVar() game_count_label = Label(frame1, textvariable=self.game_count).pack() frame2 = Frame(self) frame2.pack(fill=X, side=LEFT, expand=True) self.game_list = Listbox(frame2) self.game_list.pack(fill=Y, side=LEFT, expand=True) # Events self.bind('<<update_game_count>>', self.update_game_count) self.bind('<<update_game_list>>', self.update_game_list)
class playar(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.filenm=None self.pack(fill=BOTH, expand=1) self.parent = parent self.initplayer() def initplayer(self): self.videoFrame = Frame(self, width=800, height=480) self.videoFrame.pack(side="top", fill="both", expand=True) self.buttonframe = Frame(self, padding="2 2 11 11") self.buttonframe.pack(side="bottom", fill="x", expand=True) self.selectbutton = Button(self.buttonframe, text="Select") self.selectbutton.grid(column=0, row=0, sticky=W) self.playbutton = Button(self.buttonframe, text="Play").grid(column=1, row=0, sticky=W) for child in self.buttonframe.winfo_children(): child.grid_configure(padx=5, pady=5) self.buttonframe.rowconfigure(0, weight=1) self.buttonframe.columnconfigure(0, weight=1) self.buttonframe.columnconfigure(1, weight=1) def setwh(self,w,h): self.videoFrame.configure(width=w, height=h) def quit(self): print "QUIT CALLED" pg.quit() self.destroy()
def _create_help_tab(self, n): #================================== # Help tab layer_b1 = Frame(n) layer_b1.pack(side=TOP) explain = [ """ β: measure of relative risk of the stock with respect to the market (S&P500)\n. α: measure of the excess return with respect to the benchmark. Eq: R_i^stock="α"+"β x " R_i^market+ε_i R2: measure of how well the the returns of a stock is explained by the returns of the benchmark. Volatility: Standard deviation of the returned stocks Momentum: measure of the past returns over a certain period of time. More details @ http://gouthamanbalaraman.com/blog/calculating-stock-beta.html """ ] definition = LabelFrame(layer_b1, text="Definitions:") definition.pack(side=TOP, fill=BOTH) lbl = Label(definition, wraplength='10i', justify=LEFT, anchor=N, text=''.join(explain)) lbl.pack(anchor=NW) msg = [ """ Created by Sandeep Joshi for class FE520 Under guidance of Prof. Peter Lin @Stevens 2015 Special thanks to following people/ resources on the net: • Sentdex @Youtube • http://gouthamanbalaraman.com/blog/calculating-stock-beta.html • http://www.johnwittenauer.net/a-simple-time-series-analysis-of-the-sp-500-index/ • http://francescopochetti.com/category/stock-project/ • Moshe from SO -> http://stackoverflow.com/users/875832/moshe """ ] credits = LabelFrame(layer_b1, text="Credits:") credits.pack(side=TOP, fill=BOTH) lbl = Label(credits, wraplength='10i', justify=LEFT, anchor=S, text=''.join(msg)) lbl.pack(anchor=NW) n.add(layer_b1, text="Help/ Credits", underline=0, padding=2)
def initUI(self): self.parent.title("Book downloader") self.style = Style() self.style.theme_use("default") framesearch = Frame(self) framesearch.pack(fill=BOTH) search_label = Label(framesearch, text="Filter books:", padx=5, pady=5, width=15) search_label.pack(side=LEFT) self.search_entry = Entry(framesearch) self.search_entry.pack(side=RIGHT, fill=X) self.search_entry.bind("<Return>", self.searchHandler) #self.search_entry.bind("<Key>", self.searchHandler) framelist = Frame(self, relief=RAISED, borderwidth=1) framelist.pack(fill=BOTH, expand=True) self.lb = Listbox(framelist, height=30) scrollbar = Scrollbar(framelist) scrollbar.pack(side=RIGHT, fill=Y) self.lb.config(yscrollcommand=scrollbar.set) scrollbar.config(command=self.lb.yview) self.loadLibrary() for b in self.book_list: self.lb.insert(END, b[0]) self.lb.pack(fill=BOTH) self.pack(fill=BOTH, expand=True) DownButton = Button(self, text="Download", command=self.downloadAction) DownButton.pack(side=RIGHT)
def checkbox(self, entry, value, options, group=None): """ Renders a checkbox input :param value: :param entry: :param options: :param group: :return: """ if group is None: group = self.root Btnframe = Frame(group) Btnframe.pack(side=LEFT) col = 0 for option in options: if isinstance(option, bool): option_text = 'No' if not option else 'Yes' else: option_text = option button = Radiobutton(Btnframe, text=option_text, padx=20, variable=entry, value=option) button.grid(row=0, column=col) if option == value: button.select() col += 1
def initUI(self): self.parent.title("Example") self.pack(fill=BOTH, expand=1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) okButton = Button(self, text="OK") okButton.place(x=self.width - 200, y=self.height - 100) quitButton = Button(self.parent, text="QUIT") quitButton.place(x=self.width - 100, y=self.height - 100) scale = 0.75 self.wow_pic = Image.open("hd_1.jpg") self.wow_pic = self.wow_pic.resize( (int(self.width * scale), int(self.height * scale))) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image=self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x=10, y=10) info_x = int(self.width * scale) + 20 label_text_area = Tkinter.Label(self, text="Message received:") label_text_area.place(x=info_x, y=10) self.text_area = Tkinter.Text(self, height=10, width=40) self.text_area.place(x=info_x, y=30)
def initUI(self): self.parent.title("Mystery Room") self.pack(fill=BOTH, expand = 1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) #okButton = Button(self, text = "OK") #okButton.place(x = self.width - 200, y = self.height - 100) #quitButton = Button(self.parent, text = "QUIT", command = self.endCommand) #quitButton.place(x = self.width - 100, y = self.height - 100) scale = 0.75 self.wow_pic = Image.open("/home/pi/demo2/hd_1.jpg") self.wow_pic = self.wow_pic.resize((self.width, self.height)) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image = self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x = 0, y = 0) info_x = int(self.width*scale) + 20
def __init__(self, master, track, sequencer): TrackFrame.__init__(self, master, track) self.id_label = Label(self, text=str(track.id)) self.id_label.pack(side='left') self.instrument_label = Label(self, text=str(track.instrument_tone), width=3) self.instrument_label.pack(side='left') mute_var = IntVar() self.mute_toggle = Checkbutton(self, command=lambda: check_cmd(track, mute_var), variable=mute_var) self.mute_toggle.pack(side='left') mute_var.set(not track.mute) rhythm_frame = Frame(self) rhythm_frame.pack(side='right') subdivision = sequencer.measure_resolution / sequencer.beats_per_measure self.buttons = [] for b in range(0, len(self.track.rhythms)): button = RhythmButton(rhythm_frame, track, b, not b % subdivision) self.buttons.append(button) button.grid(row=0, column=b, padx=1) self.beat = 0
def initUI(self): #<standard set up> self.parent.title("Buttons") self.style = Style() self.style.theme_use("default") #</standard set up> #if you put buttons here, it will initiate the buttons. #then it will initiate the frame. You would get two columns. #buttons appear in the second "lowered" area and not the raised frame. #<adding an additional frame> frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand =1) #</adding an additional frame> #<standard self.pack> self.pack(fill=BOTH, expand =1) #</standard self.pack> #<buttons are placed here> closeButton = Button (self, text = "Close") closeButton.pack(side=RIGHT, padx=5, pady =5) okButton = Button(self, text = "OK") okButton.pack(side=RIGHT)
def initUI(self): crawlVar = IntVar() scanVar = IntVar() dnsVar = IntVar() emailVar = IntVar() self.filename = StringVar() self.parent.title("E-Z Security Audting") self.style = Style() self.style.theme_use("default") frame = Frame(self, borderwidth=1) frame.pack(side=TOP, fill=BOTH) self.pack(side=TOP, fill=BOTH) dnsButton = Checkbutton(self, text="DNS Recon", variable=dnsVar) dnsButton.pack(fill=X) scanButton = Checkbutton(self, text="Port Scan", variable=scanVar) scanButton.pack(fill=X) crawlButton = Checkbutton(self, text="Web Crawl", variable=crawlVar) crawlButton.pack(fill=X) emailButton = Checkbutton(self, text="Email Gathering", variable=emailVar) emailButton.pack(fill=X) lab = Label(self, width=15, text="Filename", anchor='w') ent = Entry(self,textvariable=self.filename) self.pack(side=TOP, fill=X, padx=5, pady=5) lab.pack(side=LEFT) ent.pack(side=RIGHT, fill=X)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.parent.title("Twitter Judge") self.style = Style() self.style.theme_use("default") output_frame = Frame(self, relief = RIDGE, borderwidth = 1) output_frame.pack(anchor = N, fill = BOTH, expand = True) output_text = ScrolledText(output_frame) self.output_text = output_text output_text.pack(fill = BOTH, expand = True) input_frame = Frame(self, height = 32) input_frame.pack(anchor = S, fill = X, expand = False) user_label = Label(input_frame, text = "Enter username:"******"Judge!", command = lambda: judge(user_entry.get(), self)) judge_button.pack(side = RIGHT) user_entry = Entry(input_frame) user_entry.pack(fill = X, padx = 5, pady = 5, expand = True) self.pack(fill = BOTH, expand = True)
def __init__(self, *args, **kwargs): Tk.__init__(self, *args, **kwargs) self.geometry("550x550+450+150") # the container is where we'll stack a bunch of frames # on top of each other, then the one we want visible # will be raised above the others container = Frame(self) container.pack(side="top", fill="both", expand=True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.protocol('WM_DELETE_WINDOW', self.leaveCallback) # root is your root window self.frames = {} for F in (StartPage, AboutPage, CreateServer, FindServer, ChooseType, GameWindow): page_name = F.__name__ frame = F(container, self) self.frames[page_name] = frame # put all of the pages in the same location; # the one on the top of the stacking order # will be the one that is visible. frame.grid(row=0, column=0, sticky="nsew") self.show_frame("StartPage")
class NewProjectDialog(tkSimpleDialog.Dialog): def __init__(self, parent): tkSimpleDialog.Dialog.__init__(self, parent, 'New Project') self.parent = parent def buttonbox(self): box = Frame(self) btn = Button(box, text="Create", width=10, command=self.newP, default=ACTIVE) btn.pack(side=LEFT, padx=5, pady=5) box.pack() def body(self, master): self.form = Frame(self, width = 30, height=50) self.form.pack() Label(self.form, text='Project name').grid(row=0, column=0) self.e1 = Entry(self.form) self.e1.insert(0, "default") self.e1.grid(row=0, column=1) Label(self.form, text='Video file').grid(row=1, column=0) self.e2 = Entry(self.form) self.e2.grid(row=1, column=1) Label(self.form, text='Project directory').grid(row=3, column=0) self.e3 = Entry(self.form) self.e3.insert(0, os.getcwd()) self.e3.grid(row=3, column=1) Button(self.form, text="Select Video", command=self.load_file, width=17).grid(row=2, column=1) Label(self.form, text='Number of Speakers').grid(row=4, column=0) self.e4 = Listbox(self.form, selectmode = BROWSE) for item in [1, 2, 3, 4, 5, 6, 7, 8]: self.e4.insert(END, item) self.e4.grid(row=4, column=1) def load_file(self): ftypes = [('Mov files', '*.mov'), ('Mp4 files', '*.mp4'), ('Avi files', '*.avi'), ('All files', '*.*')] dlg = tkFileDialog.Open(self.parent, filetypes=ftypes) fl = dlg.show() if fl != '': self.e2.delete(0, END) self.e2.insert(0, fl) def newP(self): if len(self.e1.get())==0: ErrorDialog(self.parent, "Need a project name.") elif len(self.e2.get())==0: ErrorDialog(self.parent, "Need a video file.") elif not os.path.exists(self.e2.get()): ErrorDialog(self.parent, "Video file does not exist.") elif len(self.e3.get())==0: ErrorDialog(self.parent, "Need a project directory.") elif not os.path.isdir(self.e3.get()): ErrorDialog(self.parent, "Project directory does not exist.") elif len(self.e4.curselection())==0: ErrorDialog(self.parent, "Need to select number of speakers.") else: self.parent.getProject(Project(self.e1.get(), self.e2.get(), self.e3.get(), int(self.e4.curselection()[0])+1)) self.parent.display.config(state=NORMAL) self.parent.display.delete(1.0,END) self.parent.display.config(state=DISABLED) self.parent.num_inserted=[] self.destroy()
class Login(Frame): """******** Funcion: __init__ ************** Descripcion: Constructor de Login Parametros: self Login parent Tk Retorno: void *****************************************************""" def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() """******** Funcion: initUI ************** Descripcion: Inicia la interfaz grafica de un Login, para ello hace uso de Frames y Widgets. Parametros: self Login Retorno: void *****************************************************""" def initUI(self): self.parent.title("Pythagram: Login") self.style = Style() self.style.theme_use("default") self.frame = Frame(self, relief=RAISED) self.frame.pack(fill=BOTH, expand=1) self.instructions = Label(self.frame,text="A new Web Browser window will open, you must log-in and accept the permissions to use this app.\nThen you have to copy the code that appears and paste it on the next text box.") self.instructions.pack(fill=BOTH, padx=5,pady=5) self.codeLabel = Label(self.frame,text="Code:") self.codeLabel.pack(fill=BOTH, padx=5,pady=5) self.codeEntry = Entry(self.frame) self.codeEntry.pack(fill=BOTH, padx=5,pady=5) self.pack(fill=BOTH, expand=1) self.closeButton = Button(self, text="Cancel", command=self.quit) self.closeButton.pack(side=RIGHT, padx=5, pady=5) self.okButton = Button(self, text="OK", command=self.login) self.okButton.pack(side=RIGHT) """******** Funcion: login ************** Descripcion: Luego que el usuario ingresa su codigo de acceso, hace la solicitud al servidor para cargar su cuenta en una ventana de tipo Profile Parametros: self Retorno: Retorna... *****************************************************""" def login(self): code = self.codeEntry.get() api = InstagramAPI(code) raw = api.call_resource('users', 'info', user_id='self') data = raw['data'] self.newWindow = Toplevel(self.parent) global GlobalID GlobalID = data['id'] p = Profile(self.newWindow,api,data['id'])
def initUI(self): scrollbar = Scrollbar(self) scrollbar.pack(side=RIGHT, fill=Y) dirLabel = Label( self, text="Directory Path of all files", ) dirLabel.pack(side=TOP) fileText = Entry(self, text="test", width=90) fileText.pack(side=TOP) outputLabel = Listbox(self, yscrollcommand=scrollbar.set, width=90) outputLabel.pack(side=TOP) var = StringVar(self) var.set("format type") # initial value menu = OptionMenu(self, var, "png", "jpg") menu.pack(side=TOP) self.parent.title("Bulk Image Converter") self.style = Style() #self.style.theme_use("clam") frame = Frame(self, relief=RAISED) frame.pack(fill=NONE, expand=True) self.pack(fill=BOTH, expand=True) def image(text, var): from PIL import Image import glob, os import sys #/Users/augustus/Pictures/iep/ filepath = text print('working....\n') if not os.path.exists(filepath): print('not a file path\n' + filepath) for file in glob.glob(filepath + "/*.*"): im = Image.open(file) file = file.strip("../") file = file.strip(".jpg") file = file.strip(".jpeg") file = file.strip(".png") file = file.strip(".tiff") file = file.strip(filepath) if not os.path.exists(filepath + "output"): os.makedirs(filepath + "output") print(file) outputLabel.insert(END, file) if var == "jpg": im.save(filepath + "output/" + file + ".jpg", "JPEG") elif var == "png": im.save(filepath + "output/" + file + ".png", "PNG") else: im.save(filepath + "output/" + file + ".jpg", "JPEG") def fileTextDef(): image(fileText.get(), var.get()) okButton = Button(self, text="OK", command=fileTextDef) okButton.pack(side=RIGHT)
def _create_main_panel(self): mainPanel = Frame(self, name='main') mainPanel.pack(side=TOP, fill=BOTH, expand=Y) inpuPanel = Frame(mainPanel, name='input') inpuPanel.pack(side=TOP, fill=BOTH, expand=Y) ## File Selection bodyframe1 = Frame(inpuPanel, borderwidth=1, pad=5) bodyframe1.pack(expand=True, fill=X) pathlabel = Label(bodyframe1, bg="lightgrey", text="File: ", pady=1) pathlabel.pack(side=LEFT) # Selected file display self.path = Label(bodyframe1, bg="white", text="", width=40, padx=23, pady=1) self.path.pack(side=LEFT, fill=X, expand=True) # Browse browsebtn1 = Button(bodyframe1, text="Browse", command=self.buttonClick) browsebtn1.pack(side=RIGHT) ## Output format bodyframe3 = Frame(inpuPanel, borderwidth=1) bodyframe3.pack(expand=True, fill=X) typelabel = Label(bodyframe3, bg="lightgrey", text="Output Type: ", pady=1) typelabel.pack(side=LEFT) self.filetype = StringVar(bodyframe3) self.filetype.set("wav") options = OptionMenu(bodyframe3, self.filetype, "wav", "mp3") options.pack(side=LEFT, padx=30) trainbtn = Button(bodyframe3, text="Train", command=self.trainButton) trainbtn.pack(side=RIGHT, padx=5) ## Submit button section submitframe = Frame(inpuPanel, relief=RAISED, borderwidth=1) submitframe.pack(fill=X) cleanbtn = Button(submitframe, text="Clean", command=self.submitButton) cleanbtn.pack(padx=25, pady=10)
def buttonbox(self): box = Frame(self) btn = Button(box, text="Create", width=10, command=self.newP, default=ACTIVE) btn.pack(side=LEFT, padx=5, pady=5) box.pack()
def initUI(self): self.parent.title("Test the Gauss point") self.pack(fill=BOTH, expand=True) self.fields = \ 'bulk_modulus', \ 'scale_hardening', \ 'max_stress_in', \ 'increment_strain', \ 'Nloop', \ 'initial_confinement', \ 'reference_pressure', \ 'modulus_n', \ 'cohesion', \ 'RMC_shape_k', \ 'dilation_angle_eta', \ 'diletion_scale' default_values = \ '1E7', \ '1E3', \ '3E4', \ '1E-4', \ '2', \ '1E5', \ '1E5', \ '0.7', \ '0.0', \ '1.0', \ '1.0', \ '1.0' # ================== # Entries for User input: self.entries = [] for idx, field in enumerate(self.fields): row = Frame(self) row.pack(fill=X) labl = Label(row, text=field, width=30) labl.pack(side=LEFT, padx=5, pady=5) entry = Entry(row) entry.insert(END, default_values[idx]) entry.pack(fill=X, padx=5, expand=True) self.entries.append((field, entry)) # print field # ================== # Button for calculation frameButtonCalc = Frame(self) frameButtonCalc.pack(fill=X) calcButton = Button(frameButtonCalc, text="calculate", command=self.calculate) calcButton.pack(side=LEFT, padx=5, pady=5) # ================== # Raw Frame for plot self.canvasFrame = Frame(self) self.canvasFrame.pack(fill=BOTH, expand=True)
def initUI(self): self.parent.title("Kinect Controlled Quadcopter") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) self.pack(fill=BOTH, expand=True) run_button = Button(self, text="Run", command = self.openFile) run_button.pack(side=RIGHT)
def predict(): student = e1.get() if int(getNoSubs()) == 1: S1_CA = e2.get() S1_WE = e3.get() val = model1(student, S1_CA, S1_WE) if int(getNoSubs()) == 2: S1_CA = e2.get() S1_WE = e3.get() S2_CA = e4.get() S2_WE = e5.get() val = model2(student, S1_CA, S2_CA, S1_WE, S2_WE) if int(getNoSubs()) == 3: S1_CA = e2.get() S1_WE = e3.get() S2_CA = e4.get() S2_WE = e5.get() S3_CA = e6.get() S3_WE = e7.get() val = model3(student, S1_CA, S2_CA, S3_CA, S1_WE, S2_WE, S3_WE) print val con = "" if val > 50.0: con = "Approved" else: con = "Not Sufficient Requirenment" window = Tk() window.configure(background='#8A002E') window.title('Margov Prediction') window.geometry('300x250') # Size 200, 200 frame = Frame(window, background='#8A002E') frame.pack() Label(frame, background='#8A002E', font=("Helvetica", 14), foreground="white", text=student + "'s predicted sucess:").grid(row=0, column=0) Label(frame, background='#8A002E', font=("Helvetica", 14), foreground="white", text=val).grid(row=0, column=1) Label(frame, background='#8A002E', font=("Helvetica", 14), foreground="white", text="%").grid(row=0, column=2) Label(frame, background='#8A002E', text=con, fg="red", font=("Helvetica", 24)).grid(row=1, column=0) Button(frame, text='Quit', command=window.quit).grid(row=2, column=2, sticky=W, pady=4)
def initUI(self): self.parent.title("Team 604 Scouting App - ver. 0.2") self.style = Style() self.style.theme_use("default") frame1 = Frame(self, relief=RAISED, borderwidth=1) frame1.pack(fill=NONE, expand=1) #Key Functions dataPopulationButton = Button(self, te1xt="Data Population", command=Data_Population, width=12) dataPopulationButton.pack() teamLookupButton = Button(self, text="Export", # Export module needs to be made width=12) teamLookupButton.pack() teamRankingButton = Button(self, text="Team Ranking", command=Team_Ranking, width=12) teamRankingButton.pack() teamEntryDeletionButton = Button(self, text="Match Deletion", width=12) #TODO: Make TeamEntryDeletion GUI teamEntryDeletionButton.pack() #Formatting to look pretty frame2 = Frame(self, relief=RAISED, borderwidth=1) frame2.pack(fill=NONE, expand =1) quitButton = Button(self, text="Quit", command=self.quit) quitButton.pack(side=RIGHT, padx=15, pady=5) #TODO: Fix Button placement self.pack(fill=BOTH, expand=1)
def show(self): self.setup() #contents of dialog f = Frame(self.root) Label(f, text='Warning, Testing Dialog Boxes!', width=40).pack() Button(f, text='Close', width=10, command=self.wm_delete_window).pack(pady=15) f.pack(padx=5, pady=5) self.enable()
def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) MyButton1 = Button(frame1, text="INICIAR", width=10) MyButton1.pack(padx=200, pady=350)
def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) MyButton1 = Button(frame1, text="INICIAR", width=10) MyButton1.pack(padx=200,pady=350)
def initUI(self, parser) : # TODO required arguments # TODO repeated arguments (e.g. filenames) self.parent.title(self.progname) self.pack(fill=BOTH, expand=1) self.centerWindow() Grid.rowconfigure(self,1,weight=1) Grid.columnconfigure(self,0,weight=1) inputFrame = Frame(self) inputFrame.grid(row=0, column=0, sticky='WE') outputFrame = Frame(self) outputFrame.grid(row=1, column=0, sticky='WENS') self.outputText = ReadOnlyText(outputFrame) self.outputText.pack(fill=BOTH, expand=1) # Main controls frame mainFrame = Frame(inputFrame) mainFrame.pack(fill=BOTH, expand=1) # Auto-resize column Grid.columnconfigure(mainFrame,1,weight=1) # Ok button okButton = Button(inputFrame, text='Run', command=self.run, default='active') okButton.pack(side=RIGHT, padx=5, pady=5) # Cancel button cancelButton = Button(inputFrame, text='Exit', command=self.quit) cancelButton.pack(side=RIGHT) # Add controls to mainframe for all options for index, action in enumerate(parser._actions) : action_type = type(action).__name__ if action_type == '_HelpAction' : pass else : self.function.append(lambda v : [v]) self.variables.append(None) if action.choices : self._add_choice( mainFrame, index, action.dest, action.choices, action.default, action.option_strings[0] ) elif action_type == '_StoreTrueAction' : self._add_check( mainFrame, index, action.dest, False, action.option_strings[0] ) elif action_type == '_CountAction' : self._add_count( mainFrame, index, action.dest, 0, action.option_strings[0] ) elif action.type and action.type.__name__ == 'inputfile' : self._add_filename( mainFrame, index, action.dest, 'r', action.option_strings ) elif action.type and action.type.__name__ == 'outputfile' : self._add_filename( mainFrame, index, action.dest, 'w', action.option_strings ) else : self._add_field( mainFrame, index, action.dest )
class addNoiseApp: def __init__(self, parent): self.parent = parent self.frame = Frame(self.parent) self.parent.title("Add Noise") self.initUI() def initUI(self): #Create 3x3 Grid for columns in range(0, 3): self.parent.columnconfigure(columns, pad = 14) for rows in range(0, 3): self.parent.rowconfigure(rows, pad = 14) #Add Noise Options noise = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Noise", command = self.noiseClicked) colorNoise = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Color Noise", command = self.colorNoiseClicked) noise.grid(row = 1, column = 1, padx = 10, pady = 10, sticky = 'w') colorNoise.grid(row = 1, column = 2, padx = 10, pady = 10, sticky = 'w') self.frame.pack() def noiseClicked(self): global _img whiteNoise = where(random.random(_img.shape) > 0.9, 1.0, 0.0) #Turn into black and white nred = zeros((whiteNoise.shape[0], whiteNoise.shape[1])) ngreen = zeros((whiteNoise.shape[0], whiteNoise.shape[1])) nblue = zeros((whiteNoise.shape[0], whiteNoise.shape[1])) for a in range(whiteNoise.shape[0]): for b in range(whiteNoise.shape[1]): nred[a, b] = whiteNoise[a, b, 0] ngreen[a, b] = whiteNoise[a, b, 1] nblue[a, b] = whiteNoise[a, b, 2] for a in range(0, _img.shape[0]): for b in range(0, _img.shape[1]): whiteNoise[a, b, 0] = (nred[a, b] + ngreen[a,b] + nblue[a,b]) / 3.0 whiteNoise[a, b, 1] = (nred[a, b] + ngreen[a,b] + nblue[a,b]) / 3.0 whiteNoise[a, b, 2] = (nred[a, b] + ngreen[a,b] + nblue[a,b]) / 3.0 _img = (((_img/255.0) + whiteNoise) * 255.0).astype('uint8') updateImage() def colorNoiseClicked(self): global _img colorNoise = (where(random.random(_img.shape) > 0.9, 0.5, 0.0)) _img = (((_img/255.0) + colorNoise) * 255.0).astype('uint8') updateImage()
def control_button_widget(self): frame = Frame(self, style='button.TFrame', padding=10) frame.pack(side='top', fill=BOTH) buttons = Button(frame, text="Start", command=self._start_timer) buttons.pack(padx=5, side='left') buttons = Button(frame, text="Stop", command=self._stop_timer) buttons.pack(padx=5, side='left') buttons = Button(frame, text="Reset", command=self._reset_timer) buttons.pack(padx=5, side='left') buttons = Button(frame, text="Quit", command=self._quit_timer) buttons.pack(padx=5, side='left')
def show(self): self.setup() #contents of dialog f = Frame(self.root) Label(f, text=self.text, width=40).pack() Button(f, text='Close', width=10, command=self.close).pack(pady=15) f.pack(padx=5, pady=5) self.root.bind("<Return>", self.close) self.enable()
def _creat_top_panel(self): ## Top frame topframe = Frame(self, relief=RAISED, borderwidth=1) topframe.pack(side=TOP, fill=X) label1 = Label(topframe, justify="left", text="BleepIt", font=('times', 20)) label1.pack(fill=X)
def initUI(self): self.parent.title("Pipeline Simulator") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) self.pack(fill=BOTH, expand=1) global clockButton self.clockButton.pack(pady=10)
def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) lbl1 = Label(frame1, text="Title", width=6) lbl1.pack(side=LEFT, padx=5, pady=5) entry1 = Entry(frame1) entry1.pack(fill=X, padx=5, expand=True)
class FaceEditor(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.parent.title("Face Editor") self.pack(fill=BOTH, expand=1) self.face = Frame(self) self.state = [IntVar() for _ in range(16)] button_config = [('#99cc99', '#00ff00')]*5 + \ [('#cccc99', '#ffff00')]*5 + \ [('#cc9999', '#ff0000')]*6 button_config_base = dict(indicatoron=False, width=15, height=15, image=BitmapImage(data="#define im_width 1\n#define im_height 1\nstatic char im_bits[] = { 0x00 };")) for key, (background, selectcolor) in enumerate(button_config): button_config[key] = dict(background=background, selectcolor=selectcolor) button_config[key].update(button_config_base) self.buttons = [] for i in range(16): for x, y in leds[i]: b = Checkbutton(self.face, variable=self.state[i], command=self.recompute, onvalue=1, offvalue=0) b.configure(**button_config[i]) self.buttons.append(b) b.place(x=x*10, y=y*10) self.face.pack(fill=BOTH, expand=1) self.binvalue = Text(self, width=16, height=1, wrap=NONE) self.binvalue.configure(inactiveselectbackground=self.binvalue.cget("bg"), relief=FLAT) self.binvalue.pack(side=RIGHT) self.hexvalue = Text(self, width=4, height=1, wrap=NONE) self.hexvalue.configure(inactiveselectbackground=self.hexvalue.cget("bg"), relief=FLAT) self.hexvalue.pack(side=LEFT) self.recompute() def recompute(self): value = 0 for i, var in enumerate(self.state): value += 2**i if var.get()==1 else 0 binvalue = bin(value)[2:].zfill(16) hexvalue = hex(value)[2:].zfill(4) self.value = value self.binvalue.delete(1.0, END) self.binvalue.insert(END, binvalue) self.hexvalue.delete(1.0, END) self.hexvalue.insert(END, hexvalue) print binvalue, hexvalue
def initUI(self): self.parent.title("Simple FTP-Client") self.pack(fill=BOTH, expand=True) # self.parent.title("Buttons") #frame2 = Frame(self) #frame2.pack(anchor=W,side=LEFT) #lbl2 = Label(frame2, text="Command Line", width=6) #lbl2.pack(fill=X,anchor=W,expand=True,padx=5, pady=5) #txt2 = Text(frame2) #txt2.pack(fill=X,side=BOTTOM,pady=5, padx=5) frame3 = Frame(self, width=400, height=500) frame3.pack(side=BOTTOM,anchor=NW) lbl3 = Label(frame3, text="Command Line", width=6) lbl3.pack(fill=X,anchor=NE,expand=True,padx=5, pady=5) txt = Text(frame3) txt.pack(fill=BOTH,pady=5, padx=5) wid = frame3.winfo_id() os.system('xterm -into %d -geometry 400x400 -sb &' % wid) f1 = Frame(self) f1.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10) lb=Label(f1, text="Host:").grid(row=0, column=0) e1 = Entry(f1) e1.grid(row=0, column=1, padx=1) f2 = Frame(self) f2.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10) lb2=Label(f2, text="Username:"******"Password:"******"Port:").grid(row=0, column=2) e4 = Entry(f4) e4.grid(row=0, column=3, padx=5) connectButton = Button(self, text="Connect", command=callback) connectButton.pack(expand=True,fill=X,side=LEFT, anchor=NW, padx=10, pady=10)
def addPortfolioList(self, companies): portfolioFrame = Frame(self.stocksFrame) scrollbar = Scrollbar(portfolioFrame, orient="vertical") companyList = Listbox(portfolioFrame, yscrollcommand=scrollbar.set) scrollbar.config(command=companyList.yview) scrollbar.pack(side="right", fill="y") #lb = Listbox(root, width=50, height=20, yscrollcommand=scrollbar.set) companyList.pack(fill=X, expand=0, side=TOP, padx=PAD, pady=PAD) for company in companies: companyList.insert(END,company) portfolioFrame.pack(fill=BOTH, expand=1, side=TOP)
def main(): # método principal, chama outros métodos e os instancia root = Tk() #root.geometry("700x500+500+500") # define os parâmetros de lagura, altura e comprimento da janela app = Example(root) # trocar o uso do Frame pelo Canvas frame = Frame( root, width=700, height=500 ) # nesse caso, o tamanho do frame sobre o root é do msm tamanho do root frame.bind(centerWindow) # tentativa de chamada do metodo centerWindow frame.bind("<Button-1>", callback) frame.pack() root.mainloop()
def goal_button_widget(self): frame = Frame(self) frame.pack(padx=0, pady=0, side='top') buttons = Button(frame, text="Home Goal", command=lambda: self._goal_scored('home'), style="goal.TButton") buttons.pack(padx=5, pady=20, side='top') buttons = Button(frame, text="Away Goal", command=lambda: self._goal_scored('away'), style="goal.TButton") buttons.pack(padx=5, pady=20, side='top')
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=True) self.pack(fill=BOTH, expand=True) closeButton = Button(self, text="Close") closeButton.pack(side=RIGHT, padx=5, pady=5) okButton = Button(self, text="OK") okButton.pack(side=RIGHT)
def populate(self): """ Populate form :return: """ for key, section in self.data.iteritems(): group = LabelFrame(self.scrolledFrame, text=key, padx=5, pady=5) group.pack(fill=X, padx=10, pady=10) row = 0 for field_name, info in section.iteritems(): frame = Frame(group) frame.pack(anchor=N, fill=X) label = info['label'] value = info['value'] input_type = info['type'] # Render label lab = Label(frame, width=15, text=label) lab.pack(anchor='w', side=LEFT, padx=2, pady=2) # Guess the entry type entry, var_type = self.get_type(value) # Convert list to comma separated string if var_type == 'list': value = ','.join(str(e) for e in value) # Build input if input_type == 'text': self.input(entry, group=frame, value=value) elif input_type == 'select': self.select(entry, value, info['options'], group=frame) elif input_type == 'checkbox': self.checkbox(entry, value, options=info['options'], group=frame) if key in self.entries: self.entries[key][field_name] = (field_name, entry, var_type) else: self.entries.update( {key: { field_name: (field_name, entry, var_type) }}) row += 1
def f(marks,prb): if len(marks)!=1: print "Error" else: #states = ["A+","A","A-", "B+","B","B-","C+","C","C-", "F"] states = ["A","B","C", "F"] n_states = len(states) observations = ["Sub1:A+","Sub1:A","Sub1:A-", "Sub1:B+", "Sub1:B", "Sub1:B-", "Sub1:C+", "Sub1:C", "Sub1:C_","Sub1:F"] n_observations = len(observations) #Starting proberbilities start_probability = np.array([0.25, 0.25,0.25, 0.25]) #Transision proberbilities transition_probability = np.array([[0.4, 0.3,0.2, 0.1],[0.3, 0.4,0.2, 0.1],[0.1, 0.3,0.4, 0.2],[0.1, 0.2,0.3, 0.4]]) # Emission proberbilities are read from file emission_probability = np.array(prb) model = hmm.MultinomialHMM(n_components=n_states) model._set_startprob(start_probability) model._set_transmat(transition_probability) model._set_emissionprob(emission_probability) bob_says = marks #bob_says=[0] logprob, pred = model.decode(bob_says, algorithm="viterbi") # Display the result print "Previous Exam Result:", ", ".join(map(lambda x: observations[x], bob_says)) print "Predicted Software Engineering Result:", ", ".join(map(lambda x: states[x], pred)) ''' If C and F values are not get as a predicted then student is displayed as approved ''' if (pred[0]!=3)&(pred[0]!=2): con="Student Approved" else:con="Not Sufficient Requirement" # Create GUI window = Tk() window.configure(background='#8A002E') window.title('Margov Prediction') window.geometry('480x200') # Size 200, 200 frame = Frame(window,background='#8A002E') frame.pack() def back(): window.withdraw() Label(frame, background='#8A002E',font=("Helvetica", 14),foreground="white",text="Student's predicted success:").grid(row=0, column=0) Label(frame, background='#8A002E',font=("Helvetica", 14),foreground="white",text=map(lambda x: states[x], pred)).grid(row=0, column=1) Label(frame,background='#8A002E', text=con,fg="red",font=("Helvetica", 20)).grid(row=1, column=0) Button(frame, text='Next', command=back).grid(row=2, column=2, sticky=W, pady=4) return pred[0]
def initUI(self): self.parent.title("Chaos Dungeon Generator") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) self.pack(fill=BOTH, expand=True) closeButton = Button(self, text="Quit", command=quit) closeButton.pack(side=LEFT, padx=5, pady=5) okButton = Button(self, text="Start", command=self.generateRoom) okButton.pack(side=LEFT)
def __init__(self, master): master.minsize(width=1500, height=1500) root = Frame(master) root.pack(side=TOP, fill=BOTH) master.title('Stocks evaluation - Sandeep Joshi (FE520)') n = Notebook(root) n.enable_traversal() n.pack(fill=BOTH) self._create_stat_tab(n) self._create_help_tab(n) self.data = {} self.start = '' self.end = '' self.tickers = [] self.tree
def start(self): """ Стартовое окно виджета """ self.win = tk.Toplevel() self.win.wm_title('Добавить/Изменить комментарий для канала - %s' % self.name) frame_comment = Frame(self.win) frame_comment.pack(side=LEFT) frame_buttons = Frame(self.win) frame_buttons.pack(side=LEFT) self.text = ScrolledText.ScrolledText(frame_comment, height=5, width=50, font=tkFont.Font( family=main_font, size=size_font), wrap=WORD) self.text.pack() for item in all_values.keys(): for all_dict in all_values[item][0]: if self.name == all_values[item][0][all_dict]: if item in list_moxa: with open( 'comments/comment_%s_%s.txt' % (item, self.key), 'a+') as comment: file_log = comment.readlines() self.text.delete(1.0, tk.END) for element in file_log: self.text.insert(tk.END, element) but1 = tk.Button(frame_buttons, text="Сохранить", font=tkFont.Font(family=main_font, size=size_font), command=self.add_comment, activebackground='spring green', height=1, width=12) but2 = tk.Button(frame_buttons, text="Отмена", font=tkFont.Font(family=main_font, size=size_font), command=self.win.destroy, activebackground='salmon', height=1, width=12) but1.pack() but2.pack()
def initUI(self): self.parent.title("Text Field") self.pack(fill=BOTH, expand=True) frame1 = Frame(self, width=50, height=25) frame1.pack(fill=X, expand=True) self.scroll = Scrollbar(frame1) self.scroll.pack(side="right", fill=Y) self.text = Text(frame1) self.text.pack(fill=Y) self.scroll.config(command=self.text.yview) self.text.config(yscrollcommand=self.scroll.set) frame2 = Frame(self) frame2.pack(fill=X, expand=True) self.submit = Button(frame2, text="Start Test") self.submit.bind("<Button-1>", self.startPause) self.submit.pack(fill=X)