Example #1
0
def verifydata():
    global df
    global root
    global matchdf
    # refresh tk
    root = tk.Tk()
    # get the last match
    last_match_df = matchdf.tail(6)
    # validate.findMatch("qm19")
    # get any changes that need to be made
    msg = validate.findErrors(last_match_df)

    f = tk.Frame(root)
    f.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1)
    pt = pandastable.Table(f,
                           dataframe=last_match_df,
                           showtoolbar=True,
                           showstatusbar=True)
    pt.show()
    # make the instructions appear above the dataframe
    otherstuff = tk.Frame(root)
    otherstuff.pack(side=tk.TOP)
    thing = tk.Label(otherstuff, text=f'Changes Needed:{msg}')
    thing.pack(side=tk.TOP)
    # make the thing run
    root.mainloop()
    df = df.append(pt.model.df)
    matchdf = pd.DataFrame(columns=header)
    saveData()
Example #2
0
    def __init__(self, master, controller):
        tk.Frame.__init__(self, master, borderwidth=10, bg="#363636")

        self.table = pandastable.Table(self, dataframe=df, height=550, columns=4)
        self.table.grid()
        options = {'align': 'c',
                   'cellbackgr': '#303030',
                   'cellwidth': 200,
                   'colheadercolor': '#393939',
                   'entrybackgr': '#393939',
                   'floatprecision': 6,
                   'font': 'Consolas',
                   'fontsize': 12,
                   'grid_color': '#ABB1AD',
                   'linewidth': 1,
                   'rowheight': 22,
                   'rowselectedcolor': '#555555',
                   'textcolor': '#AAAAAA'
                   }
        config.apply_options(options, self.table)
        # self.table.autoResizeColumns()
        self.table.show()

        button_table_graph = tk.Button(self, text="Grafički prikaz", font=MED_FONT, bg="#363636", fg="#18d9cc",
                                       command=lambda: controller.show_frame(GraphPage))
        button_table_graph.grid(row=3, column=0, ipadx=10, ipady=5, padx=50, pady=20)

        button_table_convert = tk.Button(self, text="Konverter valuta", font=MED_FONT, bg="#363636", fg="#18d9cc",
                                         command=lambda: controller.show_frame(ConvertPage))
        button_table_convert.grid(row=3, column=3, ipadx=10, ipady=5, padx=50, pady=20)

        self.grid_rowconfigure(3, weight=1)

        self.listenerT = self.after(refresh_rate, self.update_after)
Example #3
0
 def right_widget(self):
     self.csv_open_button = tk.Button(self,
                                      text="Opencsv",
                                      command=self.f_open_csv)
     self.csv_open_button.config(height=1, width=10)
     self.csv_open_button.grid(row=0,
                               column=0,
                               padx=10,
                               pady=10,
                               sticky=tk.W)
     self.t = pt.Table(self, rows=30, columns=30)
     self.t.grid(row=1, column=0, sticky=tk.W + tk.N + tk.E + tk.S)
     self.ptable = pt.Table(self.t,
                            dataframe=None,
                            showtoolbar=False,
                            showstatusbar=True)
     self.ptable.show()
Example #4
0
def CreateTable(frame, sql):
    #create a table to display a given query
    query = pandas.read_sql(sql, conx)
    display = pandastable.Table(frame,
                                dataframe=query,
                                showbartool=True,
                                showstatusbar=True)
    display.show()
Example #5
0
def history(
    root,
    processes,
):
    frame = tk.Frame(root)
    varProcess = tk.StringVar()
    optProcess = tk.OptionMenu(frame, varProcess, *['f001', 'foo2', 'foo3'])
    optStep = tk.OptionMenu(frame, varStep, *[1, 3, 4, 5])
    table = pt.Table(frame)
Example #6
0
 def generate_table(self, dataframe):
     topframe = tkinter.Toplevel()
     topframe.geometry('1920x1000+00+00')
     topframe.title('Table')
     table = pandastable.Table(topframe,
                               dataframe=dataframe,
                               showtoolbar=True,
                               showstatusbar=True)
     table.show()
Example #7
0
 def f_open_csv(self):
     filename = filed.askopenfile(initialdir=os.getcwd(),
                                  title="Select file",
                                  filetypes=(("csv files", "*.csv"),
                                             ("all files", "*.*")))
     readcsv = pd.read_csv(filename)
     df = pd.DataFrame(readcsv)
     t = pt.Table(self, rows=100, columns=30)
     t.grid(row=1, column=0, sticky=tk.W + tk.N + tk.E + tk.S)
     ptable = pt.Table(t,
                       dataframe=df,
                       showtoolbar=False,
                       showstatusbar=True)
     #df = pt.importCSV()
     #pt.data.TableModel(dataframe= df,rows=20,columns=9)
     #ptable = pt.Table(t,dataframe=df,showtoolbar=False, showstatusbar=True)
     ptable.show()
     return
Example #8
0
    def __init__(self, master, bot: PSMPredictBot, queue: Queue):
        # parameters that you want to send through the Frame class.
        Frame.__init__(self, master, name=WIDGET_ORDERS)

        # reference to the master widget, which is the tk window
        self.master = master
        self.queue = queue
        self.bot = bot
        self.table = pt = pandastable.Table(self,
                                            dataframe=self.bot.orders,
                                            showtoolbar=True,
                                            showstatusbar=True)
        pt.show()
Example #9
0
 def validate(self):
     if len(self.toBEValidated) > 0:
         match = self.toBEValidated.pop(0)
         # match = (pd.DataFrame(), "this is test text")
         ptf = tk.Frame(self.tableFrameChildren)
         self.pt = pandastable.Table(ptf, dataframe=match[0], showtoolbar=True, showstatusbar=True)
         f = tk.Frame(self.tableFrameChildren, bg="white")
         text = tk.Label(f, text=f"Changes Needed: {match[1]}")
         confirm = tk.Button(f, text="Confirm", bg="yellow", command=lambda:self.confirmed())
         confirm.pack(side="left")
         text.pack(side="left")
         f.pack(side="top")
         ptf.pack(side="bottom")
         self.pt.show()
     else:
         print("No matches to validate")
Example #10
0
 def callback(self):
     conn = sqlite3.connect(database)
     sql = self.entry.get("1.0", tk.END)
     print(sql)
     self.df = self.table.model.df
     self.df = pd.read_sql_query(sql, conn)
     var = self.var.get()
     self.table.destroy()
     var2 = self.var2.get()
     if var2 == 1:
         self.df = self.df.transpose()
     if var == 1:
         self.table = pt.Table(self.tableframe,
                               dataframe=self.df,
                               showtoolbar=True,
                               showstatusbar=True)
         self.table.show()
     print(self.df.head())
Example #11
0
        def open_file():
            file = filedialog.askopenfilename(initialdir="/Documents",
                                              title="Select a CSV file",
                                              filetypes=(("CSV Files",
                                                          "*.csv"),
                                                         ("All Files", "*.*")))
            file_name = os.path.basename(file)
            file_name_lbl.configure(text=file_name)

            # Change CSV file delimiter to ","
            # by detecting the current delimiter
            # and creating a new file with the correct delimiter
            with open(file, "r") as old_file:
                sniffer = csv.Sniffer().sniff(old_file.read(1024))
                dialect = sniffer.delimiter
                old_file.seek(0)
                csv_reader = csv.reader(old_file, delimiter=dialect)
                with open("temp_file.csv", "w") as new_file:
                    csv_writer = csv.writer(new_file, delimiter=",")
                    for line in csv_reader:
                        csv_writer.writerow(line)

            file = "temp_file.csv"
            df = pd.read_csv(file)
            table = pdt.Table(table_frame,
                              dataframe=df,
                              width=672,
                              height=423,
                              showstatusbar=True,
                              showtoolbar=True)
            table.show()

            # Create scrollbar for the table
            vscrollbar = tk.Scrollbar(file_frame, orient=tk.VERTICAL)
            vscrollbar.pack(side=tk.RIGHT, fill=tk.Y)
            vscrollbar.configure(command=file_canvas.yview)
            table_frame.bind("<Configure>", on_configure)
            file_canvas.configure(yscrollcommand=vscrollbar.set)

            table.redraw()
Example #12
0
root = tkinter.Tk()
frame = tkinter.Frame(root)
frame.pack()
root.title("DietDb")

#DB connection stuff

conx = pyodbc.connect(
    "DRIVER={SQL SERVER NATIVE CLIENT 11.0};SERVER=(local);DATABASE=DietDb;Trusted_Connection=yes"
)
cursor = conx.cursor()

#function to set Sql Queries to display table
query = pandas.read_sql('SELECT * FROM Food;', conx)
display = pandastable.Table(frame,
                            dataframe=query,
                            showbartool=True,
                            showstatusbar=True)
display.show()


def DisplayTable(data):
    #update table with new query
    new_query = pandas.read_sql('SELECT * FROM ' + data + ';', conx)
    display.model.df = new_query
    display.redraw()


def DisplayQuery(sql):
    new_query = pandas.read_sql(sql)
    display.model.df = new_query
    display.redraw()
Example #13
0
cursor = conx.cursor()

root = tkinter.Tk()
root.geometry('800x600')
frame=tkinter.Frame()
frame.grid(row=0,column=0,rowspan=12,columnspan=12)


sql = ("SELECT Food.FoodKey,FoodTypes.FoodType,Food.Measurement,Brands.Brand,Food.Name,Food.Calories,Food.Protein,Food.Carbs,Food.TotalFat,Food.SatFat,Food.Fiber "
		"FROM Food INNER JOIN FoodTypes ON FoodTypes.FoodTypesKey = Food.FoodType INNER JOIN Brands ON Brands.BrandKey=Food.Brand UNION SELECT "
		"Food.FoodKey,FoodTypes.FoodType,Food.Measurement,' ',Food.Name,Food.Calories,Food.Protein,Food.Carbs,Food.TotalFat,Food.SatFat,Food.Fiber "
		"FROM Food INNER JOIN FoodTypes ON FoodTypes.FoodTypesKey = Food.FoodType WHERE Food.Brand IS NULL ORDER BY FoodTypes.FoodType ASC")

query = pd.read_sql(sql,conx)

display = table.Table(frame,dataframe=query)
display.show()

labels = Util.LabelRow(root,root.grid_size()[0],11,['FoodKey','Food Type','Measurement','Brand','Food Name','Calories Per','Protein Per','Carbs Per','Total Fat Per','Sat Fat Per','Fiber Per'])


WidRow = Util.RowOfWidgets(root,root.grid_size()[0]+1)

PKLabel = Util.NextKey_Label(WidRow,'Food',width=5)
eMeasurement = ttk.Entry(WidRow,width=10)
NameEntry = ttk.Entry(WidRow,width=10)
foodtypelist = Util.SQL_ComboBox(WidRow,"SELECT FoodTypesKey, FoodType FROM FoodTypes ORDER BY FoodTypes.FoodType",width=10)
brandlist = Util.SQL_ComboBox(WidRow,"SELECT BrandKey, Brand FROM Brands ORDER BY Brand",width=10)
eCalories = ttk.Entry(WidRow,width=7)
eProtein = ttk.Entry(WidRow,width=7)
eCarbs = ttk.Entry(WidRow,width=7)
Example #14
0
    def checkData(self, data):
        '''
        Creates a window in which the input/output data may be checked, if they 
        have been imported/created correctly.

        Parameters
        ----------
        data : pandas.DataFrame
            The input/output data.

        Returns
        -------
        None.

        '''
        def myPlot(data, zax, uaxis, scale, cslice):
            '''
            Function to plot the data

            Parameters
            ----------
            data : pandas.DataFrame
                data to plot.
            zax : string
                z-axis.
            uaxis : string
                the 2 dimensions that we plot.
            scale : string
                linear or log.
            cslice : int
                the slice of the 3rd axis that we plot.

            Returns
            -------
            None

            '''
            def createFig():
                '''
                Function to create a figure and a canvas

                Returns
                -------
                fig : Figure
                    DESCRIPTION.
                canvas : Canvas
                    DESCRIPTION.

                '''
                fig = Figure(dpi=80)
                fig.set_size_inches(6.5, 5.2)
                canvas = FigureCanvasTkAgg(fig, master=frameFig)
                canvas.get_tk_widget().grid(row=0, column=0, columnspan=3)
                return fig, canvas

            def UpdateButton(uaxis, zax, cslice, data, scale):
                '''
                Function to plot new slices

                Parameters
                ----------
                uaxis : string
                    the 2 dimensions that we plot..
                zax : string
                    z-axis.
                cslice : int
                    the slice of the 3rd axis that we plot.
                data : pandas.DataFrame
                    data to plot.
                scale : string
                    linear or log.

                Returns
                -------
                None.

                '''
                self.fig.clf()  # Clear previous items
                self.fig, canvas = createFig()
                ax = self.fig.subplots()
                dpl.createPlot(self.fig, ax, uaxis, zax, cslice, data, scale)
                canvas.draw()

            def savePlot():
                '''
                Function to save the figure

                Returns
                -------
                None.

                '''
                ftypes = [('JPG', '*.jpg'), ('JPEG', '*.jpeg'),
                          ('PNG', '*.png'), ('EPS', '*.eps'),
                          ('TIFF', '*.tiff'), ('PDF', '*.pdf'),
                          ('All files', '*')]
                tmp = filedialog.asksaveasfilename(defaultextension=('JPG',
                                                                     '*.jpg'),
                                                   initialdir="/",
                                                   title="Select file",
                                                   filetypes=ftypes)
                if tmp != '':
                    #dpl.saveFig(self.fig, tmp)
                    cformat = tmp.split('.')[-1]
                    fname = ".".join(tmp.split('.')[:-1])
                    self.fig.savefig('{}.{}'.format(fname, cformat),
                                     format=cformat,
                                     dpi=300,
                                     bbox_inches='tight')

            # Figure
            window = tk.Toplevel(self.parent)
            window.title('Figure')

            # Slider
            frameSlice = tk.LabelFrame(window, text='Slice')
            frameSlice.grid(row=0, column=0, columnspan=3)

            # Identify the 3rd dimension, whose slice we get
            tmpDimList = [
                str(data.columns[0]),
                str(data.columns[1]),
                str(data.columns[2])
            ]
            tmpDimList.remove(uaxis.split('-')[0])
            tmpDimList.remove(uaxis.split('-')[1])

            # Get the number of slices that exist
            limits = set(list(data[tmpDimList[0]]))

            # Create slider
            cslider = tk.Scale(frameSlice,
                               from_=0,
                               to=len(limits) - 1,
                               orient=tk.HORIZONTAL)
            cslider.grid()

            # Frame for the figure
            frameFig = tk.Frame(window)
            frameFig.grid(row=1, column=0, columnspan=3)

            # Create figure
            self.fig, canvas = createFig()
            ax = self.fig.subplots()

            # Plot
            dpl.createPlot(self.fig, ax, uaxis, zax, 0, data, scale)

            # Update button
            updateBut = tk.Button(frameSlice,
                                  text='Update plot',
                                  command=lambda: UpdateButton(
                                      uaxis, zax, cslider.get(), data, scale))
            updateBut.grid(row=0, column=4)

            canvas.draw()

            # Frame for matplotlib toolbar
            frameToolbar = tk.Frame(master=window)
            frameToolbar.grid(row=2, column=0)

            # Matplotlib toolbar
            toolbar = NavigationToolbar2Tk(canvas, frameToolbar)
            toolbar.grid(row=0, column=0, columnspan=2)

            # Save button
            b2 = tk.Button(frameToolbar,
                           text='Save',
                           command=lambda: savePlot(),
                           width=20)
            b2.grid(row=0, column=2)

        window = tk.Toplevel(self.parent)
        window.title("Check Data")
        window.geometry('600x400')

        # Frame for the printing
        frame = tk.Frame(window)
        frame.grid(row=0, column=0, sticky='nesw')

        # Keep the first 20 rows of the dat
        tmp = data.head(20)

        # Print the first 20 rows of the data
        pt = pdt.Table(frame)
        pt.model.df = tmp
        pt.show()

        # Plot options
        framePlot = tk.LabelFrame(window, text='Plot')
        framePlot.grid(row=1, column=0, columnspan=4)

        # Variable for Z axis
        myVar = tk.StringVar()
        myVar.set('')

        tmptext = []
        plotEnabled = 'normal'
        # In case no data have been imported
        if len(data) == 0:
            options = ['']
            tmptext.extend(['x-y', 'x-z', 'y-z'])
            plotEnabled = 'disabled'
        else:
            options = list(data.columns[3:])
            # Create pairs of coordinates
            for i in range(3):
                if not data.iloc[:, i].eq(data.iloc[:, i].iloc[0]).all():
                    for j in range(i + 1, 3):
                        if not data.iloc[:, j].eq(data.iloc[:,
                                                            j].iloc[0]).all():
                            tmptext.append('{}-{}'.format(
                                data.columns[i], data.columns[j]))

        myVar.set(options[0])

        # Choose which Dimension to plot
        frameDim = tk.LabelFrame(framePlot, text='Plane')
        frameDim.grid(row=0, column=2)
        for num in range(len(tmptext)):
            tk.Radiobutton(frameDim,
                           text=tmptext[num],
                           variable=self.dataDim,
                           value=num,
                           state=plotEnabled).grid(row=0,
                                                   column=num,
                                                   sticky='w')

        # Choose z-axis
        zLabel = tk.Label(framePlot, text='Choose z-Axis: ')
        zLabel.grid(row=0, column=0)
        w = tk.OptionMenu(framePlot, myVar, *options)
        w.grid(row=0, column=1)

        # Button to plot
        frameBut = tk.Frame(framePlot)
        frameBut.grid(row=0, column=4)

        b1 = tk.Button(frameBut,
                       text='Plot',
                       command=lambda: myPlot(data, myVar.get(), tmptext[
                           self.dataDim.get()], 'linear', 0),
                       state=plotEnabled)
        b1.grid(row=0, column=0)
 def showDataset(self):
     top = tk.Toplevel(self.root)
     pt = pandastable.Table(top, dataframe=self.df, editable=False)
     pt.show()
Example #16
0
import pandas as pd
import pandastable
import tkinter as tk
root = tk.Tk()
df = pd.read_csv("qr_out.csv")
print(df)


last_match_df = df.tail(6)
# validate.findMatch("qm19")
# msg = validate.findErrors(last_match_df)
# pt = pandastable.Table(root)
f = tk.Frame(root)
f.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1)
pt = pandastable.Table(f, dataframe=df, showtoolbar=True, showstatusbar=True)
pt.show()
otherstuff = tk.Frame(root)
otherstuff.pack(side=tk.TOP)
thing = tk.Label(otherstuff, text='Changes Needed:')
thing.pack(side=tk.TOP)
root.mainloop()
print(pt.model.df)
Example #17
0
def table_cp(parent, data):
    return pt.Table(parent, dataframe=data.drop('Penalty', axis=1))
Example #18
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.lbl = tk.LabelFrame(self,
                                 text='Enter SQL Query String',
                                 font=REG_FONT,
                                 fg='white',
                                 bg=green)
        self.lbl.config(height=200)
        self.lbl.grid(row=0, column=0, sticky='new')

        self.ctrlbar = tk.Frame(self, width=40, height=80, bg=grey2)
        self.ctrlbar.grid(row=1, column=0, pady=10, sticky='nw')
        self.grid_rowconfigure(2, weight=1)
        self.grid_columnconfigure(0, weight=1)
        self.showicon = tk.PhotoImage(file=show)
        self.hideicon = tk.PhotoImage(file=hide)
        self.excelicon = tk.PhotoImage(file=excel)
        self.showHide = tk.Button(self.ctrlbar,
                                  image=self.hideicon,
                                  width=40,
                                  height=30,
                                  command=self.toggleHide)
        self.showHide.image = self.hideicon
        self.showHide.var = tk.IntVar()
        self.showHide.var.set(0)
        self.showHide.pack(side='left', pady=2)
        self.excl = tk.Button(self.ctrlbar,
                              image=self.excelicon,
                              width=40,
                              height=30,
                              command=self.popup)
        self.excl.image = self.excelicon
        self.excl.pack(side='left', pady=2)

        srchframe = tk.Frame(self.lbl, bg=green)
        srchframe.pack(fill='both', pady=10)

        self.entry = tk.Text(srchframe, height=5)
        self.entry.pack(fill='both')

        self.btn = ttk.Button(srchframe, text="Search", command=self.callback)
        self.btn.pack(side='bottom')
        self.var = tk.IntVar()
        self.var2 = tk.IntVar()
        self.showtable = tk.Checkbutton(srchframe,
                                        text='Add results in table',
                                        var=self.var,
                                        font=REG_FONT,
                                        fg='white',
                                        bg=green)
        self.tanspose = tk.Checkbutton(srchframe,
                                       text='Transpose Results',
                                       var=self.var2,
                                       font=REG_FONT,
                                       fg='white',
                                       bg=green)
        self.tanspose.pack(side='bottom')
        self.showtable.pack(side='bottom')
        self.lbl2 = tk.LabelFrame(self,
                                  text='Results Table',
                                  font=REG_FONT,
                                  fg='white',
                                  bg=green)
        self.lbl2.grid(row=2, column=0, columnspan=2, sticky='nsew')

        self.tableframe = tk.Frame(self.lbl2)
        self.tableframe.pack(fill='both', expand=True)
        self.df = None
        self.fname = None
        self.label2 = None
        self.table = pt.Table(self.tableframe,
                              showtoolbar=True,
                              showstatusbar=True)
        self.table.show()

        self.configure(bg=green)
        print(
            'SELECT fed_rssd, (netinc/asset) AS ROA from data where repdte="3/31/2010"'
        )