def DataGrid(xValues, yValues):
    ## setup window
    dataGrid = Tk()
    dataGrid.wm_title("Data")

    ## setup frame
    frame = Frame(dataGrid)
    frame.pack()

    label = Label(dataGrid, text=("Showing %.0f data points" % len(xValues)), font=("Verdana", 12))
    label.pack(pady=5, padx=10)

    dataDict = {}

    ## iterate through time
    for i in range(0, len(xValues)):
        xVal = "%.2f" % float(xValues[i])
        yVal = "%.2f" % float(yValues[i])
        dataDict[xVal] = {"Time (s)": xVal, "Height (m)": yVal}

    model = TableModel()
    model.importDict(dataDict)
    model.moveColumn(model.getColumnIndex("Time (s)"), 0)

    table = TableCanvas(frame, model=model, editable=False)
    table.createTableFrame()

    ## order by time
    table.sortTable(columnName="Time (s)")

    dataGrid.mainloop()
示例#2
0
class App(Frame):
    """Basic test frame for the table"""
    data = {}
    table = TableCanvas

    def __init__(self, parent=None):

        self.table = TableCanvas
        self.parent = parent
        Frame.__init__(self)
        self.main = self.master
        self.main.title('Test')
        # Initialize frame for the table
        #f = Frame(self.main)

        # Initialize the grid location of the table
        #f.grid(row=0, column=1, sticky="nsew")

        # no need to pack since we using grid geometry
        # f.pack(fill=tk.Y,expand=-1,side = tk.LEFT)

        # Create/Format table
        #table = TableCanvas(f, cellwidth=60, data = test, cellbackgr='white', thefont=('Arial',12),rowheight=25, rowheaderwidth=30, rowselectedcolor='yellow', editable=True)

        #Import table from csv
        #table.importCSV('2017_Traffic_Volume_Flow.csv')
        """if importing table as dictionary, use this: data is of type dictionary
        """
        # table = TableCanvas(f, cellwidth=60, data = data, cellbackgr='white',
        #                    thefont=('Arial', 12), rowheight=25, rowheaderwidth=30,
        #                    rowselectedcolor='yellow', editable=True)

        #print (table.model.columnNames)
        #table.show()
        # sort the first column from highest to lowest (the sum of incident column)
        # table.sortTable(reverse=1)

        return

    def importData(self, dataImport):
        data = dataImport
        model = TableModel()
        model.importDict(data)
        f = Frame(self.main)
        self.table = TableCanvas(f,
                                 model,
                                 cellwidth=60,
                                 cellbackgr='white',
                                 thefont=('Arial', 12),
                                 rowheight=25,
                                 rowheaderwidth=30,
                                 rowselectedcolor='yellow',
                                 editable=True)
        self.table.createTableFrame()
        self.table.show()
        f.grid(row=0, column=1, sticky="nsew")

    def sortData(self, l, c):
        self.table.sortTable(reverse=l, columnIndex=c)
        self.table.redraw()
示例#3
0
def DataGrid(xValues, yValues):
    ## setup window
    dataGrid = Tk()
    dataGrid.wm_title("Data")

    ## setup frame
    frame = Frame(dataGrid)
    frame.pack()

    label = Label(dataGrid,
                  text=("Showing %.0f data points" % len(xValues)),
                  font=("Verdana", 12))
    label.pack(pady=5, padx=10)

    dataDict = {}

    ## iterate through time
    for i in range(0, len(xValues)):
        xVal = ("%.2f" % float(xValues[i]))
        yVal = ("%.2f" % float(yValues[i]))
        dataDict[xVal] = {"Time (s)": xVal, "Height (m)": yVal}

    model = TableModel()
    model.importDict(dataDict)
    model.moveColumn(model.getColumnIndex('Time (s)'), 0)

    table = TableCanvas(frame, model=model, editable=False)
    table.createTableFrame()

    ## order by time
    table.sortTable(columnName='Time (s)')

    dataGrid.mainloop()
  def classify_handler(self):

    # Show Classification waiting window
    wdw = Tkinter.Toplevel()
    wdw.title('Classification Results ' + self.dropdown_value.get())
    Tkinter.Label(wdw, text="Classification in Progress... Please wait", font=("Helvetica", 12), width=50, fg="blue").pack()
    wdw.update()
    wdw.deiconify()
  
    # Predict and load results
    resultModel = TableModel()
    resultDict = speakerclassifier.classify_audio(self.currentFile, self.dropdown_value.get())
    if len(resultDict) > 0 :
      resultModel.importDict(resultDict)
    wdw.destroy()
  
    if len(resultDict) > 0 :
      # Show Classification results in modal table window
      wdw = Tkinter.Toplevel()
      wdw.geometry('350x200+200+200')
      wdw.title('Classification Results ' + self.dropdown_value.get())
      tframe = Tkinter.Frame(wdw)
      tframe.pack()
      
      table = TableCanvas(tframe, model=resultModel, editable=False)
      table.createTableFrame()
      table.sortTable(columnName='Score (%)', reverse=True)
      
      wdw.transient(self.root)
      wdw.grab_set()
      self.root.wait_window(wdw)
    else :
      tkMessageBox.showerror('Classification Results', 'There are currently no users in the System')
示例#5
0
    def classify_handler(self):

        # Show Classification waiting window
        wdw = Tkinter.Toplevel()
        wdw.title('Classification Results ' + self.dropdown_value.get())
        Tkinter.Label(wdw,
                      text="Classification in Progress... Please wait",
                      font=("Helvetica", 12),
                      width=50,
                      fg="blue").pack()
        wdw.update()
        wdw.deiconify()

        # Predict and load results
        resultModel = TableModel()
        resultDict = speakerclassifier.classify_audio(
            self.currentFile, self.dropdown_value.get())
        if len(resultDict) > 0:
            resultModel.importDict(resultDict)
        wdw.destroy()

        if len(resultDict) > 0:
            # Show Classification results in modal table window
            wdw = Tkinter.Toplevel()
            wdw.geometry('350x200+200+200')
            wdw.title('Classification Results ' + self.dropdown_value.get())
            tframe = Tkinter.Frame(wdw)
            tframe.pack()

            table = TableCanvas(tframe, model=resultModel, editable=False)
            table.createTableFrame()
            table.sortTable(columnName='Score (%)', reverse=True)

            wdw.transient(self.root)
            wdw.grab_set()
            self.root.wait_window(wdw)
        else:
            tkMessageBox.showerror(
                'Classification Results',
                'There are currently no users in the System')
示例#6
0
    inplace=True)

games_prediction = games_prediction[['Date', 'Visitor', 'Visitor Win%', 'Home', 'Home Win%']]

elos.to_csv('elos.csv', index=True)
games_prediction.to_csv('prediction.csv', index=False)


root = Tk()
root.title('NHL Elo Predictions')
root.geometry('800x600')
one = Label(root, text='NHL Elo Rankings', bg='blue', fg='white')
one.pack()
tframe = Frame(root)
tframe.pack()
table = TableCanvas(tframe, rowheaderwidth=0,
                    cellwidth=100, editable=False, width=325)
table.importCSV('elos.csv')
table.sortTable(columnName='Elo Rating', reverse=1)
colIndex = 1
table.show()
two = Label(root, text='Games Today', bg='blue', fg='white')
two.pack()
tframe2 = Frame(root)
tframe2.pack()
table2 = TableCanvas(tframe2, rowheaderwidth=0, editable=False, width=725)
table2.importCSV('prediction.csv')
table2.show()

root.mainloop()