def __init__(self, parent, id): self.client = client = httplib2.Http( disable_ssl_certificate_validation=True) self.client.add_credentials(username, password) ## Pull View Name self.viewResp, self.viewContent = client.request( "https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json") self.viewData = json.loads(self.viewContent) print repr(self.viewData) self.countResp, self.countContent = client.request( "https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + "/count.json") self.viewResp, self.viewContent = client.request( "https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json") self.countData = json.loads(self.countContent) print repr(self.countContent) self.parent = parent print(self.parent.winfo_width()) self.label = Label(text=self.viewData["view"]["title"] + " " + str(self.countData["view_count"]["value"])) self.label.pack(fill=BOTH)
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)
def setup_general(self): '''add options part''' dct = self.user_input Label(self, text='').grid(row=9, column=0, columnspan=2) dct['feature-threshold'] = self.general_component( 'Feature threshold', 10, 0)
def initUI(self): self.parent.title("WORLD") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #pack = a geometry manager #button b = Button(self, text=" GO ", command=self.callback) b.pack(side=TOP, padx=15, pady=20) #text t = Text(self, height=3, width=40) t.pack(side=TOP, padx=15) t.insert( END, "Welcome.\nPlease select the number of years\nyou would like to run the Simulation.\n" ) #slider slider = Scale(self, from_=0, to=400, command=self.onScale) #values of slider! slider.pack(side=TOP, padx=15) self.var = IntVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack(side=TOP, padx=15)
def initUI(self): self.parent.title("Food List Editor") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=7) self.rowconfigure(4, weight=1) self.rowconfigure(5, pad=7) lbl = Label(self, text="Food List") lbl.grid(sticky=W, pady=4, padx=5) abtn = Button(self, text="Add Food", command=self.sequence) abtn.grid(row=1, column=3) dbtn = Button(self, text="Delete Food", command=self.delete_food) dbtn.grid(row=2, column=3, pady=4) upbtn = Button(self, text="Refresh", command=self.update_list) upbtn.grid(row=3, column=3) cbtn = Button(self, text="Close", command=self.close_program) cbtn.grid(row=5, column=3) scrollbar = Scrollbar(self, orient="vertical") self.lb = Listbox(self, width=50, height=20,\ yscrollcommand=scrollbar.set) scrollbar.config(command=self.lb.yview) self.make_list()
def _add_filename(self, frame, index, name, mode, option): if option: self.function[-1] = lambda v: [option, v] else: self.function[-1] = lambda v: [v] self.variables[-1] = StringVar() var = self.variables[-1] def set_name(): if mode == "r": fn = tkFileDialog.askopenfilename(initialdir=".") else: fn = tkFileDialog.asksaveasfilename(initialdir=".") var.set(fn) label = Label(frame, text=name) label.grid(row=index, column=0, sticky="W", padx=10) field_button = Frame(frame) Grid.columnconfigure(field_button, 0, weight=1) field = Entry(field_button, textvariable=var) field.grid(row=0, column=0, sticky="WE") button = Button(field_button, text="...", command=set_name, width=1, padding=0) button.grid(row=0, column=1) field_button.grid(row=index, column=1, sticky="WE")
def initUI(self): self.parent.title("AUTO TIPS") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=7) self.rowconfigure(3, weight=1) self.rowconfigure(5, pad=7) lbl = Label(self, text="Status") lbl.grid(sticky=W, pady=4, padx=5) area = Text(self) area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) abtn = Button(self, text="Drive Command", command=win3) abtn.grid(row=1, column=3) cbtn = Button(self, text="Tester Manual Control", command=win2) cbtn.grid(row=2, column=3, pady=4) dbtn = Button(self, text="Auto Run", command=AutoTIPS) dbtn.grid(row=3, column=3, pady=4) obtn = Button(self, text="OK", command=self.parent.destroy) obtn.grid(row=5, column=3)
def initUI(self): self.entries_found = [] self.parent.title("Search your command cards") self.style = Style() self.style.theme_use("default") self.pack() self.input_title = Label(self, text="Enter your command below") self.input_title.grid(row=0, columnspan=2) self.input_box = Entry(self, width=90) self.input_box.grid(row=1, column=0) self.input_box.focus() self.input_box.bind("<Key>", self.onUpdateSearch) self.search_btn = Button(self, text="Search", command=self.onSearch) self.search_btn.grid(row=1, column=1) self.output_box = Treeview(self, columns=("Example")) ysb = Scrollbar(self, orient='vertical', command=self.output_box.yview) xsb = Scrollbar(self, orient='horizontal', command=self.output_box.xview) self.output_box.configure(yscroll=ysb.set, xscroll=xsb.set) self.output_box.heading('Example', text='Example', anchor='w') self.output_box.column("#0", minwidth=0, width=0, stretch=NO) self.output_box.column("Example", minwidth=0, width=785) self.output_box.bind("<Button-1>", self.OnEntryClick) self.output_box.grid(row=3, columnspan=2) self.selected_box = Text(self, width=110, height=19) self.selected_box.grid(row=4, columnspan=2) self.gotoadd_btn = Button(self, text="Go to Add", command=self.onGoToAdd) self.gotoadd_btn.grid(row=5)
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 showHighscores(): # get top 5 scores arr = session.query(Highscores).all() for i in range(len(arr)): for j in range(i, len(arr)): if (arr[i].score > arr[j].score): arr[i], arr[j] = arr[j], arr[i] top = Toplevel() top.title('Highscores') msg = Message(top, text='Top 5 Leaderboard:') msg.pack count = 1 for i in range(5): text = str(count) text += '. ' text += str(arr[i].name) text += ': ' text += str(arr[i].score) label = Label(top, text=text) label.pack() count += 1 button = Button(top, text='Dismiss', command=top.destroy) button.pack() top.geometry('%dx%d+%d+%d' % (200, 200, 600, 300))
def initUI(self): self.parent.title("Paste IP's Here:") self.style = Style() self.style.theme_use("aqua") self.pack(fill=BOTH, expand=1) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=7) self.rowconfigure(3, weight=1) self.rowconfigure(5, pad=7) lbl = Label(self, text="Paste IP's Here:") lbl.grid(sticky=W, pady=4, padx=5) area = Text(self) area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) abtn = Button(self, text="Open", command=self.onOpen()) abtn.grid(row=1, column=3) cbtn = Button(self, text="Close") cbtn.grid(row=2, column=3, pady=4) hbtn = Button(self, text="Help") hbtn.grid(row=5, column=0, padx=5) obtn = Button(self, text="OK") obtn.grid(row=5, column=3)
def initUI(self): self.parent.title("Import RHD to Neo") self.pack(fill=BOTH, expand=True) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=7) self.rowconfigure(3, weight=1) self.rowconfigure(5, pad=7) lbl = Label(self, text="Windows") lbl.grid(sticky=W, pady=4, padx=5) area = Text(self) area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) abtn = Button(self, text="Activate") abtn.grid(row=1, column=3) cbtn = Button(self, text="Close") cbtn.grid(row=2, column=3, pady=4) hbtn = Button(self, text="Help") hbtn.grid(row=5, column=0, padx=5) obtn = Button(self, text="OK") obtn.grid(row=5, column=3)
def initUI(self, parent): self.style = Style() self.style.theme_use("classic") Style().configure("TLabel", font='serif 10', weight="Bold") # creating layout from frames self.frame1 = Frame(parent) self.frame1.pack(fill="both", expand="True") self.frame2 = Frame(parent) self.frame2.pack(fill="both", expand="True") # putting text in frame1 Label(self.frame1, text="Completed!! \n Do you want to EXIT?", font="Helvetica 10 bold").pack(side="bottom", anchor='center') # putting button in frame2 self.b10 = Button(self.frame2, text="Yes", width=7, state="active", font='serif 10', command=self.yes_clicked) self.b11 = Button(self.frame2, text="No", width=7, state="active", font='serif 10', command=self.no_clicked) self.b10.pack(side="left", padx=8) self.b11.pack(side="left", padx=8) self.b10.bind('<Return>', self.yes_clicked) self.b11.bind('<Return>', self.no_clicked)
def __init__(self, panedwindow, sash_index, disallow_dragging=False, on_click=None, **kw): image = kw.pop("image", None) Frame.__init__(self, panedwindow, class_="Handle", **kw) self._sash_index = sash_index if image: self._event_area = Label(self, image=image) self._event_area.pack() else: self._event_area = self self._center = int(self._event_area.winfo_reqwidth() / 2), int( self._event_area.winfo_reqheight() / 2) if disallow_dragging: if on_click: self._event_area.bind('<Button-1>', lambda event: on_click()) else: self._event_area.bind('<Button-1>', self._initiate_motion) self._event_area.bind('<B1-Motion>', self._on_dragging) self._event_area.bind('<ButtonRelease-1>', self.master._on_release)
def __init__(self, parent, question): Frame.__init__(self, parent) self.answer = StringVar() self.question = Label(self, text=question, style='Title.TLabel') self.question.grid(column=0, row=0, padx=10, pady=10, sticky='w') self.configure(background='yellow') self.question.configure(background='yellow') self.bar = Separator(self, orient=HORIZONTAL) self.bar.grid(column=0, row=2, columnspan=2, padx=5, pady=5, sticky='nsew') self.ok = Button(self, text='OK', command=self.OkBut) self.ok.grid(column=0, row=3, padx=5, pady=5) self.grid() # Center the Window parent.update_idletasks() xp = (parent.winfo_screenwidth() / 2) - (self.winfo_width() / 2) - 8 yp = (parent.winfo_screenheight() / 2) - (self.winfo_height() / 2) - 20 parent.geometry('{0}x{1}+{2}+{3}'.format(self.winfo_width(), self.winfo_height(), xp, yp)) self.update() parent.mainloop()
def img_label(self, path="cat1.jpeg"): window = Toplevel() #window.geometry('400x400') window.title('image') img = ImageTk.PhotoImage(Image.open(path)) label = Label(window, image=img) label.pack() window.mainloop()
def _add_choice(self, frame, index, name, choices, default, option): self.function[-1] = lambda v: [option, v] label = Label(frame, text=name) label.grid(row=index, column=0, sticky="W", padx=10) field = Combobox(frame, values=choices, state="readonly") field.set(default) field.grid(row=index, column=1, sticky="WE") self.variables[-1] = field
def __init__(self, master=Tk()): Frame.__init__(self, master) self.grid() self.image = Image.open("test.jpg") self.photo = PhotoImage(self.image) self.label = Label(master, image=self.photo) self.label.image = photo self.label.pack()
def _add_check(self, frame, index, name, default, option) : self.variables[-1] = StringVar() self.variables[-1].set('') label = Label(frame, text=name) label.grid(row=index, column=0, sticky='W', padx=10) field = Checkbutton(frame, variable=self.variables[-1], onvalue=option, offvalue='') field.grid(row=index, column=1, sticky='WE')
def _add_count(self, frame, index, name, default, option) : self.function[-1] = lambda v : [option]*int(v) self.variables[-1] = StringVar() self.variables[-1].set(default) label = Label(frame, text=name) label.grid(row=index, column=0, sticky='W', padx=10) field = Spinbox(frame, from_=0, to=100, textvariable=self.variables[-1]) field.grid(row=index, column=1, sticky='WE')
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.cell_number_var = StringVar() self.elapsed_time_var = StringVar() self.polyomino_number_var = StringVar() number_label = Label(self, text='Number of cells:') self.add_to_grid(0, 0, number_label, sticky=E) number_entry = Entry(self, width=5, textvariable=self.cell_number_var) self.cell_number_var.set(4) self.add_to_grid(1, 0, number_entry, sticky=W) generate_button = Button(self, text='Generate Polyominoes', command=self.generate_polyominoes) self.add_to_grid(2, 0, generate_button, sticky=E) self.add_separator(1) time_message = Label(self, text='Elapsed time:') self.add_to_grid(0, 2, time_message, sticky=E) elapsed_time = Label(self, textvariable=self.elapsed_time_var, width=15) self.add_to_grid(1, 2, elapsed_time, sticky=W) polyomino_message = Label(self, text='Number of generated polyominoes:') self.add_to_grid(0, 3, polyomino_message, sticky=E) polyomino_number = Label(self, textvariable=self.polyomino_number_var, width=10) self.add_to_grid(1, 3, polyomino_number, sticky=W) self.add_separator(4) close_button = Button(self, text='Close', command=self.parent.destroy) self.add_to_grid(0, 5, close_button, columnspan=3)
def estimate(self, event): # estimating phase try: for wid in self.frame3.winfo_children(): wid.destroy() self.label4 = Label(self.frame3, text=" Top 3 Estimates:", font='Helvetica 10 bold') self.label4.pack(in_=self.frame3) except: print 'ERROR !!!!' widget = event.widget selection = widget.curselection() picked = widget.get(selection[0]) x = picked.split('(') dict_ = {} for cat in self.course_list: # getting estimating scores dict_[cat] = self.classifier_obj.prob(x[1], cat) * 10 scores = dict_ sorted_scores = sorted(scores.items(), key=operator.itemgetter(1), reverse=True) # sorting dictionary top_3 = sorted_scores[0:3] # getting top 3 scores print top_3 dict_temp = {x[0].split(' ')[0]: top_3} m = 1 for key, value in dict_temp.items(): # adding items as labels for i in value: department, score = i if department != key: # checking if it is true estimation or not color = 'red' else: color = 'green' self.first_element = Label(self.frame3, text=department + ':' + str(score), font='Helvetica 15 bold', background=color, width=20) if m == 1: self.first_element.pack(in_=self.frame3) elif m == 2: self.first_element.pack(in_=self.frame3) elif m == 3: self.first_element.pack(in_=self.frame3) m = m + 1
def bigger_preview(): image = Image.open( get_image_from_internet_binary( u"%s%s" % (main_url, self.current_image[u"file_url"]))) photo = ImageTk.PhotoImage(image) self.bigpreview = Toplevel(self) labelu = Label(self.bigpreview, image=photo) labelu.image = photo labelu.pack(fill=Y, expand=0, side=LEFT)
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 _add_field(self, frame, index, name): self.variables[-1] = StringVar() label = Label(frame, text=name) label.grid(row=index, column=0, sticky="W", padx=10) field = Entry(frame) field.grid(row=index, column=1, sticky="WE", textvariable=self.variables[-1])
def update_symbols(self, text, timestamp = None, inspeakers = None, inidea = None): #Stores timestamp if timestamp == None: timestamp = self.player.query_position(gst.FORMAT_TIME, None)[0] self.display.mark_set("mine", "1.%d" % floor(timestamp/1000000000.0/.2)) if len(str(self.display.get("mine"))) == 0: self.display.config(state=NORMAL) self.display.delete("mine") self.display.config(state=DISABLED) #Stores current speakers current_speakers = [] store_speakers = [] if inspeakers == None: for i in range(len(self.speakers)): if self.checkvars[i].get() == 1: current_speakers.append((self.alpha[i], self.colors[i])) store_speakers.append(i+1) else: store_speakers = inspeakers current_speakers = [(self.alpha[i-1], self.colors[i-1]) for i in inspeakers] tempstr = "" for sp in current_speakers: tempstr += sp[0] if inidea or (inidea == None and self.idea_var.get()==1): tmplbl = Label(self.display, name="%u" % self.imgID, image=self.imagemap[text], text=tempstr, compound="bottom", background="yellow") else: tmplbl = Label(self.display, name="%u" % self.imgID, image=self.imagemap[text], text=tempstr, compound="bottom", background="white") tmpwin = self.display.window_create('mine', window=tmplbl) tmplbl.bind("<Button-3>", self.deleteSymbol) #right click tmplbl.bind("<Button-1>", lambda ev: EditSymDialog(self, ev)) #left click self.imgID += 1 idea = False if inidea == True or (inidea == None and self.idea_var.get() == 1): idea = True if self.project != None: curr = Code(timestamp/1000000000.0, text, store_speakers, idea) self.project.seq.insert(curr) self.imgMap[self.imgID-1] = timestamp/1000000000.0
def initUI(self): self.parent.title("Catalog Analyzer") Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10') self.columnconfigure(0, pad=3) self.columnconfigure(1, pad=3) self.columnconfigure(2, pad=3) self.columnconfigure(3, pad=3) self.rowconfigure(0, pad=3) self.rowconfigure(1, pad=3) ## ENTRY ### band1Label = Label(self, text='Band 1') band1Label.grid(row=0, column=0) band1Entry = Entry(self) band1Entry.grid(row=0, column=1) band2Label = Label(self, text='Band 2') band2Label.grid(row=0, column=2) band2Entry = Entry(self) band2Entry.grid(row=0, column=3 ) band3Label = Label(self, text='Band 3') band3Label.grid(row=1, column=0) band3Entry = Entry(self) band3Entry.grid(row=1, column=1) band4Label = Label(self, text='Band 4') band4Label.grid(row=1, column=2) band4Entry = Entry(self) band4Entry.grid(row=1, column=3 ) ## BUTTONS ### sizeMagButton = Button(self, text ="Size Magnitude", command = sizeMag) sizeMagButton.grid(row=2 , column = 0) hrButton = Button(self, text ="H-R Diagram", command = HR) hrButton.grid(row=2 , column = 1) colorColorButton = Button(self, text='Color Color', command=colorColor) colorColorButton.grid(row=2 , column = 2) self.pack()
def initUI(self): self.parent.title("Driver Control Panel") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.label = Label(self, text="Bus Tracker - Driver", font=('Helvetica', '21')) self.label.grid(row=0, column=0) self.l = Label(self, text="Bus Line", font=('Helvetica', '18')) self.l.grid(row=1, column=0) self.e = Entry(self, font=('Helvetica', '18')) self.e.grid(row=2, column=0) self.l = Label(self, text="Direction", font=('Helvetica', '18')) self.l.grid(row=3, column=0) # add vertical space self.l = Label(self, text="", font=('Helvetica', '14')) self.l.grid(row=5, column=0) self.e = Entry(self, font=('Helvetica', '18')) self.e.grid(row=4, column=0) self.search = Button(self, text="Start") self.search.grid(row=6, column=0) ######### used for debug ########## # add vertical space self.l2 = Label(self, text="", font=('Helvetica', '14')) self.l2.grid(row=5, column=0) self.turnOnBtn = Button(self, text="Turn On") self.turnOnBtn["command"] = self.turnOn self.turnOnBtn.grid(row=6, column=0) self.startBtn = Button(self, text="Start") self.startBtn["command"] = self.start self.startBtn.grid(row=7, column=0) self.turnOffBtn = Button(self, text="Turn Off") self.turnOffBtn["command"] = self.turnOff self.turnOffBtn.grid(row=8, column=0)
def init_ui(root): root.geometry("500x500+500+500") f = Frame(root) f.pack(fill=BOTH, expand=True) frame1 = Frame(f) frame1.pack(fill=X) lbl1 = Label(frame1, text="Enter url here", width=6) lbl1.pack(side=LEFT, padx=5, pady=5) entry1 = Entry(frame1) entry1.pack(fill=X, padx=5, expand=True) frame3 = Frame(f) frame3.pack(fill=X) lbl3 = Label(frame3, text="Keywords", width=6) lbl3.pack(side=LEFT, anchor=N, padx=5, pady=5) txt = Text(frame3) txt.pack(fill=BOTH, pady=5, padx=5, expand=True) def on_click(): url = entry1.get() print url keywords = get_keywords(url) res = ", ".join(keywords) print res txt.delete("1.0", END) txt.insert("1.0", res) def on_click2(): entry1.delete(0, END) frame2 = Frame(f) frame2.pack(fill=X) tk.Button(frame2, text="Get keywords", command=on_click).pack() tk.Button(frame2, text="Clear", command=on_click2).pack()
def timer_widget(self): """ Make the time lable. """ l = Label(self, textvariable=self.timestr, background="White", font=('Helvetica', 32), anchor='center', relief='sunken') self._set_time(self._elapsedtime) l.pack(fill=X, expand=NO, pady=50, padx=50)