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)
def initUI(self): self.parent.title("HW3") self.pack(fill=BOTH, expand=1) Button(self, text="Select File", command=openFile).grid(row=0, column=0, pady=5) self.fileName = StringVar() Label(self, textvariable=self.fileName).grid(row=0, column=1, columnspan=2, pady=5, sticky=W) Label(self, text="Select Mode: ").grid(row=1, column=0, pady=5) mode = StringVar(self) mode.set("Q1-ColorHistogram") om = OptionMenu(self, mode, "Q1-ColorHistogram", "Q2-ColorLayout", "Q3-SIFT Visual Words", "Q4-Visual Words using stop words") om.grid(row=1, column=1, pady=5, sticky=W) Button(self, text="SEARCH", command=lambda: startSearching(self.fileName.get(), mode.get()) ).grid(row=3, column=0, pady=5) self.images = [] for i in range(10): self.images.append(Label(self)) self.images[i].grid(row=i / 5 + 4, column=i % 5, pady=50)
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 body(self, master): self.form = Frame(self, width = 30, height=50) self.form.pack() Label(self.form, text='Code type').grid(row=0, column=0) self.typevar = StringVar(self.form) self.e1 = OptionMenu(self.form, self.typevar, 'move','block','deflection','interrupt','humour','question','hesitation','support','overcoming','yesand','yesandquestion') self.typevar.set(self.code.symbol) self.e1.grid(row=0, column=1) Label(self.form, text='Timestamp (sec)').grid(row=1, column=0) self.e2 = Entry(self.form) self.e2.insert(0, ""+str(self.code.time)) self.e2.grid(row=1, column=1) Label(self.form, text='Speakers').grid(row=2, column=0) scrollbar = Scrollbar(self.form, orient=HORIZONTAL) self.e3 = Listbox(self.form, selectmode = MULTIPLE, height=len(self.parent.speakers)) alpha = ['A','B','C','D','E','F','G','H','I'] for num in range(len(self.parent.speakers)): self.e3.insert(END, alpha[num]) for index in self.code.speaker: self.e3.selection_set(int(index)-1) self.e3.grid(row=2, column=1) Label(self.form, text='Idea').grid(row=3, column=0) self.ivar = BooleanVar() e4 = Checkbutton(self.form, variable=self.ivar) self.ivar.set(self.code.idea) e4.grid(row=3, column=1) self.tvar = BooleanVar() '''
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("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) lbl1 = Label(frame1, text="Your Speed Is:", width=18, font=("Helvetica", 16)) lbl1.pack(padx=5, pady=5) frame2 = Frame(self) frame2.pack(fill=X) mph = Label(frame2, text="MPH", width=6, font=("Helvetica", 20)) mph.pack(side=RIGHT, padx=5, pady=5) self.speed_text = StringVar() speed_label = Label(frame2, textvariable = self.speed_text, width = 18, font=("Helvetica", 60)) speed_label.pack(fill=X, padx=5, expand=True) frame3 = Frame(self) frame3.pack(fill=BOTH, expand=True) self.v = StringVar() self.v.set("Late For Class?") self.speed = Label(frame3, textvariable=self.v, width=16, font=("Helvetica", 40)) self.speed.pack(padx=5, pady=5)
def setup_IO_dirs(self): '''add I/O part''' dct = self.user_input Label(self, text='CSV with the ROC and confusion matrix:').grid(row=0, column=0, columnspan=2, sticky=W) dct['f_general'] = self.add_file_browser(self, 'Browse', '', 1, 0) Label(self, text='CSV with the predictors + importances:').grid(row=2, column=0, columnspan=2, sticky=W) dct['f_predictors'] = self.add_file_browser(self, 'Browse', '', 3, 0) Label(self, text='CSV with the corresponding data:').grid(row=4, column=0, columnspan=2, sticky=W) dct['f_data'] = self.add_file_browser(self, 'Browse', '', 5, 0) Label(self, text='CSV to write to:').grid(row=6, column=0, columnspan=2, sticky=W) dct['f_out'] = self.add_file_browser(self, 'Browse', '', 7, 0) dct['delimiter'] = self.general_component('Delimiter', 8, 0, init_val=',')
def initUI(self): self.parent.title("Windows") 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): # This should be different if running on Windows.... content = pyperclip.paste() print content self.entries_found = [] self.parent.title("Add a new command card") self.style = Style() self.style.theme_use("default") self.pack() self.new_title_label = Label(self, text="Title") self.new_title_label.grid(row=0, columnspan=2) self.new_title_entry = Entry(self, width=90) self.new_title_entry.grid(row=1, column=0) self.new_title_entry.focus() self.new_content_label = Label(self, text="Card") self.new_content_label.grid(row=2, columnspan=2) self.new_content_text = Text(self, width=110, height=34) self.new_content_text.insert(END, content) self.new_content_text.grid(row=3, columnspan=2) self.add_new_btn = Button(self, text="Add New Card", command=self.onAddNew) self.add_new_btn.grid(row=4)
def initUI(self): self.parent.title("Windows") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) # Configures padding between items in application self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=7) self.rowconfigure(3, weight=1) self.rowconfigure(5, pad=7) self.lbl = Label(self, text="Windows") self.lbl.grid(sticky=W, pady=4, padx=5) self.area = Label(self) # Column and row span make box go to that column/row self.area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E+W+S+N) self.abtn = Button(self, text="Connect", command = self.connect) # self.abtn["command"] = update_box() self.abtn.grid(row=1, column=3) self.cbtn = Button(self, text="Close") self.cbtn.grid(row=2, column=3, pady=4) self.hbtn = Button(self, text="Help") self.hbtn.grid(row=5, column=0, padx=5) self.obtn = Button(self, text="Open") self.obtn.grid(row=5, column=3)
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 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 __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, container, frame, label='', text='', row=0, column=0): self.container = container self.is_b0 = BooleanVar(container.parent) self.is_dw = BooleanVar(container.parent) self.column = column self.direction = StringVar(container.parent) self.label_from = Label(frame, text='from') self.text_from = Entry(frame) self.text_from.insert(0, text) self.button_file_from = Button(frame, text='...', command=lambda:filenameDialog_text(self.text_from)) self.button_rm = Button(frame, text='remove', command=self.click_remove) self.radio_ap = Radiobutton(frame, text='AP', variable=self.direction, value='AP', command=self.set_direction) self.radio_pa = Radiobutton(frame, text='PA', variable=self.direction, value='PA', command=self.set_direction) self.label_to = Label(frame, text='to') self.text_to = Entry(frame) #self.text_to.insert(0, text) self.button_file_to = Button(frame, text='Gen', command=self.set_filename_to) self.check_b0 = Checkbutton(frame, text='B0', variable=self.is_b0) self.check_dw = Checkbutton(frame, text='DWI', variable=self.is_dw) self.button_up = Button(frame, text='up', width=3, command=self.click_up) self.button_dn = Button(frame, text='down', width=3, command=self.click_dn) self.row = -1 self.change_row(row) if text != '': self.set_appa() self.set_filename_to()
def initUI(self): self.parent.title("Windows") 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) 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): 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)
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.pack(side=LEFT, padx=15) self.var = IntVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack(side=LEFT) def onScale(self, val): v = int(float(val)) self.var.set(v)
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 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 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 setupUI(self): self.master.title("Markwhat") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.grid_columnconfigure(0, weight=1) self.grid_columnconfigure(1, weight=1) self.rowconfigure(1, weight=1) self.markwhat_label = Label(self, text="Markwhat") self.markwhat_label.grid(sticky=W, row=0, column=0) self.markwhat_textarea = WhatText(self, background='white') self.markwhat_textarea.grid(row=1, column=0, sticky=NSEW) self.markwhat_textarea.beenModified = self.on_markwhat_modfified self.markup_label = Label(self, text="Markup") self.markup_label.grid(sticky=W, row=0, column=1) self.markup_preview = HtmlFrame(self) self.markup_preview.grid(row=1, column=1, sticky=NSEW) self.preview_button_text = StringVar() self.preview_button = Button( self, textvariable=self.preview_button_text, command=self.on_preview_click, ) self.preview_button_text.set('HTML') self.preview_button.grid(row=2, column=1, sticky=W)
class TabServices(Frame): def __init__(self, parent, txt=dict()): """Instanciating the output workbook.""" self.parent = parent Frame.__init__(self) # variables self.url_srv = StringVar(self, 'http://suite.opengeo.org/geoserver/wfs?request=GetCapabilities') # widgets self.lb_url_srv = Label(self, text='Web service URL GetCapabilities: ') self.ent_url_srv = Entry(self, width=75, textvariable=self.url_srv) self.btn_check_srv = Button(self, text="youhou") # widgets placement self.lb_url_srv.grid(row=0, column=0, sticky="NSWE", padx=2, pady=2) self.ent_url_srv.grid(row=0, column=1, sticky="NSWE", padx=2, pady=2) self.btn_check_srv.grid(row=0, column=2, sticky="NSWE", padx=2, pady=2)
def initUI(self): self.parent.title("windows widget") 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 = "Windows") lbl.grid(sticky = W, pady=4, padx=5) area = Text(self) area.grid(row=1, column=0, columnspan=3, 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 _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.frame_top = Frame(self) self.frame_graph = MplCanvas(self) self.frame_bottom = Frame(self) Label(self.frame_top, text='Z = ').pack(side=LEFT) self.spin_z = Spinbox(self.frame_top, from_=0, to=self.shape[2] - 1, increment=1, command=self.change_z) self.spin_z.pack(side=LEFT) self.make_checkbox(self.frame_bottom, width=4) Label(self.frame_top, text=' CSV').pack(side=LEFT) self.txt_filename_csv = Entry(self.frame_top) self.txt_filename_csv.pack(side=LEFT) self.button_read = Button(self.frame_top, text='Read', command=self.run_read) self.button_read.pack(side=LEFT) self.button_save = Button(self.frame_top, text='Save', command=self.run_save) self.button_save.pack(side=LEFT) Label(self.frame_top, text=' ').pack(side=LEFT) button_reset = Button(self.frame_top, text='Reset', command=self.reset).pack(side=LEFT) self.frame_top.pack(side=TOP) self.frame_graph.get_tk_widget().pack(fill=BOTH, expand=TRUE) self.frame_bottom.pack(fill=BOTH, expand=TRUE) self.pack(fill=BOTH, expand=True)
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
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 __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 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 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)
class CommAdd(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): # This should be different if running on Windows.... content = pyperclip.paste() print content self.entries_found = [] self.parent.title("Add a new command card") self.style = Style() self.style.theme_use("default") self.pack() self.new_title_label = Label(self, text="Title") self.new_title_label.grid(row=0, columnspan=2) self.new_title_entry = Entry(self, width=90) self.new_title_entry.grid(row=1, column=0) self.new_title_entry.focus() self.new_content_label = Label(self, text="Card") self.new_content_label.grid(row=2, columnspan=2) self.new_content_text = Text(self, width=110, height=34) self.new_content_text.insert(END, content) self.new_content_text.grid(row=3, columnspan=2) self.add_new_btn = Button(self, text="Add New Card", command=self.onAddNew) self.add_new_btn.grid(row=4) def onAddNew(self): pass
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) eagles = ["Sam Bradford", "Jordan Matthews", "LeBron James", "Donnie Jones"] lb = Listbox(self) for i in eagles: lb.insert(END, i) lb.bind("<<ListboxSelect>>", self.onSelect) lb.pack(pady=15) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack() def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value)
def __init__(self,topwin,argv,**kwargs): global text_font self.topwin = topwin self.filefolder = 'log/' if len(argv) > 1: self.filefolder = argv[1] self.thread_status = 'Ready:' set_winicon(self.topwin,'icon_grey') self.frame3 = Frame(self.topwin, width=700,height=40, relief=SUNKEN) self.frame3.pack_propagate(0) self.frame3.pack(side=BOTTOM,pady=10) self.frame1 = Frame(self.topwin, width=150,height=460, relief=SUNKEN) self.frame1.pack_propagate(0) self.frame1.pack(side=LEFT,padx=10,pady=10) self.frame2 = Frame(self.topwin, width=550,height=460, relief=SUNKEN) self.frame2.pack_propagate(0) self.frame2.pack(side=LEFT,padx=10,pady=10) self.frame4 = Frame(self.frame3, width=450,height=40, relief=SUNKEN) self.frame4.pack_propagate(0) self.frame4.pack(side=RIGHT) self.label1 = Label(self.frame1,text='Files:') self.label1.pack(side=TOP) self.Fscroll = Scrollbar(self.frame1) self.Fscroll.pack(side=RIGHT, fill=Y, expand=NO) self.listbox = Listbox(self.frame1) self.listbox.pack(expand=1, fill="both") self.Fscroll.configure(command=self.listbox.yview) self.listbox.configure(yscrollcommand=self.Fscroll.set) self.Tbox = Text(self.frame2, height=12, width=40,wrap=WORD) self.Tbox.tag_configure('blackcol', font=text_font, foreground='black') self.Tbox.tag_configure('redcol', font=text_font, foreground='red') self.Tbox.configure(inactiveselectbackground="#6B9EB7", selectbackground="#4283A4") self.Tbox.tag_raise("sel") self.Tscroll = Scrollbar(self.frame2) self.Tbox.focus_set() self.Tbox.config(yscrollcommand=self.Tscroll.set) self.Tscroll.config(command=self.Tbox.yview) self.Tscroll.pack(side=RIGHT, fill=Y) self.Tbox.pack(side=BOTTOM,fill=BOTH,expand=1) self.loadLabel = Label(self.frame3,text='Ready:') self.loadLabel.pack(side=LEFT,padx=30) bb1 = Button(self.frame4, text='Change folder', command=self.load_other_folder) bb1.pack(side=LEFT,padx=30) bb2 = Button(self.frame4, text='Save', command=self.save_file) bb2.pack(side=LEFT) bb3 = Button(self.frame4, text='Close', command=self.close_func) bb3.pack(side=LEFT,padx=30) self.reload_file_list() self.topwin.bind('<Escape>', self.close_func) self.topwin.bind("<Control-a>", lambda x: widget_sel_all(self.Tbox)) self.Tbox.bind('<Control-f>',lambda x: search_text_dialog(self.Tbox,self.Tscroll)) self.listbox.bind('<Button-1>', lambda x: self.topwin.after(20,self.file_loader)) self.topwin.protocol('WM_DELETE_WINDOW', self.close_func) self.topwin.after(200,self.after_task) self.colortag()
def initUI(self): # Set the name of the UI window self.parent.title("Bennington File System Client") # Set the style using the default theme self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) # Set the "Open File" options self.file_opt = options = {} # Allow for any file to be choosable options["defaultextension"] = "" options["filetypes"] = "" # Set the directory window will open up to initially options["initialdir"] = "C:\\" options["parent"] = self # Create a label object which holds the text labeling the listbox lbl = Label(self, text="Bennington File System Files List", foreground="black") # Place the text in the top left lbl.grid(column=0, row=0, pady=4, padx=5) # Create the listbox, which will contain a list of all the files on the system self.area = Listbox(self, height=20) # Place the lisbox in the UI frame self.area.grid(row=1, column=0, columnspan=1, rowspan=10, padx=5, sticky=N + W + E + S) # Ask the master server which files it has, then populate the listbox with the response self.getFiles() # Create a button labeled 'Upload', and bind the uploadFile() function to it uploadbtn = Button(self, text="Upload", command=self.uploadFile) # Place the button in the UI frame uploadbtn.grid(row=1, column=3) # Create a button labeled 'Download', and bind the downloadFile() function to it dwnbtn = Button(self, text="Download", command=self.downloadFile) # Place the button in the UI frame dwnbtn.grid(row=2, column=3) # Create a button labeled 'Delete', and bind the deleteFile() function to it delbtn = Button(self, text="Delete", command=self.deleteFile) # Place the button in the UI frame delbtn.grid(row=3, column=3) # Create a button labeled 'Undelete', and bind the undeleteFile() function to it undelbtn = Button(self, text="Undelete", command=self.undeleteFile) # Place the button in the UI frame undelbtn.grid(row=4, column=3) # Create a button labeled 'Refresh List', and bind the getFiles() function to it refbtn = Button(self, text="Refresh List", command=self.getFiles) # Place the button in the UI frame refbtn.grid(row=5, column=3) # Create a button labeled 'Quit', and bind the exitProgram() function to it quitButton = Button(self, text="Quit", command=self.exitProgram) # Place the button in the UI frame quitButton.grid(sticky=W, padx=5, pady=4)
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 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 __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_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 general_component(self, s, r, c, init_val='', help_txt=''): '''adds a label, plus an entry and its associated variable''' Label(self, text=s).grid(row=r, column=c, sticky=W) var = StringVar() var.set(init_val) Entry(self, textvariable=var).grid(row=r, column=c + 1) Label(self, text=help_txt).grid(row=r, column=c + 2) return var
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 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()
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'])
class MainFrame(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() 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 turnOn(self): host.enqueue({"SM":"DRIVER_SM", "action":"turnOn", "busId":DRIVERID, "localIP":IP, "localPort":int(PORT)}) def start(self): host.enqueue({"SM":"DRIVER_SM", "action":"start", "route":ROUTNO, "direction":"north", "location":(0,0)}) def turnOff(self): host.enqueue({"SM":"DRIVER_SM", "action":"turnOff"})
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 open_file_handler(): global file1 file1= askopenfilename() print file1 captn = Label( top, text=file1, foreground="red") #captn.pack(side=TOP) captn.grid(row=3) #file2=str(file1) return file1
class MainWindow(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.setupUI() def setupUI(self): self.master.title("Markwhat") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.grid_columnconfigure(0, weight=1) self.grid_columnconfigure(1, weight=1) self.rowconfigure(1, weight=1) self.markwhat_label = Label(self, text="Markwhat") self.markwhat_label.grid(sticky=W, row=0, column=0) self.markwhat_textarea = WhatText(self, background='white') self.markwhat_textarea.grid(row=1, column=0, sticky=NSEW) self.markwhat_textarea.beenModified = self.on_markwhat_modfified self.markup_label = Label(self, text="Markup") self.markup_label.grid(sticky=W, row=0, column=1) self.markup_preview = HtmlFrame(self) self.markup_preview.grid(row=1, column=1, sticky=NSEW) self.preview_button_text = StringVar() self.preview_button = Button( self, textvariable=self.preview_button_text, command=self.on_preview_click, ) self.preview_button_text.set('HTML') self.preview_button.grid(row=2, column=1, sticky=W) def on_markwhat_modfified(self, event): text = self.markwhat_textarea.get('1.0', END) markup_text = parse_markdown(text) if isinstance(self.markup_preview, HtmlFrame): self.markup_preview.set_content(markup_text) else: self.markup_preview.delete('1.0', END) self.markup_preview.insert('1.0', markup_text) def on_preview_click(self): if isinstance(self.markup_preview, HtmlFrame): self.markup_preview = WhatText(self, background="white") self.preview_button_text.set('HTML') else: self.markup_preview = HtmlFrame(self) self.preview_button_text.set('HTML Source') self.markup_preview.grid(row=1, column=1, sticky=NSEW) self.on_markwhat_modfified(None)
def body(self, parent): self.parent = parent questionLabel = Label(self.parent, text="Give your champion pool a name:") questionLabel.grid(row=0) self.poolTitle = Entry(self.parent) self.poolTitle.grid(row=1) return self.poolTitle
def pack_text(self, text, frame=None): """adds some label text in the desired location""" if frame is None: label = Label(self.window, text=text) else: label = Label(frame, text=text) label.pack()
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): #title self.parent.title("HW3") #pack_info self.pack(fill=BOTH, expand=1) #Button_SelectFile Button(self, text="Select File", command=openFile).grid(row=0, column=0, pady=5) self.fileName = StringVar() Label(self, textvariable=self.fileName).grid(row=0, column=1, columnspan=2, pady=5, sticky=W) #Default_file self.fileName = StringVar(value="./dataset/ukbench00000.jpg") #Image_SelectedFile self.thumb = Label(self) self.thumb.grid(row=0, column=1, pady=5, sticky=W) image = Image.open(self.fileName.get()) image = ImageTk.PhotoImage( image.resize((int(image.size[0] * 0.8), int(image.size[1] * 0.8)), Image.ANTIALIAS)) self.thumb.configure(image=image) self.thumb.image = image #mode_SelectMode Label(self, text="Select Mode: ").grid(row=1, column=0, pady=5) mode = StringVar(self) #default mode.set("Q3-SIFT Visual Words") om = OptionMenu(self, mode, "Q1-ColorHistogram", "Q2-ColorLayout", "Q3-SIFT Visual Words", "Q4-Visual Words using stop words") om.grid(row=1, column=1, pady=5, sticky=W) #Button_Search Button(self, text="SEARCH", command=lambda: startSearching(self.fileName.get(), mode.get()) ).grid(row=3, column=0, pady=5) self.imgs = [] #RankList for i in xrange(10): self.imgs.append(Label(self)) self.imgs[i].grid(row=i / 5 + 4, column=i % 5, padx=5, pady=10)
class gui(Frame): 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_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 initUI(self): self.parent.title("Sequence modification parser") self.columnconfigure(0, pad=5) self.columnconfigure(1, pad=5, weight = 1) self.columnconfigure(2, pad=5) self.rowconfigure(0, pad=5, weight = 1) self.rowconfigure(1, pad=5, weight = 1) self.rowconfigure(2, pad=5, weight = 1) self.rowconfigure(3, pad=5, weight = 1) self.rowconfigure(4, pad=5, weight = 1) self.rowconfigure(5, pad=5, weight = 1) self.lInput = Label(self, text = "Input file") self.lInput.grid(row = 0, column = 0, sticky = W) self.lPRS = Label(self, text = "phospoRS Column Name") self.lPRS.grid(row = 1, column = 0, sticky = W) self.lScore = Label(self, text = "Min phosphoRS Score") self.lScore.grid(row = 2, column = 0, sticky = W) self.lDA = Label(self, text = "Check deamidation sites") self.lDA.grid(row = 3, column = 0, sticky = W) self.lLabFile = Label(self, text = "Label description file") self.lLabFile.grid(row = 4, column = 0, sticky = W) self.ifPathText = StringVar() self.prsScoreText = StringVar(value = '0') self.prsNameText = StringVar() self.doDAVar = IntVar() self.labFileText = StringVar(value = path.abspath('moddict.txt')) self.ifPath = Entry(self, textvariable = self.ifPathText) self.ifPath.grid(row = 0, column = 1, sticky = W+E) self.prsName = Entry(self, textvariable = self.prsNameText) self.prsName.grid(row = 1, column = 1, sticky = W+E) self.prsScore = Entry(self, textvariable = self.prsScoreText, state = DISABLED) self.prsScore.grid(row = 2, column = 1, sticky = W+E) self.doDABox = Checkbutton(self, variable = self.doDAVar) self.doDABox.grid(row = 3, column = 1, sticky = W) self.labFile = Entry(self, textvariable = self.labFileText) self.labFile.grid(row = 4, column = 1, sticky = W+E) self.foButton = Button(self, text = "Select file", command = self.selectFileOpen) self.foButton.grid(row = 0, column = 2, sticky = E+W, padx = 3) self.prsButton = Button(self, text = "Select column", state = DISABLED, command = self.selectColumn) self.prsButton.grid(row = 1, column = 2, sticky = E+W, padx = 3) self.labFileButton = Button(self, text = "Select file", command = self.selectLabFileOpen) self.labFileButton.grid(row = 4, column = 2, sticky = E+W, padx = 3) self.startButton = Button(self, text = "Start", command = self.start, padx = 3, pady = 3) self.startButton.grid(row = 5, column = 1, sticky = E+W) self.pack(fill = BOTH, expand = True, padx = 5, pady = 5)
def initialize(self): self.master.title(settings.APP_TITLE) self.pack(fill=Tkinter.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="Журнал") lbl.grid(sticky=Tkinter.W, pady=4, padx=5) self.area = Tkinter.Text(self) self.area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=Tkinter.E + Tkinter.W + Tkinter.S + Tkinter.N) self.widgetLogger = WidgetLogger(self.area) lbl = Label(self, text="Адрес репозитория: ") lbl.grid(row=6) self.repo_addr_str = Tkinter.StringVar() self.repo_addr = Tkinter.Entry(self, textvariable=self.repo_addr_str) self.repo_addr.grid(row=7) lbl = Label(self, text="FTP для размещения: ") lbl.grid(row=6, column=1) self.ftp_addr_str = Tkinter.StringVar() self.ftp_addr = Tkinter.Entry(self, textvariable=self.ftp_addr_str) self.ftp_addr.grid(row=7, column=1, pady=1) self.deploybtn = Button(self, text="Начать обновление", command=self.start_update_thread) self.deploybtn.grid(row=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) frame2 = Frame(self) frame2.pack(fill=X) lbl2 = Label(frame2, text="Author", width=6) lbl2.pack(side=LEFT, padx=5, pady=5) entry2 = Entry(frame2) entry2.pack(fill=X, padx=5, expand=True) frame3 = Frame(self) frame3.pack(fill=BOTH, expand=True) lbl3 = Label(frame3, text="Review", 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 __init__(self, brdNum, frmRow, parentFrm): self.brdNum = brdNum self.brdPos = frmRow self.statLbl = StringVar() self.prevLedState = 0x00 #1 is on, 0 is off self.bitFrms = [] self.canvas = [] if (TkLedBrd._ledOffImage == 0): TkLedBrd._ledOffImage = PhotoImage(file="graphics/ledOff.gif") if (TkLedBrd._ledOnWhtImage == 0): TkLedBrd._ledOnWhtImage = PhotoImage(file="graphics/ledOnWht.gif") if (TkLedBrd._ledOnGrnImage == 0): TkLedBrd._ledOnGrnImage = PhotoImage(file="graphics/ledOnGrn.gif") #Create main frame self.ledCardFrm = Frame(parentFrm, borderwidth = 5, relief=RAISED) self.ledCardFrm.grid(column = 0, row = frmRow) #Create card info frame ledCardInfoFrm = Frame(self.ledCardFrm) ledCardInfoFrm.grid(column = 8, row = 0) #Add card info tmpLbl = Label(ledCardInfoFrm, text="LED Card %d" % (brdNum + 1)) tmpLbl.grid(column = 0, row = 0) tmpLbl = Label(ledCardInfoFrm, text="Status") tmpLbl.grid(column = 0, row = 1) tmpLbl = Label(ledCardInfoFrm, textvariable=self.statLbl, relief=SUNKEN) self.statLbl.set("0x%02x" % self.prevLedState) tmpLbl.grid(column = 0, row = 2) for i in xrange(rs232Intf.NUM_LED_PER_BRD): TkLedBrd.createBitFrame(self, i)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.controller = controller ChooseType.socket = None ChooseType.create_player = None self.plx_name = "PLAYER" ChooseType.plx_type = "SPECTATOR" ChooseType.start_game = None label_1 = Label(self, text="Create character", font=TITLE_FONT, justify=CENTER, anchor=CENTER) label_2 = Label(self, text="Name: ") self.entry_1 = Entry(self) self.entry_1.insert(0, 'Player_') label_3 = Label(self, text="Join as: ") button1 = Button(self, text="FROG", command=self.callback_frog) button2 = Button(self, text="FLY", command=self.callback_fly) button3 = Button(self, text="SPECTATOR", command=self.callback_spec) ChooseType.button4 = Button(self, text="Back", command=lambda: controller.show_frame("StartPage")) label_1.pack(side="top", fill="x", pady=10) label_2.pack() self.entry_1.pack() label_3.pack() button1.pack() button2.pack() button3.pack() ChooseType.button4.pack(pady=20)
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")
class MainFrame(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() # define options for opening or saving a file self.file_opt = options_file = {} options_file['defaultextension'] = '.txt' options_file['filetypes'] = [('all files', '.*'), ('text files', '.txt')] options_file['initialdir'] = '../' options_file['initialfile'] = 'testFile' options_file['parent'] = self.parent options_file['title'] = 'Choose configuration file' # define options for asking local name self.ask_localname_opt = options_localName = {} options_localName['parent'] = self.parent options_localName['initialvalue'] = "alice" conf = tkFileDialog.askopenfilename(**self.file_opt) localName = tkSimpleDialog.askstring("local name", "Please enter your name:", **self.ask_localname_opt) MessagePasser.initialize(conf, localName) def initUI(self): self.parent.title("Bus Tracker") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.label = Label(self, text="Ready") self.label.grid(row=0, column=0) # TEST ONLY self.testButton = Button(self, text="Send", command= lambda: self.send("alice", "hi alice")) self.testButton.grid(row=1, column=0) self.testButton = Button(self, text="Multicast", command= lambda: self.multicast("group1", "hi group1")) self.testButton.grid(row=1, column=1) self.quitButton = Button(self, text="Quit", command=self.quit) self.quitButton.grid(row=1, column=2) def receive(self): self.label["text"] = MessagePasser.receive() #self.labelString.set(MessagePasser.receive()) def send(self, dst, data): MessagePasser.normalSend(dst, data) def multicast(self, group, data): MessagePasser.multicast(group, data)
def create_window(self): t = Toplevel(self) t.wm_title("Elastic constants") l = Label(t, text="Elastic constants:") l.grid(row=0, column=0) textf = Text(t) try: textf.insert(INSERT, self.ec.get_C()) except: textf.insert(INSERT, '') textf.grid(row=1, column=0)