Esempio n. 1
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 CreateTable(Main, Data):
    
    tframe = tk.Frame(Main,
                      bg ="blue",
                      highlightcolor = "blue") 
    tframe.place(x = 50, y =275,
                 height = 275, width =1100)
    
    rec, col = Data.shape
    aux = dict()
    data = dict()
    
    for i in range(rec):
        for j in range(col):
            aux [Data.columns[j]] = Data.values[i,j]
        data['rec'+str(i+1)] = aux.copy()
    
    model = TableModel()    
    table = TableCanvas(tframe, cellbackgr='white', 
    			thefont=('Arial',12, ), cellwidth = 100 ,
                rowheight=25, rowheaderwidth=30,
    			rowselectedcolor='yellow', editable=False,
                model = model)
    table.createTableFrame()
    model = table.model
    model.importDict(data)

    table.show()
    return table, model
Esempio n. 3
0
def show_transaction_table(frame, frame1):
    model = TableModel()
    transactionItems = transactions_database.getData()

    data = {}
    data1 = {}

    totalSale = 0.0

    for i in range(len(transactionItems)):
        totalSale += float(transactionItems[i][1])

    for i in range(len(transactionItems)):
        data['row' + str(i + 1)] = {
            'Name': transactionItems[i][0],
            'S.Price': transactionItems[i][1],
            'Date': transactionItems[i][2]
        }

        data1['row1'] = {'Total ($)': totalSale}

        table1 = TableCanvas(frame1, data=data1, takefocus=0)
        table = TableCanvas(frame, data=data, takefocus=0)

        table.show()
        table1.show()
Esempio n. 4
0
def demo2(root):
    frame = Frame(root)
    frame.pack()
    model = TableModel()
    model.importDict(data)
    table = TableCanvas(frame, model=model)
    table.createTableFrame()
Esempio n. 5
0
    def loginto():
        aa= MySQLdb.connect(host='127.0.0.1',port= 3306,user="******",passwd="010905885",db="kitpage")
        mm = aa.cursor()
        username = e1.get()
        password = e2.get()
        mm.execute('SELECT * FROM singup WHERE username = %s AND passwords = %s', (username, password))
        for i in username:
            print i
        if mm.fetchall():
            tkMessageBox.showinfo("Welcome to %s" %username, "Let GO")
            R.destroy()
            master = Tk()
            tframe = Frame(master)
            tframe.pack()
            table = TableCanvas(tframe)
            table.createTableFrame()

            model = TableModel()adf
            table = TableCanvas(tframe, model=model)


            master.mainloop()

            
            
        else:
            tkMessageBox.showinfo("Sorry" , "Wrong Password")
Esempio n. 6
0
    def display_leaderboard(self):
        self.cursor.execute(
            'SELECT player.username, MAX(data.kills) AS kills, data.date FROM data INNER JOIN player ON data.playerID = player.playerID GROUP BY username limit 0, 10 '
        )
        result = self.cursor.fetchall()
        data = Convert(result)

        kills_dict = dict()
        for key in data:
            data_value = list(data[key].values())
            kills_dict[key] = data_value[1]

        kills_dict = mergeSortDict(kills_dict, ascending=False)

        final_dict = dict()

        for key in kills_dict:
            final_dict[key] = data[key]

        tframe = Frame(self.my_w)
        tframe.pack()
        model = TableModel()
        table = TableCanvas(tframe,
                            model=model,
                            data=final_dict,
                            editable=False,
                            width=800,
                            height=300)
        table.show()
        self.my_w.mainloop()
Esempio n. 7
0
def MenuAssignments():
    AssignmentsWindow = tk.Toplevel(window)
    AssignmentsWindow.title("Replenisher Assignments") 
    AssignmentsWindow.geometry('800x500')
    
    UserList = [
    "User Selection", 
    "User1",
    "User2",
    "User3" 
    ] 
    UserVariable = StringVar(AssignmentsWindow)
    UserVariable.set(UserList[0]) # default value 
    UserOptionMenu = tk.OptionMenu(AssignmentsWindow, UserVariable, *UserList)
    UserOptionMenu.pack()
    
    TaskList = [
    "Task Selection", 
    "Task1",
    "Task2",
    "Task3" 
    ] 
    TaskVariable = StringVar(AssignmentsWindow)
    TaskVariable.set(TaskList[0]) # default value 
    TaskOptionMenu = tk.OptionMenu(AssignmentsWindow, TaskVariable, *TaskList)
    TaskOptionMenu.pack()    
    
    def AddUserTask():
        tkMessageBox.showinfo('Add User and Task', "Added User: "******";  " + "Added Task: " + TaskVariable.get() )  
    
    AddUserTaskBT = tk.Button(AssignmentsWindow, text="Add User and Task", command=AddUserTask)
    AddUserTaskBT.pack()
    
    #Add a table 
    '''
    RowNum = 2
    ColNum = 2
    for i in range(RowNum): 
        for j in range(ColNum): 
            b = tk.Entry(AssignmentsWindow, text="")
            b.grid(row=i, column=j)
            b.pack()
    '''
    
    #To use tkintertable  
    tframe = tk.Frame(AssignmentsWindow)
    tframe.pack()  
    model = TableModel()
    table = TableCanvas(tframe, model=model)
    table.createTableFrame()
    
    model = table.model
    data = {'rec1': {'User': '******', 'Task': 'Task1', 'Status': 'Open', 'Rank': 1, 'Priority': 'High', 'Start Time': '05-19-2018 10:30', 'Finish Time': ''},  
            'rec2': {'User': '******', 'Task': 'Task2', 'Status': 'Open', 'Rank': 2, 'Priority': 'Low', 'Start Time': '05-19-2018 11:30', 'Finish Time': '05-19-2018 22:30'},
            'rec3': {'User': '******', 'Task': 'Task3', 'Status': 'Open', 'Rank': 3, 'Priority': 'Low', 'Start Time': '05-19-2018 12:30', 'Finish Time': '05-19-2018 22:45'}               
           }  
    model.importDict(data) #Import from a dictionary to populate model
    table.redrawTable()
    
    AssignmentsWindow.mainloop()
Esempio n. 8
0
    def initFrame(self):
        # *****界面区*****
        # 布局参数
        params = ['row','column','rowspan','columnspan']
        gridMap =  {'label':(0,0),
                'entry':(0,1),
                'search_button':(0,2),
                'table':(1,1,None,3),
                'next_page':(2,1),
                'modify':(2,2),
                'corfirm':(2,3)}
        cnfs = {}
        for k,vals in gridMap.items():
            dic = {}
            for i,v in enumerate(vals):
                dic[params[i]] = v
            cnfs[k] = dic
        ttk.Label(self, text='搜索', style="BW.TLabel").grid(cnfs['label'])

        self.keyword = tk.StringVar()   # 搜索框
        tk.Entry(self, borderwidth=3, width=40, textvariable=self.keyword, selectbackground='gray').grid(cnfs['entry'])
        ttk.Button(self, text='搜索', command="", width=9).grid(cnfs['search_button'])
        frame = tk.Frame(self)
        frame.grid(cnfs['table'])
        model = TableModel()
        self.table = TableCanvas(frame,model)
        self.table.show()
        ttk.Button(self, text='下一页', command="", width=9).grid(cnfs['next_page'])
        ttk.Button(self, text='设为组合', command=self.set_combo, width=9).grid(cnfs['next_page'],sticky=tk.E)
        ttk.Button(self, text='修改', command=self.modify, width=9).grid(cnfs['modify'])
        ttk.Button(self, text='选择', command=self.choic, width=9).grid(cnfs['corfirm'])
Esempio n. 9
0
        def __init__(self,tktk = None,
                        br_image = None,
                        pathico = None,
                        br_image_path = None):

                Frame.__init__(self, tktk)
                self.tktk = tktk

                self.br_image_path  = br_image_path

                self.br_image = br_image

                self.pathico = pathico

                self.filewin = Toplevel(self.tktk)

                gui (tktk=self.filewin,
                        pathico=self.pathico,
                        width=1280,
                        height=1024,
                        widthx=300,
                        widthy=0,
                        resizable=[True,True]).setcfbs()
                        
                # set data
                data = createData()
                menu (tktk=self.filewin).createmenu()

                #create label 
                self.framelb = Frame(self.filewin,bg = "slate gray")
                self.framelb.pack(side = TOP)

                #creare frame for infomation
                self.frameinfor = Frame(self.filewin,bg = "slate gray")
                self.frameinfor.pack(side = TOP)


                #create title 
                self.framett = Frame(self.filewin,bg = "slate gray")
                self.framett.pack(side = TOP)

                # creare frame for table  
                self.tframe = Frame(self.filewin)
                self.tframe.pack(fill = X,side = TOP)

                model = TableModel()
                table = TableCanvas(self.tframe, model=model,data=data,height=650)
                table.show()

               #update quotation
                self.frameupdate = Frame(self.filewin,bg = "slate gray")
                self.frameupdate.pack(side = TOP)
                
                # import and export excel 
                self.frameimeex = Frame(self.filewin,bg = "slate gray")
                self.frameimeex.pack(side = TOP)


                self.createguiin()
Esempio n. 10
0
def demo3(root):
    frame = Frame(root)
    frame.pack()
    model = TableModel()
    model.importDict(data)
    table = TableCanvas(frame, model=model)
    table.createTableFrame()
    table.model.data['rec2']['col2'] = 50
    table.redrawTable()
Esempio n. 11
0
def ClearTable():

    DataTracking.Question = []
    DataTracking.Answers = []
    DataTracking.Correct = []

    Data = {}
    model = TableModel()
    table = TableCanvas(tframe, data=Data)
    table.show()
Esempio n. 12
0
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.configure(width=1250, height=500)

        self.frCal = Frame(self)
        self.frCal.place(relx=0, rely=0)
        self.frCal.configure(bd=1, relief=RAISED)
        self.calWidget = tkcalendar.Calendar(self.frCal,
                                             showweeknumbers=False,
                                             locale="ru_RU",
                                             maxdate=self.today)
        self.calWidget.pack()
        self.calWidget.bind('<<CalendarSelected>>', self.getDate)

        self.dayDataFrame = Frame(self)
        self.dayDataFrame.grid_propagate(0)
        self.dayDataFrame.place(relx=0, rely=1, anchor=SW)
        self.dayDataFrame.configure(width=1250,
                                    height=300,
                                    bd=1,
                                    relief=RAISED)

        self.tableModel = TableModel()
        self.table = TableCanvas(self.dayDataFrame,
                                 cellwidth=300,
                                 model=self.tableModel,
                                 rowheight=25)
        self.table.show()

        self.drawFrame = Frame(self)
        self.drawFrame.grid_propagate(0)
        self.drawFrame.place(relx=1, rely=0, anchor=NE)
        self.drawFrame.configure(width=966, height=200, bd=1, relief=RAISED)

        self.createCanvas()

        self.dateList = []
        self.hourUsed = [0 for i in range(24)]

        self.strInfo = StringVar()
        self.labelInfo = Label(self,
                               textvariable=self.strInfo,
                               width=30,
                               height=1,
                               bg='white',
                               bd=1,
                               relief=RAISED,
                               font='Arial 10')
        self.strInfo.set('Test')
        self.labelInfo.place(x=0, y=175)

        self.createFileList()
        self.createTable()
        self.readReportFile(self.today)
Esempio n. 13
0
def LoadWebPage():

    HtmlFile = filedialog.askopenfilename()
    File = open(HtmlFile, encoding='utf-8')
    soup = BeautifulSoup(File.read(), features="html.parser")
    Data = GetQuestions.GetAnswers(soup)

    model = TableModel()
    table = TableCanvas(tframe, data=Data)
    table.thefont = ('Arial', 10)
    table.show()
Esempio n. 14
0
def demo4(root):
    frame = Frame(root)
    frame.pack()
    model = TableModel()
    model.importDict(data)
    table = TableCanvas(frame,
                        model=model,
                        rowheaderwidth=0,
                        cellwidth=150,
                        rowheight=20,
                        editable=False,
                        rowselectedcolor='red',
                        reverseorder=1)
    table.createTableFrame()
Esempio n. 15
0
 def drawEnemyFleetTable(self):
     self.model = TableModel()
     self.table = TableCanvas(self.EnemyFleet,
                              model=self.model,
                              cellwidth=50,
                              cellbackgr='white',
                              thefont=self.tkFont,
                              rowheight=16,
                              editable=True,
                              rowselectedcolor='white',
                              reverseorder=1)
     self.table.createTableFrame()
     self.table.model.columnNames = ['A', 'B', 'C', 'D', 'E']
     self.table.redrawTable
     self.iniEnemyFleet()
Esempio n. 16
0
 def iniEnemyFleet(self):
     self.model = TableModel()
     self.table = TableCanvas(self.EnemyFleet,
                              model=self.model,
                              cellwidth=106,
                              cellbackgr='white',
                              thefont=self.tkFont,
                              rowheight=106,
                              editable=True,
                              rowselectedcolor="white",
                              reverseorder=1,
                              align='center')
     self.model.importDict(self.enemyFleetDict)
     self.table.createTableFrame()
     self.table.autoResizeColumns()
     self.table.redrawTable
Esempio n. 17
0
 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")
Esempio n. 18
0
 def display_personal_statistics(self, LOGGEDIN_PLAYERID):
     self.cursor.execute(
         'SELECT player.username, data.kills, data.date FROM data INNER JOIN player ON data.playerID = player.playerID WHERE player.playerID=%s ORDER BY date DESC',
         (LOGGEDIN_PLAYERID, ))
     result = self.cursor.fetchall()
     data = Convert(result)
     tframe = Frame(self.my_w)
     tframe.pack()
     model = TableModel()
     table = TableCanvas(tframe,
                         model=model,
                         data=data,
                         editable=False,
                         width=800,
                         height=300)
     table.show()
     self.my_w.mainloop()
Esempio n. 19
0
 def loadAfllictTable(self):
     global showingTables
     afflicDataTableModel = TableModel()
     if debug:
         afflicDataTableModel.importCSV("D:\\TAMS Stuff\\TAMS Research\\Dr. Chyan Lab\\TAMS Summer Research 2020\\MEDA\\FPS Testing\\Sample 1 TI Device\\S1 Reg B\\Results\\15FPM\\0.25FPS AfflictData.csv", sep=",")
     else:
         print(directory + "/" + str(fps) + "FPS AfflictData.csv")
         afflicDataTableModel.importCSV(directory + "/" + str(fps) + "FPS AfflictData.csv")
     self.afflictTable = TableCanvas(self.FAfflictTable, model=afflicDataTableModel, rowheaderwidth=0, read_only=True, cols=3, height=865, width=384)
     self.afflictTable.cellwidth=121
     self.afflictTable.maxcellwidth=121
     self.afflictTable.grid(column=0, row=0, sticky="NSW")
     self.afflictTable.show()
     self.afflictTable.resizeColumn(0, 82)
     self.afflictTable.resizeColumn(1, 123)
     self.afflictTable.resizeColumn(2, 178)
     self.showAfflictTable()
Esempio n. 20
0
def viewFreqOutput(event):
    top = Toplevel()
    analysis = {}
    f = open("frequency_output.txt")
    for line in f:
        record = {}
        tokens = line.rstrip('\n').split(' ')
        if tokens[0] not in analysis:
            record["Label"] = tokens[0]
            record["Frequency"] = tokens[1]
            analysis[tokens[0]] = record
    # print(analysis)
    model = TableModel()
    model.importDict(analysis)
    table = TableCanvas(top, model=model)
    table.createTableFrame()
    top.mainloop()
Esempio n. 21
0
    def __init__(self, master, columns):

        # default params
        self.params = {
            'cellwidth': 110,
            'precision': 6,
        }

        self.data = []

        self.model = TableModel()
        self.columns = columns
        for column in columns:
            self.model.addColumn(colname=column)
        self.table = TableCanvas(parent=master, model=self.model, cellwidth=self.params['cellwidth'], read_only=True)
        self.table.setSelectedRow(-1)
        self.table.show()
        
        self.n_rows = 0
Esempio n. 22
0
def MenuUser():
    UserWindow = tk.Toplevel(window)
    UserWindow.title("Add New User") 
    UserWindow.geometry('800x500')
    
    UserList = [
    "Add User"
    ] 
    UserVariable = StringVar(UserWindow)
    UserVariable.set(UserList[0]) # default value 
    UserOptionMenu = tk.OptionMenu(UserWindow, UserVariable, *UserList)
    UserOptionMenu.pack()
        
    def AddUser():
        tkMessageBox.showinfo('WLabs Replenisher', 'Successfully Add New User')  
    
    AddUserBT = tk.Button(UserWindow, text="Add User", command=AddUser)
    AddUserBT.pack()
    
    #To use tkintertable  
    tframe = tk.Frame(UserWindow)
    tframe.pack()  
    model = TableModel()
    table = TableCanvas(tframe, model=model)
    table.createTableFrame()
    
    model = table.model
    data = {'rec1': {'ID': 'User1', 'First Name': 'Tom', 'Last Name': 'Cross' },  
            'rec2': {'ID': 'User2', 'First Name': 'Jim', 'Last Name': 'Wood' },
            'rec3': {'ID': 'User3', 'First Name': 'Bryan', 'Last Name': 'Bush' }               
           }  
    model.importDict(data) #Import from a dictionary to populate model
    table.redrawTable()

    #Add New Row button
    def AddRowButton():
        table.addRow() 
        table.redrawTable() 
    
    AddRowBTN = tk.Button(UserWindow,text='Add New Row', command = AddRowButton)
    AddRowBTN.place(relx=0.9, rely=0.15, anchor=tk.CENTER)     
    
    UserWindow.mainloop()
Esempio n. 23
0
def MenuTask():
    TaskWindow = tk.Toplevel(window)
    TaskWindow.title("Add New Tasks") 
    TaskWindow.geometry('800x500')
    
    TaskList = [
    "Add Task"
    ] 
    TaskVariable = StringVar(TaskWindow)
    TaskVariable.set(TaskList[0]) # default value 
    TaskOptionMenu = tk.OptionMenu(TaskWindow, TaskVariable, *TaskList)
    TaskOptionMenu.pack()    
    
    def AddTask():
        tkMessageBox.showinfo('WLabs Replenisher', 'Successfully Add New Task')  
    
    AddTaskBT = tk.Button(TaskWindow, text="Add Task", command=AddTask)
    AddTaskBT.pack()
    
    #To use tkintertable  
    tframe = tk.Frame(TaskWindow)
    tframe.pack()  
    model = TableModel()
    table = TableCanvas(tframe, model=model)
    table.createTableFrame()
    
    model = table.model
    data = {'rec1': {'ID': 'Task1', 'Priority': 'High' },  
            'rec2': {'ID': 'Task2', 'Priority': 'Low'  },
            'rec3': {'ID': 'Task3', 'Priority': 'Low'  }               
           }  
    model.importDict(data) #Import from a dictionary to populate model
    table.redrawTable()
    
    #Add New Row button
    def AddRowButton():
        table.addRow() 
        table.redrawTable() 
    
    AddRowBTN = tk.Button(TaskWindow,text='Add New Row', command = AddRowButton)
    AddRowBTN.place(relx=0.9, rely=0.15, anchor=tk.CENTER)      
        
    TaskWindow.mainloop()
Esempio n. 24
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        # Background Label
        self.bgImg = tk.PhotoImage(file='background.png')
        bgLabel = tk.Label(self, image=self.bgImg)
        bgLabel.place(relheight=1, relwidth=1, anchor='nw')

        # new frame to see data
        self.itemsListFrame = tk.Frame(self, bg='#b536aa')
        self.itemsListFrame.place(relx=0.15,
                                  rely=0.2,
                                  relheight=0.6,
                                  relwidth=0.7)

        model = TableModel()
        items = item_database.getData()
        print(len(items))
        data = {}

        for i in range(len(items)):
            data['row' + str(i + 1)] = {
                'Name': items[i][0],
                'Barcode': items[i][1],
                'P.Price': items[i][2],
                'S.Price': items[i][3],
                'Quantity': items[i][4]
            }

        table = TableCanvas(self.itemsListFrame, data=data)
        table.show()

        # Add a new frame for back button
        frame = tk.Frame(self, bg='#b536aa')
        frame.place(relx=0.15, rely=0.8, relheight=0.1, relwidth=0.7)

        # Add Back Button
        back_btn = tk.Button(
            frame,
            text='Back',
            font=('Courier', 15, 'bold'),
            command=lambda: controller.show_frame(InventoryPage))
        back_btn.place(relx=0.35, rely=0.3, relheight=0.3, relwidth=0.3)
Esempio n. 25
0
 def muestradatos(self, event):
     model = TableModel()
     self.curs.execute(self.var_sql.get())
     output = self.curs.fetchall()  #output from query
     columns = [description[0] for description in self.curs.description]
     output_dict = {}
     for index in range(
             len(output)):  #use an index to create new dictionary elements
         data = output[
             index]  #use that index to find the next piece of data to insert into output dictionary
         dictrecord = {}
         for indcol in range(len(columns)):
             dictrecord[columns[indcol]] = data[indcol]
         output_dict[index] = dictrecord
         #create new dictionary element, using
         #the index as the key and setup a nested dictionary as the value associated with the key
     table = TableCanvas(self.frtab,
                         data=output_dict,
                         width=600,
                         height=300)
     table.show()
Esempio n. 26
0
 def SQL_ALTERNATIVE_display_leaderboard(self):
     '''
     display top 10 kills, by using sql limit
     then sort the list by using mergesort, with highest kill on top. Could have also used sql ORDER BY
     '''
     self.cursor.execute(
         'SELECT player.username, MAX(data.kills) AS kills, data.date FROM data INNER JOIN player ON data.playerID = player.playerID GROUP BY username ORDER BY data.kills DESC limit 0, 10 '
     )
     result = self.cursor.fetchall()
     data = Convert(result)
     tframe = Frame(self.my_w)
     tframe.pack()
     model = TableModel()
     table = TableCanvas(tframe,
                         model=model,
                         data=data,
                         editable=False,
                         width=800,
                         height=300)
     table.show()
     self.my_w.mainloop()
Esempio n. 27
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')
Esempio n. 28
0
def populateData(type):
    top = Toplevel()
    analysis = {}
    if type == "LDA":
        with open("./analysis/LDA_output.txt") as f:
            next(f)
            index = 0
            for line in f:
                tokens = line.rstrip('\n').split(':')
                topicWords = tokens[1].split('+')
                print(topicWords)
                for w in topicWords:
                    record = {}
                    tw = w.split('*')
                    record["Topic ID"] = tokens[0]
                    record["Probability"] = tw[0]
                    word = tw[1].replace('"', '').replace('"', '')
                    record["Word"] = word
                    analysis[index] = record
                    index = index + 1
    else:
        with open("./analysis/LSI_output.txt") as f:
            next(f)
            index = 0
            for line in f:
                record = {}
                tokens = line.rstrip('\n').split(':')
                record["Document Name"] = tokens[0]
                record["Document ID"] = tokens[1]
                record["Probability"] = tokens[2]
                analysis[index] = record
                index = index + 1
    model = TableModel()
    model.importDict(analysis)
    table = TableCanvas(top, model=model)
    table.createTableFrame()
    top.mainloop()
Esempio n. 29
0
def submit(*value):
    print('_____________________________________________________________')

    model = TableModel()
    # load data
    data = load_data(name, value)
    # import data to tablemodel
    model.importDict(data)

    # Create table for records preview
    table = TableCanvas(recordsFrame,
                        name="tablica",
                        model=model,
                        width=420,
                        height=600,
                        cols=0,
                        rows=0,
                        cellwidth=50,
                        editable=False,
                        showkeynamesinheader=True,
                        reverseorder=0)
    table.grid(row=0, sticky=W + N + S)
    table.createTableFrame()
    table.redrawTable()
Esempio n. 30
0
def openfile():
    global table, time, x_angle, y_angle, day, month, year, root, embedFrame, recordsFrame, play

    name = tkFileDialog.askopenfilename(initialdir=".",
                                        title="Select file",
                                        filetypes=(("Text File", "*.txt"),
                                                   ("All Files", "*.*")))

    if name == "":
        # if file openning was cancelled then return
        return
    else:
        try:
            path = name.split('/')
            # get date from file name
            filename = path[len(path) - 1]
            day = filename[6:8]
            month = filename[4:6]
            year = filename[2:4]

            # create data
            model = TableModel()
            # load data
            data = load_data(name)
            # import data ti tablemodel
            model.importDict(data)
        except:
            tkMessageBox.showerror("Error", "File reading failed!")
            return

    # If another file is open already then close it
    if table != None:
        closefile()

    # Change App title to include currently open file
    root.title('Smart Egg 3D Visualisation ver.1.1 - ' + filename)

    # Create embed frame for pygame window
    embedFrame = tk.Frame(root, width=700, height=600)
    embedFrame.grid(row=0, column=0)
    # Create embed frame for table
    recordsFrame = tk.Frame(root, width=450, height=600)
    recordsFrame.grid(row=0, column=1)
    recordsFrame.pack_propagate(0)
    # Create table for records preview
    table = TableCanvas(recordsFrame,
                        name="tablica",
                        model=model,
                        width=420,
                        height=600,
                        cols=0,
                        rows=0,
                        cellwidth=50,
                        editable=False,
                        showkeynamesinheader=True,
                        reverseorder=0)
    table.grid(row=0, sticky=W + N + S)
    table.createTableFrame()
    # arrange columns width and order
    model.moveColumn(model.getColumnIndex('time'), 1)
    model.moveColumn(model.getColumnIndex('x'), 2)
    model.moveColumn(model.getColumnIndex('y'), 3)
    model.moveColumn(model.getColumnIndex('z'), 4)
    model.moveColumn(model.getColumnIndex('roll'), 5)
    model.moveColumn(model.getColumnIndex('pitch'), 6)
    model.columnwidths['time'] = 150

    table.redrawTable()

    # Initiate and embed pygame
    os.environ['SDL_WINDOWID'] = str(embedFrame.winfo_id())
    #os.environ['SDL_VIDEODRIVER'] = 'windib'
    screen = pygame.display.set_mode(SCREEN_SIZE,
                                     HWSURFACE | OPENGL | DOUBLEBUF)
    resize(*SCREEN_SIZE)
    pygame.init()
    pygame.display.init()

    #Bind keys and buttons events
    root.bind('<ButtonRelease-1>', handle_click)  #click release event
    root.bind_all("<Up>", handle_arrow_keys)  #press Up key event
    root.bind_all("<Down>", handle_arrow_keys)  #press Down key event
    root.bind_all("<Left>", handle_arrow_keys)  #press Left key event
    root.bind_all("<Right>", handle_arrow_keys)  #press Right key event

    # Initiate OpenGL
    init_opengl()

    # Create OpenGL object
    egg = Egg((0.7, 0.0, 0.0), (1, .95, .8))

    # Load first element
    values = get_record(0)
    if values != None:
        time = values[0] + ' ' + values[1]
        x_angle = values[2]
        y_angle = values[3]

    root.update()

    # loop control variable
    play = True

    while play:
        drawXYZCoordinate()
        # Draw XYZ axis labels
        drawText3D(-1.2, -1.0, -2.4, 'x')
        drawText3D(-2.2, -0.6, -2.4, 'y')
        drawText3D(-2.2, -1.0, -2.0, 'z')

        for event in pygame.event.get():
            if event.type == KEYUP:
                handle_arrow_keys(event.key)

        glPushMatrix()
        # rotate object
        glRotate(float(x_angle), 0, 0, 1)
        glRotate(float(y_angle), 1, 0, 0)
        # render object and text
        egg.render(pygame)
        glPopMatrix()
        drawText(0, 2, time)
        # refresh screen
        pygame.display.flip()
        root.update()