Example #1
0
 def _open(self, *args):
     """
     Open the address book selected by the user.
     """
     name = self.e.get()
     if name not in data.get_book_names() and len(name.strip()) > 0:
         self.result = address.gui.MainWindow(name, NEW)
         self.destroy()
     elif len(name.strip()) == 0:
         mb.message(mb.WARNING, "Book name cannot be empty!", parent=self.parent)
     else:
         mb.message(mb.WARNING, ("There is already a book named %s, new name pls!") % name, parent=self.parent)
Example #2
0
 def _open(self, *args):
     """
     Open the address book selected by the user.
     """
     name = self.e.get()
     if name not in data.get_book_names() and len(name.strip()) > 0:
         self.destroy()
         try:
             self.result = address.gui.MainWindow(name, IMPORT, self.import_path)
         except ValueError:
             mb.message(mb.ERROR,"File is corrupted!",parent=self.parent)
     elif len(name.strip()) == 0:
         mb.message(mb.WARNING, "Book name cannot be empty!", parent=self.parent)
     else:
         mb.message(mb.WARNING, ("There is already a book named %s, new name pls!") % name, parent=self.parent)
Example #3
0
    def __init__(self, parent, title=None):
        tk.Toplevel.__init__(self, parent)
        self.result = None
        if title is not None:
            self.title = title

        self.parent = parent

        self.bind("<Return>", self._open)
        tk.Label(self, text="Open address book").pack(padx=5, pady=5)
        list_frame = tk.Frame(self)
        list_frame.pack(side=tk.TOP, padx=5, pady=5)
        scroll_bar = tk.Scrollbar(list_frame)
        scroll_bar.pack(side=tk.RIGHT, fill=tk.Y)
        self.list_box = tk.Listbox(list_frame, selectmode=tk.SINGLE)
        self.list_box.pack(side=tk.LEFT, fill=tk.Y)
        scroll_bar.config(command=self.list_box.yview)
        self.list_box.config(yscrollcommand=scroll_bar.set)

        self.metadata = data.get_book_names()

        for item in self.metadata:
            self.list_box.insert(tk.END, item)
        button_frame = tk.Frame(self)
        button_frame.pack(side=tk.BOTTOM)
        open_button = tk.Button(button_frame,
                                  text="Open",
                                  command=self._open)
        open_button.pack()
        cancel_button = tk.Button(button_frame,
                                  text="Cancel",
                                  command=self.destroy)
        cancel_button.pack()


        self.grab_set()
        self.parent.wait_window(self)