Ejemplo n.º 1
0
    def __table__(self, master):
        try:
            if self.rule_win.state() == 'normal':
                pass
        except:
            data = {}
            colnums = ['Rule', 'Node', 'Question', 'Yes', 'No']
            rule_dict = self.df.ix[:, 'Rule':'No']

            for r in range(len(rule_dict.index)):
                plice = {}
                for c in range(len(rule_dict.columns)):
                    if rule_dict.iloc[r, c] == 'nan':
                        plice[rule_dict.columns[c]] = ' '
                    else:
                        plice[rule_dict.columns[c]] = rule_dict.iloc[r, c]
                data[str(r)] = plice

            self.rule_win = Toplevel(master)
            frame = Frame(self.rule_win)
            frame.pack()
            model = TableModel()

            for key in colnums:
                model.addColumn(key)  #sort the columns

            model.importDict(data)
            table = TableCanvas(frame,
                                model=model,
                                width=800,
                                height=500,
                                rowheight=20,
                                editable=False,
                                cellbackgr='#E3F6CE',
                                reverseorder=1,
                                rowselectedcolor='yellow')
            table.createTableFrame()
            table.sortTable(columnName='Rule')
Ejemplo n.º 2
0
    def set_columns(self, columns, main_column=None):
        self.deleteColumns()
        for col in columns:
            TableModel.addColumn(self, col)

        self.main_column = columns[0] if main_column is None else main_column
Ejemplo n.º 3
0
    def set_columns(self, columns, main_column=None):
        self.deleteColumns()
        for col in columns:
            TableModel.addColumn(self, col)

        self.main_column = columns[0] if main_column is None else main_column
Ejemplo n.º 4
0
from tkintertable.Tables import TableCanvas
from tkintertable.TableModels import TableModel
from Tkinter import *
master = Tk()
tframe = Frame(master)
tframe.pack()
model = TableModel()

model.addColumn('c1')
model.addColumn('c2')
model.addRow('1')
model.addRow('2')
row= 1
column = 1
table = TableCanvas(tframe,model=model)
table.model.data['1']['c1']= 10  
table.createTableFrame()

#table.pack()
master.mainloop()
Ejemplo n.º 5
0
class my_graph(object):
    def __init__(self, frame, usable_width, direction):

        self.deleted = False

        self.directed = direction

        self.ftable = Frame(frame.ftables)
        self.ft = Frame(self.ftable)
        self.fnp = Frame(self.ftable)

        #frame network properties
        if(usable_width > 1500)       :
            button_width=17
            button_width_plot=7
            font=('Verdana',9)
            image_button = 23
            list_fonts = list( tkFont.families() )
        elif(usable_width > 1200):
            button_width=15
            button_width_plot=6
            image_button = 28
            font=('Verdana',10)
        else:
            button_width=14
            button_width_plot=5
            image_button = 28
            font=('Verdana',8)


        if(usable_width > 1500):
            self.save_img = PhotoImage(file="save.gif")
            self.load_img = PhotoImage(file="load.gif")
            self.delete_img = PhotoImage(file="delete.gif")
        elif(usable_width > 1200):
            self.save_img = PhotoImage(file="save22.gif")
            self.load_img = PhotoImage(file="load22.gif")
            self.delete_img = PhotoImage(file="delete.gif")
        else:
            self.save_img = PhotoImage(file="save20.gif")
            self.load_img = PhotoImage(file="load20.gif")
            self.delete_img = PhotoImage(file="delete.gif")

        labelfnp_width = 10
        pos = 0
        # buttons area for the right panel of each graph
        self.buttonSave = Button(master=self.fnp, image=self.save_img, command=lambda num=frame.number_table: save_network(frame, num), relief=FLAT, width=image_button)
        self.buttonSave.image = self.save_img
        self.buttonSave.grid(row=0, column=0, pady=1, padx=1)

        self.buttonDelete = Button(master=self.fnp, image=self.delete_img, command=lambda num=frame.number_table: delete_network(frame, num), relief=FLAT, width=image_button)
        self.buttonDelete.image = self.delete_img
        self.buttonDelete.grid(row=pos, column=1, pady=1, padx=1)
        pos += 1

        self.plot_button = Button(master=self.fnp, text='Plot', command=lambda num=frame.number_table: plot_graph(frame, num), width=button_width)
        self.plot_button.grid(row=pos, column=0, columnspan=2, pady=2, padx=5)

        pos += 1

        self.netPro_label = Label(self.fnp, text="Network properties:", width=3*labelfnp_width, anchor=CENTER)
        self.netPro_label.grid(row=pos, column=0, columnspan=2, pady=2, padx=5)
        pos += 1
        self.number_nodesLabel = Label(self.fnp, text="Nodes: ", width=labelfnp_width, anchor=W)
        self.number_nodesLabel.grid(row=pos, column=0, pady=2, padx=5)
        self.number_nodes_str = StringVar()
        self.number_nodes_l = Label(self.fnp, textvariable=self.number_nodes_str, width=labelfnp_width, anchor=W)
        self.number_nodes_l.grid(row=pos, column=1, pady=2, padx=5)
        pos += 1

        self.number_arcsLabel = Label(self.fnp, text="Arcs: ", width=labelfnp_width, anchor=W)
        self.number_arcsLabel.grid(row=pos, column=0, pady=2, padx=5)
        self.number_arcs_str = StringVar()
        self.number_arcs_l = Label(self.fnp, textvariable=self.number_arcs_str, width=labelfnp_width, anchor=W)
        self.number_arcs_l.grid(row=pos, column=1, pady=2, padx=5)
        pos += 1

        self.number_diameterLabel = Label(self.fnp, text="Diameter: ", width=labelfnp_width, anchor=W)
        self.number_diameterLabel.grid(row=pos, column=0, pady=2, padx=5)
        self.diameter_str = StringVar()
        self.diameter_l = Label(self.fnp, textvariable=self.diameter_str, width=labelfnp_width, anchor=W)
        self.diameter_l.grid(row=pos, column=1, pady=2, padx=5)
        pos += 1

        self.assortativityLabel = Label(self.fnp, text="Assortativity: ", width=labelfnp_width, anchor=W)
        self.assortativityLabel.grid(row=pos, column=0, pady=2, padx=5)
        self.assortativity_str = StringVar()
        self.assortativity_l = Label(self.fnp, textvariable=self.assortativity_str, width=labelfnp_width, anchor=W)
        self.assortativity_l.grid(row=pos, column=1, pady=2, padx=5)
        pos += 1

        self.entropyLabel = Label(self.fnp, text="Entropy: ", width=labelfnp_width, anchor=W)
        self.entropyLabel.grid(row=pos, column=0, pady=2, padx=5)
        self.entropy_str = StringVar()
        self.entropy_l = Label(self.fnp, textvariable=self.entropy_str, width=labelfnp_width, anchor=W)
        self.entropy_l.grid(row=pos, column=1, pady=2, padx=5)
        pos += 1

        self.subgraph_ind_sub = Button(master=self.fnp, text='Induced subgraph', font=font, command=lambda num=frame.number_table: induced_subgraph(frame, num, usable_width), width=button_width)
        self.subgraph_ind_sub.grid(row=pos, column=0, pady=2, padx=5)

        pos+=1
        self.subgraph_ind_sub_lev = Button(master=self.fnp, text='Subgraph level', font=font, command=lambda num=frame.number_table: subgraph_levels(frame, num, usable_width), width=button_width)
        self.subgraph_ind_sub_lev.grid(row=pos, column=0, pady=2, padx=5)
        self.frame_but = Frame(self.fnp)



        #table part, create and fill columns
        self.columnNames = columnNames

        self.model = TableModel()
        self.model.data = {}
        for i in xrange(len(self.columnNames)):
            if(direction):
                if(columnNames[i] != "Information centrality"):
                    self.model.addColumn(self.columnNames[i])
            else:
                if(columnNames[i] != 'Eccentricity in'):
                    if(columnNames[i] != 'Vibrational centrality in'):
                        if(columnNames[i] != 'In degree'):
                            if(columnNames[i] != 'Total degree'):
                                self.model.addColumn(self.columnNames[i].replace(" out", "").replace("Out degree", "Degree"))

        if(usable_width > 1500):
            thefont=30
            rowheight=22

        else:
            thefont=5
            rowheight=20

        self.table = TableCanvas(self.ft, model=self.model, rows=0, cols=0, rowheaderwidth=0, rowheight=rowheight,
                                 cellbackgr='#ffffff', thefont=thefont, editable=False, showkeynamesinheader=True,
                                  autoresizecols=True, fill=X)

        self.model.addRow()
        self.table.createTableFrame()

        self.file_name = StringVar()
        self.file_name_label = Label(self.ftable, textvariable=self.file_name)

        self.file_name_label.pack(side=TOP)
        self.ft.pack(side=LEFT, expand=True, fill=X)
        self.fnp.pack(side=RIGHT)

        self.ftable.pack(expand=True, fill=X)

        #create the centrality list
        self.centrality = [[] for x in xrange(len(self.columnNames))]

        self.table.fontsize=thefont
        self.table.setFontSize()
        self.adj_matrix = None
        self.laplacian_psinv = None


        frame.canvas.config(scrollregion=frame.canvas.bbox("all"))
Ejemplo n.º 6
0
from tkintertable.Tables import TableCanvas
from tkintertable.TableModels import TableModel
from Tkinter import *
master = Tk()
tframe = Frame(master)
tframe.pack()
model = TableModel()

model.addColumn('c1')
model.addColumn('c2')
model.addRow('1')
model.addRow('2')
row = 1
column = 1
table = TableCanvas(tframe, model=model)
table.model.data['1']['c1'] = 10
table.createTableFrame()

#table.pack()
master.mainloop()