Exemple #1
0
 def browsefordatabase(self):
     """ Opens an Open File window to select the Database File """
     file = tkfiledialog.askopenfilename(filetypes=[('SQLite File','*.sqlite3'),],initialdir=BRDWebApp.ROOTDIR)
     if not file: return
     dbfile = self.checkdbfile(file)
     if not dbfile: return
     smarttkinter.setentry(self.pane.databasefileentry,file)
Exemple #2
0
 def getfolder(self):
     folder = filedialog.askdirectory(mustexist=True)
     if not folder: return
     folder = pathlib.Path(folder)
     if not folder.exists():
         messagebox.showerror("Invalid Folder", "Could not find folder")
         return
     smarttk.setentry(self.pane.folderentry, str(folder))
Exemple #3
0
 def getoutput(self):
     file = filedialog.asksaveasfilename(filetypes=[
         (".csv", "CSV File"),
     ])
     if not file: return
     file = pathlib.Path(file)
     if file.suffix.lower() != ".csv":
         file.suffix = file.with_suffix(".csv")
     smarttk.setentry(self.pane.outputentry, str(file))
Exemple #4
0
 def getquickbooks(self):
     file = tkfiledialog.askopenfilename(
         filetypes=(["Excel File", (".xls", ".xlsx")], ))
     file = imethods.testfileintegrity(file)
     if not isinstance(file, pathlib.Path):
         tkmessagebox.showerror(
             "Invalid File",
             f"Could not load file: please try loading another file. (error code: {file})"
         )
     smarttkinter.setentry(self.pane.quickbooksentry, file)
Exemple #5
0
 def getdatabase(self):
     file = tkfiledialog.askopenfilename(
         filetypes=(["Database", (".db", ".sqlite3")], ))
     file = imethods.testfileintegrity(file)
     if not isinstance(file, pathlib.Path):
         tkmessagebox.showerror(
             "Invalid File",
             f"Could not load file: please try loading another file. (error code: {file})"
         )
     smarttkinter.setentry(self.pane.databaseentry, file)
Exemple #6
0
 def getqb(self):
     file = filedialog.askopenfilename(filetypes=[
         (".csv", "CSV File"),
     ])
     if not file: return
     file = pathlib.Path(file)
     if not file.exists():
         messagebox.showerror("Invalid File", "Could not find file")
         return
     if not file.suffix.lower() == ".csv":
         messagebox.showerror("Invalid File",
                              "Incorrect file type: must be csv")
     smarttk.setentry(self.pane.qbentry, str(file))
Exemple #7
0
 def getfile(self):
     """ Gets the file name """
     ftype = self.pane.exportvar.get()
     if ftype == "csv":
         defaultextension = ".csv"
         filetypes = [
             ("Comma-Separated", ".csv"),
         ]
     elif ftype == "db":
         defaultextension = ".db"
         filetypes = [("Database", (".db", ".sqlite3"))]
     file = tkfiledialog.asksaveasfilename(
         defaultextension=defaultextension, filetypes=filetypes)
     if not file:
         tkmessagebox.showerror(
             "No File", "You did not select a filename to save as.")
         return
     if ftype == "csv": entry = self.pane.csventry
     elif ftype == "db": entry = self.pane.dbentry
     smarttkinter.setentry(entry, file)
Exemple #8
0
 def addworkbook(self, file):
     """ Validates a file and sets the workbookentry with its path """
     try:
         workbook = classes.Workbook(file)
     except:
         tkmessagebox.showerror(
             "Bad File",
             "Could not load the selected Workbook File: {file}")
         return
     if workbook == self.workbook: return
     if not self.parent.checkworkbook(workbook):
         tkmessagebox.showerror(
             "Workbook Exists",
             "Workbook is alread open; please use existing entry")
         return
     p = self.pane
     self.workbook = workbook
     smarttkinter.setentry(p.workbookentry, file)
     p.addworksheetbutton.pack(side='left')
     p.clearworksheets()
     self.addworksheet()
Exemple #9
0
    def __init__(self,parent,**kw):
        super().__init__(parent,**kw)

        ttk.Label(self,text="Items",style="Title.TLabel")
        ttk.Label(self,text="Items without a Database ID will not be included",style="Italics.Subtitle.TLabel")

        f = smarttkinter.ttk.SmartFrame(self)
        self.matchitembutton = ttk.Button(f,text="Find Selected")
        ttk.Label(f,text="Search:")
        self.searchvar = tk.StringVar()
        self.searchentry = ttk.Entry(f,textvariable= self.searchvar)
        self.searchentry.bind("<Escape>",lambda *event: smarttkinter.setentry(self.searchentry,""))
        smarttkinter.masspack(f,side='left',padx=3)

        self.treeview = smarttkinter.ttk.SmartTreeview(self,columns = ["Date","Item","Item Descript","DB ID"])

        bf = smarttkinter.ttk.SmartFrame(self)
        self.continuebutton = ttk.Button(bf,text="Continue")
        self.cancelbutton = ttk.Button(bf,text="Cancel")
        smarttkinter.masspack(bf,side='left',padx=3)

        smarttkinter.masspack(self)
        self.treeview.pack_configure(fill='both',expand = True)
Exemple #10
0
 def setmessage(self, title, message):
     self.title.configure(text=title)
     smarttkinter.setentry(self.output, message)
Exemple #11
0
 def getoutput(self):
     file = tkfiledialog.asksaveasfilename(
         filetypes=(["Comma-separated Values", ".csv"], ),
         defaultextension=".csv")
     smarttkinter.setentry(self.pane.outputentry, file)
 def getdirectory(self):
     ask = tkfiledialog.askdirectory(mustexist = True)
     if not ask: return
     smarttkinter.setentry(self.pane.directoryentry, ask)
Exemple #13
0
 def prettyprinttarget(self,*event):
     """ Updates the target entry to look nice (and calls checktarget to boot)"""
     number = self.gettarget()
     smarttkinter.setentry(self.pane.targetentry,currency(number))
     self.checktarget()