def __init__(self, context, url, title, infp): self.__context = context self.__url = url self.__title = title self.__infp = infp top = self.__top = tktools.make_toplevel(context.browser.root) top.title("Print Action") fr, topfr, botfr = tktools.make_double_frame(top) Label(topfr, bitmap="warning", foreground='red').pack(side=LEFT, fill=Y, padx='2m') # font used by the Tk4 dialog.tcl script: font = "-Adobe-Times-Medium-R-Normal--*-180-*-*-*-*-*-*" try: label = Label(topfr, text=self.UNKNOWN_TYPE_MESSAGE, font=font, justify=LEFT) except TclError: # font not found, use one we are sure exists: font = context.browser.viewer.text.tag_cget('h2_b', '-font') label = Label(topfr, text=self.UNKNOWN_TYPE_MESSAGE, font=font, justify=LEFT) label.pack(side=RIGHT, fill=BOTH, expand=1, padx='1m') b1 = Button(botfr, text="Cancel", command=self.skipit) b1.pack(side=RIGHT) b2 = Button(botfr, text="Print", command=self.doit) b2.pack(side=LEFT) tktools.unify_button_widths(b1, b2) tktools.set_transient(top, context.browser.root)
def __init__(self, old_context, filename, reader, restart=1): url = old_context.get_url() headers = old_context.get_headers() self.app = old_context.browser.app self.root = tktools.make_toplevel( old_context.browser.master, class_="GrailTransfer") self.root.protocol("WM_DELETE_WINDOW", self.stop) import Context self.context = Context.SimpleContext(self, self) self.context._url = self.context._baseurl = url reader.last_context = self.context self.__filename = filename self.__reader = reader self.__save_file = reader.save_file reader.save_file = self if filename: self.root.title("Grail: Downloading " + os.path.basename(filename)) else: self.root.title("Grail Download") self.root.iconname("Download") # self.content_length = None if headers.has_key('content-length'): self.content_length = int(headers['content-length']) self.create_widgets(url, filename, self.content_length) # if restart: reader.restart(reader.url) reader.bufsize = 8096 tktools.set_transient(self.root, old_context.browser.master) history = old_context.app.global_history if not history.inhistory_p(url): history.remember_url(url) self.root.update_idletasks()
def __init__(self, master, netloc, realmvalue): self.root = tktools.make_toplevel(master, title="Authentication Dialog") self.prompt = Label(self.root, text="Enter user authentication\nfor %s on %s" % (realmvalue, netloc)) self.prompt.pack(side=TOP) self.user_entry, dummy = tktools.make_form_entry(self.root, "User:"******"Password:"******"*") self.passwd_entry.bind('<Return>', self.ok_command) self.ok_button = Button(self.root, text="OK", command=self.ok_command) self.ok_button.pack(side=LEFT) self.cancel_button = Button(self.root, text="Cancel", command=self.cancel_command) self.cancel_button.pack(side=RIGHT) self.user_passwd = None tktools.set_transient(self.root, master) self.root.grab_set()
def __init__(self, rootwin, searchable): self._searchable = searchable from utils import tktools self._root = tktools.make_toplevel(rootwin, title="Search Dialog", class_="Search") self.create_widgets() tktools.set_transient(self._root, rootwin, rely=0.0) self.__rootwin = rootwin
def __init__(self, master, title=None, new=1): # create widgets self.__frame = tktools.make_toplevel( master, title=title or "Open Location Dialog") # fr, top, btnframe = tktools.make_double_frame( self.__frame, relief=FLAT) # self.__entry, frame, label = tktools.make_labeled_form_entry( top, 'URI:', 40) self.__entry.insert(0, self.__lasturi) # okbtn = Button(btnframe, text='Open', command=self.okaycmd) newbtn = Button(btnframe, text='New', command=self.newcmd) clearbtn = Button(btnframe, text='Clear', command=self.clearcmd) cancelbtn = Button(btnframe, text='Cancel', command=self.cancelcmd) tktools.unify_button_widths(okbtn, newbtn, clearbtn, cancelbtn) # okbtn.pack(side=LEFT) if new: newbtn.pack(side=LEFT, padx='1m') cancelbtn.pack(side=RIGHT) clearbtn.pack(side=RIGHT, padx='1m') # tktools.set_transient(self.__frame, master) # self.__entry.bind('<Return>', self.okaycmd) self.__entry.bind('<Control-C>', self.cancelcmd) self.__entry.bind('<Control-c>', self.cancelcmd) if new: self.__frame.bind('<Alt-n>', self.newcmd) self.__frame.bind('<Alt-N>', self.newcmd) self.__frame.bind("<Alt-w>", self.cancelcmd) self.__frame.bind("<Alt-W>", self.cancelcmd) # self.__frame.protocol('WM_DELETE_WINDOW', self.cancelcmd)
def __init__(self, master, context, class_="DocumentInfo"): root = tktools.make_toplevel(master, class_=class_, title="Document Info") self.root = root self.app = context.app page_title = context.page.title() if page_title: root.title("Document Info: " + page_title) destroy = self.destroy for seq in ("<Alt-W>", "<Alt-w>", "<Return>"): root.bind(destroy) root.protocol("WM_DELETE_WINDOW", destroy) frame, self.__topfr, botfr = tktools.make_double_frame(root) # # Info display # url = context.page.url() scheme, netloc, path, params, query, fragment = urlparse(url) url = urllib.urlunparse((scheme, netloc, path, '', '', '')) self.add_label_field("Title", page_title or "(unknown)", "title") self.add_label_field("URI", url, "uri") if fragment: self.add_label_field("Fragment", fragment, "fragment") headers = context.get_headers() if headers.has_key("date") and type(headers["date"]) is type(self): self.add_label_field("", "(Loaded from local cache.)", "cached") items = headers.items() items.sort() s = "" for k, v in items: if k == 'date' and type(v) is type(self): from . import ht_time v = ht_time.unparse(v.get_secs()) s = "%s%s:\t%s\n" % (s, k, v) stretch = self.add_text_field("Response headers", s, "headers") if query: query = str.translate(query, FIELD_BREAKER) stretch = stretch or \ self.add_text_field("Query fields", query, "query") postdata = context.get_postdata() if postdata: postdata = str.translate(postdata, FIELD_BREAKER) stretch = stretch or \ self.add_text_field("POST fields", postdata, "postdata") # # Bottom button # fr = tkinter.Frame(botfr, borderwidth=1, relief=tkinter.SUNKEN) fr.pack() btn = tkinter.Button(fr, text="OK", command=destroy) # '2m' is the value from the standard Tk 'tk_dialog' command btn.pack(padx='2m', pady='2m') btn.focus_set() # del self.__topfr # loose the reference tktools.set_transient(root, master) root.update_idletasks() reqwidth = root.winfo_reqwidth() reqheight = root.winfo_reqheight() root.minsize(reqwidth, reqheight) if not stretch: root.maxsize(reqwidth, reqheight)
def __init__(self, context, url, title, infp, ctype): from utils import tktools # self.infp = infp self.ctype = ctype self.context = context self.baseurl = context.get_baseurl() self.prefs = context.app.prefs self.settings = printing.settings.get_settings(context.app.prefs) if USER_DATA_DIR not in self.settings.user_data_dirs: self.settings.user_data_dirs.append(USER_DATA_DIR) settings = self.settings # self.title = title self.master = self.context.root self.root = tktools.make_toplevel(self.master, title="Print Dialog", class_="PrintDialog") # do this early in case we're debugging: self.root.protocol('WM_DELETE_WINDOW', self.cancel_command) self.root.bind("<Alt-w>", self.cancel_event) self.root.bind("<Alt-W>", self.cancel_event) self.cursor_widgets = [self.root] fr, top, botframe = tktools.make_double_frame(self.root) # Print to file controls: generalfr = tktools.make_group_frame(top, "general", "General options:", fill=X) self.cmd_entry, dummyframe = tktools.make_form_entry( generalfr, "Print command:") self.cmd_entry.insert(END, settings.printcmd) self.add_entry(self.cmd_entry) self.printtofile = IntVar(self.root) self.printtofile.set(settings.fileflag) fr = Frame(generalfr) fr.pack(fill=X) self.file_check = Checkbutton(fr, text="Print to file:", command=self.check_command, variable=self.printtofile) self.file_check.pack(side=LEFT) self.file_entry = Entry(fr) self.file_entry.pack(side=RIGHT, fill=X) self.file_entry.insert(END, settings.printfile) self.add_entry(self.file_entry) if self.ctype != "application/postscript": # page orientation Frame(generalfr, height=2).pack() fr = Frame(generalfr) fr.pack(fill=X) self.orientation = StringVar(top) self.orientation.set(str.capitalize(settings.orientation)) opts = printing.paper.paper_rotations.keys() opts.sort() opts = tuple(map(str.capitalize, opts)) Label(fr, text="Orientation: ", width=13, anchor=E).pack(side=LEFT) Frame(fr, width=3).pack(side=LEFT) menu = OptionMenu(fr, self.orientation) + opts width = reduce(max, map(len, opts), 6) menu.config(anchor=W, highlightthickness=0, width=width) menu.pack(expand=1, fill=NONE, anchor=W, side=LEFT) Frame(generalfr, height=2).pack() # font size fr = Frame(generalfr) fr.pack(fill=X) Label(fr, text="Font size: ", width=13, anchor=E).pack(side=LEFT) Frame(fr, width=3).pack(side=LEFT) e = self.fontsize = Entry(fr, width=12) e.insert(END, settings.get_fontspec()) e.pack(side=LEFT) self.add_entry(e) self.mod = self.get_type_extension() if self.mod.add_options: Frame(top, height=8).pack() self.mod.add_options(self, settings, top) # Command buttons: ok_button = Button(botframe, text="OK", command=self.ok_command) ok_button.pack(side=LEFT) cancel_button = Button(botframe, text="Cancel", command=self.cancel_command) cancel_button.pack(side=RIGHT) tktools.unify_button_widths(ok_button, cancel_button) tktools.set_transient(self.root, self.master) self.check_command()
def __init__(self, context, historyobj=None): if not historyobj: # XXX I guess this is here for testing? (It's used nowhere.) self._history = History() else: self._history = historyobj # self._context = context self._history.set_dialog(self) self._frame = tktools.make_toplevel(self._context.viewer.frame, class_="History", title="History Dialog") self._frame.protocol("WM_DELETE_WINDOW", self._close) # get preferences self._viewby = StringVar(self._frame) self._prefs = prefs = get_grailapp().prefs prefs.AddGroupCallback(HISTORY_PREFGROUP, self._notify) try: viewby = prefs.Get(HISTORY_PREFGROUP, VIEW_BY_PREF) if viewby not in [VIEW_BY_TITLES, VIEW_BY_URLS]: raise TypeError except (KeyError, TypeError): viewby = VIEW_BY_TITLES self._viewby.set(viewby) # add a couple of buttons btnbar = Frame(self._frame) btnbar.pack(fill=BOTH, side=BOTTOM) gotobtn = Button(self._frame, name='goto', command=self._goto) gotobtn.pack(side=LEFT, padx='1m', pady='1m', in_=btnbar) closebtn = Button(self._frame, name='close', command=self._close) closebtn.pack(side=LEFT, in_=btnbar) tktools.unify_button_widths(gotobtn, closebtn) # radio button for view option rbframe = Frame(btnbar) rbframe.pack() rb1 = Radiobutton(self._frame, name='titles', command=self._viewby_command, variable=self._viewby, value=VIEW_BY_TITLES) rb2 = Radiobutton(self._frame, name='uris', command=self._viewby_command, variable=self._viewby, value=VIEW_BY_URLS) rb1.pack(anchor='w', in_=rbframe) rb2.pack(anchor='w', in_=rbframe) # create listbox self._listbox, frame = tktools.make_list_box(self._frame, 40, 24, 1, 1, name="list") self.refresh() self._listbox.config(takefocus=0, exportselection=0) self._listbox.bind('<Double-Button-1>', self._goto) self._listbox.bind('<Double-Button-2>', self._goto_new) self._listbox.bind('<ButtonPress-2>', self._highlight) # Yes, yes, the mapping seems inverted, but it has to do with # the way history elements are displayed in reverse order in # the listbox. These mappings mirror those used in the Bookmarks # dialog. self._frame.bind("<Right>", self.next_cmd) self._frame.bind("<Alt-Right>", self.next_cmd) self._frame.bind("<Left>", self.previous_cmd) self._frame.bind("<Alt-Left>", self.previous_cmd) self._frame.bind("<Up>", self.up_cmd) self._frame.bind("p", self.up_cmd) self._frame.bind("P", self.up_cmd) self._frame.bind("<Down>", self.down_cmd) self._frame.bind("n", self.down_cmd) self._frame.bind("N", self.down_cmd) self._frame.bind("g", self._goto) self._frame.bind("G", self._goto) self._frame.bind("<Return>", self._goto) self._frame.bind('<Alt-W>', self._close) self._frame.bind('<Alt-w>', self._close) tktools.set_transient(self._frame, self._context.root)