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
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 updateImage(self): global init #Displays the dicom images ds = dicom.read_file(self.dicomName) self.dataArr = ds.pixel_array thisArr1Max = np.max(self.dataArr[::,::]) if thisArr1Max == 0: thisArr1Max=1 thisArr1 = self.dataArr[::,::].astype(np.float) / thisArr1Max self.figDrawing.set_data(thisArr1) self.canvas.draw() #Display the Image Number name = self.dicomName.split(".") number = name[0].split("-") self.num = number[-1].lstrip("0") test = Label(self, text=("Image Num: %s" % self.num), width=14) test.grid(row=1, column=1, sticky=E, pady=10) #Display the Series Number series = ds.SeriesNumber test = Label(self, text=("Series Num: %s" % series), width=15) test.grid(row=1, column=2, sticky=W, pady=10)
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") 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("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("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.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("AlienTiles") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) lbl = Label(self, text="Choose goal colour:") lbl.grid(sticky=W, padx=5, columnspan=4) redbtn = tk.Button(self, width=3, command = self.colour_red, bg='red') redbtn.grid(row=1, column=0, padx=12, pady=10) greenbtn = tk.Button(self, width=3, command = self.colour_green, bg='green') greenbtn.grid(row=1, column=1, padx=12, pady=10) bluebtn = tk.Button(self, width=3, command = self.colour_blue, bg='blue') bluebtn.grid(row=1, column=2, padx=12, pady=10) purplebtn = tk.Button(self, width=3, command = self.colour_purple, bg='purple') purplebtn.grid(row=1, column=3, padx=12, pady=10) for i in range(dimension) : for j in range(dimension) : btn.insert(i*dimension+j, tk.Button(self, width=5, bg='red')) btn[i*dimension+j].grid(row=i+2, column=j, padx=10, pady=1) hbtn = Button(self, text="Help", command = self.print_help) hbtn.grid(row=dimension+3, column=0, padx=1) ibtn = Button(self, text="Initial State", command = self.initial_state) ibtn.grid(row=dimension+3, column=1, padx=1) sbtn = Button(self, text="Solution", command = self.solution) sbtn.grid(row=dimension+3, column=2, padx=1)
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")
class InfoFrame(Frame): 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 OkBut(self): self.quit()
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 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): # 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_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 _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')
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"})
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 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)
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 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
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 _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 init_ui(self): self.parent.title("Information Theory") Style().configure("TButton", padding=(0, 5, 0, 5), font='Verdana 10') self.columnconfigure(0, pad=3) self.columnconfigure(1, pad=3) self.columnconfigure(2, pad=3) self.columnconfigure(3, pad=3) self.columnconfigure(4, pad=3) self.rowconfigure(0, pad=3) self.rowconfigure(1, pad=3) self.rowconfigure(2, pad=3) self.rowconfigure(3, pad=3) self.rowconfigure(4, pad=3) self.rowconfigure(5, pad=3) string_to_search_label = Label(self, text="Search a string: ") string_to_search_label.grid(row=0, column=0, rowspan=2) self.string_to_search_textfield = Entry(self) self.string_to_search_textfield.grid(row=0, column=1, rowspan=2, columnspan=2, sticky=W) self.string_to_search_textfield.bind('<Return>', self.get_string_from_textfield) self.compression_ratio_text = StringVar() self.compression_ratio_text.set('Compression Ratio: ') compression_ratio_label = Label(self, textvariable=self.compression_ratio_text).grid(row=0, column=2, columnspan=4) Separator(self, orient=HORIZONTAL).grid(row=1) string_to_encode_label = Label(self, text="Encode a string: ") string_to_encode_label.grid(row=2, column=0, rowspan=2) self.string_to_encode_textfield = Entry(self) self.string_to_encode_textfield.grid(row=2, column=1, rowspan=2, columnspan=2, sticky=W) self.string_to_encode_textfield.bind('<Return>', self.get_string_from_textfield_to_encode) Separator(self, orient=HORIZONTAL).grid(row=3) self.area = Text(self) self.area.grid(row=4, column=0, columnspan=3, rowspan=1, padx=5, sticky=E + W) self.area.config(width=10, height=15) self.possible_options_text = StringVar() self.possible_options_text.set("Possible Options: ") self.possible_options_label = Label(self, textvariable=self.possible_options_text).grid(row=4, column=3, sticky=N) huffman_coding_button = Button(self, text="Huffman", command=self.huffman_coding_callback).grid(row=5, column=0) arithmetic_coding_button = Button(self, text="Arithmetic Coding", command=self.arithmetic_coding_callback).grid(row=5, column=1) dictionary_coding_button = Button(self, text="Dictionary", command=self.dictionary_coding_callback).grid(row=5, column=2) elias_coding_button = Button(self, text="Elias", command=self.elias_coding_callback).grid(row=5, column=3) our_coding_button = Button(self, text="Elemental Coding", command=self.elemental_coding_callback).grid(row=5, column=4) self.pack() self.elemental_coding_callback()
def initUI(self): self.parent.title("Story Creator") self.columnconfigure(0, pad=0) self.columnconfigure(1, pad=0) self.rowconfigure(0, pad=0) self.grid(row=0, column=0) logo = ImageTk.PhotoImage(Image.open("prelaunch_logo.png")) logolabel = Label(self, image=logo) logolabel.image = logo logolabel.grid(row=0, column=0)
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)
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 initUI(self): self.MPDInitialize() self.parent.title("RaspiPlayer") 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) #self.CurrentSongInfo() self.poll() titleframe = LabelFrame(self, width=200, height=70) titleframe.grid(row=0, column=0, columnspan=2) titleframe.grid_propagate(0) titlelbl = Label(titleframe, text="RaspPi Player", font=('Garamond', (20), 'bold')) titlelbl.grid(row=0, column=0) PreviousButton = Button(self, text="Previous", command=self.PreviousClick) PreviousButton.grid(row=2, column=0) PlayButton = Button(self, text="Play", command=self.PlayClick) PlayButton.grid(row=2, column=1, padx=4) StopButton = Button(self, text="Stop", command=self.StopClick) StopButton.grid(row=2, column=2) PauseButton = Button(self, text="Pause", command=self.PauseClick) PauseButton.grid(row=2, column=3, padx=4) NextButton = Button(self, text="Next", command=self.NextClick) NextButton.grid(row=2, column=4) UploadButton = Button(self, text="Upload", command=self.UploadClick) UploadButton.grid(row=2, column=5, padx=4) VolumeBar = Scale(self, from_=0, to=100, orient="horizontal", label="Volume", command=self.VolumeBar) VolumeBar.grid(row=2, column=6, padx=5) VolumeBar.set(50)
def loginInit(self): self.parent.title("Password Keeper") Style().configure("Tlabel",font="Times") lbusr = Label(self,text="Master Username") lbusr.grid(row=0,column=0) lbps = Label(self,text="Master Password") lbps.grid(row=1,column=0) enusr = Entry(self) enusr.grid(row=0,column=1) enps = Entry(self) enps.grid(row=1,column=1) def login(): credict = {} with open("cred.json","rb") as f: credict = json.load(f) for key in credict: if key == enusr.get() and credict[key] == enps.get(): switch() elif key != enusr.get() and credict[key] == enps.get(): tkMessageBox.showinfo(title=None,message="Wrong Username! Please Re-enter") enusr.delete(0, Tkinter.END) enps.delete(0, Tkinter.END) break elif key == enusr.get() and credict[key] != enps.get(): tkMessageBox.showinfo(title=None,message="Wrong password! Please Re-enter.") enusr.delete(0, Tkinter.END) enps.delete(0, Tkinter.END) break else: tkMessageBox.showinfo(title=None,message="Username/Password combination is wrong! Please Re-enter") enusr.delete(0, Tkinter.END) enps.delete(0, Tkinter.END) break def switch(): self.parent.destroy() root = Tk() Primary(root,self.dict,self.enlist) root.mainloop() reg = Button(self,text="New User",command=self.register) reg.grid(row=2,column=0,sticky=W+E) lgn = Button(self,text="Login",command=login) lgn.grid(row=2,column=1,sticky=W+E) self.pack()
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("HW3") self.pack(fill=BOTH, expand=1) # File abtn = Button(self, text="-- Select File --", command=openFile) abtn.grid(row=0, column=0, pady=5) self.fileName = StringVar(value="./dataset/clothing/ukbench00000.jpg") albl = Label(self, textvariable=self.fileName) albl.grid(row=0, column=2, columnspan=3, pady=5, sticky=W) 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((image.size[0] / 2, image.size[1] / 2), Image.ANTIALIAS)) self.thumb.configure(image=image) self.thumb.image = image # Mode mode = StringVar(self) mode.set('-- Select Mode --') menu = OptionMenu(self, mode, 'Q1-Color_Histogram', 'Q2-Color_Layout', 'Q3-SIFT_Visual_Words', 'Q4-Visual_Words_Using_Stop_Words', 'Q5-Average_HSV', 'Q6-HSV_Histogram') menu.grid(row=1, column=0, pady=5, sticky=W) # Start Searching dbtn = Button( self, text="START SEARCHING", command=lambda: startSearching(mode.get(), self.fileName.get())) dbtn.grid(row=1, column=1, pady=5, sticky=W) # Return Ranking List self.imgs = [] for i in xrange(10): self.imgs.append(Label(self)) self.imgs[i].grid(row=i / 5 + 4, column=i % 5, padx=10, pady=20)
def initUI(self, parameterDict, callback, validate, undoCallback): self.parent.title("Choose parameters for fit") Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10') self.columnconfigure(0, pad=3) self.columnconfigure(1, pad=3) count = 0 entries = {} for key, value in parameterDict.iteritems(): self.rowconfigure(count, pad=3) label = Label(self, text=key) label.grid(row=count, column=0) entry = Entry(self) entry.grid(row=count, column=1) entry.insert(0, value) entries[key] = entry count = count + 1 def buttonCallback(*args): #the *args here is needed because the Button needs a function without an argument and the callback for function takes an event as argument try: newParameterDict = {} for key, value in entries.iteritems(): newParameterDict[key] = value.get() self.parent.withdraw() #hide window feedback = callback(newParameterDict) if validate: if(askyesno("Validate", feedback, default=YES)): self.parent.destroy() #clean up window else: undoCallback() #rollback changes done by callback self.parent.deiconify() #show the window again else: self.parent.withdraw() self.parent.destroy() except Exception as e: import traceback traceback.print_exc() self.parent.destroy() self.parent.bind("<Return>", buttonCallback) self.parent.bind("<KP_Enter>", buttonCallback) run = Button(self, text="Run fit", command=buttonCallback) run.grid(row=count, column=0) count = count + 1 self.pack()
def createBitFrame(self, bit): ledCardBitFrm = Frame(self.ledCardFrm, borderwidth = 5, relief=RAISED) self.bitFrms.append(ledCardBitFrm) ledCardBitFrm.grid(column = rs232Intf.NUM_LED_PER_BRD - bit - 1, row = 0) tmpLbl = Label(ledCardBitFrm, text="%s" % GameData.LedBitNames.LED_BRD_BIT_NAMES[self.brdNum][bit]) tmpLbl.grid(column = 0, row = 0) #Graphic of LED on self.canvas.append(Canvas(ledCardBitFrm, width=100, height=80)) self.canvas[bit].grid(column = 0, row = 1) if ((self.prevLedState & (1 << bit)) == 0): self.canvas[bit].create_image(48, 40, image=TkLedBrd._ledOffImage) else: self.canvas[bit].create_image(48, 40, image=TkLedBrd._ledOnGrnImage)
def initUI(self): #create initial Beings object (not instantiated until live is called) self.wc = WorldConfiguration() self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.columnconfigure(2, weight=1) self.columnconfigure(4, pad=7) self.rowconfigure(3, weight=1) lbl = Label(self, text="PyLife") lbl.grid(sticky=W, padx=25, pady=5) self.world = Canvas(self, background="#7474DB") self.world.grid(row=1, column=0, columnspan=3, rowspan=8, padx=5, sticky=E + W + N + S) self.sbtn = Button(self, text="Stop") self.sbtn.grid(row=1, column=4, pady=5, sticky=E) self.bbox = Text(self, height=20, width=36) self.bbox.grid(row=3, column=4, padx=5, sticky=E + W + N + S) self.bbox1 = Text(self, height=11, width=36) self.bbox1.grid(row=4, column=4, padx=5, sticky=E + W + N + S) self.cbtn = Button(self, text="Close", command=self.parent.destroy) self.cbtn.grid(row=9, column=4, pady=5) self.cnfbtn = Button(self, text="Configure Universe") self.cnfbtn.grid(row=9, column=0, padx=5) self.timelbl = Text(self, height=1, width=10) self.timelbl.grid(row=2, column=4, pady=5) b = Beings(self) abtn = Button( self, text="Start", command=b.live ) #Beings(cnfbtn, world, 4, 10, sbtn, bbox, bbox1, timelbl).live) abtn.grid(row=1, column=4, pady=5, sticky=W) self.cnfbtn.config(command=b.configure)
def __draw_new_draft_window(self, parent): self.parent.title("New Draft") style = StringVar() style.set("Snake") opponent_label = Label(parent, text="Opponents") opponent_entry = Entry(parent, width=5) position_label = Label(parent, text="Draft Position") position_entry = Entry(parent, width=5) rounds_label = Label(parent, text="Number of Rounds") rounds_entry = Entry(parent, width=5) style_label = Label(parent, text="Draft Style") style_menu = OptionMenu(parent, style, "Snake", "Linear") def begin_draft(): """ initializes variables to control the flow of the draft calls the first window of the draft. """ self.game.number_of_opponents = int(opponent_entry.get()) self.game.draft_position = int(position_entry.get()) self.game.number_of_rounds = int(rounds_entry.get()) self.game.draft_style = style.get() self.game.opponents = [] self.game.current_position = 1 self.game.current_round = 1 for x in xrange(self.game.number_of_opponents): self.game.opponents.append(Opponent.Opponent(x)) if self.game.draft_position <= self.game.number_of_opponents + 1: MainUI(self.parent, self.game) else: tkMessageBox.showinfo("Error", "Draft position too high!\nYou would never get to pick a player" ) def begin_button(event): begin_draft() ok_button = Button(parent, text="OK", command=begin_draft) self.parent.bind("<Return>", begin_button) opponent_label.grid(row=0, pady=5) opponent_entry.grid(row=0, column=1, pady=5) position_label.grid(row=1) position_entry.grid(row=1, column=1) rounds_label.grid(row=2, pady=5) rounds_entry.grid(row=2, column=1, pady=5, padx=5) style_label.grid(row=3) style_menu.grid(row=3, column=1) ok_button.grid(row=4, column=1, sticky="se", pady=5, padx=5)
def initUI(self): self.parent.title("IHM Virtual Regatta") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=1) #self.columnconfigure(3, pad=7) self.rowconfigure(6, weight=1) #self.rowconfigure(5, pad=7) user_btn = Button(self, text="User",command=self.button_update) user_btn.grid(row=0, column=0) help_btn = Button(self, text="Help") help_btn.grid(row=1, column=0) ok_btn = Button(self, text="OK") ok_btn.grid(row=2, column=0) update_btn = Button(self, text="Update",command=self.button_update) update_btn.grid(row=3, column=0) text_distance_label = Label(self, textvariable=self.text_distance) text_distance_label.grid(row=0,column=1) text_angle_label = Label(self, textvariable=self.text_angle) text_angle_label.grid(row=1,column=1) text_wind_angle_label = Label(self, textvariable=self.text_wind_angle) text_wind_angle_label.grid(row=2,column=1) text_debug_label = Label(self, textvariable=self.text_debug) text_debug_label.grid(row=3,column=1) if False : self.canvas = Canvas(self, width=(self.longitude_start-self.longitude_end)*SQUARE_SIZE, height=(self.latitude_end-self.latitude_start)*SQUARE_SIZE) else : self.canvas = Canvas(self) self.canvas.pack(fill=BOTH, expand=1) self.canvas.grid(row=6, column=1, columnspan=3, sticky=E+W+S+N) self.canvas.bind("<Button-1>", self.click_left) self.canvas.bind("<Button-2>", self.click_right) self.canvas.bind("<Motion>", self.motion) #self.imageTk = ImageTk.PhotoImage(Image.open("saved_png/map_6_10_11.png")) #self.canvas.create_image(0,0, anchor=NW, image=self.imageTk) self.showSea(self.longitude_start,self.latitude_start,self.longitude_end,self.latitude_end) zero_btn = Button(self, text="0H",command=self.button_0h) zero_btn.grid(row=0, column=2) douze_btn = Button(self, text="12H",command=self.button_12h) douze_btn.grid(row=1, column=2) vingtquatre_btn = Button(self, text="24H",command=self.button_24h) vingtquatre_btn.grid(row=2, column=2) close_btn = Button(self, text="Close",command=self.button_close) close_btn.grid(row=4, column=2)
def initUI(self): self.parent.title("Add Food") self.style = Style() self.style.theme_use("default") self.grid() l_name = Label(self.parent, text="Name") l_day = Label(self.parent, text="Day") l_month = Label(self.parent, text="Month") l_year = Label(self.parent, text="Year") l_name.grid(row=0, column=3) l_day.grid(row=0, column=0) l_month.grid(row=0, column=1) l_year.grid(row=0, column=2) days = [] months = [] years = [] days.extend(range(1, 32)) months.extend(range(1, 13)) years.extend(range(2015, 2036)) days = map(str, days) months = map(str, months) years = map(str, years) self.var_day = StringVar(self.parent) self.var_month = StringVar(self.parent) self.var_year = StringVar(self.parent) self.var_name = StringVar(self.parent) self.var_day.set(days[0]) self.var_month.set(months[0]) self.var_year.set(years[0]) f_name = Entry(self.parent, textvariable=self.var_name) f_day = apply(OptionMenu, (self.parent, self.var_day) + tuple(days)) f_month = apply(OptionMenu, (self.parent, self.var_month) +\ tuple(months)) f_year = apply(OptionMenu, (self.parent, self.var_year) +\ tuple(years)) f_name.grid(row=1, column=3) f_day.grid(row=1, column=0) f_month.grid(row=1, column=1) f_year.grid(row=1, column=2) add_btn = Button(self.parent, text="Add Food", command=self.add_food) add_btn.grid(row=0, column=5) cancel_btn = Button(self.parent, text="Cancel",\ command=self.cancel_food) cancel_btn.grid(row=1, column=5)
def initUI(self): self.parent.title("Graphs") self.style = Style() self.style.theme_use("clam") self.pack(fill=BOTH, expand=1) self.columnconfigure(1, weight=1) self.columnconfigure(3, weight=1) self.columnconfigure(6, pad=7) self.rowconfigure(3, weight=1) self.rowconfigure(5, pad=7) lbl = Label(self, text="Graphs") lbl.grid(sticky=W, pady=4, padx=5) area1 = ScrolledList(self, ['a', 'b,', 'c', 'd', 'e'], lambda x: self.load_hunt_data(x)) area1.grid(row=1, column=0, columnspan=3, rowspan=4, padx=5, sticky=E + W + S + N) area2 = TkinterGraph(self) area2.grid(row=1, column=3, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) btn1 = Button(self, text="Left") btn1.grid(row=1, column=6) btn2 = Button(self, text="Right") btn2.grid(row=2, column=6, pady=4) btn3 = Button(self, text="csv") btn3.grid(row=5, column=0, padx=5) btn5 = Button(self, text="dat") btn5.grid(row=5, column=2, padx=5) btn4 = Button(self, text="OK") btn4.grid(row=5, column=6)
def initUI(self): self.parent.title("Windows") 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(7, weight=1) self.rowconfigure(8, pad=7) buttonBrowse = Button(self, text="Browse", command= self.control.browseFile) buttonBrowse.grid(row=0, column=0, sticky=W+E, pady=4, padx=5) self.addressViewer = Entry(self) self.addressViewer.grid(row=0, column=1, sticky=W+E+N+S, pady=4, padx=5) self.photoViewer = Canvas(self,bd=0, highlightthickness=0, relief="raised") self.photoViewer.grid(row=1, column=0, columnspan=2, rowspan=7, padx=5, sticky=E+W+S+N) buttonGrayScale = Button(self, text="Original", command=self.control.showOriginal) buttonGrayScale.grid(row=1, column=3, pady= 4) buttonGrayScale = Button(self, text="Grayscale", command=self.control.turn2Grayscale) buttonGrayScale.grid(row=2, column=3, pady= 4) buttonInvers = Button(self, text="Invers", command=self.control.turn2Invers) buttonInvers.grid(row=3, column=3, pady=4) buttonSplit = Button(self, text="Split", command=self.control.splitImage) buttonSplit.grid(row=4, column=3, pady=4) buttonReLoad = Button(self, text="Re-Load", command=self.control.reload) buttonReLoad.grid(row=5, column=3, pady=4) buttonSolve = Button(self, text="Solve", command=self.control.solve) buttonSolve.grid(row=6, column=3, pady=4) # inputW = Entry(self, text = "300000") # inputW.grid(row=4, column=3, pady=4) buttonClose = Button(self, text="Close", command= self.quit) buttonClose.grid(row=7, column=3, pady=4) labelName = Label(self, text="Developer: Muh.Alif Akbar (1103132163)") labelName.grid(row=8,pady=5, padx=5)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() 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 connect(self): # self.area["text"] = "Activated" port = '/dev/tty.OBDII-Port' ser = serial.Serial(port)
class YearSelector(): def __init__(self, parent=None, text='Year:', min_value=1950, max_value=2100, **kwargs): # NOTE: This class used to be a subclass of Frame, but it did not grid properly #Frame.__init__(self, parent) self.label = Label(parent, text=text) self.year = StringVar() self.year_selector = Spinbox(parent, from_=min_value, to=max_value, textvariable=self.year, command=self.on_change, width=5) self.set_args() def set_args(self, **kwargs): self.check_other_func = kwargs['check_other_func'] if 'check_other_func' in kwargs else None def get_value(self): value = int(self.year.get()) return value def set_value(self, value): self.year.set(value) def set_grid(self, row=0, padx=0, pady=0): #self.grid(row=row) self.label.grid(row=row, column=0, sticky='e') self.year_selector.grid(row=row, column=1, padx=padx, pady=pady, sticky='w') def on_change(self): if self.check_other_func != None: value = int(self.year.get()) new_value = self.check_other_func(value) if value != new_value: self.set_value(new_value) else: pass def get_less_than(self, compare_value): value = int(self.year.get()) compare_value = int(compare_value) if value <= compare_value: return value return compare_value def get_greater_than(self, compare_value): value = int(self.year.get()) compare_value = int(compare_value) if value >= compare_value: return value return compare_value
def put_image(self, photo): # print type(photo) if self.column_count > GUI.max_count-1: self.column_count = 0 self.row_count += 2 canvas = Canvas(self.picture_frame, width=100, height=100) canvas.grid(row=self.row_count, column=self.column_count, padx=3, pady=3) self.put_oncanvas(canvas, photo) #put on canvas text_var = StringVar() text_var.set('Un-Tested') text = Label(self.picture_frame, textvariable=text_var) text.grid(row=self.row_count+1, column=self.column_count, sticky=S, padx=3, pady=3) self.column_count += 1 self.picture_frames.append([photo, text_var])
def put_image(self, data): # print type(photo) photo=data[0] name = data[1] if self.column_count > GUI.max_count-1: self.column_count = 0 self.row_count += 2 canvas = Canvas(self.picture_frame, width=100, height=100) canvas.grid(row=self.row_count, column=self.column_count, padx=3, pady=3) self.put_oncanvas(canvas, photo) #put on canvas text = Label(self.picture_frame, text=name) text.grid(row=self.row_count+1, column=self.column_count, sticky=S, padx=3, pady=3) self.column_count += 1 cimage = name.split('.') self.picture_frames.append([cimage[0][0], cimage[0][1], photo])
def init_ui(self): self.parent.title("Network Intrusion Detection System") 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="Data Log") lbl.grid(sticky=W, pady=4, padx=5) self.area = Text(self) sys.stdout = self self.area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) abtn = Button(self, text=" Start Checking", command=self.on_button_start) abtn.grid(row=1, column=3) cbtn = Button(self, text=" Stop Checking ", command=self.on_button_stop) cbtn.grid(row=2, column=3, pady=4) hbtn = Button(self, text="View Log", command=self.on_load) hbtn.grid(row=5, column=0, padx=5) obtn = Button(self, text="Close", command=self.on_button_close) obtn.grid(row=5, column=3) menubar = Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Menu(menubar) fileMenu.add_command(label="Open", command=self.on_load) fileMenu.add_command(label="Exit", command=self.on_button_close) menubar.add_cascade(label="File", menu=fileMenu) self.parent.bind('<Control-c>', self.on_button_close)
def insert_dynamiclabel(self, header, frame_name, idx, **kwargs): side = kwargs.get('side',None) stick = kwargs.get('stick', None) unit = kwargs.get('units', None) frame = self.frames[frame_name] # pack info label1 = Label(frame, text=header+': ', ) label2 = Label(frame, text='---'+unit) label1.grid(row=idx[0], column=idx[1], sticky=stick) label2.grid(row=idx[0], column=idx[1]+1, sticky=stick) # save data regarding the widget if self.dynamiclabels.get(frame_name, None) == None: self.dynamiclabels[frame_name] = {} self.dynamiclabels[frame_name][header] = label2
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 createui(self): image = Image.open('header.png') photo = ImageTk.PhotoImage(image) lbl = Label(self, image=photo) lbl.image = photo lbl.grid(row=0, column=0, columnspan=2, sticky='ns') self.treeview = Treeview(self) self.treeview['columns'] = ['title'] self.treeview.heading("#0", text='Repeticiones', anchor='center') self.treeview.column("#0", anchor="center", width=90) self.treeview.heading('title', text='Titulo', anchor='w') self.treeview.column('title', anchor='w', width=700) self.treeview.grid(sticky=(N, S, W, E)) self.treeview.bind("<Double-1>", self.openlink) ysb = Scrollbar(self, width=18, orient='vertical', command=self.treeview.yview) ysb.grid(row=1, column=1, sticky='ns') self.treeview.configure(yscroll=ysb.set) self.grid_rowconfigure(1, weight=1) self.grid_columnconfigure(0, weight=1)
def init(self): self.parent.title('FuzzyOctoDubstep') 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) conv_scrollbar = Scrollbar(self) conv_scrollbar.grid(row=1, column=2) conv = Listbox(self, width=80, height=30, yscrollcommand=conv_scrollbar.set) conv.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) conv.insert(END, 'Hello') conv_scrollbar.config(command=conv.yview) 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 _init_ui(self): """ Composes the UI and associates the appropriate handler for the actions to catch. """ self._parent.title("Events") 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) label = Label(self, text="Actions") label.grid(sticky=W, pady=4, padx=5) self._text_area = self.ReadOnlyText(self) self._text_area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) scrollbar = Scrollbar(self, command=self._text_area.yview) scrollbar.grid(row=1, column=2, rowspan=4, sticky=N + S) self._text_area['yscrollcommand'] = scrollbar.set start_button = Button(self, text="Start", command=self._rec_start) start_button.grid(row=1, column=3) stop_button = Button(self, text="Stop", command=self._rec_stop) stop_button.grid(row=2, column=3, pady=4) save_button = Button( self, text="Save", ) save_button.grid(row=5, column=3) quit_button = Button(self, text="Quit", command=self._exit) quit_button.grid(row=5, column=0, padx=5)
def __init__(self, parent, control): Frame.__init__(self, parent) self.parent = parent self.parent.title("Mipsx - GUI for gdb multiarch") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) # Para expandir cuando las ventanas cambian de tamao for i in range(3): self.columnconfigure(i, weight=1) for i in range(20): self.rowconfigure(i, weight=1) lbl = Label(self, text="Foto") lbl.grid(row=3,column=0, sticky=W, pady=4, padx=5) self.registros = Text(self,height=12,width=40) self.registros.grid(row=4, column=0, columnspan=1, rowspan=5, sticky=E+W+S+N) lbl = Label(self, text="Foto 2") lbl.grid(row=3,column=1, sticky=W, pady=4, padx=5) self.foto2 = Text(self,height=12,width=40) self.foto2.grid(row=4, column=1, sticky=E+W+S+N) lbl = Label(self, text="Numero de la Video Camara") lbl.grid(row=2,column=0, sticky=W, pady=1, padx=5) self.camara = Entry(self) self.camara.grid(row=2, column=1, columnspan=1, padx=1, sticky=E+W+S+N) lbl = Label(self, text="Limite de grosor") lbl.grid(row=1,column=0, sticky=W, pady=4, padx=5) self.editor = Entry(self) self.editor.grid(row=1, column=1, columnspan=1, padx=1, sticky=E+W+S+N) menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_command(label="Tomar Foto", command=control.ejecutar) helpmenu = Menu(menu) menu.add_cascade(label="Ayuda", menu=helpmenu) helpmenu.add_command(label="Acerca de...", command=control.acercade) menu.add_command(label="Salir", command=control.salir)
def initUI(self): self.parent.title("Whiteboarder") 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=0) self.rowconfigure(5, pad=7) frame = Frame(self, relief=RAISED, borderwidth=1) #frame.pack() lbl = Label(self) lbl.grid(sticky=W, pady=5, padx=15) root = Tk() area = StructureCanvas(root)#Text(self) root.mainloop() area.grid(row=1, column=0, columnspan=2, rowspan= 6, padx=15, sticky=E+W+S+N) #area.pack(side="top", fill="both", expand=True) def createLL(): _LL_.linked_list() print "Linked List chosen" lbtn = Button(self, text="Linked List", command = createLL()) lbtn.grid(row=1, column=3, padx = 2, pady=4) abtn = Button(self, text="Array") abtn.grid(row=2, column=3, padx = 2, pady=4) tbtn = Button(self, text="Tree") tbtn.grid(row=3, column=3, padx = 2, pady=4) ogbtn = Button(self, text="Other Graph") ogbtn.grid(row=4, column=3, padx = 2, pady=4) obtn = Button(self, text="Process") obtn.grid(row=7, column=3, pady=4)
def initUI(self): #create initial Beings object (not instantiated until live is called) self.wc = WorldConfiguration() self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) self.columnconfigure(2, weight=1) self.columnconfigure(4, pad=7) self.rowconfigure(3, weight=1) lbl = Label(self, text="PyLife") lbl.grid(sticky = W, padx=25, pady=5) self.world = Canvas(self, background="#7474DB") self.world.grid(row=1, column=0, columnspan=3, rowspan=8, padx=5, sticky=E+W+N+S) self.sbtn = Button(self, text="Stop") self.sbtn.grid(row=1, column=4, pady = 5, sticky=E) self.bbox = Text(self, height=20, width=36) self.bbox.grid(row=3, column = 4, padx=5, sticky=E+W+N+S) self.bbox1 = Text(self, height=11, width=36) self.bbox1.grid(row=4, column=4, padx=5, sticky=E+W+N+S) self.cbtn = Button(self, text="Close", command=self.parent.destroy) self.cbtn.grid(row=9, column=4, pady=5) self.cnfbtn = Button(self, text="Configure Universe") self.cnfbtn.grid(row=9, column=0, padx=5) self.timelbl = Text(self, height=1, width=10) self.timelbl.grid(row=2, column=4, pady=5 ) b = Beings(self) abtn = Button(self, text="Start", command=b.live) #Beings(cnfbtn, world, 4, 10, sbtn, bbox, bbox1, timelbl).live) abtn.grid(row=1, column=4, pady=5, sticky=W) self.cnfbtn.config(command=b.configure)
class DirectorySelector(): def __init__(self, parent=None, text='Directory:', get_default=None): # NOTE: This class used to be a subclass of Frame, but it did not grid properly in the main window #Frame.__init__(self, parent) self.parent = parent self.label = Label(parent, text=text) self.directory = StringVar() on_change_cmd = parent.register(self.on_change) self.dir_entry = Entry(parent, textvariable=self.directory, validatecommand=on_change_cmd, validate='all') self.browse_btn = BrowseDirectoryButton(parent, entry=self) self.get_default = get_default self.notify_other = None def set_notify(self, notify_other): self.notify_other = notify_other def set_grid(self, row=0, padx=0): #self.grid(row=row) self.label.grid(row=row, column=0, sticky='e') self.dir_entry.grid(row=row, column=1, padx=padx, sticky='w') self.browse_btn.grid(row=row, column=2) def set_directory(self, directory): self.directory.set(directory) if self.notify_other != None: self.notify_other() #if self.parent != None: #self.parent.on_focus() def get_directory(self): directory = str(self.directory.get()) if len(directory) > 0 and directory[len(directory)-1] != '/': directory = directory + '/' return directory def on_change(self): if self.get_default != None and self.get_directory() == '': self.set_directory(self.get_default()) return True def notify(self): self.on_change()
def createBitFrame(self, bit): ledCardBitFrm = Frame(self.ledCardFrm, borderwidth=5, relief=RAISED) self.bitFrms.append(ledCardBitFrm) ledCardBitFrm.grid(column=rs232Intf.NUM_LED_PER_BRD - bit - 1, row=0) tmpLbl = Label( ledCardBitFrm, text="%s" % GameData.LedBitNames.LED_BRD_BIT_NAMES[self.brdNum][bit]) tmpLbl.grid(column=0, row=0) #Graphic of LED on self.canvas.append(Canvas(ledCardBitFrm, width=100, height=80)) self.canvas[bit].grid(column=0, row=1) if ((self.prevLedState & (1 << bit)) == 0): self.canvas[bit].create_image(48, 40, image=TkLedBrd._ledOffImage) else: self.canvas[bit].create_image(48, 40, image=TkLedBrd._ledOnGrnImage)
def initUI(self): self.parent.title("Windows") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #<grid system> self.columnconfigure(1, weight=1) self.columnconfigure(3,pad=7) self.rowconfigure(3,weight=1) self.rowconfigure(5, pad=7) #I believe you don't have to define every single row and column #It just assumes that there are 5 rows and 3 columns #3 and 5 are the largest numbers in col and row respectively. #</grid system> #<Text or label is used> lbl=Label(self, text="Windows") lbl.grid(sticky=W,pady=4,padx=5) #notice that not grid position was specified, thus it assumes it is put #into the top entry. #</Text of label is used> #<text box spanning multiple rows> area = Text(self) area.grid(row=1, column= 0, columnspan=2,rowspan=4,padx=5, sticky=E+W+S+N) #</text box spanning multiple rows> 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)
class EntryFrame(Frame): def __init__(self, parent, question, default_text): Frame.__init__(self, parent) self.answer = StringVar() self.answer.set(default_text) self.question = Label(self, text=question, style='Title.TLabel') self.question.grid(column=0, row=0, padx=10, pady=10, sticky='w') self.entry = Entry(self, width=25, textvariable=self.answer) self.entry.grid(column=0, row=1, padx=10) self.entry.select_range(0, END) self.entry.icursor(END) self.entry.bind('<Return>', func=lambda e: self.quit()) self.entry.focus_force() 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, sticky='e') 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 OkBut(self): self.quit()
def initGUI(self): self.master.title("Stepper Motor Control Panel") self.pack(fill=BOTH, expand=True) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=5) self.rowconfigure(4, weight=1) self.rowconfigure(5, pad=7) lbl = Label(self, text="Coil Sequence") lbl.grid(sticky=W, pady=4, padx=5) self.user_step = 0 self.formed_step_list = False self.step_holder = [] self.stop = False self.entry1 = Text(self) self.entry1.grid(row=1, column=0, columnspan=2, rowspan=6, padx=5, sticky=E + W + S + N) self.current_step = StringVar() lbl2 = Label(self, text="", textvariable=self.current_step) lbl2.grid(row=1, column=3) abtn = Button(self, text="Apply Single Step", command=self.single_step) abtn.grid(row=2, column=3) lbl3 = Label(self, text="Continuous motion") lbl3.grid(row=3, column=3, rowspan=1, columnspan=1) lbl4 = Label(self, text="Delay between steps (ms)") lbl4.grid(row=4, column=3, rowspan=1, columnspan=1) self.delay = StringVar() entry2 = Entry(self, textvariable=self.delay) entry2.grid(row=5, column=3, rowspan=1, columnspan=1, sticky=W + S + N) bbtn = Button(self, text="Continuous Run", command=self.continuous_run) bbtn.grid(row=6, column=3) cbtn = Button(self, text="STOP", command=self.stop_motor) cbtn.grid(row=7, column=3)