def instructions(self): """Open instructions window.""" # Instantiates separate Toplevel instruction window. instr_window = Toplevel(self.root) instr_window.geometry('550x575+25+25') instr_window.title('Instructions') instr_window.wm_iconbitmap(constants.ICO) instr_window.resizable(False, False) # Creatse Scrollbar and Frame for containing other widgets. instr_scroll = Scrollbar(instr_window) instr_scroll.pack(fill=Y, side="right") instr_frame = Frame(instr_window, bg='white') instr_frame.pack(fill=BOTH, side="left") # Adds instruction text from constants and adds image of Cinzano's diagram. instr = Text(instr_frame, width=65, height=40, padx=10, pady=5, bd=0, wrap="word") instr.insert("end", constants.INSTR) cdiagram_file = Image.open("./static/cinzano_diagram.PNG") cdiagram_file = cdiagram_file.resize((500, 450), Image.ANTIALIAS) self.cdiag = ImageTk.PhotoImage(cdiagram_file) instr.image_create("end", image=self.cdiag) instr.tag_add("top", "1.0", "4.10") instr.tag_config("top", font='Times 12 bold') instr.tag_add("body", "5.0", "19.20") instr.tag_config("body", font='Times 12') instr.insert("end", constants.CDIAG) instr.pack() instr_scroll.config(command=instr.yview)
class console: def __init__(self, master): self.Yscroll = Scrollbar(master) self.Yscroll.pack(side=RIGHT, fill=Y) self.text = Text(master, padx=5, pady=5, height=10, bg="Black", fg="White", font=(DEFAULT_FONT, 12), yscrollcommand=self.Yscroll.set) self.Yscroll.config(command=self.text.yview) self.text.bind("<Key>", lambda e: "break") self.text.pack(fill=BOTH, expand=1) def __str__(self): """ str(s) -> string """ return self.text.get() def write(self, string): """ Adds string to the bottom of the console """ self.text.insert(END, string) self.text.see(END) return def read(self): """ Returns contents of the console widget """ return str(self)
def __init__(self, parent): """Construct a DualBox. :param parent """ Frame.__init__(self) self._select_callback = parent.select_cart # make scroll bar scroll_bar = Scrollbar(self, orient=Tkinter.VERTICAL, command=self._scroll_bar) label1 = Label(self, text=TEXT_LABEL1) label2 = Label(self, text=TEXT_LABEL2) # make two scroll boxes self._list_box1 = Listbox(self, yscrollcommand=scroll_bar.set, exportselection=0, width=40) self._list_box2 = Listbox(self, yscrollcommand=scroll_bar.set, exportselection=0, width=40) # fill the whole screen - pack! scroll_bar.pack(side=Tkinter.RIGHT, fill=Tkinter.Y) label1.pack(side=Tkinter.LEFT, fill=Tkinter.X, expand=True) self._list_box1.pack(side=Tkinter.LEFT, fill=Tkinter.X, expand=True, padx=5, pady=5) self._list_box2.pack(side=Tkinter.LEFT, fill=Tkinter.X, expand=True, padx=5, pady=5) label2.pack(side=Tkinter.LEFT, fill=Tkinter.X, expand=True) # mouse wheel binding self._list_box1.bind("<MouseWheel>", self._scroll_wheel) self._list_box2.bind("<MouseWheel>", self._scroll_wheel) # onclick binding? self._list_box1.bind("<<ListboxSelect>>", self.select) self._list_box2.bind("<<ListboxSelect>>", self.select)
class searchDialog(Toplevel): def __init__(self, parent, title): self.top = Toplevel(parent) self.top.wm_title(title) self.top.wm_minsize(width=300, height=400) self.top.bind("<Return>", self.searchThreader) self.top.bind("<Escape>", self.close) self.searchy = Text(self.top) self.searchy.config(wrap=WORD) self.search_entry = Entry(self.top) self.close = Button(self.top, text="Close", command=self.close) self.search_button = Button(self.top, text="Search", command=self.searchThreader) self.scrollbar = Scrollbar(self.top) self.scrollbar.pack(side=RIGHT, fill=Y, expand=0) self.searchy.config(yscrollcommand=self.scrollbar.set, state=DISABLED) self.searchy.pack(side=TOP, fill=BOTH, expand=1) self.search_entry.pack(side=LEFT, fill=X, expand=1) self.close.pack(side=RIGHT, fill=BOTH, expand=0) self.search_button.pack(side=RIGHT, fill=BOTH, expand=0) self.linker = HyperlinkManager(self.searchy) def close(self, event=None): global SEARCH SEARCH = None self.top.destroy() def putText(self, text): updateDisplay(text, self.searchy, self.linker) def clearSearch(self): self.searchy.config(state=NORMAL) self.searchy.delete(1.0, END) self.searchy.config(state=DISABLED) def searchThreader(self, event=None, text=None): self.sear = upThread(6, 'search', (self, text)) self.sear.start() def search(self, toSearch=None): if toSearch is None: keyword = self.search_entry.get() self.search_entry.delete(0, END) else: keyword = toSearch self.clearSearch() self.top.wm_title("Search - " + keyword) if keyword.split('@')[0] == '': self.putText( API.GetUserTimeline( screen_name=keyword.split('@')[1] ) ) else: self.putText(API.GetSearch(term=keyword))
def __init__(self, root=None): self.root = root or Tk() self.root.title('Pylint') top_frame = Frame(self.root) res_frame = Frame(self.root) btn_frame = Frame(self.root) top_frame.pack(side=TOP, fill=X) res_frame.pack(side=TOP, fill=BOTH, expand=True) btn_frame.pack(side=TOP, fill=X) Label(top_frame, text='Module or package').pack(side=LEFT) self.txtModule = Entry(top_frame, background='white') self.txtModule.bind('<Return>', self.run_lint) self.txtModule.pack(side=LEFT, expand=True, fill=X) Button(top_frame, text='Run', command=self.run_lint).pack(side=LEFT) scrl = Scrollbar(res_frame) self.results = Listbox(res_frame, background='white', font='fixedsys', selectmode='browse', yscrollcommand=scrl.set) scrl.configure(command=self.results.yview) self.results.pack(side=LEFT, expand=True, fill=BOTH) scrl.pack(side=RIGHT, fill=Y) Button(btn_frame, text='Quit', command=self.quit).pack(side=BOTTOM) #self.root.bind('<ctrl-q>', self.quit) self.txtModule.focus_set()
def buildDisplay(self): winWidth = 1000 winHeight = 800 frame = Frame(self.root, width=winWidth, height=winHeight) frame.pack(side=TOP, expand=YES, fill=X) c = Canvas(frame, width=winWidth, height=winHeight, scrollregion=(0, 0, self.canvasWidth, self.canvasHeight)) hbar = Scrollbar(frame, orient=HORIZONTAL) hbar.pack(side=BOTTOM, fill=X) hbar.config(command=c.xview) vbar = Scrollbar(frame, orient=VERTICAL) vbar.pack(side=RIGHT, fill=Y) vbar.config(command=c.yview) c.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set) c.pack(side=LEFT, expand=YES, fill=BOTH) self.canvas = c editFrame = Frame(self.root, width=winWidth, height=0) editFrame.pack(side=BOTTOM, fill=X) self.editFrame = editFrame
def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args, **kw) # create a canvas object and a vertical scrollbar for scrolling it vscrollbar = Scrollbar(self, orient=VERTICAL) vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE) canvas = Canvas(self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set) canvas.pack(side=LEFT, fill=BOTH, expand=TRUE) vscrollbar.config(command=canvas.yview) # reset the view canvas.xview_moveto(0) canvas.yview_moveto(0) # create a frame inside the canvas which will be scrolled with it self.interior = interior = Frame(canvas) interior_id = canvas.create_window(0, 0, window=interior, anchor=NW) # track changes to the canvas and frame width and sync them, # also updating the scrollbar def _configure_interior(event=None): # update the scrollbars to match the size of the inner frame size = (interior.winfo_reqwidth(), interior.winfo_reqheight()) canvas.config(scrollregion="0 0 %s %s" % size) if interior.winfo_reqwidth() != canvas.winfo_width(): # update the canvas's width to fit the inner frame canvas.config(width=interior.winfo_reqwidth()) interior.bind('<Configure>', _configure_interior) def _configure_canvas(event=None): if interior.winfo_reqwidth() != canvas.winfo_width(): # update the inner frame's width to fill the canvas canvas.itemconfigure(interior_id, width=canvas.winfo_width()) canvas.bind('<Configure>', _configure_canvas)
def __init__(self, master, title, text): Toplevel.__init__(self, master=master) self.title(title) fra = Frame(self) fra.grid(row=0, column=0, pady=5, padx=5) self.tx = Text(fra, width=130, height=20, wrap=WORD) scr = Scrollbar(fra, command=self.tx.yview) self.tx.configure(yscrollcommand=scr.set) self.tx.pack(side=LEFT) scr.pack(side=RIGHT, fill=Y) self.tx.bind('<Enter>', lambda e: self._bound_to_mousewheel(e, self.tx)) self.tx.bind('<Leave>', self._unbound_to_mousewheel) self.tx.insert(END, text) self.tx.configure(state='disabled') if platform == "darwin": button_font = Font(family='Arial', size=15) else: button_font = Font(font=Button()["font"]) closeTopolPrevB = Button(self, text='Exit', bg='red', command=self.destroy, font=button_font) closeTopolPrevB.grid(row=1, column=0, pady=5)
class console: def __init__(self, master): self.Yscroll = Scrollbar(master) self.Yscroll.pack(side=RIGHT, fill=Y) self.text = Text( master, padx=5, pady=5, height=10, bg="Black", fg="White", font=(DEFAULT_FONT, 12), yscrollcommand=self.Yscroll.set) self.Yscroll.config(command=self.text.yview) self.text.bind("<Key>", lambda e: "break") self.text.pack(fill=BOTH, expand=1) def __str__(self): """ str(s) -> string """ return self.text.get() def write(self, string): """ Adds string to the bottom of the console """ self.text.insert( END, string ) self.text.see(END) return def read(self): """ Returns contents of the console widget """ return str(self)
def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args, **kw) vscrollbar = Scrollbar(self, orient=VERTICAL) vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE) canvas = Canvas(self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set) canvas.pack(side=LEFT, fill=BOTH, expand=TRUE) vscrollbar.config(command=canvas.yview) canvas.xview_moveto(0) canvas.yview_moveto(0) self.interior = interior = Frame(canvas) interior_id = canvas.create_window(0, 0, window=interior, anchor=NW) self.canv = canvas # @UndefinedVariable self.scroller = vscrollbar def _configure_interior(event): size = (interior.winfo_reqwidth(), interior.winfo_reqheight()) canvas.config(scrollregion="0 0 %s %s" % size) if interior.winfo_reqwidth() != canvas.winfo_width(): canvas.config(width=interior.winfo_reqwidth()) interior.bind('<Configure>', _configure_interior) def _configure_canvas(event): if interior.winfo_reqwidth() != canvas.winfo_width(): canvas.itemconfigure(interior_id, width=canvas.winfo_width()) canvas.bind('<Configure>', _configure_canvas)
class ScrolledText2(Text): def __init__(self, master=None, change_hook=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) self.hbar = Scrollbar(self.frame, orient=HORIZONTAL) self.hbar.pack(side=BOTTOM,fill=X) kw.update({'yscrollcommand': self.vbar.set}) kw.update({'xscrollcommand': self.hbar.set}) kw.update({'wrap': 'none'}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview self.hbar['command'] = self.xview # Copy geometry methods of self.frame without overriding Text # methods -- hack! text_meths = vars(Text).keys() methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() methods = set(methods).difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m)) def __str__(self): return str(self.frame)
def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args, **kw) # create a canvas object and a vertical scrollbar for scrolling it vscrollbar = Scrollbar(self, orient=Tkinter.VERTICAL) vscrollbar.pack(fill=Tkinter.Y, side=Tkinter.RIGHT, expand=Tkinter.FALSE) hscrollbar = Scrollbar(self, orient=Tkinter.HORIZONTAL) hscrollbar.pack(fill=Tkinter.X, side=Tkinter.BOTTOM, expand=Tkinter.FALSE) canvas = Canvas(self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set, xscrollcommand=hscrollbar.set) canvas.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=Tkinter.TRUE) vscrollbar.config(command=canvas.yview) hscrollbar.config(command=canvas.xview) # reset the view canvas.xview_moveto(0) canvas.yview_moveto(0) # create a frame inside the canvas which will be scrolled with it self.interior = interior = Frame(canvas) interior_id = canvas.create_window(0, 0, window=interior, anchor=Tkinter.NW) # track changes to the canvas and frame width and sync them, # also updating the scrollbar def _configure_interior(event): ''' update the scrollbars to match the size of the inner frame ''' size = (interior.winfo_reqwidth(), interior.winfo_reqheight()) canvas.config(scrollregion='0 0 %s %s' % size) if interior.winfo_reqwidth() != canvas.winfo_width(): # update the canvas's width to fit the inner frame canvas.config(width=interior.winfo_reqwidth()) interior.bind('<Configure>', _configure_interior) def _configure_canvas(event): ''' _configure_canvas is used to resize the window size to fit content. Can be used when changing window. ''' if interior.winfo_reqwidth() != canvas.winfo_width(): # update the inner frame's width to fill the canvas canvas.itemconfigure(interior_id, width=canvas.winfo_width())
def __init__(self, list_=None, master=None, title=None): '''Must have master, title is optional, li is too.''' self.master = master if self.master is not None: self.top = Toplevel(self.master) else: return self.v = None if list_ is None or not isinstance(list_, list): self.list = [] else: self.list = list_[:] self.top.transient(self.master) self.top.grab_set() self.top.bind("<Return>", self._choose) self.top.bind("<Escape>", self._cancel) if title: self.top.title(title) lf = Frame(self.top) #Sets up the list. lf.pack(side=TOP) scroll_bar = Scrollbar(lf) scroll_bar.pack(side=RIGHT, fill=Y) self.lb = Listbox(lf, selectmode=SINGLE) self.lb.pack(side=LEFT, fill=Y) scroll_bar.config(command=self.lb.yview) self.lb.config(yscrollcommand=scroll_bar.set) self.list.sort() for item in self.list: self.lb.insert(END, item) #Inserts items into the list. bf = Frame(self.top) bf.pack(side=BOTTOM) Button(bf, text="Select", command=self._choose).pack(side=LEFT) Button(bf, text="New", command=self._new).pack(side=LEFT) Button(bf, text="Cancel", command=self._cancel).pack(side=LEFT)
def __init__(self, root=None): Frame.__init__(self, root) self.textedit = PinguinoTextEdit(self, borderwidth=0, relief=FLAT, highlightthickness=0, font="mono 11") self.linenumber = LineNumber(self, bg="#afc8e1", borderwidth=0, relief=FLAT, highlightthickness=0) self.linenumber.set_editor(self.textedit) self.textedit.set_linenumber(self.linenumber) ysb = Scrollbar(self.textedit, orient='vertical', command=self.textedit.yview) xsb = Scrollbar(self.textedit, orient='horizontal', command=self.textedit.xview) self.textedit.set_scrolls(xsb, ysb) self.textedit.configure(yscroll=ysb.set, xscroll=xsb.set) xsb.pack(side=BOTTOM, fill=X, expand=False) ysb.pack(side=RIGHT, fill=Y, expand=False) self.textedit.pack(side=RIGHT, fill=BOTH, expand=True) self.linenumber.pack(side=LEFT, fill=Y, expand=False) Frame(self, bg="#e7e7e7", width=10).pack(side=LEFT, fill=Y) Frame(self, bg="#ffffff", width=5).pack(side=LEFT, fill=Y) ysb.bind("<B1-Motion>", self.textedit.update_linenumber) self.textedit.bind("<B1-Motion>", self.textedit.update_linenumber) self.textedit.bind("<Button-4>", self.textedit.update_linenumber) self.textedit.bind("<Button-5>", self.textedit.update_linenumber) self.textedit.bind("<MouseWheel>", self.textedit.update_linenumber)
def __init__(self, host, port, queue, thread_client): """ @param host: unicode @param port: int @param queue: Queue """ # initialization self.threaded_client=thread_client # Constants self.TEXT_WIDTH = 150 self.INPUT_WIDTH = self.TEXT_WIDTH - self.TEXT_WIDTH/3 # Connecting socket self.queue = queue self.socket = socket(AF_INET, SOCK_STREAM) self.socket.connect((host, port)) # Mount widgets scrollbar = Scrollbar() scrollbar.pack(side=RIGHT, fill=Y) self.text = Text(width=self.TEXT_WIDTH, yscrollcommand=scrollbar.set) self.text.pack(side=TOP) self.input = Entry(width=self.INPUT_WIDTH) self.input.pack(side=LEFT) self.send = Button(text="Send a message", command=self.send_message) self.send.pack(side=LEFT) self.input.bind("<Return>", self.send_message)
def get_box(self): if not self.dialog: from Tkinter import Tk,Listbox,Button,Scrollbar,X,Y,BOTTOM,RIGHT,HORIZONTAL,VERTICAL,OptionMenu,StringVar self.dialog = Tk() self.dialog.title("TODO") scrollbar = Scrollbar(self.dialog,orient=HORIZONTAL) yscrollbar = Scrollbar(self.dialog,orient=VERTICAL) self.todolist = Listbox(self.dialog,width=50,xscrollcommand=scrollbar.set,yscrollcommand=yscrollbar.set) scrollbar.config(command=self.todolist.xview) scrollbar.pack(side=BOTTOM,fill=X) yscrollbar.config(command=self.todolist.yview) yscrollbar.pack(side=RIGHT,fill=Y) self.todolist.pack(side="left",fill="both",expand=True) cat_list_name = StringVar() cat_list_name.set("Category") btn = Button(self.dialog,text="Refresh",command=self.refresh_list) btn.pack() self.refresh_list() if self.categories: self.cat_list = OptionMenu(self.dialog,cat_list_name,*(self.categories+["ALL","NONE"]),command=self.filter_list) self.cat_list.pack() return (self.dialog,self.todolist)
def _init_grammar(self, parent): # Grammar view. self._prodframe = listframe = Frame(parent) self._prodframe.pack(fill='both', side='left', padx=2) self._prodlist_label = Label(self._prodframe, font=self._boldfont, text='Available Expansions') self._prodlist_label.pack() self._prodlist = Listbox(self._prodframe, selectmode='single', relief='groove', background='white', foreground='#909090', font=self._font, selectforeground='#004040', selectbackground='#c0f0c0') self._prodlist.pack(side='right', fill='both', expand=1) self._productions = list(self._parser.grammar().productions()) for production in self._productions: self._prodlist.insert('end', (' %s' % production)) self._prodlist.config(height=min(len(self._productions), 25)) # Add a scrollbar if there are more than 25 productions. if len(self._productions) > 25: listscroll = Scrollbar(self._prodframe, orient='vertical') self._prodlist.config(yscrollcommand=listscroll.set) listscroll.config(command=self._prodlist.yview) listscroll.pack(side='left', fill='y') # If they select a production, apply it. self._prodlist.bind('<<ListboxSelect>>', self._prodlist_select)
class ScrolledText2(Text): def __init__(self, master=None, change_hook=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) self.hbar = Scrollbar(self.frame, orient=HORIZONTAL) self.hbar.pack(side=BOTTOM, fill=X) kw.update({'yscrollcommand': self.vbar.set}) kw.update({'xscrollcommand': self.hbar.set}) kw.update({'wrap': 'none'}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview self.hbar['command'] = self.xview # Copy geometry methods of self.frame without overriding Text # methods -- hack! text_meths = vars(Text).keys() methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() methods = set(methods).difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m)) def __str__(self): return str(self.frame)
def build_dlg(self): top = self.top button = UpdatedButton(top, text = _("Close"), name = 'close', command = self.close_dlg) button.pack(side = BOTTOM, expand = 0, fill = X) button = UpdatedButton(top, text = _("Apply"), command = self.apply_style, sensitivecb = self.can_apply) button.pack(side = BOTTOM, expand = 0, fill = X) self.Subscribe(SELECTION, button.Update) button = UpdatedButton(top, text = _("Delete"), command = self.remove_style, sensitivecb = self.can_remove) button.pack(side = BOTTOM, expand = 0, fill = X) list_frame = Frame(top) list_frame.pack(side = TOP, expand = 1, fill = BOTH) sb_vert = Scrollbar(list_frame, takefocus = 0) sb_vert.pack(side = RIGHT, fill = Y) styles = UpdatedListbox(list_frame, name = 'list') styles.pack(expand = 1, fill = BOTH) styles.Subscribe(COMMAND, self.apply_style) sb_vert['command'] = (styles, 'yview') styles['yscrollcommand'] = (sb_vert, 'set') self.styles = styles
def build_dlg(self): top = self.top frame = Frame(top) frame.pack(side = BOTTOM, fill = X) button = UpdatedButton(frame, bitmap = pixmaps.LayerNew, name = 'new', command = self.new_layer) button.pack(side = LEFT, fill = BOTH, expand = 1) button = UpdatedButton(frame, bitmap = pixmaps.LayerUp, name = 'up', command = self.layer_up) button.pack(side = LEFT, fill = BOTH, expand = 1) button = UpdatedButton(frame, bitmap = pixmaps.LayerDown, name = 'down', command = self.layer_down) button.pack(side = LEFT, fill = BOTH, expand = 1) button = UpdatedButton(frame, text = _("Close"), name = 'close', command = self.close_dlg) button.pack(side = LEFT, fill = BOTH, expand = 1) list_frame = Frame(top) list_frame.pack(side = LEFT, expand = 1, fill = BOTH) sb_vert = Scrollbar(list_frame, takefocus = 0) sb_vert.pack(side = RIGHT, fill = Y) self.canvas = canvas = Canvas(list_frame) canvas.pack(expand = 1, fill = BOTH) self.frame = frame = Frame(canvas, name = 'list') canvas.create_window(0, 0, window = frame, anchor = NW) sb_vert['command'] = (canvas, 'yview') canvas['yscrollcommand'] = (sb_vert, 'set') self.active_var = IntVar(top)
class ScrolledList(object): # TODO add columns to the Scrolled list: # http://stackoverflow.com/questions/5286093/display-listbox-with-columns-using-tkinter def __init__(self, parent_frame): self._vsbar = Scrollbar(parent_frame) self._hsbar = Scrollbar(parent_frame, orient='horizontal') self._list = Listbox(parent_frame, relief=SUNKEN, font=('courier', 12)) self._vsbar.config(command=self._list.yview, relief=SUNKEN) self._hsbar.config(command=self._list.xview, relief=SUNKEN) self._list.config(yscrollcommand=self._vsbar.set, relief=SUNKEN) self._list.config(xscrollcommand=self._hsbar.set) self._vsbar.pack(side=RIGHT, fill=Y) self._hsbar.pack(side=BOTTOM, fill=X) self._list.pack(side=LEFT, expand=YES, fill=BOTH) #self._list.bind('<Double-1>', self.handlelist) self._list_pos = 0 def clear(self): self._list.delete(0, END) self._list_pos = 0 def append_list_entry(self, entry_str, fg=None): pos = self._list_pos self._list_pos += 1 self._list.insert(END, entry_str) if fg: self._list.itemconfig(pos, fg=fg) return pos def highlight_entry(self, entry_index, bg): self._list.itemconfig(index=entry_index, bg=bg)
def initUI(self): self.parent.title("Book downloader") self.style = Style() self.style.theme_use("default") framesearch = Frame(self) framesearch.pack(fill=BOTH) search_label = Label(framesearch, text="Filter books:", padx=5, pady=5, width=15) search_label.pack(side=LEFT) self.search_entry = Entry(framesearch) self.search_entry.pack(side=RIGHT, fill=X) self.search_entry.bind("<Return>", self.searchHandler) #self.search_entry.bind("<Key>", self.searchHandler) framelist = Frame(self, relief=RAISED, borderwidth=1) framelist.pack(fill=BOTH, expand=True) self.lb = Listbox(framelist, height=30) scrollbar = Scrollbar(framelist) scrollbar.pack(side=RIGHT, fill=Y) self.lb.config(yscrollcommand=scrollbar.set) scrollbar.config(command=self.lb.yview) self.loadLibrary() for b in self.book_list: self.lb.insert(END, b[0]) self.lb.pack(fill=BOTH) self.pack(fill=BOTH, expand=True) DownButton = Button(self, text="Download", command=self.downloadAction) DownButton.pack(side=RIGHT)
def __init__(self, master, lists): Frame.__init__(self, master) self.lists = [] for l, w in lists: self.frame = Frame(self) self.frame.pack(side=LEFT, expand=YES, fill=BOTH) Label(self.frame, text=l, borderwidth=1, relief=RAISED).pack(fill=X) lb = Listbox(self.frame, width=w, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE) lb.pack(expand=YES, fill=BOTH) self.lists.append(lb) lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) lb.bind('<Button-1>', lambda e, s=self: s._select(e.y)) lb.bind('<Leave>', lambda e: 'break') lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) lb.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) lb.bind('<Button-4>', lambda e, s=self: s._scroll(SCROLL, -1, UNITS)) lb.bind('<Button-5>', lambda e, s=self: s._scroll(SCROLL, 1, UNITS)) frame = Frame(self) frame.pack(side=LEFT, fill=Y) Label(frame, borderwidth=1, relief=RAISED).pack(fill=X) sb = Scrollbar(frame, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand'] = sb.set
def __init__(self, master=None): Frame.__init__(self, master) self.parent = master self.parent.geometry("640x480") self.parent.title(os.getenv("NAME") + " - Stdout") self.textedit = Text(self.parent, font="mono 10") self.textedit.pack(expand=True, fill=BOTH) buton = Button(self.parent, text="Close", command=self.quit) buton.pack(side=RIGHT, expand=False, padx=10, pady=10, ipadx=10) ysb = Scrollbar(self.textedit, orient='vertical', command=self.textedit.yview) xsb = Scrollbar(self.textedit, orient='horizontal', command=self.textedit.xview) self.textedit.configure(yscroll=ysb.set, xscroll=xsb.set) xsb.pack(side=BOTTOM, fill=X, expand=False) ysb.pack(side=RIGHT, fill=Y, expand=False) self.textedit.pack(side=TOP, fill=BOTH, expand=True) self.show_file()
def __init__(self, master, d_list, a_function): Frame.__init__(self, master) scrl_bar = Scrollbar(self) self.listbox = Listbox(self) scrl_bar.config(command=self.listbox.yview) scrl_bar.pack(side=RIGHT, fill=Y) self.listbox.config(yscrollcommand=scrl_bar.set) self.listbox.pack(side=LEFT, expand=YES, fill=BOTH) #load the listbox idx = 0 for item in d_list: fparts = item.split('.') # DEBUG print fparts if fparts[-1] == 'csv': self.listbox.insert(idx, item) idx += 1 # link double click to the processList self.listbox.bind('<Double-1>', self.processList) # attach a function passed form the master # not this si done as passd function so it could be anything self.passed_function = a_function
def _init_results_box(self, parent): innerframe = Frame(parent) i1 = Frame(innerframe) i2 = Frame(innerframe) vscrollbar = Scrollbar(i1, borderwidth=1) hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz') self.results_box = Text(i1, font=tkFont.Font(family='courier', size='16'), state='disabled', borderwidth=1, yscrollcommand=vscrollbar.set, xscrollcommand=hscrollbar.set, wrap='none', width='40', height='20', exportselection=1) self.results_box.pack(side='left', fill='both', expand=True) self.results_box.tag_config(self._HIGHLIGHT_WORD_TAG, foreground=self._HIGHLIGHT_WORD_COLOUR) self.results_box.tag_config(self._HIGHLIGHT_LABEL_TAG, foreground=self._HIGHLIGHT_LABEL_COLOUR) vscrollbar.pack(side='left', fill='y', anchor='e') vscrollbar.config(command=self.results_box.yview) hscrollbar.pack(side='left', fill='x', expand=True, anchor='w') hscrollbar.config(command=self.results_box.xview) #there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!! Label(i2, text=' ', background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e') i1.pack(side='top', fill='both', expand=True, anchor='n') i2.pack(side='bottom', fill='x', anchor='s') innerframe.pack(side='top', fill='both', expand=True)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent button_frame = Frame(self) button_frame.pack(side=TOP, fill=X, expand=0) text_frame = Frame(self) text_frame.pack(side=TOP, fill=BOTH, expand=1) t = Text(text_frame) t.pack(side=LEFT, fill=BOTH, expand=1) s = Scrollbar(text_frame) s.pack(side=LEFT, fill=Y, expand=1) bplay = Button(button_frame, text='Play', command=self.foo) bnext = Button(button_frame, text='Next') cplot = Checkbutton(button_frame, text="Backplot") cmat = Checkbutton(button_frame, text="Material") cbit = Checkbutton(button_frame, text="Bit") cpause1 = Checkbutton(button_frame, text="Pause after line") cpause2 = Checkbutton(button_frame, text="Pause after cmt") bplay.pack(side=LEFT) bnext.pack(side=LEFT) cplot.pack(side=LEFT) cmat.pack(side=LEFT) cbit.pack(side=LEFT) cpause1.pack(side=LEFT) cpause2.pack(side=LEFT)
def build_dlg(self): top = self.top list_frame = Frame(top) list_frame.pack(side=TOP, expand=1, fill=BOTH) sb_vert = Scrollbar(list_frame, takefocus=0) sb_vert.pack(side=RIGHT, fill=Y) module_list = UpdatedListbox(list_frame, name="list") module_list.pack(expand=1, fill=BOTH) module_list.Subscribe(COMMAND, self.do_reload) sb_vert["command"] = (module_list, "yview") module_list["yscrollcommand"] = (sb_vert, "set") self.module_list = module_list frame = Frame(top) frame.pack(side=BOTTOM, fill=X) for text, cmd in [ ("Reload Module", self.do_reload), ("Update List", self.update_list), ("Close", self.close_dlg), ]: button = UpdatedButton(frame, text=text, command=cmd) button.pack(side=TOP, fill=X, expand=1) self.update_list()
def __init__(self, parent, scrollbar=True, **kw): parent = mx.get_master(parent) self.parent = parent frame = Frame(parent) frame.pack(fill='both', expand=True) # text widget if "wrap" not in kw: kw["wrap"] = "word" tk.Text.__init__(self, frame, **kw) #self.pack(side='left', fill='both', expand=True) mx.AllMixins.__init__(self, parent) # scrollbar if scrollbar: scrb = Scrollbar(frame, orient='vertical', command=self.yview) self.config(yscrollcommand=scrb.set) scrb.pack(side='right', fill='y') # pop-up menu self.popup = Menu(self, tearoff=0) self.popup.add_command(label='Cut', command=self._cut) self.popup.add_command(label='Copy', command=self._copy) self.popup.add_command(label='Paste', command=self._paste) self.popup.add_separator() self.popup.add_command(label='Select All', command=self._select_all) self.popup.add_command(label='Clear All', command=self._clear_all) self.bind('<Button-3>', self._show_popup) # only allow mouse scroll when mouse inside text self.bind("<Leave>", lambda event: self.winfo_toplevel().focus_set(), "+") self.bind("<Enter>", lambda event: self.focus_set(), "+")
def _init_readingListbox(self, parent): self._readingFrame = listframe = Frame(parent) self._readingFrame.pack(fill="both", side="left", padx=2) self._readingList_label = Label(self._readingFrame, font=self._boldfont, text="Readings") self._readingList_label.pack() self._readingList = Listbox( self._readingFrame, selectmode="single", relief="groove", background="white", foreground="#909090", font=self._font, selectforeground="#004040", selectbackground="#c0f0c0", ) self._readingList.pack(side="right", fill="both", expand=1) # Add a scrollbar if there are more than 25 examples. listscroll = Scrollbar(self._readingFrame, orient="vertical") self._readingList.config(yscrollcommand=listscroll.set) listscroll.config(command=self._readingList.yview) listscroll.pack(side="right", fill="y") self._populate_readingListbox()
def _init_exampleListbox(self, parent): self._exampleFrame = listframe = Frame(parent) self._exampleFrame.pack(fill="both", side="left", padx=2) self._exampleList_label = Label(self._exampleFrame, font=self._boldfont, text="Examples") self._exampleList_label.pack() self._exampleList = Listbox( self._exampleFrame, selectmode="single", relief="groove", background="white", foreground="#909090", font=self._font, selectforeground="#004040", selectbackground="#c0f0c0", ) self._exampleList.pack(side="right", fill="both", expand=1) for example in self._examples: self._exampleList.insert("end", (" %s" % example)) self._exampleList.config(height=min(len(self._examples), 25), width=40) # Add a scrollbar if there are more than 25 examples. if len(self._examples) > 25: listscroll = Scrollbar(self._exampleFrame, orient="vertical") self._exampleList.config(yscrollcommand=listscroll.set) listscroll.config(command=self._exampleList.yview) listscroll.pack(side="left", fill="y") # If they select a example, apply it. self._exampleList.bind("<<ListboxSelect>>", self._exampleList_select)
def __init__(self, parent, tile_size, grid_vm=None): Frame.__init__(self, parent, relief=RAISED, borderwidth=1) self.parent = parent self.tile_size = tile_size self.grid_vm = grid_vm self.columnconfigure(0, weight=1) self.columnconfigure(1, pad=3) self.rowconfigure(0, weight=1) self.rowconfigure(1, pad=3) hbar = Scrollbar(self, orient=HORIZONTAL) vbar = Scrollbar(self, orient=VERTICAL) canvas = Canvas(self, xscrollcommand=hbar.set, yscrollcommand=vbar.set) self.canvas = canvas self.lines = [] canvas.bind_all("<MouseWheel>", self._on_mousewheel_vertical) canvas.bind_all("<Shift-MouseWheel>", self._on_mousewheel_horizontal) # Set up scroll bars hbar.pack(side=BOTTOM, fill=X) hbar.config(command=canvas.xview) vbar.pack(side=RIGHT, fill=Y) vbar.config(command=canvas.yview) canvas.grid(column=0, row=0, sticky=N + W + E + S) hbar.grid(column=0, row=1, sticky=W + E) vbar.grid(column=1, row=0, sticky=N + S) if grid_vm: self.set_vm(grid_vm)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.selected = ""; self.controller = controller label = Label(self, text="Select server", font=TITLE_FONT, justify=CENTER, anchor=CENTER) label.pack(side="top", fill="x", pady=10) self.button1 = Button(self, text="Next",state="disabled", command=self.callback_choose) button2 = Button(self, text="Refresh", command=self.callback_refresh) button3 = Button(self, text="Back", command=self.callback_start) scrollbar = Scrollbar(self) self.mylist = Listbox(self, width=100, yscrollcommand = scrollbar.set ) self.mylist.bind("<Double-Button-1>", self.twoClick) self.button1.pack() button2.pack() button3.pack() # create list with a scroolbar scrollbar.pack( side = "right", fill="y" ) self.mylist.pack( side = "top", fill = "x", ipadx=20, ipady=20, padx=20, pady=20 ) scrollbar.config( command = self.mylist.yview ) # create a progress bar label2 = Label(self, text="Refresh progress bar", justify='center', anchor='center') label2.pack(side="top", fill="x") self.bar_lenght = 200 self.pb = Progressbar(self, length=self.bar_lenght, mode='determinate') self.pb.pack(side="top", anchor='center', ipadx=20, ipady=20, padx=10, pady=10) self.pb.config(value=0)
def _init_grammar(self, parent): # Grammar view. self._prodframe = listframe = Frame(parent) self._prodframe.pack(fill='both', side='left', padx=2) self._prodlist_label = Label(self._prodframe, font=self._boldfont, text='Available Expansions') self._prodlist_label.pack() self._prodlist = Listbox(self._prodframe, selectmode='single', relief='groove', background='white', foreground='#909090', font=self._font, selectforeground='#004040', selectbackground='#c0f0c0') self._prodlist.pack(side='right', fill='both', expand=1) self._productions = list(self._parser.grammar().productions()) for production in self._productions: self._prodlist.insert('end', (' %s' % production)) self._prodlist.config(height=min(len(self._productions), 25)) # Add a scrollbar if there are more than 25 productions. if len(self._productions) > 25: listscroll = Scrollbar(self._prodframe, orient='vertical') self._prodlist.config(yscrollcommand = listscroll.set) listscroll.config(command=self._prodlist.yview) listscroll.pack(side='left', fill='y') # If they select a production, apply it. self._prodlist.bind('<<ListboxSelect>>', self._prodlist_select)
def setup_UI(self): # setup tk self.root = tk.Tk() self.root.title(settings.S_LIST_VERSION) self.root.geometry("180x" + str(self.root.winfo_screenheight() - 100) + "-50+20") self.root.wm_attributes("-topmost", 1) self.root.protocol("WM_DELETE_WINDOW", self.xmlrpc_kill) self.customFont = tkFont.Font(family="Helvetica", size=8) # set up lists listframe = Frame(self.root) scrollbar = Scrollbar(listframe, orient=tk.VERTICAL) self.listbox_numbering = tk.Listbox(listframe, yscrollcommand=scrollbar.set, font=self.customFont) self.listbox_content = tk.Listbox(listframe, yscrollcommand=scrollbar.set, font=self.customFont) h = 52 lbn_opt = {"height":h, "width":4} lbn_opt2 = {"height":h} scrollbar.config(command=self._scroll_lists) scrollbar.pack(side=tk.RIGHT, fill=tk.Y) self.listbox_numbering.config(lbn_opt) self.listbox_numbering.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.listbox_content.config(lbn_opt2) self.listbox_content.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) listframe.pack()
def buscar(pattern, index): def listar(event): lista.delete(0, END) ix = open_dir(index) with ix.searcher() as searcher: query = QueryParser(pattern, ix.schema).parse(unicode(entrada.get())) results = searcher.search(query) for r in results: lista.insert(END, r['titulo']) lista.insert(END, r['fecha']) lista.insert(END, r['username']) lista.insert(END, '') root = Tkinter.Toplevel() frame1 = Frame(root) entrada = Entry(frame1, bd=2, width=60) lab = Label(frame1, text="Buscar: ") entrada.bind("<Return>", listar) sc = Scrollbar(root) sc.pack(side=RIGHT, fill=Y) lista = Listbox(root, yscrollcommand=sc.set) frame1.pack(side=TOP) lista.pack(side=TOP, fill=BOTH) lab.pack(side=LEFT) entrada.pack(side=LEFT) sc.config(command=lista.yview) root.mainloop()
def _init_exampleListbox(self, parent): self._exampleFrame = listframe = Frame(parent) self._exampleFrame.pack(fill='both', side='left', padx=2) self._exampleList_label = Label(self._exampleFrame, font=self._boldfont, text='Examples') self._exampleList_label.pack() self._exampleList = Listbox(self._exampleFrame, selectmode='single', relief='groove', background='white', foreground='#909090', font=self._font, selectforeground='#004040', selectbackground='#c0f0c0') self._exampleList.pack(side='right', fill='both', expand=1) for example in self._examples: self._exampleList.insert('end', (' %s' % example)) self._exampleList.config(height=min(len(self._examples), 25), width=40) # Add a scrollbar if there are more than 25 examples. if len(self._examples) > 25: listscroll = Scrollbar(self._exampleFrame, orient='vertical') self._exampleList.config(yscrollcommand=listscroll.set) listscroll.config(command=self._exampleList.yview) listscroll.pack(side='left', fill='y') # If they select a example, apply it. self._exampleList.bind('<<ListboxSelect>>', self._exampleList_select)
def _init_readingListbox(self, parent): self._readingFrame = listframe = Frame(parent) self._readingFrame.pack(fill='both', side='left', padx=2) self._readingList_label = Label(self._readingFrame, font=self._boldfont, text='Readings') self._readingList_label.pack() self._readingList = Listbox(self._readingFrame, selectmode='single', relief='groove', background='white', foreground='#909090', font=self._font, selectforeground='#004040', selectbackground='#c0f0c0') self._readingList.pack(side='right', fill='both', expand=1) # Add a scrollbar if there are more than 25 examples. listscroll = Scrollbar(self._readingFrame, orient='vertical') self._readingList.config(yscrollcommand=listscroll.set) listscroll.config(command=self._readingList.yview) listscroll.pack(side='right', fill='y') self._populate_readingListbox()
def concolefooter(self): footerframe = Frame(self.master) footerframe.config(padx=5, pady=5, bg=Styles.colours["darkGrey"]) title = Message(footerframe, text="Console:", justify=CENTER, bg=Styles.colours["darkGrey"], foreground=Styles.colours["yellow"], width=100, font=Styles.fonts["entry"]) consoletext = Text(footerframe, height=5, width=80, bg=Styles.colours["darkGrey"], foreground=Styles.colours["grey"], state=NORMAL, relief=FLAT, font=Styles.fonts["console"]) consoletext.insert(END, "Welcome to Project Bi") consoletext.config(state=DISABLED) self.console.setconsolefield(consoletext) scroll = Scrollbar(footerframe, command=consoletext.yview, relief=FLAT) consoletext.configure(yscrollcommand=scroll.set) self.boptimize = yellowbutton(footerframe, "Optimize", 20, lambda e: self.observerstage()) deactivatebutton(self.boptimize) self.boptimize.pack(side=RIGHT, fill=BOTH, padx=5, pady=5) self.boptimize.configure(font=Styles.fonts["h1Button"]) title.pack(side=LEFT, fill=BOTH) scroll.pack(side=LEFT, fill=BOTH) consoletext.pack(side=LEFT, fill=BOTH) footerframe.grid(row=2, column=0, sticky=W + E + N + S, columnspan=2) return footerframe
def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args, **kw) vscrollbar = Scrollbar(self, orient=VERTICAL) vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE) canvas = Canvas( self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set) canvas.pack(side=LEFT, fill=BOTH, expand=TRUE) vscrollbar.config(command=canvas.yview) canvas.xview_moveto(0) canvas.yview_moveto(0) self.interior = interior = Frame(canvas) interior_id = canvas.create_window(0, 0, window=interior, anchor=NW) self.canv = canvas # @UndefinedVariable self.scroller = vscrollbar def _configure_interior(event): size = (interior.winfo_reqwidth(), interior.winfo_reqheight()) canvas.config(scrollregion="0 0 %s %s" % size) if interior.winfo_reqwidth() != canvas.winfo_width(): canvas.config(width=interior.winfo_reqwidth()) interior.bind('<Configure>', _configure_interior) def _configure_canvas(event): if interior.winfo_reqwidth() != canvas.winfo_width(): canvas.itemconfigure(interior_id, width=canvas.winfo_width()) canvas.bind('<Configure>', _configure_canvas)
def __init__(self, parent, scrollbar=True, **kw): self.parent = parent frame = Frame(parent) frame.pack(fill='both', expand=True) # text widget Text.__init__(self, frame, **kw) self.pack(side='left', fill='both', expand=True) # scrollbar if scrollbar: scrb = Scrollbar(frame, orient='vertical', command=self.yview) self.config(yscrollcommand=scrb.set) scrb.pack(side='right', fill='y') # pop-up menu self.popup = Menu(self, tearoff=0) self.popup.add_command(label='Cut', command=self._cut) self.popup.add_command(label='Copy', command=self._copy) self.popup.add_command(label='Paste', command=self._paste) self.popup.add_separator() self.popup.add_command(label='Select All', command=self._select_all) self.popup.add_command(label='Clear All', command=self._clear_all) self.bind('<Button-3>', self._show_popup)
def show_source_tree(head): root = Tk() frame = Frame(root) frame.pack(fill = 'both') tree = ttk.Treeview(frame) #insert root subroutine # @type head Node parent_id = tree.insert('', 'end', '', text = head.name) for child in head.children: child.insert_to_tree(tree, parent_id) #add scrollbar v_scrollbar = Scrollbar(frame, orient = VERTICAL, command = tree.yview) h_scrollbar = Scrollbar(frame, orient = HORIZONTAL, command = tree.xview) tree.configure(yscrollcommand = v_scrollbar.set, xscrollcommand = h_scrollbar.set) v_scrollbar.pack(side = 'right', fill = 'y') h_scrollbar.pack(side = 'bottom', fill = 'x') tree.pack(fill = 'both') root.geometry("600x600") root.mainloop()
def construct(self): status = Frame(self) self._update_bar = StatusBar(status) self._drawer = MazeCanvas.MazePlannerCanvas(self, self._update_bar, manager=self.manager) self._drawer.pack(expand=True,fill=BOTH) self._status_bar = StatusBar(status) Debug.d_level.set_message_pad(self._status_bar) self._status_bar.pack(side=BOTTOM, fill=X) self._update_bar.pack(side=BOTTOM, fill=X) x_scroll = Scrollbar(self._parent, orient=HORIZONTAL) x_scroll.config(command=self._drawer._canvas.xview) x_scroll.pack(side=BOTTOM,fill=X) y_scroll = Scrollbar(self._parent, orient=VERTICAL) y_scroll.config(command=self._drawer._canvas.yview) y_scroll.pack(side=RIGHT,fill=Y) self._drawer._canvas.config(xscrollcommand=x_scroll.set, yscrollcommand=y_scroll.set, scrollregion=(-MAX_CANVAS_X, -MAX_CANVAS_Y, MAX_CANVAS_X, MAX_CANVAS_Y)) self._drawer._canvas.bind() status.pack(side=BOTTOM, fill=X)
def _init_exampleListbox(self, parent): self._exampleFrame = listframe = Frame(parent) self._exampleFrame.pack(fill='both', side='left', padx=2) self._exampleList_label = Label(self._exampleFrame, font=self._boldfont, text='Examples') self._exampleList_label.pack() self._exampleList = Listbox(self._exampleFrame, selectmode='single', relief='groove', background='white', foreground='#909090', font=self._font, selectforeground='#004040', selectbackground='#c0f0c0') self._exampleList.pack(side='right', fill='both', expand=1) for example in self._examples: self._exampleList.insert('end', (' %s' % example)) self._exampleList.config(height=min(len(self._examples), 25), width=40) # Add a scrollbar if there are more than 25 examples. if len(self._examples) > 25: listscroll = Scrollbar(self._exampleFrame, orient='vertical') self._exampleList.config(yscrollcommand = listscroll.set) listscroll.config(command=self._exampleList.yview) listscroll.pack(side='left', fill='y') # If they select a example, apply it. self._exampleList.bind('<<ListboxSelect>>', self._exampleList_select)
def _init_grammar(self, parent): # Grammar view. self._prodframe = listframe = Frame(parent) self._prodframe.pack(fill="both", side="left", padx=2) self._prodlist_label = Label(self._prodframe, font=self._boldfont, text="Available Expansions") self._prodlist_label.pack() self._prodlist = Listbox( self._prodframe, selectmode="single", relief="groove", background="white", foreground="#909090", font=self._font, selectforeground="#004040", selectbackground="#c0f0c0", ) self._prodlist.pack(side="right", fill="both", expand=1) self._productions = list(self._parser.grammar().productions()) for production in self._productions: self._prodlist.insert("end", (" %s" % production)) self._prodlist.config(height=min(len(self._productions), 25)) # Add a scrollbar if there are more than 25 productions. if len(self._productions) > 25: listscroll = Scrollbar(self._prodframe, orient="vertical") self._prodlist.config(yscrollcommand=listscroll.set) listscroll.config(command=self._prodlist.yview) listscroll.pack(side="left", fill="y") # If they select a production, apply it. self._prodlist.bind("<<ListboxSelect>>", self._prodlist_select)
def xGC_skew(seq, window=1000, zoom=100, r=300, px=100, py=100): """Calculates and plots normal and accumulated GC skew (GRAPHICS !!!).""" from Tkinter import Scrollbar, Canvas, BOTTOM, BOTH, ALL, \ VERTICAL, HORIZONTAL, RIGHT, LEFT, X, Y yscroll = Scrollbar(orient=VERTICAL) xscroll = Scrollbar(orient=HORIZONTAL) canvas = Canvas(yscrollcommand=yscroll.set, xscrollcommand=xscroll.set, background='white') win = canvas.winfo_toplevel() win.geometry('700x700') yscroll.config(command=canvas.yview) xscroll.config(command=canvas.xview) yscroll.pack(side=RIGHT, fill=Y) xscroll.pack(side=BOTTOM, fill=X) canvas.pack(fill=BOTH, side=LEFT, expand=1) canvas.update() X0, Y0 = r + px, r + py x1, x2, y1, y2 = X0 - r, X0 + r, Y0 - r, Y0 + r ty = Y0 canvas.create_text(X0, ty, text='%s...%s (%d nt)' % (seq[:7], seq[-7:], len(seq))) ty += 20 canvas.create_text(X0, ty, text='GC %3.2f%%' % (GC(seq))) ty += 20 canvas.create_text(X0, ty, text='GC Skew', fill='blue') ty += 20 canvas.create_text(X0, ty, text='Accumulated GC Skew', fill='magenta') ty += 20 canvas.create_oval(x1, y1, x2, y2) acc = 0 start = 0 for gc in GC_skew(seq, window): r1 = r acc += gc # GC skew alpha = pi - (2*pi*start)/len(seq) r2 = r1 - gc*zoom x1 = X0 + r1 * sin(alpha) y1 = Y0 + r1 * cos(alpha) x2 = X0 + r2 * sin(alpha) y2 = Y0 + r2 * cos(alpha) canvas.create_line(x1, y1, x2, y2, fill='blue') # accumulated GC skew r1 = r - 50 r2 = r1 - acc x1 = X0 + r1 * sin(alpha) y1 = Y0 + r1 * cos(alpha) x2 = X0 + r2 * sin(alpha) y2 = Y0 + r2 * cos(alpha) canvas.create_line(x1, y1, x2, y2, fill='magenta') canvas.update() start += window canvas.configure(scrollregion=canvas.bbox(ALL))
class TextViewer(Toplevel): """A simple text viewer dialog for IDLE """ def __init__(self, parent, title, text): """Show the given text in a scrollable window with a 'close' button """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry( "=%dx%d+%d+%d" % (625, 500, parent.winfo_rootx() + 10, parent.winfo_rooty() + 10)) #elguavas - config placeholders til config stuff completed self.bg = '#ffffff' self.fg = '#000000' self.CreateWidgets() self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.textView.focus_set() #key bindings for this dialog self.bind('<Return>', self.Ok) #dismiss dialog self.bind('<Escape>', self.Ok) #dismiss dialog self.textView.insert(0.0, text) self.textView.config(state=DISABLED) self.wait_window() def CreateWidgets(self): frameText = Frame(self, relief=SUNKEN, height=700) frameButtons = Frame(self) self.buttonOk = Button(frameButtons, text='Close', command=self.Ok, takefocus=False) self.scrollbarView = Scrollbar(frameText, orient=VERTICAL, takefocus=False) self.textView = Text(frameText, wrap=WORD, fg=self.fg, bg=self.bg, highlightthickness=0) self.scrollbarView.config(command=self.textView.yview) self.textView.config(yscrollcommand=self.scrollbarView.set) self.buttonOk.pack() self.scrollbarView.pack(side=RIGHT, fill=Y) self.textView.pack(side=LEFT, expand=True, fill=BOTH) frameButtons.pack(side=BOTTOM) frameText.pack(side=TOP, expand=True, fill=BOTH) if TTK: frameButtons['style'] = 'RootColor.TFrame' def Ok(self, event=None): self.destroy()
def xGC_skew(seq, window = 1000, zoom = 100, r = 300, px = 100, py = 100): """Calculates and plots normal and accumulated GC skew (GRAPHICS !!!).""" from Tkinter import Scrollbar, Canvas, BOTTOM, BOTH, ALL, \ VERTICAL, HORIZONTAL, RIGHT, LEFT, X, Y yscroll = Scrollbar(orient = VERTICAL) xscroll = Scrollbar(orient = HORIZONTAL) canvas = Canvas(yscrollcommand = yscroll.set, xscrollcommand = xscroll.set, background = 'white') win = canvas.winfo_toplevel() win.geometry('700x700') yscroll.config(command = canvas.yview) xscroll.config(command = canvas.xview) yscroll.pack(side = RIGHT, fill = Y) xscroll.pack(side = BOTTOM, fill = X) canvas.pack(fill=BOTH, side = LEFT, expand = 1) canvas.update() X0, Y0 = r + px, r + py x1, x2, y1, y2 = X0 - r, X0 + r, Y0 -r, Y0 + r ty = Y0 canvas.create_text(X0, ty, text = '%s...%s (%d nt)' % (seq[:7], seq[-7:], len(seq))) ty +=20 canvas.create_text(X0, ty, text = 'GC %3.2f%%' % (GC(seq))) ty +=20 canvas.create_text(X0, ty, text = 'GC Skew', fill = 'blue') ty +=20 canvas.create_text(X0, ty, text = 'Accumulated GC Skew', fill = 'magenta') ty +=20 canvas.create_oval(x1,y1, x2, y2) acc = 0 start = 0 for gc in GC_skew(seq, window): r1 = r acc+=gc # GC skew alpha = pi - (2*pi*start)/len(seq) r2 = r1 - gc*zoom x1 = X0 + r1 * sin(alpha) y1 = Y0 + r1 * cos(alpha) x2 = X0 + r2 * sin(alpha) y2 = Y0 + r2 * cos(alpha) canvas.create_line(x1,y1,x2,y2, fill = 'blue') # accumulated GC skew r1 = r - 50 r2 = r1 - acc x1 = X0 + r1 * sin(alpha) y1 = Y0 + r1 * cos(alpha) x2 = X0 + r2 * sin(alpha) y2 = Y0 + r2 * cos(alpha) canvas.create_line(x1,y1,x2,y2, fill = 'magenta') canvas.update() start += window canvas.configure(scrollregion = canvas.bbox(ALL))
def makeWidgets(self, width): scrbar_width = 30 scrbar = Scrollbar(self, width=scrbar_width) self.list = Listbox(self, relief=SUNKEN, width=width-30) scrbar.config(command=self.list.yview) self.list.config(yscrollcommand=scrbar.set) scrbar.pack(side=RIGHT, fill=Y) self.list.pack(side=LEFT, expand=YES, fill=BOTH)
def make_widgets(self): sbar = Scrollbar(self) text = Text(self, relief=SUNKEN) sbar.config(command=text.yview) # xlink sbar and text text.config(yscrollcommand=sbar.set) # move one moves other sbar.pack(side=RIGHT, fill=YES) # pack first=clip last text.pack(side=LEFT, expand=YES, fill=BOTH) # text clipped first self.text = text
def makewidgets(self): sbar = Scrollbar(self) text = Text(self, relief=SUNKEN) sbar.config(command=text.yview) text.config(yscrollcommand=sbar.set) sbar.pack(side=RIGHT, fill=YES) text.pack(side=LEFT, expand=YES, fill=BOTH) self.text = text
class TextViewer(Toplevel): """A simple text viewer dialog for IDLE """ def __init__(self, parent, title, text, modal=True, _htest=False): """Show the given text in a scrollable window with a 'close' button If modal option set to False, user can interact with other windows, otherwise they will be unable to interact with other windows until the textview window is closed. _htest - bool; change box location when running htest. """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) # place dialog below parent if running htest self.geometry("=%dx%d+%d+%d" % (750, 500, parent.winfo_rootx() + 10, parent.winfo_rooty() + (10 if not _htest else 100))) #elguavas - config placeholders til config stuff completed self.bg = '#ffffff' self.fg = '#000000' self.CreateWidgets() self.title(title) self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.textView.focus_set() #key bindings for this dialog self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.textView.insert(0.0, text) self.textView.config(state=DISABLED) if modal: self.transient(parent) self.grab_set() self.wait_window() def CreateWidgets(self): frameText = Frame(self, relief=SUNKEN, height=700) frameButtons = Frame(self) self.buttonOk = Button(frameButtons, text='Close', command=self.Ok, takefocus=FALSE) self.scrollbarView = Scrollbar(frameText, orient=VERTICAL, takefocus=FALSE, highlightthickness=0) self.textView = Text(frameText, wrap=WORD, highlightthickness=0, fg=self.fg, bg=self.bg) self.scrollbarView.config(command=self.textView.yview) self.textView.config(yscrollcommand=self.scrollbarView.set) self.buttonOk.pack() self.scrollbarView.pack(side=RIGHT,fill=Y) self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH) frameButtons.pack(side=BOTTOM,fill=X) frameText.pack(side=TOP,expand=TRUE,fill=BOTH) def Ok(self, event=None): self.destroy()
def setScrollBar(canvas,frame): hbar=Scrollbar(frame,orient=HORIZONTAL) hbar.pack(side=BOTTOM,fill=X) hbar.config(command=canvas.xview) vbar=Scrollbar(frame,orient=VERTICAL) vbar.pack(side=RIGHT,fill=Y) vbar.config(command=canvas.yview) canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set) canvas.pack(side=LEFT,expand=True,fill=BOTH)
def __init__(self, net, parent=None, width=4): Frame.__init__(self, parent) self.top = self.winfo_toplevel() self.gheight = 800 self.top.title('Mininet') self.net = net self.menubar = self.createMenuBar() self.consoles = {} self.sconsoles = {} # consoles themselves titles = { 'hosts': 'Host', 'switches': 'Switch', 'controllers': 'Controller' } # (servers + clients) * 20 canvas = self.canvas = Canvas( self, width=1600, height=800, scrollregion=(0, 0, 0, ((servers + nathost + clients + 200) // 4) * 280)) # cframe = self.cframe = Frame(canvas, width=1600, height=((servers + nathost + clients + 3) // 4) * 264) cframe = self.cframe = Frame(canvas) for name in titles: nodes = getattr(net, name) frame, consoles = self.createConsoles(cframe, nodes, width, titles[name]) self.consoles[name] = Object(frame=frame, consoles=consoles) canvas.create_window( (800, ((servers + nathost + clients + 100) // 4) * 132), window=cframe) self.selected = None self.select('hosts') ybar = Scrollbar(self, orient='vertical', command=canvas.yview) canvas.config(yscrollcommand=ybar.set) ybar.pack(side='right', fill='y') canvas.pack(expand=True, fill='both') cleanUpScreens() # Close window gracefully Wm.wm_protocol(self.top, name='WM_DELETE_WINDOW', func=self.quit) # Initialize graph graph = Graph(cframe) self.consoles['graph'] = Object(frame=graph, consoles=[graph]) self.graph = graph self.graphVisible = False self.updates = 0 self.hostCount = len(self.consoles['hosts'].consoles) self.bw = 0 self.pack(expand=True, fill='both')