Ejemplo n.º 1
0
    def __init__(self):
    	self.MyQStation = QStation()
        self.root = Tk(className=self.TITLE)
        self.root.title(self.TITLE)
        self.root.resizable(0, 0)
        self.root.configure(background=self.BACKGROUND)
        icon = PhotoImage(file='icons/icon.gif')
        self.root.tk.call('wm', 'iconphoto', self.root._w, icon)
        
        self.mainframe = Frame(self.root)
        self.mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
        self.mainframe.columnconfigure(0, weight=1)
        self.mainframe.rowconfigure(0, weight=1)
        self.mainframe.configure(background=self.BACKGROUND)

        self.udp_client = NONE
        self.ip = StringVar()
        self.name = StringVar()
        self.color = ()
        self.status = IntVar()
        self.response = StringVar()
        self.item = StringVar()
        self.item_id = IntVar()

        self.bulb_treeview = ttk.Treeview(self.mainframe)
        self.bulb_treeview.heading("#0", text="Bulbs")
        self.bulb_treeview.grid(column=0, row=0, rowspan=2, sticky=(N, W, E, S))
        self.bulb_treeview.bind('<<TreeviewSelect>>', self.callback_bulb_treeview)

        Label(self.mainframe, text='Q Station IP').grid(column=1, row=0, sticky=W)

        self.ip_entry = Entry(self.mainframe, textvariable=self.ip)
        self.ip_entry.grid(column=2, row=0, sticky=(W, E))

        img_connect = PhotoImage(file='icons/arrow_refresh.gif')
        Button(self.mainframe, command=self.callback_get_bulbs, image=img_connect).grid(column=3, row=0, sticky=(W, E))

        Button(self.mainframe, command=self.callback_get_groups, image=img_connect).grid(column=3, row=10, sticky=(W, E))

        self.labelframe = LabelFrame(self.mainframe, text='Bulb Settings')
        self.labelframe.grid(column=1, columnspan=3, row=1, sticky=(N, W, E, S))

        Label(self.labelframe, text='Name').grid(column=1, row=1, sticky=W)

        self.name_entry = Entry(self.labelframe, textvariable=self.name)
        self.name_entry.grid(column=2, row=1, sticky=(W, E))

        Label(self.labelframe, text='Brightness').grid(column=1, row=3, sticky=W)
        
        self.bright_scale = Scale(self.labelframe, from_=0, to=255, orient=HORIZONTAL)
        self.bright_scale.set(0)
        self.bright_scale.grid(column=2, row=3, sticky=(N, W, E, S))

        Label(self.labelframe, text='Status').grid(column=1, row=2, sticky=W)

        Checkbutton(self.labelframe, text=' Turn the bulb on or off', variable=self.status).grid(column=2,
                                                                                                 columnspan=2,
                                                                                                 row=2,
                                                                                                 sticky=(W, E))

        img_accept = PhotoImage(file='icons/accept.gif')
        Button(self.labelframe, text='Set Values', command=1, image=img_accept,
               compound=LEFT).grid(column=1, columnspan=2, row=5, sticky=(W, E))

        Label(self.labelframe, text='Color').grid(column=1, row=4, sticky=W)

        img_color = PhotoImage(file='icons/color_wheel.gif')
        self.color_button = Button(self.labelframe, command=1, image=img_color)
        self.color_button.grid(column=2, row=4, sticky=(W, E))

        for child in self.mainframe.winfo_children():
            try:
                child.grid_configure(padx=10, pady=5)
                child.configure(background=self.BACKGROUND)
            except:
                pass

        for child in self.labelframe.winfo_children():
            try:
                child.grid_configure(padx=10, pady=5)
                child.configure(background=self.BACKGROUND)
                child.configure(state='disable')
            except:
                pass

        self.ip_entry.focus()

        self.root.mainloop()
Ejemplo n.º 2
0
 def __init__(self, master, manifold):
     self.manifold = manifold.copy()
     self.num = 0  # make the superclass happy
     self.result = []
     style = SnapPyStyle(master)
     self.root = root = Tk_.Toplevel(master,
                                     class_='SnapPy',
                                     bg=style.WindowBG)
     title = 'Cover'
     root.title(title)
     root.iconname(title)
     root.bind('<Return>', self.handle_return)
     top_frame = Tk_.Frame(root, bg=style.WindowBG)
     top_frame.grid_rowconfigure(2, weight=1)
     top_frame.grid_columnconfigure(0, weight=1)
     top_frame.grid_columnconfigure(1, weight=1)
     msg_font = Font(family=style.font_info['family'],
                     weight='bold',
                     size=int(style.font_info['size'] * 1.2))
     msg = ttk.Label(top_frame,
                     font=msg_font,
                     text='Choose covering spaces to browse:')
     msg.grid(row=0, column=0, columnspan=3, pady=10)
     degree_frame = Tk_.Frame(top_frame, bg=style.WindowBG)
     self.degree_var = degree_var = Tk_.StringVar()
     ttk.Label(degree_frame, text='Degree: ').grid(row=0,
                                                   column=0,
                                                   sticky=Tk_.E)
     self.degree_option = degree_option = ttk.OptionMenu(
         degree_frame,
         degree_var,
         None,
         *range(2, 9),
         command=self.clear_list)
     degree_option.grid(row=0, column=1)
     self.cyclic_var = cyclic_var = Tk_.BooleanVar()
     cyclic_or_not = Tk_.Checkbutton(degree_frame,
                                     bg=style.WindowBG,
                                     variable=cyclic_var,
                                     text='cyclic covers only',
                                     command=self.clear_list)
     cyclic_or_not.grid(row=0, column=2, padx=6, sticky=Tk_.W)
     self.action = action = ttk.Button(degree_frame,
                                       text='Find Covers',
                                       command=self.show_covers)
     action.grid(row=0, column=3, padx=8, sticky=Tk_.W)
     degree_frame.grid(row=1, column=0, pady=2, padx=6, sticky=Tk_.EW)
     self.covers = covers = ttk.Treeview(
         top_frame,
         selectmode='extended',
         columns=['index', 'cover_type', 'num_cusps', 'homology'],
         show='headings')
     covers.heading('index', text='')
     covers.column('index', stretch=False, width=20)
     covers.heading('cover_type', text='Type')
     covers.column('cover_type', stretch=False, width=80)
     covers.heading('num_cusps', text='# Cusps')
     covers.column('num_cusps', stretch=False, width=80, anchor=Tk_.CENTER)
     covers.heading('homology', text='Homology')
     covers.column('homology', stretch=True, width=300)
     covers.bind('<Double-Button-1>', self.choose)
     self.covers.grid(row=2,
                      column=0,
                      columnspan=2,
                      padx=6,
                      pady=6,
                      sticky=Tk_.NSEW)
     top_frame.pack(fill=Tk_.BOTH, expand=1)
     button_frame = Tk_.Frame(self.root, bg=style.WindowBG)
     button_frame.grid_columnconfigure(0, weight=1)
     button_frame.grid_columnconfigure(1, weight=1)
     self.browse = ttk.Button(button_frame,
                              text='Browse',
                              command=self.choose,
                              default='active')
     self.browse.grid(row=0, column=0, sticky=Tk_.E, padx=6)
     button = ttk.Button(button_frame, text='Cancel', command=self.cancel)
     button.grid(row=0, column=1, sticky=Tk_.W, padx=6)
     button_frame.pack(pady=6, fill=Tk_.BOTH, expand=1)
     self.root.protocol('WM_DELETE_WINDOW', self.cancel)
     self._set_transient(master)
     degree_var.set('2')
     cyclic_var.set(True)
     self.show_covers()
Ejemplo n.º 3
0
    def __init__(self, master):
        self.master = master
        self.master.bind('<Button-1>', self.show_properties)
        self.IPs = []
        self.finished_port = False
        Label(master, text='Starting IP:').grid(row=0, column=0)
        self.ip_mac_pairs = {}

        self.e = Entry(master)
        self.e.grid(row=0, column=1)
        Label(master, text='Ending IP:').grid(row=0, column=2)

        self.e2 = Entry(master)
        self.e2.grid(row=0, column=3)

        self.b = Button(master, text='Scan', command=lambda: self.wrapper(False, None, None))
        self.b.grid(row=0, column=4)

        self.properties_butt = Button(master, text='Properties', state=DISABLED, command=self.properties)
        self.properties_butt.grid(row=0, column=5)

        self.tree = ttk.Treeview(master)
        self.tree['columns'] = ('ip', 'name', 'mac_addr', 'company')
        self.tree.heading("ip", text="IP Address")
        self.tree.heading('name', text='Hostname')
        self.tree.heading('mac_addr', text='Mac Address')
        self.tree.heading("company", text='Vendor Name')
        self.tree['displaycolumns'] = ('ip', 'name', 'mac_addr', 'company')
        self.tree['show'] = 'headings'
        self.tree.grid(row=1, column=0, columnspan=5)
        start = time.clock()

        self.threads = []
        try:
            f = open('data.dat', 'r')
            lines = f.read().splitlines()
            last_scan_unix, startip, endip = lines[0], lines[1], lines[2]
            self.e.insert(0, startip)
            self.e2.insert(0, endip)
            # Index Will Move Up - So 1st 3 - 0,0,0
            del lines[0]
            del lines[0]
            del lines[0]
            f.close()
            self.parse_from_file(lines)
            self.b.config(text='Refresh')
            diff = int(time.time()) - int(last_scan_unix)
            if diff >= 86400:
                # Forces Refresh
                raise IOError
        except IOError:
            lines = []
            if self.e.get() == '' or self.e2.get() == '':
                self.e.delete(0, 'end')
                self.e2.delete(0, 'end')
                self.e.insert(0, '192.168.0.0')
                self.e2.insert(0, '192.168.0.255')
                temp_e = self.e.get()
                temp_e2 = self.e2.get()
                self.wrapper(True, temp_e, temp_e2)
        finally:
            print 'creating table'
            self.table_wrapper()
            self.file_writer()
            print 'Total Time:', time.clock() - start
            tree_scroller = Scrollbar(master)
            tree_scroller.configure(command=self.tree.yview)
            self.tree.configure(yscrollcommand=tree_scroller.set)
            tree_scroller.grid(row=1, column=5, sticky='NSW')
            master.mainloop()
Ejemplo n.º 4
0
    def InitUI(self):
        
        self.frame = Frame(self.parent)
        self.frame.pack(expand=1, fill='both')

        for i in range(0, 3):
            self.frame.columnconfigure(i, weight=6)
        self.frame.columnconfigure(3, weight=1)
        
        for i in range(3, 4):
            self.frame.rowconfigure(i, weight=1)

        self.labelID   = Label(self.frame, text=u'Identifier')
        self.labelName = Label(self.frame, text=u'Real Name')
        self.labelDoB  = Label(self.frame, text=u'Date of Birth (YYYY-MM-DD)')

        self.buttonAdd    = Button(self.frame, width=12,
                                   text=u'Add candidate',
                                   command=self.AddIdentifierEvent
                                  )
        self.buttonClear  = Button(self.frame, width=12,
                                   text=u'Clear fields',
                                   command=self.clear
                                  )
        self.buttonSearch = Button(self.frame, width=12,
                                   text=u'Search candidate',
                                   command=self.search
                                  )
        self.buttonEdit   = Button(self.frame, width=12,
                                   text=u'Edit candidate',
                                   command=self.edit
                                  )

        self.textCandId  = StringVar()
        self.candidateid = Entry(self.frame,
                                 textvariable=self.textCandId,
                                 width=20
                                )
        self.candidateid.focus_set()

        self.textCandName  = StringVar()
        self.candidatename = Entry(self.frame,
                                   textvariable=self.textCandName,
                                   width=20
                                  )

        self.textCandDoB  = StringVar()
        self.candidateDoB = Entry(self.frame,
                                  textvariable=self.textCandDoB,
                                  width=20
                                 )

        self.tableColumns = ("Identifier", "Real Name", "Date of Birth")
        self.datatable    = ttk.Treeview(self.frame,
                                         selectmode='browse',
                                         columns=self.tableColumns,
                                         show="headings")
        for col in self.tableColumns:
            self.datatable.heading(col, text=col.title(), 
                                   command=lambda c=col: sortby(self.datatable, c, 0))

        self.datatable.bind("<<TreeviewSelect>>", self.OnRowClick)
      
        self.ErrorMessage = StringVar()
        self.error = Label(self.frame, textvariable=self.ErrorMessage, fg='red')

        self.labelID.grid(row=0, column=0, padx=(0,4), sticky=E+W)
        self.labelName.grid(row=0, column=1, padx=(4,4), sticky=E+W)
        self.labelDoB.grid(row=0, column=2, padx=(4,4), sticky=E+W)

        self.candidateid.grid(row=1, column=0, padx=(0,4), pady=(0,10), sticky=E+W)
        self.candidatename.grid(row=1, column=1, padx=(4,4), pady=(0,10), sticky=E+W)
        self.candidateDoB.grid(row=1, column=2, padx=(4,4), pady=(0,10), sticky=E+W)
 
        self.buttonAdd.grid(row=2, column=1, padx=(4,0), sticky=E+W)
        self.buttonClear.grid(row=1, column=3, padx=(4,0), sticky=E+W)
        self.buttonSearch.grid(row=2, column=0, padx=(4,0), sticky=E+W)
        self.buttonEdit.grid(row=2, column=2, padx=(4,0), sticky=E+W)

        self.datatable.grid(row=3, column=0, columnspan=3, pady=10, sticky='nsew')
        self.error.grid(row=3, column=3)
Ejemplo n.º 5
0
 def build_invariants(self):
     style = self.style
     frame = Tk_.Frame(self.window, bg=style.GroupBG)
     frame.columnconfigure(1, weight=1)
     self.volume = SelectableText(frame, labeltext='Volume')
     self.volume.grid(row=0, column=0, padx=30, pady=5, sticky=Tk_.E)
     self.cs = SelectableText(frame, labeltext='Chern-Simons Invariant')
     self.cs.grid(row=1, column=0, padx=30, pady=5, sticky=Tk_.E)
     self.homology = SelectableText(frame, labeltext='First Homology')
     self.homology.grid(row=2, column=0, padx=30, pady=5, sticky=Tk_.E)
     self.orientability = SelectableText(frame, labeltext='Orientability')
     self.orientability.grid(row=3, column=0, padx=30, pady=5, sticky=Tk_.E)
     self.pi_one = SelectableMessage(frame, labeltext='Fundamental Group')
     self.pi_one.grid(row=0,
                      column=1,
                      rowspan=3,
                      padx=30,
                      pady=5,
                      sticky=Tk_.NSEW)
     self.pi_one_options = Tk_.Frame(frame, bg=style.GroupBG)
     self.simplify_var = Tk_.BooleanVar(frame, value=True)
     self.simplify = Tk_.Checkbutton(self.pi_one_options,
                                     variable=self.simplify_var,
                                     text='simplified presentation',
                                     bg=style.GroupBG,
                                     borderwidth=0,
                                     highlightthickness=0,
                                     command=self.compute_pi_one)
     self.simplify.pack(anchor=Tk_.W)
     self.minimize_var = Tk_.BooleanVar(frame, value=True)
     self.minimize = Tk_.Checkbutton(self.pi_one_options,
                                     variable=self.minimize_var,
                                     text='minimal number of generators',
                                     bg=style.GroupBG,
                                     borderwidth=0,
                                     highlightthickness=0,
                                     command=self.compute_pi_one)
     self.minimize.pack(anchor=Tk_.W)
     self.gens_change_var = Tk_.BooleanVar(frame, value=True)
     self.gens_change = Tk_.Checkbutton(
         self.pi_one_options,
         variable=self.gens_change_var,
         text='fillings may affect generators',
         bg=style.GroupBG,
         borderwidth=0,
         highlightthickness=0,
         command=self.compute_pi_one)
     self.gens_change.pack(anchor=Tk_.W)
     self.pi_one_options.grid(row=3, column=1, padx=30, sticky=Tk_.EW)
     self.length_spectrum = NBLabelframe(frame, text='Length Spectrum')
     self.length_spectrum.grid_columnconfigure(1, weight=1)
     ttk.Label(self.length_spectrum,
               text='Length Cutoff:').grid(row=0,
                                           column=0,
                                           sticky=Tk_.E,
                                           padx=5,
                                           pady=5)
     self.length_cutoff = 1.0
     self.cutoff_var = Tk_.StringVar(self.window, self.length_cutoff)
     self.cutoff_entry = cutoff_entry = ttk.Entry(
         self.length_spectrum,
         takefocus=False,
         width=6,
         textvariable=self.cutoff_var,
         validate='focusout',
         validatecommand=(self.window.register(self.validate_cutoff), '%P'))
     cutoff_entry.bind('<Return>', lambda event: self.window.focus_set())
     cutoff_entry.grid(row=0, column=1, sticky=Tk_.W, pady=5)
     self.geodesics = geodesics = ttk.Treeview(
         self.length_spectrum,
         height=6,
         columns=['mult', 'length', 'topology', 'parity'],
         show='headings')
     geodesics.heading('mult', text='Mult.')
     geodesics.column('mult', stretch=False, width=40)
     geodesics.heading('length', text='Length')
     geodesics.column('length', stretch=True, width=460)
     geodesics.heading('topology', text='Type')
     geodesics.column('topology', stretch=False, width=40)
     geodesics.heading('parity', text='P')
     geodesics.column('parity', stretch=False, width=20)
     geodesics.grid(row=1, columnspan=2, sticky=Tk_.EW, padx=5, pady=5)
     self.length_spectrum.grid(row=4,
                               columnspan=2,
                               padx=10,
                               pady=10,
                               sticky=Tk_.EW)
     self.aka = NBLabelframe(frame, text='Also Known As')
     self.aka_viewer = aka_viewer = ttk.Treeview(
         self.aka,
         selectmode='none',
         height=4,
         columns=['manifold', 'as_link'],
         show='headings')
     aka_viewer.heading('manifold', text='Manifold')
     aka_viewer.column('manifold', stretch=True, width=200)
     aka_viewer.heading('as_link', text='Same link complement')
     aka_viewer.column('as_link', stretch=False, width=200)
     aka_viewer.pack(expand=True, fill=Tk_.BOTH)
     self.aka.grid(row=5,
                   column=0,
                   columnspan=2,
                   padx=6,
                   pady=6,
                   sticky=Tk_.NSEW)
     return frame
root = tk.Tk()
root.title(name_dic['app_name'])

#title author

for index, text in enumerate([name_dic['title'], name_dic['author']]):
    frame = tk.Frame(root)
    tk.Label(frame, text=text, width=10).pack(side=tk.LEFT)
    ens += [tk.Entry(frame)]
    ens[index].pack(expand=False, fill='x')
    frame.pack(expand=False, fill='x')

#tree
frame = tk.Frame(root)
frame.pack(expand=True, fill='both')
tree = ttk.Treeview(frame)
tree.pack(side=tk.LEFT, fill='both', expand=True)
add_scrollbar(root, frame, tree)
tree.bind("<Delete>", tree_delete)
tree.bind("<Prior>", tree_up)
tree.bind("<Next>", tree_down)
tree['show'] = 'headings'
tree["columns"] = column_headings
tree['displaycolumns'] = (0, 1, 2)

tree.heading('title',
             text=name_dic['title'],
             command=lambda: tree_sort('title', False))
tree.heading('author',
             text=name_dic['author'],
             command=lambda: tree_sort('author', False))
Ejemplo n.º 7
0
	def __init__(self, master):
		self.master = master
		master.title("PlateRunner386")

		self.wells = {}
		self.wells_chem = {}
		self.scale = 50
		self.species = []

		#plate related things
		#self.mainplate = Frame(master)
		self.plate = Canvas(master, width=self.scale*12, height=self.scale*8, bd=0, highlightthickness=0)
		self.platerefalph = Canvas(master, width=self.scale/2, height=self.scale*8, bd=0, highlightthickness=0)
		self.platerefnum=Canvas(master, width=self.scale*12, height=self.scale/2, bd=0, highlightthickness=0)

		self.plate.xd=0
		self.plate.yd=0
		self.plate.selected=[]
		self.plate.dragged=[]
		self.plate.legend_raw=[]
		self.plate.legend={}

		self.quads = {}
		self.quads_chem = {}

		#event binds for plate
		self.plate.bind("<Button-1>", self.platemousedown)
		self.plate.bind("<ButtonRelease-1>", self.platemouseup)
		self.plate.bind("<B1-Motion>", self.platemousemove)
		self.plate.bind("<Control-1>", self.platectrl)
		
		#creating physical display of plate
		self.plate_create()		
		self.platerefalph.grid(row = 1, column = 0, sticky = E)
		self.platerefnum.grid(row = 0, column = 1, columnspan = 3, sticky = S)
		self.plate.grid(row = 1, column = 1, rowspan = 1, columnspan = 3, sticky = NW)

		#creating empty space
		self.empty1 = Canvas(master, width = self.scale, height = self.scale/2, bd=0, highlightthickness=0)
		self.empty1.create_rectangle(0,0,self.scale, self.scale, width=0)
		self.empty1.grid(row=3, column=1, sticky=W)

		self.empty2 = Canvas(master, width = self.scale, height = self.scale/2, bd=0, highlightthickness=0)
		self.empty2.create_rectangle(0,0,self.scale, self.scale, width=0)
		self.empty2.grid(row=6, column=1, sticky=W)


		"""
		self.quadrant = Canvas(master, width=self.scale*3.6, height=self.scale*3.6, bd=0, highlightthickness=0)
		self.quadrant_create(384)
		self.quadrant.grid(row=4, column = 3, sticky = NE)
		
		self.quadrant.xd=0
		self.quadrant.yd=0
		self.quadrant.selected=[]

		self.quadrant.bind("<Button-1>", self.quadmousedown)
		self.quadrant.bind("<Control-1>", self.quadctrl)
		"""

		#Variable 1 tree
		self.var1frame = Frame(master)

		self.var1 = ttk.Treeview(self.var1frame, columns = ["v1"], show = "headings")
		self.var1.heading("v1", text = "Variable 1")
		self.var1.column("v1", width = int(self.scale*3))

		self.var1.insert("", "end", values = ('"*No Variable 1*"'))

		self.vsb1 = ttk.Scrollbar(master, orient="vertical", command=self.var1.yview)
		self.hsb1 = ttk.Scrollbar(master, orient="horizontal", command=self.var1.xview)
		self.var1.configure(yscrollcommand=self.vsb1.set, xscrollcommand=self.hsb1.set)
		self.var1.grid(sticky=NSEW)
		self.vsb1.grid(column=1, row=0, sticky= NS, in_ = self.var1frame)
		self.hsb1.grid(column=0, row=1, sticky= EW, in_ = self.var1frame)

		self.var1_input = Entry(self.var1frame)
		self.var1_input.grid(row = 2, columnspan = 4, sticky = W)

		self.var1_btn=Button(self.var1frame, text="Add Variable 1", command=self.updatevar1)
		self.var1_btn.grid(row = 3, columnspan = 4, sticky = W)

		self.var1frame.grid(row = 4, column=1, rowspan = 2, sticky = NW)


		#Variable 2 tree
		self.var2frame = Frame(master)
		self.var2 = ttk.Treeview(self.var2frame, columns = ["v2"], show = "headings")
		self.var2.heading("v2", text = "Variable 2")
		self.var2.column("v2", width = int(self.scale*3))
		
		self.var2.insert("", "end", values = ('"*No Variable 2*"'))

		self.vsb2 = ttk.Scrollbar(master, orient="vertical", command=self.var2.yview)
		self.hsb2 = ttk.Scrollbar(master, orient="horizontal", command=self.var2.xview)
		self.var2.configure(yscrollcommand=self.vsb2.set, xscrollcommand=self.hsb2.set)
		self.var2.grid(sticky=NSEW)
		self.vsb2.grid(column=1, row=0, sticky= NS, in_ = self.var2frame)
		self.hsb2.grid(column=0, row=1, sticky= EW, in_ = self.var2frame)

		self.var2_input = Entry(self.var2frame)
		self.var2_input.grid(row = 2, columnspan = 4, sticky = W)

		self.var2_btn=Button(self.var2frame, text="Add Variable 2", command=self.updatevar2)
		self.var2_btn.grid(row = 3, columnspan = 4, sticky = W)

		self.var2frame.grid(row = 4, column = 2, rowspan = 2, sticky = N)


		#pH, dpH/dT and Control
		self.otherinputs = Frame(master)

		Label(self.otherinputs, text = "pH:").grid(row = 11, column = 9, sticky = SW)
		Label(self.otherinputs, text = "dpH/dT:  ").grid(row = 12, column = 9, sticky = W)
		Label(self.otherinputs, text = "Control?").grid(row = 13, column = 9, sticky = W)

		self.pH_input = Entry(self.otherinputs)
		self.pH_input.grid(row = 11, column = 10, columnspan = 2, sticky = SW)

		self.dpH_input = Entry(self.otherinputs)
		self.dpH_input.grid(row = 12, column = 10, columnspan = 2, sticky = W)

		self.ctr = IntVar() 
		self.chkbtn = Checkbutton(self.otherinputs, variable=self.ctr)
		self.chkbtn.grid(row=13, column = 10, sticky = W)

		self.otherinputs.grid(row = 4, column = 3, sticky = NE)


		#content key related things

		self.assign_btn=Button(master, text="Assign selected wells", command=self.assign)
		self.assign_btn.grid(row = 7, column = 1, sticky = W)

		self.clear_btn=Button(master, text="Clear selected wells", command=self.unassign)
		self.clear_btn.grid(row = 8, column = 1, sticky = W)

		self.create_btn=Button(master, text="CREATE CONTENT MAP", command=self.create_map)
		self.create_btn.grid(row = 8, column = 3, sticky = E)

		self.empty2=Canvas(master, width=self.scale*0.5, height=self.scale*0.5, bd=0, highlightthickness=0)
		self.empty2.grid(row=0, column=13)

		self.master.bind("<Return>", self.enter)
		self.master.bind("<Delete>", self.welldel)
Ejemplo n.º 8
0
e_entry = ttk.Entry(mainframe,width=20,textvariable=e,state=DISABLED)
e_entry.grid(column=1,row=7)
#计算按钮
ttk.Button(mainframe,text='计算',command=formula).grid(column=1,row=8,sticky=(W,E))
#添加输入框,
result_n = StringVar()
N_entry = ttk.Entry(mainframe,width=20,textvariable=result_n)
N_entry.grid(column=1,row=9)
#保存按钮
ttk.Button(mainframe,text='保存',command=savetxt).grid(column=0,row=10,sticky=(W,E))
#查询按钮
inquiry = ttk.Button(mainframe,text='查询',command=showrecord)
inquiry.grid(column=2,row=10,sticky=(W,E))
#子窗口校正记录
ttk.Label(childframe,text='校正记录',font=50).grid(column=0,row=1,sticky=(W,E))
tree = ttk.Treeview(childframe,show="headings",columns=('a','b','c','d','e','f'))
tree.grid(column=0,row=2,rowspan=15)
tree.heading('a',text='N\'')
tree.heading('b',text='a')
tree.heading('c',text='Cn')
tree.heading('d',text='e0')
tree.heading('e',text='N')
tree.heading('f',text='time')
tree.column('a',width=50)
tree.column('b',width=50)
tree.column('c',width=50)
tree.column('d',width=50)
tree.column('e',width=50)
tree.column('f',width=200)
vbar = ttk.Scrollbar(childframe, orient=VERTICAL, command=tree.yview)
vbar.grid(row=2,column=2,rowspan=15,sticky=NS)
Ejemplo n.º 9
0
    def __init__(self, tl, chief, ttl, h, cols=None, ipath=None, resize=False):
        """
         initialize
         tl: the Toplevel of this panel
         chief: the master/controlling panel
         ttl: title to display
         h: # of lines to configure the treeview's height
         cols: a list of tuples col<i> =(l,w,t) where:
           l is the text to display in the header
           w is the desired width of the column in pixels
           t is the type of data in the column
         ipath: path of appicon
         resize: allow Panel to be resized by user
        """
        SlavePanel.__init__(self, tl, chief, ttl, ipath, resize)

        # create and allow derived classes to setup top frame
        frmT = ttk.Frame(self)
        if self.topframe(frmT): frmT.grid(row=0, column=0, sticky='nwse')

        # setup the main frame (NOTE: we set the row to 1 regardless of topframe)
        frmM = ttk.Frame(self)
        frmM.grid(row=1, column=0, sticky='nwse')

        # create a multi-column Tree
        self._tree = ttk.Treeview(frmM)
        self._tree.grid(row=0, column=0, sticky='nwse')
        self._tree.config(height=h)
        self._tree.config(selectmode='extended')

        # with attached horizontal/vertical scrollbars
        vscroll = ttk.Scrollbar(frmM,
                                orient=tk.VERTICAL,
                                command=self._tree.yview)
        vscroll.grid(row=0, column=1, sticky='ns')
        self._tree['yscrollcommand'] = vscroll.set
        hscroll = ttk.Scrollbar(frmM,
                                orient=tk.HORIZONTAL,
                                command=self._tree.xview)
        hscroll.grid(row=1, column=0, sticky='ew')
        self._tree['xscrollcommand'] = hscroll.set

        # configure the headers
        self._ctypes = []  # the type in this column
        self._tree['columns'] = [t[0] for t in cols]
        for i in xrange(len(cols)):
            # for each one set the column to the use specified width (or 0)
            # and set the text for each header if present as well as the sort
            # functionality (the sort functionality is set in a separate fct)
            self._ctypes.append(cols[i][2])
            try:
                w = max(lenpix(cols[i][0]), cols[i][1])
                if w is None: w = 0
            except:
                w = 0
            self._tree.column(i, width=w, anchor=tk.CENTER)
            if cols[i][0] != '': self._makesort(i, cols[i][0])

        # bind right click on the tree
        self._tree.bind('<Button-3>', self.treerc)
        self._tree.bind('<Control-a>', self.treeca)

        # allow a bottom frame
        frmB = ttk.Frame(self)
        if self.bottomframe(frmB): frmB.grid(row=2, column=0, sticky='nwse')
Ejemplo n.º 10
0
        def RE_submit():
            column_to_run_RE = column_name_RE.get()
            RE_pattern = RE_query.get('1.0', END)
            RE_pattern = RE_pattern[
                0:len(RE_pattern) -
                1]  # the get method in the last line will add a "\n" at the end of the text automatically. So we use this line to remove the "\n"

            ## Execute the Regular Expression and return the rows with this pattern
            def RE_execution(table, column, pattern):

                # obtain all the data in the column selected
                RE_command = 'select ' + column + ' from ' + table
                data_to_run_RE = con.execute(RE_command)
                data_to_run_RE = data_to_run_RE.fetchall()

                for i in range(len(data_to_run_RE)):
                    data_to_run_RE[i] = data_to_run_RE[i][0]

                # Run Regular Expression and generate a vector which will label if each record meet the requirement of RE
                match_result_index = []
                for i in range(len(data_to_run_RE)):
                    temp_match = re.search(str(pattern),
                                           str(data_to_run_RE[i]))
                    if temp_match:
                        match_result_index.append(1)
                    else:
                        match_result_index.append(0)

                return match_result_index

            RE_match_result = RE_execution(variable_table_choosing.get(),
                                           column_to_run_RE, RE_pattern)

            RE_result_view = Tk()
            RE_result_view.title("正则表达式筛选结果")
            RE_result_view.geometry('1000x300')
            tree = ttk.Treeview(RE_result_view)
            tree['show'] = 'headings'

            table_choosed = variable_table_choosing.get()
            temp_result = con.execute("select * from " + table_choosed)
            temp_column_name = con.execute("pragma table_info(" +
                                           table_choosed + ");").fetchall()

            column_name = []
            for i in range(len(temp_column_name)):
                column_name.append(temp_column_name[i][1])

            query_result = temp_result.fetchall()
            n_row = len(query_result)

            # Based on the vector obtained above, select the correspding rows and return them
            exact_result = []
            for i in range(n_row):
                if RE_match_result[i] == 1:
                    exact_result.append(query_result[i])
            n_row = len(exact_result)
            n_col = len(exact_result[0])

            tree["columns"] = column_name
            for i in column_name:
                tree.column(i, width=100)
                tree.heading(i, text=i)
            for i in range(n_row):
                tree.insert("", "end", text=str(i + 1), values=exact_result[i])
            tree.grid(row=0, column=0)
            Label(RE_result_view,
                  text=str(n_row) + " 行被提取.",
                  font='Helvetica 12').grid(row=1, column=0)

            def export_to_csv():
                save_path = tkFileDialog.asksaveasfilename(
                    title="导出至?", defaultextension="*.csv")

                csv_content = [",".join(column_name)]
                for i in range(n_row):
                    for j in range(n_col):
                        exact_result[i] = list(exact_result[i])
                        exact_result[i][j] = str(exact_result[i][j])
                    csv_content.append(",".join(exact_result[i]))

                to_write = "\n".join(csv_content)

                f = open(save_path, "w")
                f.write(to_write)
                f.close()

            Button(RE_result_view, text="导出为CSV文件",
                   command=export_to_csv).grid(row=2, column=0)

            def close():
                RE_result_view.destroy()

            Button(RE_result_view, text="关闭", command=close).grid(row=3,
                                                                  column=0)
Ejemplo n.º 11
0
    def create_UI(self):
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)
        central_panel = tkinter.PanedWindow(self,
                                            orient=tkinter.HORIZONTAL,
                                            sashwidth=self.p * 2,
                                            sashrelief=tkinter.RIDGE,
                                            background=self.host.back)
        central_panel.grid(row=0, column=0, sticky="NSEW")

        base_frame = tkinter.Frame(central_panel)
        base_frame.columnconfigure(0, weight=1)
        base_frame.rowconfigure(1, weight=1)

        top_frame = tkinter.Frame(base_frame)
        tkinter.Label(top_frame, text="Max e-value:").grid(row=0,
                                                           column=0,
                                                           sticky="NSW")
        self.evalue_threshold = tkinter.Entry(top_frame,
                                              state=tkinter.DISABLED,
                                              width=8)
        self.evalue_threshold.grid(row=0,
                                   column=1,
                                   sticky="NSW",
                                   padx=self.p,
                                   pady=self.p)
        tkinter.Label(top_frame, text="# of σ (hit):").grid(row=0,
                                                            column=2,
                                                            sticky="NSW")
        self.sigma_num_self = tkinter.Entry(top_frame,
                                            state=tkinter.DISABLED,
                                            width=4)
        self.sigma_num_self.grid(row=0,
                                 column=3,
                                 sticky="NSW",
                                 padx=self.p,
                                 pady=self.p)
        self.self_hits_button = tkinter.Button(top_frame,
                                               state=tkinter.DISABLED,
                                               text="Find self-hits",
                                               command=self.find_self_hits)
        self.self_hits_button.grid(row=0,
                                   column=4,
                                   sticky="NSW",
                                   padx=self.p,
                                   pady=self.p)
        self.white_crow_button = tkinter.Button(
            top_frame,
            state=tkinter.DISABLED,
            text="Apply options",
            command=self.apply_purification_options)
        self.white_crow_button.grid(row=1,
                                    column=4,
                                    sticky="NSW",
                                    padx=self.p,
                                    pady=self.p)
        tkinter.Label(top_frame, text="Min length:").grid(row=1,
                                                          column=0,
                                                          sticky="NSW")
        self.min_length = tkinter.Entry(top_frame, width=6)
        self.min_length.insert(tkinter.END, "0")
        self.min_length.grid(row=1,
                             column=1,
                             sticky="NSW",
                             padx=self.p,
                             pady=self.p)
        tkinter.Label(top_frame, text="Max length:").grid(row=1,
                                                          column=2,
                                                          sticky="NSW")
        self.max_length = tkinter.Entry(top_frame, width=6)
        self.max_length.insert(tkinter.END, "10000")
        self.max_length.grid(row=1,
                             column=3,
                             sticky="NSW",
                             padx=self.p,
                             pady=self.p)

        top_frame.grid(row=0, column=0, columnspan=2, sticky="NSEW")

        y_scrollbar = tkinter.Scrollbar(base_frame)
        y_scrollbar.grid(row=1, column=1, sticky="NS")
        actions = ttk.Treeview(base_frame,
                               columns=("action", "organism"),
                               selectmode="extended",
                               yscrollcommand=y_scrollbar.set)
        y_scrollbar.config(command=actions.yview)
        actions.grid(row=1, column=0, sticky="NSEW")
        actions.column("action", width=50, anchor="w")
        actions.heading("action", text="Action")
        actions.column("organism", width=50, anchor="w")
        actions.heading("organism", text="Organism")
        actions.bind("<Double-Button-1>", self.get_click)
        self.actions = actions
        self.actions.menu_available = True  # To show <ActionMenu> only at this widget
        central_panel.add(base_frame)

        self.alignment = Aln_basic.TextFrameWithLabelAndButton(
            central_panel, self.p, self.host.header, "#FFFFFF",
            "Suggested changes in alignment:", "Load domains")
        self.alignment.button.configure(state=tkinter.DISABLED,
                                        command=self.create_domain_tags)
        self.alignment.text_widget.purify_text_widget = True  # To show <TextMenu> only at this widget
        self.show_features = tkinter.Button(self.alignment.panel,
                                            state=tkinter.DISABLED,
                                            text="Show domains",
                                            command=self.show_domains)
        self.show_features.grid(row=0,
                                column=2,
                                sticky="NSW",
                                padx=self.p,
                                pady=self.p)
        self.hide_features = tkinter.Button(self.alignment.panel,
                                            state=tkinter.DISABLED,
                                            text="Hide domains",
                                            command=self.hide_domains)
        self.hide_features.grid(row=0,
                                column=3,
                                sticky="NSW",
                                padx=self.p,
                                pady=self.p)
        self.load_taxonomy = tkinter.Button(self.alignment.panel,
                                            state=tkinter.DISABLED,
                                            text="Color taxonomy",
                                            command=self.color_taxonomy)
        self.load_taxonomy.grid(row=0,
                                column=4,
                                sticky="NSW",
                                padx=self.p,
                                pady=self.p)
        self.act = tkinter.Button(self.alignment.panel,
                                  state=tkinter.DISABLED,
                                  text="Apply actions",
                                  background=self.host.header,
                                  foreground="#FFFFFF",
                                  command=self.apply_actions)
        self.act.grid(row=0,
                      column=5,
                      sticky="NSW",
                      padx=self.p * 3,
                      pady=self.p)
        tkinter.Label(self.alignment.panel,
                      text="Presence required (%):").grid(row=0, column=6)
        self.presence_entry = tkinter.Entry(self.alignment.panel, width=3)
        self.presence_entry.insert(tkinter.END, "0")
        self.presence_entry.grid(row=0, column=7, padx=self.p, pady=self.p)

        central_panel.add(self.alignment)

        self.update_idletasks()
        central_panel.sash_place(0, base_frame.winfo_reqwidth(), 1)
Ejemplo n.º 12
0
    def submit():

        # according to current workflow, once the execution succecced, the "view" window will be closed and built again.
        # then the SQL command entered last time will be gone.
        # but in most situations, we want the SQL command we entered to keep there.
        global SQL_command
        SQL_command = query.get('1.0', END)

        temp = con.execute(SQL_command)
        con.commit()
        selected_column_names = temp.description
        temp = temp.fetchall()

        # if the execution will lead to any content returned, then a separate window will be built to show these contents
        # This feature is mainly for 'select' execution
        if len(temp) > 0:

            n_row = len(temp)
            n_col = len(temp[0])

            # to obtain the column names of the selected result
            selected_column_names = list(selected_column_names)
            for i in range(len(selected_column_names)):
                selected_column_names[i] = selected_column_names[i][0]

            execution_show = Tk()
            execution_show.title('执行结果')
            execution_show.geometry('1000x350')
            Label(execution_show, text="已执行的SQL语句:",
                  font="Helvetica 14 bold").place(x=20, y=20)
            Label(execution_show, text=query.get('1.0', END),
                  fg="blue").place(x=20, y=40)

            tree = ttk.Treeview(execution_show)
            tree['show'] = 'headings'

            tree["columns"] = selected_column_names
            for i in selected_column_names:
                tree.column(i, width=100)
                tree.heading(i, text=i)
            for i in range(n_row):
                tree.insert("", "end", text=str(i + 1), values=temp[i])
            tree.place(x=20, y=80)

            Label(execution_show,
                  text="维度: " + str(n_row) + " 行, " + str(n_col) + " 列.",
                  font='Helvetica 12').place(x=20, y=280)

            def export_to_csv():
                save_path = tkFileDialog.asksaveasfilename(
                    title="导出至?", defaultextension="*.csv")

                csv_content = [",".join(selected_column_names)]
                for i in range(n_row):
                    for j in range(n_col):
                        temp[i] = list(temp[i])
                        temp[i][j] = str(temp[i][j])
                    csv_content.append(",".join(temp[i]))

                to_write = "\n".join(csv_content)

                f = open(save_path, "w")
                f.write(to_write)
                f.close()

            Button(execution_show, text="导出为CSV文件",
                   command=export_to_csv).place(x=18, y=310)

        view.destroy()
        view_interface()
Ejemplo n.º 13
0
def view_interface():

    global view
    view = Tk()
    view.title("查看表格")
    view.geometry('900x550')

    tree = ttk.Treeview(view)
    tree['show'] = "headings"

    if (db_type == "existing"):
        db_path = db_path_entry.get()
    else:
        db_path = new_db_entry.get()

    # build the connection with the .db file
    global con
    con = sqlite3.connect(db_path)
    table_list_cursor = con.execute(
        "select name from sqlite_master where type = 'table';")
    table_list = []
    for row in table_list_cursor:
        table_list.append(row[0])

    if len(table_list) == 0:
        table_list.append("空")

    # a modeule to deal with the situation in which the .db file is empty.
    # will give a reminding and close the window.
    if table_list[0] == '空':
        empty_warning = Tk()
        empty_warning.title("数据库文件为空")
        empty_warning.geometry('250x100')

        view.destroy()

        w = Message(empty_warning,
                    text="该数据库文件为空.",
                    width=300,
                    font='Helvetica 15')
        w.place(x=35, y=20)

        def close():
            empty_warning.destroy()

        Button(empty_warning, text="确认", command=close).place(x=100, y=60)

    variable_table_choosing = StringVar(view)
    variable_table_choosing.set(table_list[0])  # default value

    Label(view, text="表格:", font='Helvetica 14 bold').place(x=30, y=30)
    table_choosing = apply(OptionMenu,
                           (view, variable_table_choosing) + tuple(table_list))
    table_choosing.configure(
        width=12)  # set the width of the OptionMenu widget
    table_choosing.place(x=30, y=50)

    def choose_table():
        view_work()

    Button(view, text="选择", comman=choose_table).place(x=30, y=75)

    # this two lines are added to help show the current table in viewer.
    # the specific table name will be assigned within function view_work below
    current_table_to_show = Label(view, text=" ", font='Helvetica 15 bold')
    current_table_to_show.place(x=200, y=20)

    # these two lines are added to hlep show the table size in viewer
    # the specific size will be assined within  the function view_work below
    table_size = Label(view, text=" ", font='Helvetica 12')
    table_size.place(x=200, y=260)

    def view_work():

        # delete all the entries in the tree currently
        for i in tree.get_children():
            tree.delete(i)

        table_choosed = variable_table_choosing.get()
        temp_result = con.execute("select * from " + table_choosed)
        temp_column_name = con.execute("pragma table_info(" + table_choosed +
                                       ");").fetchall()

        global column_name
        column_name = []
        for i in range(len(temp_column_name)):
            column_name.append(temp_column_name[i][1])

        global query_result
        query_result = temp_result.fetchall()

        global n_row
        global n_col
        n_row = len(query_result)
        n_col = len(query_result[0])

        tree["columns"] = column_name
        for i in column_name:
            tree.column(i, width=100)
            tree.heading(i, text=i)

        if (n_row >= 30):
            for i in range(30):
                tree.insert("", "end", text=str(i + 1), values=query_result[i])
        else:
            for i in range(n_row):
                tree.insert("", "end", text=str(i + 1), values=query_result[i])

        current_table_to_show.configure(text="当前表格: " +
                                        str(variable_table_choosing.get()))
        table_size.configure(text="维度: " + str(n_row) + " 行, " + str(n_col) +
                             " 列.")

    view_work()

    Label(view, text="操作:", font='Helvetica 14 bold').place(x=30, y=130)

    #----------------------------------------------------------------------------------------------------------------------------------------

    #######################################
    # View full table
    #######################################
    def view_all():
        view = Tk()
        view.title("查看完整表格")
        view.geometry('1000x300')
        tree = ttk.Treeview(view)
        tree['show'] = 'headings'

        tree["columns"] = column_name
        for i in column_name:
            tree.column(i, width=100)
            tree.heading(i, text=i)
        for i in range(n_row):
            tree.insert("", "end", text=str(i + 1), values=query_result[i])
        tree.place(x=20, y=20)

        Label(view,
              text="维度: " + str(n_row) + " 行, " + str(n_col) + " 列.",
              font='Helvetica 12').place(x=20, y=230)

        def close():
            view.destroy()

        Button(view, text="关闭", command=close).place(x=20, y=250)

    Button(view, text="查看完整表格", command=view_all).place(x=30, y=150)

    #----------------------------------------------------------------------------------------------------------------------------------------

    #######################################
    # "export to CSV" module
    #######################################

    def export_to_csv():
        save_path = tkFileDialog.asksaveasfilename(title="导出至?",
                                                   defaultextension="*.csv")

        csv_content = [",".join(column_name)]
        for i in range(n_row):
            for j in range(n_col):
                query_result[i] = list(query_result[i])
                query_result[i][j] = str(query_result[i][j])
            csv_content.append(",".join(query_result[i]))

        to_write = "\n".join(csv_content)

        f = open(save_path, "w")
        f.write(to_write)
        f.close()

    Button(view, text="导出至.CSV文件", command=export_to_csv).place(x=30, y=180)

    #----------------------------------------------------------------------------------------------------------------------------------------

    #######################################
    # "Import from CSV" module
    #######################################

    def import_from_csv():
        global import_interface
        import_interface = Tk()
        import_interface.geometry('330x250')
        import_interface.title("从.CSV文件导入表格")

        # entry for the path and name of the CSV file
        Label(import_interface, text="CSV文件路径:").place(x=30, y=30)
        csv_name = StringVar()
        csv_entry = Entry(import_interface, textvariable=csv_name)
        csv_entry.place(x=30, y=50)

        def browse_csv_path():
            types = [('.CSV files', '*.csv')]
            csv_path = tkFileDialog.askopenfilename(title='从CSV文件导入表格',
                                                    filetypes=types)
            csv_entry.delete(0, END)
            csv_entry.insert(0, csv_path)

        Button(import_interface, text="浏览",
               command=browse_csv_path).place(x=230, y=50)

        # specify the name of the new table (which will be built from the CSV file)
        Label(import_interface, text="导入至表格:").place(x=30, y=100)
        table_name = StringVar()
        table_name_entry = Entry(import_interface, textvariable=table_name)
        table_name_entry.place(x=30, y=120)

        def import_act():

            f = open(csv_entry.get(), "r")
            content = f.readlines(
            )  # if the csv file contains n rows, then "content" should be a list with length n

            # this function split each row from CSV file into format ready for SQL inserting
            def split_row(x_row):
                splitted_row = x_row.split(',')
                splitted_row[len(splitted_row) -
                             1] = splitted_row[len(splitted_row) -
                                               1].split('\n')[0]
                return splitted_row

            csv_column_name = split_row(content[0])

            # check if the new table name is empty
            if table_name_entry.get() == "":
                temp = Tk()
                temp.title("表格名为空")
                temp.geometry('250x100')
                Message(temp, text="表格名为空", width=300,
                        font='Helvetica 14').place(x=35, y=20)

                def close():
                    temp.destroy()

                Button(temp, text="确认", command=close).place(x=100, y=60)
                return 0

            # check if the new table name already exist
            if table_name_entry.get() in table_list:
                temp = Tk()
                temp.title("该表格名已存在")
                temp.geometry('250x100')
                Message(temp, text="该表格名已存在", width=300,
                        font='Helvetica 14').place(x=35, y=20)

                def close():
                    temp.destroy()

                Button(temp, text="Okay", command=close).place(x=100, y=60)
                return 0

            # build the table by SQL
            for i in range(len(csv_column_name)):
                csv_column_name[i] = csv_column_name[i] + " text"
            temp = ','.join(csv_column_name)
            build_command = "create table " + table_name_entry.get(
            ) + "(" + temp + ");"

            con.execute(build_command)
            con.commit()

            # insert the content of the CSV into the table whcih was built above
            for i in range(1, len(content)):

                content[i] = split_row(content[i])
                for j in range(len(content[i])):
                    content[i][j] = "'" + content[i][j] + "'"

                temp = ",".join(content[i])
                insert_command = "insert into " + table_name_entry.get(
                ) + " values(" + temp + ");"

                con.execute(insert_command)
                con.commit()

            # the block below is to remind the user once the importing is finished
            importing_finished_interface = Tk()
            importing_finished_interface.title("导入完成")
            importing_finished_interface.geometry('250x100')
            Message(importing_finished_interface,
                    text="导入完成",
                    width=300,
                    font='Helvetica 14').place(x=35, y=20)

            import_interface.destroy()

            def close():
                importing_finished_interface.destroy()

            Button(importing_finished_interface, text="确认",
                   command=close).place(x=100, y=60)

            view.destroy()
            view_interface()

        Button(import_interface, text="导入", command=import_act).place(x=50,
                                                                      y=180)

        def close_outer():
            import_interface.destroy()

        Button(import_interface, text="关闭", command=close_outer).place(x=140,
                                                                       y=180)

    Button(view, text="从CSV文件导入", command=import_from_csv).place(x=30, y=210)

    tree.place(x=200, y=50)
    # tree view:
    # http://www.tkdocs.com/tutorial/tree.html

    #----------------------------------------------------------------------------------------------------------------------------------------

    #######################################
    # "SQL command execution" module
    #######################################

    # SQL Execution Module
    Label(view, text="SQL查询:", font='Helvetica 15 bold').place(x=200, y=300)
    sentence = StringVar()
    query = Text(view, width=40, height=5, background="lightblue")
    query.place(x=200, y=320)
    query.insert(END, SQL_command)

    def submit():

        # according to current workflow, once the execution succecced, the "view" window will be closed and built again.
        # then the SQL command entered last time will be gone.
        # but in most situations, we want the SQL command we entered to keep there.
        global SQL_command
        SQL_command = query.get('1.0', END)

        temp = con.execute(SQL_command)
        con.commit()
        selected_column_names = temp.description
        temp = temp.fetchall()

        # if the execution will lead to any content returned, then a separate window will be built to show these contents
        # This feature is mainly for 'select' execution
        if len(temp) > 0:

            n_row = len(temp)
            n_col = len(temp[0])

            # to obtain the column names of the selected result
            selected_column_names = list(selected_column_names)
            for i in range(len(selected_column_names)):
                selected_column_names[i] = selected_column_names[i][0]

            execution_show = Tk()
            execution_show.title('执行结果')
            execution_show.geometry('1000x350')
            Label(execution_show, text="已执行的SQL语句:",
                  font="Helvetica 14 bold").place(x=20, y=20)
            Label(execution_show, text=query.get('1.0', END),
                  fg="blue").place(x=20, y=40)

            tree = ttk.Treeview(execution_show)
            tree['show'] = 'headings'

            tree["columns"] = selected_column_names
            for i in selected_column_names:
                tree.column(i, width=100)
                tree.heading(i, text=i)
            for i in range(n_row):
                tree.insert("", "end", text=str(i + 1), values=temp[i])
            tree.place(x=20, y=80)

            Label(execution_show,
                  text="维度: " + str(n_row) + " 行, " + str(n_col) + " 列.",
                  font='Helvetica 12').place(x=20, y=280)

            def export_to_csv():
                save_path = tkFileDialog.asksaveasfilename(
                    title="导出至?", defaultextension="*.csv")

                csv_content = [",".join(selected_column_names)]
                for i in range(n_row):
                    for j in range(n_col):
                        temp[i] = list(temp[i])
                        temp[i][j] = str(temp[i][j])
                    csv_content.append(",".join(temp[i]))

                to_write = "\n".join(csv_content)

                f = open(save_path, "w")
                f.write(to_write)
                f.close()

            Button(execution_show, text="导出为CSV文件",
                   command=export_to_csv).place(x=18, y=310)

        view.destroy()
        view_interface()

    Button(view, text="提交", comman=submit).place(x=510, y=350)

    #----------------------------------------------------------------------------------------------------------------------------------------

    #######################################
    # STATUS module
    #######################################

    Label(view, text="状态:", font='Helvetica 15 bold').place(x=200, y=430)
    Label(view, text="数据库文件路径: " + db_path).place(x=200, y=450)
    # BUG:  for now, if I create a table with SQL execution, the number here will not change correspondingly.
    status_num_of_table = Label(view, text="表格数量: " + str(len(table_list)))
    status_num_of_table.place(x=200, y=470)

    # the lines below are used to modify the unit of file size automatically.
    # The dafault unit is "bytes".
    # if the file size is too big, it would be better to use 'Kb' or 'Mb' correspondingly.
    db_file_size = os.path.getsize(db_path)
    if db_file_size > 10485760:
        db_file_size = round(db_file_size / 1048576.0, 3)
        db_file_size_unit = "Mb"
    elif db_file_size > 102400:
        db_file_size = round(db_file_size / 1024.0, 3)
        db_file_size_unit = "Kb"
    else:
        db_file_size_unit = "Bytes"

    Label(view, text="数据库文件大小: " + str(db_file_size) + " " +
          db_file_size_unit).place(x=200, y=490)

    #----------------------------------------------------------------------------------------------------------------------------------------

    #######################################
    # "Regular Expression Filter" Module
    #######################################

    # this is a new feature with which user can filter the records in database with Regular Expression
    def RE():
        RE_filter = Tk()
        RE_filter.title("以正则表达式进行筛选")
        RE_filter.geometry('350x230')

        variable_table_choosing = StringVar(RE_filter)
        variable_table_choosing.set(table_list[0])  # default value
        Label(RE_filter, text="选择表格以及列:", font='Helvetica 14 bold').place(x=30,
                                                                          y=20)
        table_choosing = apply(OptionMenu,
                               (RE_filter, variable_table_choosing) +
                               tuple(table_list))
        table_choosing.configure(
            width=15)  # set the width of the OptionMenu widget
        table_choosing.place(x=30, y=40)

        def choose_table_RE():
            column_select_RE['menu'].delete(0, 'end')
            table_choosed = variable_table_choosing.get()
            temp = con.execute("pragma table_info(" + table_choosed +
                               ");").fetchall()

            temp_column_name = []
            for i in range(len(temp)):
                temp_column_name.append(temp[i][1])

            # add the column names of the selected table into the optionMedu widget
            #http://www.prasannatech.net/2009/06/tkinter-optionmenu-changing-choices.html
            column_name_RE.set(temp_column_name[0])
            for i in temp_column_name:
                column_select_RE["menu"].add_command(
                    label=i,
                    command=lambda temp=i: column_select_RE.setvar(
                        column_select_RE.cget("textvariable"), value=temp))

        Button(RE_filter, text="选择", command=choose_table_RE).place(x=180,
                                                                    y=40)

        column_name_RE = StringVar(RE_filter)
        column_name_RE.set(" ")
        column_select_RE = OptionMenu(RE_filter, column_name_RE, " ")
        column_select_RE.configure(width=15)
        column_select_RE.place(x=30, y=80)

        Label(RE_filter, text="Pattern:",
              font='Helvetica 14 bold').place(x=30, y=120)
        RE_query = Text(RE_filter, width=40, height=1, background="lightblue")
        RE_query.place(x=30, y=140)

        def RE_submit():
            column_to_run_RE = column_name_RE.get()
            RE_pattern = RE_query.get('1.0', END)
            RE_pattern = RE_pattern[
                0:len(RE_pattern) -
                1]  # the get method in the last line will add a "\n" at the end of the text automatically. So we use this line to remove the "\n"

            ## Execute the Regular Expression and return the rows with this pattern
            def RE_execution(table, column, pattern):

                # obtain all the data in the column selected
                RE_command = 'select ' + column + ' from ' + table
                data_to_run_RE = con.execute(RE_command)
                data_to_run_RE = data_to_run_RE.fetchall()

                for i in range(len(data_to_run_RE)):
                    data_to_run_RE[i] = data_to_run_RE[i][0]

                # Run Regular Expression and generate a vector which will label if each record meet the requirement of RE
                match_result_index = []
                for i in range(len(data_to_run_RE)):
                    temp_match = re.search(str(pattern),
                                           str(data_to_run_RE[i]))
                    if temp_match:
                        match_result_index.append(1)
                    else:
                        match_result_index.append(0)

                return match_result_index

            RE_match_result = RE_execution(variable_table_choosing.get(),
                                           column_to_run_RE, RE_pattern)

            RE_result_view = Tk()
            RE_result_view.title("正则表达式筛选结果")
            RE_result_view.geometry('1000x300')
            tree = ttk.Treeview(RE_result_view)
            tree['show'] = 'headings'

            table_choosed = variable_table_choosing.get()
            temp_result = con.execute("select * from " + table_choosed)
            temp_column_name = con.execute("pragma table_info(" +
                                           table_choosed + ");").fetchall()

            column_name = []
            for i in range(len(temp_column_name)):
                column_name.append(temp_column_name[i][1])

            query_result = temp_result.fetchall()
            n_row = len(query_result)

            # Based on the vector obtained above, select the correspding rows and return them
            exact_result = []
            for i in range(n_row):
                if RE_match_result[i] == 1:
                    exact_result.append(query_result[i])
            n_row = len(exact_result)
            n_col = len(exact_result[0])

            tree["columns"] = column_name
            for i in column_name:
                tree.column(i, width=100)
                tree.heading(i, text=i)
            for i in range(n_row):
                tree.insert("", "end", text=str(i + 1), values=exact_result[i])
            tree.grid(row=0, column=0)
            Label(RE_result_view,
                  text=str(n_row) + " 行被提取.",
                  font='Helvetica 12').grid(row=1, column=0)

            def export_to_csv():
                save_path = tkFileDialog.asksaveasfilename(
                    title="导出至?", defaultextension="*.csv")

                csv_content = [",".join(column_name)]
                for i in range(n_row):
                    for j in range(n_col):
                        exact_result[i] = list(exact_result[i])
                        exact_result[i][j] = str(exact_result[i][j])
                    csv_content.append(",".join(exact_result[i]))

                to_write = "\n".join(csv_content)

                f = open(save_path, "w")
                f.write(to_write)
                f.close()

            Button(RE_result_view, text="导出为CSV文件",
                   command=export_to_csv).grid(row=2, column=0)

            def close():
                RE_result_view.destroy()

            Button(RE_result_view, text="关闭", command=close).grid(row=3,
                                                                  column=0)

        Button(RE_filter, text="运行", command=RE_submit).place(x=30, y=170)

        def close():
            RE_filter.destroy()

        Button(RE_filter, text="关闭", command=close).place(x=100, y=170)

    Button(view, text="正则表达式", command=RE).place(x=30, y=240)

    def close():
        view.destroy()

    Button(view, text="关闭", height=2, command=close,
           font='Helvetica 15').place(x=30, y=400)
Ejemplo n.º 14
0
 def Treeview(cls,master,**kw):
     return ttk.Treeview(master,**kw)
Ejemplo n.º 15
0
def main(mbdb, backup_path):
    global filename
    global callstree, textarea

    filename = os.path.join(
        backup_path,
        mbdb.realFileName(filename="call_history.db",
                          domaintype="WirelessDomain"))

    if (not os.path.isfile(filename)):
        print("Invalid file name for SMS database")
        return

    # main window
    callswindow = Toplevel()
    callswindow.title('Call History data')
    callswindow.focus_set()

    callswindow.grid_columnconfigure(2, weight=1)
    callswindow.grid_rowconfigure(1, weight=1)

    # header label
    callstitle = Label(callswindow,
                       text="Calls history data from: " + filename,
                       relief=RIDGE)
    callstitle.grid(column=0, row=0, sticky="ew", columnspan=4, padx=5, pady=5)

    # tree
    callstree = ttk.Treeview(
        callswindow,
        columns=("address", "date", "duration", "flags", "id", "name",
                 "countrycode"),
        displaycolumns=("address", "date", "duration", "flags"),
        yscrollcommand=lambda f, l: autoscroll(mvsb, f, l))

    callstree.heading("#0", text="ID", anchor='w')
    callstree.heading("date", text="Date", anchor='w')
    callstree.heading("address", text="Address", anchor='w')
    callstree.heading("duration", text="Duration", anchor='w')
    callstree.heading("flags", text="Flags", anchor='w')

    callstree.column("#0", width=50)
    callstree.column("date", width=200)
    callstree.column("address", width=150)
    callstree.column("duration", width=100)
    callstree.column("flags", width=100)

    callstree.grid(column=0, row=1, sticky="ns")

    # textarea
    textarea = Text(callswindow,
                    bd=2,
                    relief=SUNKEN,
                    width=50,
                    yscrollcommand=lambda f, l: autoscroll(tvsb, f, l))
    textarea.grid(column=2, row=1, sticky="nsew")

    # scrollbars for tree
    mvsb = ttk.Scrollbar(callswindow, orient="vertical")
    mvsb.grid(column=1, row=1, sticky='ns')
    mvsb['command'] = callstree.yview

    # scrollbars for main textarea
    tvsb = ttk.Scrollbar(callswindow, orient="vertical")
    tvsb.grid(column=3, row=1, sticky='ns')
    tvsb['command'] = textarea.yview

    # footer label
    footerlabel = StringVar()
    callsfooter = Label(callswindow, textvariable=footerlabel, relief=RIDGE)
    callsfooter.grid(column=0,
                     row=2,
                     sticky="ew",
                     columnspan=4,
                     padx=5,
                     pady=5)

    # destroy window when closed
    callswindow.protocol("WM_DELETE_WINDOW", callswindow.destroy)

    # opening database
    tempdb = sqlite3.connect(filename)
    tempcur = tempdb.cursor()

    # footer statistics
    query = "SELECT count(ROWID) FROM call"
    tempcur.execute(query)
    callsnumber = tempcur.fetchall()[0][0]
    footerlabel.set("Found %s calls." % callsnumber)

    def readKey(key):
        query = "SELECT value FROM _SqliteDatabaseProperties WHERE key = \"%s\"" % key
        tempcur.execute(query)
        data = tempcur.fetchall()
        if (len(data) > 0):
            value = data[0][0]
        else:
            value = 0
        return value

    def formatTime(seconds):
        durationtot = int(seconds)
        durationmin = int(durationtot / 60)
        durationhh = int(durationmin / 60)
        durationmin = durationmin - (durationhh * 60)
        durationsec = durationtot - (durationmin * 60) - (durationhh * 3600)
        duration = "%i:%.2i:%.2i" % (durationhh, durationmin, durationsec)
        return duration

    # populating textarea with data from _SqliteDatabaseProperties
    textarea.insert(
        END, "Call history limit: %s\n" % (readKey("call_history_limit")))
    textarea.insert(
        END, "Last call duration: %s\n" % (formatTime(readKey("timer_last"))))
    textarea.insert(
        END, "Incoming calls duration: %s\n" %
        (formatTime(readKey("timer_incoming"))))
    textarea.insert(
        END, "Outgoing calls duration: %s\n" %
        (formatTime(readKey("timer_outgoing"))))
    textarea.insert(
        END, "Total call duration: %s\n" % (formatTime(readKey("timer_all"))))
    textarea.insert(
        END, "Total lifetime call duration: %s\n" %
        (formatTime(readKey("timer_lifetime"))))

    # populating tree with calls
    query = "SELECT ROWID, address, date, duration, flags, id, name, country_code FROM call ORDER BY date"
    tempcur.execute(query)
    calls = tempcur.fetchall()
    tempdb.close()

    for call in calls:
        rowid = call[0]
        address = call[1]
        date = datetime.fromtimestamp(int(call[2]))
        duration = formatTime(call[3])

        flagval = call[4]
        if (flagval == 5): flags = "Outgoing"
        elif (flagval == 4): flags = "Incoming"
        else: flags = "Cancelled"

        id = call[5]
        name = call[6]
        country_code = call[7]
        callstree.insert('',
                         'end',
                         text=rowid,
                         values=(address, date, duration, flags))
Ejemplo n.º 16
0
    def __init__(self, top=None):
        def affichage():
            connexion = mysql.connect("localhost", "root", "", "test")
            cursor = connexion.cursor()
            sql = """SELECT * FROM table1"""
            try:
                #execution de la commande sql
                cursor.execute(sql)
                # selection de tous les champs
                results = cursor.fetchall()
                for row in results:
                    codeposte = row[0]
                    codeposte = str(codeposte)
                    libpost = row[1]
                    libpost = str(libpost)
                    self.listead.insert('', 1, values=(codeposte, libpost))

            except:
                showwarning("ERREUR", "probleme de connexion a la bd")

        def active():
            self.Entry1.configure(state=NORMAL)
            self.Entry2.configure(state=NORMAL)

        #inssertion dans la bd et dans le tableau
        def inserer():

            active()
            connexion = mysql.connect("localhost", "root", "", "test")
            cursor = connexion.cursor()

            sql = """INSERT INTO `test`.`table1` ( `id` ,`nom` )VALUES NULL , '""" + Postes_support.libpost.get(
            ) + """')"""
            try:
                cursor.execute(sql)
                connexion.commit()

            except:
                connexion.rollback()
                connexion.close()

            self.listead.insert('',
                                1,
                                values=(Postes_support.codeposte.get(),
                                        Postes_support.libpost.get()))

        #suppresion d'un element dans la bd
        def supprimer():

            selectioner = self.listead.selection()
            reponse = askyesno("CONFIRMATION", "voulez vous supprimer")
            #demande de confirmation
            if reponse:

                if selectioner:
                    elmtsup = selectioner[0]
                    elementsupbd = self.listead.set(elmtsup)
                    Postes_support.codeposte.set(elementsupbd['col1'])
                    connexion = mysql.connect("localhost", "root", "", "test")
                    cursor = connexion.cursor()

                    sql = """DELETE FROM `test`.`table1` WHERE `table1`.`id` =""" + Postes_support.codeposte.get(
                    ) + """ """
                    try:
                        cursor.execute(sql)
                        connexion.commit()
                    except:
                        connexion.rollback()
                        connexion.close()
                else:
                    showinfo('INFORMATION',
                             'sélectionner d\'abord l\'élément à supprimer')
            self.listead.delete(elmtsup)

        #modification d'un element de la bd
        def modifier():
            selectioner = self.listead.selection()
            reponse = askyesno("confirmation", "vous voulez vous modifier")
            if reponse:

                if selectioner:
                    idtableau = selectioner[0]
                    v = self.listead.set(idtableau)

                    Postes_support.codeposte.set(v['col1'])
                    Postes_support.libpost.set(v['col2'])

                    self.Entry1.configure(state=DISABLED)
                    supprimer()

                else:
                    showinfo('INFORMATION',
                             'sélectionner d\'abord l\'élément à modifier')

        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'

        top.geometry("960x788+300+00")
        top.title("Mise à jour poste")
        top.configure(background="#EFF0EF")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.Labelframe1 = LabelFrame(top)
        self.Labelframe1.place(relx=0.04,
                               rely=0.1,
                               relheight=0.44,
                               relwidth=0.92)
        self.Labelframe1.configure(relief=GROOVE)
        self.Labelframe1.configure(foreground="black")
        self.Labelframe1.configure(text='''Info/Poste''')
        self.Labelframe1.configure(background="#EFF0EF")
        self.Labelframe1.configure(highlightbackground="#d9d9d9")
        self.Labelframe1.configure(highlightcolor="black")
        self.Labelframe1.configure(width=920)

        self.Label1 = Label(self.Labelframe1)
        self.Label1.place(relx=0.05, rely=0.42, height=26, width=41)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#EFF0EF")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Code''')

        self.Label2 = Label(self.Labelframe1)
        self.Label2.place(relx=0.65, rely=0.43, height=26, width=61)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(background="#EFF0EF")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Libéllé''')

        self.Entry1 = Entry(self.Labelframe1)
        self.Entry1.place(relx=0.17, rely=0.42, relheight=0.07, relwidth=0.16)
        self.Entry1.configure(background="white")
        self.Entry1.configure(disabledforeground="#a3a3a3")
        self.Entry1.configure(font="TkFixedFont")
        self.Entry1.configure(foreground="#000000")
        self.Entry1.configure(highlightbackground="#d9d9d9")
        self.Entry1.configure(highlightcolor="black")
        self.Entry1.configure(insertbackground="black")
        self.Entry1.configure(selectbackground="#c4c4c4")
        self.Entry1.configure(selectforeground="black")
        self.Entry1.configure(textvariable=Postes_support.codeposte)

        self.Entry2 = Entry(self.Labelframe1)
        self.Entry2.place(relx=0.76, rely=0.43, relheight=0.07, relwidth=0.16)
        self.Entry2.configure(background="white")
        self.Entry2.configure(disabledforeground="#a3a3a3")
        self.Entry2.configure(font="TkFixedFont")
        self.Entry2.configure(foreground="#000000")
        self.Entry2.configure(highlightbackground="#d9d9d9")
        self.Entry2.configure(highlightcolor="black")
        self.Entry2.configure(insertbackground="black")
        self.Entry2.configure(selectbackground="#c4c4c4")
        self.Entry2.configure(selectforeground="black")
        self.Entry2.configure(textvariable=Postes_support.libpost)

        self.Button1 = Button(top)
        self.Button1.place(relx=0.3, rely=0.6, height=33, width=156)
        self.Button1.configure(activebackground="#218DF2")
        self.Button1.configure(activeforeground="white")
        self.Button1.configure(activeforeground="white")
        self.Button1.configure(background="#218DF2")
        self.Button1.configure(disabledforeground="#a3a3a3")
        self.Button1.configure(foreground="white")
        self.Button1.configure(highlightbackground="#d9d9d9")
        self.Button1.configure(highlightcolor="black")
        self.Button1.configure(pady="0")
        self.Button1.configure(text='''VALIDER''', command=inserer)
        self.Button1.bind('<Button-1>', lambda e: Postes_support.Valider(e))

        self.Buttona = Button(top)
        self.Buttona.place(relx=0.5, rely=0.6, height=33, width=156)
        self.Buttona.configure(activebackground="#218DF2")
        self.Buttona.configure(activeforeground="white")
        self.Buttona.configure(activeforeground="white")
        self.Buttona.configure(background="#218DF2")
        self.Buttona.configure(disabledforeground="#a3a3a3")
        self.Buttona.configure(foreground="white")
        self.Buttona.configure(highlightbackground="#d9d9d9")
        self.Buttona.configure(highlightcolor="black")
        self.Buttona.configure(pady="0")
        self.Buttona.configure(text='''+Postes''')
        self.Buttona.bind('<Button-1>', lambda e: Postes_support.Nvposte(e))

        self.Labelframe4 = LabelFrame(top)
        self.Labelframe4.place(relx=0.03,
                               rely=0.68,
                               relheight=0.24,
                               relwidth=0.93)
        self.Labelframe4.configure(relief=GROOVE)
        self.Labelframe4.configure(foreground="black")
        self.Labelframe4.configure(text='''Liste des postes''')
        self.Labelframe4.configure(background="#EFF0EF")
        self.Labelframe4.configure(highlightbackground="#d9d9d9")
        self.Labelframe4.configure(highlightcolor="black")
        self.Labelframe4.configure(width=930)

        self.listead = ttk.Treeview(self.Labelframe4, columns=('col1', 'col2'))
        #self.defilY=Scrollbar(self.configure,orient='vertical',command=self.listead.yview)
        self.listead.column('#0', width=0)
        self.listead.column('#1', width=250)
        self.listead.column('#2', width=450)
        #listead.column('#7',width=130)
        self.listead.heading('#1', text='Code', anchor=CENTER)
        self.listead.heading('#2', text='Libéllé', anchor=CENTER)

        #listead.heading('#7',text='nationalité',anchor=CENTER)
        self.listead.grid(row=0)
        #self.defilY.grid(row=3)
        affichage()
        self.Button3 = Button(self.Labelframe4)
        self.Button3.place(relx=0.84, rely=0.26, height=33, width=89)
        self.Button3.configure(activebackground="#218DF2")
        self.Button3.configure(activeforeground="white")
        self.Button3.configure(activeforeground="white")
        self.Button3.configure(background="#218DF2")
        self.Button3.configure(disabledforeground="#a3a3a3")
        self.Button3.configure(foreground="white")
        self.Button3.configure(highlightbackground="#d9d9d9")
        self.Button3.configure(highlightcolor="black")
        self.Button3.configure(pady="0")
        self.Button3.configure(text='''Modifier''', command=modifier)
        self.Button3.configure(width=89)

        self.Button4 = Button(self.Labelframe4)
        self.Button4.place(relx=0.84, rely=0.52, height=33, width=89)
        self.Button4.configure(activebackground="#EA8144")
        self.Button4.configure(activeforeground="white")
        self.Button4.configure(background="#EA8144")
        self.Button4.configure(disabledforeground="#a3a3a3")
        self.Button4.configure(foreground="white")
        self.Button4.configure(highlightbackground="#d9d9d9")
        self.Button4.configure(highlightcolor="black")
        self.Button4.configure(pady="0")
        self.Button4.configure(text='''Supprimer''', command=supprimer)

        self.Labelframe5 = LabelFrame(top)
        self.Labelframe5.place(relx=0.04,
                               rely=0.01,
                               relheight=0.09,
                               relwidth=0.92)
        self.Labelframe5.configure(relief=GROOVE)
        self.Labelframe5.configure(foreground="black")
        self.Labelframe5.configure(text='''Information/système''')
        self.Labelframe5.configure(background="#EFF0EF")
        self.Labelframe5.configure(highlightbackground="#d9d9d9")
        self.Labelframe5.configure(highlightcolor="black")
        self.Labelframe5.configure(width=920)

        self.Label8 = Label(self.Labelframe5)
        self.Label8.place(relx=0.82, rely=0.4, height=26, width=92)
        self.Label8.configure(activebackground="#f9f9f9")
        self.Label8.configure(activeforeground="black")
        self.Label8.configure(background="#EFF0EF")
        self.Label8.configure(disabledforeground="#a3a3a3")
        self.Label8.configure(foreground="#000000")
        self.Label8.configure(highlightbackground="#d9d9d9")
        self.Label8.configure(highlightcolor="black")
        self.Label8.configure(text='''Heure''')
        self.Label8.configure(textvariable=Postes_support.heure)
        Mise_à_jour_poste.maj()

        self.Label9 = Label(self.Labelframe5)
        self.Label9.place(relx=0.77, rely=0.4, height=26, width=53)
        self.Label9.configure(activebackground="#f9f9f9")
        self.Label9.configure(activeforeground="black")
        self.Label9.configure(background="#EFF0EF")
        self.Label9.configure(disabledforeground="#a3a3a3")
        self.Label9.configure(foreground="#000000")
        self.Label9.configure(highlightbackground="#d9d9d9")
        self.Label9.configure(highlightcolor="black")
        self.Label9.configure(text='''Heure :''')

        self.Label10 = Label(self.Labelframe5)
        self.Label10.place(relx=0.77, rely=0.0, height=26, width=45)
        self.Label10.configure(activebackground="#f9f9f9")
        self.Label10.configure(activeforeground="black")
        self.Label10.configure(background="#EFF0EF")
        self.Label10.configure(disabledforeground="#a3a3a3")
        self.Label10.configure(foreground="#000000")
        self.Label10.configure(highlightbackground="#d9d9d9")
        self.Label10.configure(highlightcolor="black")
        self.Label10.configure(text='''Date :''')

        self.Label11 = Label(self.Labelframe5)
        self.Label11.place(relx=0.82, rely=0.0, height=26, width=82)
        self.Label11.configure(background="#EFF0EF")
        self.Label11.configure(disabledforeground="#a3a3a3")
        self.Label11.configure(foreground="#000000")
        self.Label11.configure(
            text="{0} /{1} /{2}".format(date.day, mois[m], date.year))
        self.Label11.configure(width=82)
Ejemplo n.º 17
0
    def create_widgets(self):
        #create over/under paned window
        self.panel = PanedWindow(orient=VERTICAL)
        self.panel.pack(fill=BOTH, expand=1)
        self.panel.place(relwidth=1, relheight=1)

        # TOP FRAME
        # Populate the top pane
        self.listFrame = Frame(self.panel)
        self.listFrame.pack(side=TOP)
        self.listFrame.place(relwidth=1.0, height=126)
        self.panel.paneconfigure(self.listFrame, height=126, minsize=126)

        # SEARCH PATH
        #label to describe search directory
        self.pathLabel = Label(self.listFrame,
                               text="Search Directory:",
                               anchor=E)
        self.pathLabel.pack(side=LEFT)
        self.pathLabel.place(relwidth=0.2, height=28, y=10)
        #entry to hold directory path
        self.path = Entry(self.listFrame, bg="#f2f2f2", justify="center")
        self.path.insert(END, "")
        self.path.pack(side=LEFT)
        self.path.place(relwidth=0.6, relx=0.2, height=28, y=10)
        #button to browse for search directory
        self.pathButton = Button(self.listFrame,
                                 bg="#f2f2f2",
                                 relief=GROOVE,
                                 text="Select Directory")
        self.pathButton["command"] = self.askdirectory
        self.pathButton.pack(side=LEFT)
        self.pathButton.place(relwidth=0.19, relx=0.804, height=28, y=10)

        # WORDS TO SEARCH
        #label to describe words to search
        self.wordLabel = Label(self.listFrame,
                               text="Words to Count:",
                               anchor=E)
        self.wordLabel.pack(side=LEFT)
        self.wordLabel.place(relwidth=0.2, height=28, y=38)
        #entry to hold the space-delimited words to search for
        self.words = Entry(self.listFrame, bg="#f2f2f2", justify="center")
        self.words.insert(END, "")
        self.words.pack(side=LEFT)
        self.words.place(relwidth=0.6, relx=0.2, height=28, y=38)
        #label to describe how to format search word entry
        self.spaceLabel = Label(self.listFrame,
                                text="(separate search words with a space)",
                                anchor=N)
        self.spaceLabel.pack(side=LEFT)
        self.spaceLabel.place(relwidth=1, height=28, y=68)

        #case sensitive compare check
        self.caseCheckbutton = Checkbutton(
            self.listFrame,
            text="Case Sensitive",
            variable=self.caseCheckbuttonSensitive)
        self.caseCheckbutton.pack(side=LEFT)
        self.caseCheckbutton.place(relx=0.8, relwidth=0.2, height=28, y=40)

        # GO and OPEN OUTPUT buttons
        #button to kick off the search
        self.goButton = Button(self.listFrame, relief=GROOVE, text="Start!")
        self.goButton["command"] = self.do_count
        self.goButton.pack(side=LEFT)
        self.goButton.place(relwidth=0.19, relx=0.804, height=28, y=68)
        #button to open the output csv file
        self.csvButton = Button(self.listFrame, text=self.fname, fg="blue")
        self.csvButton["command"] = self.open_ouput_file
        self.csvButton.pack(side=LEFT)
        self.csvButton.place(relwidth=0, relx=0.2, height=28, y=96)

        #plop the interface elements into the top frame
        self.panel.add(self.listFrame)
        #forget method to initialize showing of button after output is created
        self.csvButton.pack_forget()

        # BOTTOM FRAME
        # Populate the bottom pane with a tree to show our search result count
        self.wordFrame = Frame(self.panel, bg="#f2f2f2")
        self.wordFrame.pack(fill=X, padx=5, pady=5)
        #create the tree and scroll bars
        self.resultsTree = ttk.Treeview(self.wordFrame, show="headings")
        ysb = Scrollbar(self.wordFrame,
                        orient='vertical',
                        command=self.resultsTree.yview)
        xsb = Scrollbar(self.wordFrame,
                        orient='horizontal',
                        command=self.resultsTree.xview)
        self.resultsTree.configure(yscrollcommand=ysb.set,
                                   xscrollcommand=xsb.set)
        ysb.pack(side=RIGHT, fill=Y)
        xsb.pack(side=BOTTOM, fill=X)
        self.resultsTree.pack(fill=X, side=LEFT)
        self.resultsTree.place(relwidth=1, relheight=1)
        #add the tree to the lower panel
        self.panel.add(self.wordFrame)
Ejemplo n.º 18
0
    def initComponent(self):
        """ Componentes de la aplicación """
        self.parent.title("Método de Newton-Rapson")
        self.parent.resizable(0, 0)
        self.parent.config(bg="white")
        self.renderingWindow(self.parent)

        # Opciones
        font = ('Verdana', 14)
        bg = "white"
        vcmd = (self.parent.register(self.validate), '%d', '%i', '%P', '%s',
                '%S', '%v', '%V', '%W')

        # Objetos
        lblEcuacion = tk.Label(self.parent,
                               text="Ingrese la ecuación:",
                               anchor=tk.W,
                               justify=tk.LEFT)
        lblEcuacion.place(x=10, y=10, width=300, height=20)
        lblEcuacion.config(font=font, bg=bg)

        txtInstruccion = "Ingrese un valor inicial para calcular la raiz:"
        lblInstruccion = tk.Label(self.parent,
                                  text=txtInstruccion,
                                  anchor=tk.W,
                                  justify=tk.LEFT)
        lblInstruccion.place(x=10, y=50, width=700, height=20)
        lblInstruccion.config(font=font, bg=bg)

        lblInferior = tk.Label(self.parent,
                               text="V. Inicial:",
                               anchor=tk.W,
                               justify=tk.LEFT)
        lblInferior.place(x=10, y=90, width=140, height=20)
        lblInferior.config(font=font, bg=bg)

        lblError = tk.Label(self.parent,
                            text="Error:",
                            anchor=tk.W,
                            justify=tk.LEFT)
        lblError.place(x=540, y=90, width=110, height=20)
        lblError.config(font=font, bg=bg)

        lblRes = tk.Label(self.parent,
                          text="Resultados:",
                          anchor=tk.W,
                          justify=tk.LEFT)
        lblRes.place(x=10, y=170, width=700, height=20)
        lblRes.config(font=font, bg=bg)

        self.txtEcuacion = tk.Entry(self.parent)
        self.txtEcuacion.place(x=320, y=10, width=200, height=20)
        self.txtEcuacion.focus()

        self.txtInferior = tk.Entry(self.parent)
        self.txtInferior.place(x=160, y=90, width=130, height=20)

        self.txtError = tk.Entry(self.parent,
                                 validate='key',
                                 validatecommand=vcmd)
        self.txtError.place(x=660, y=90, width=130, height=20)

        btnGrafica = tk.Button(self.parent,
                               text="Graficar",
                               command=lambda: self.graficar())
        btnGrafica.place(x=670, y=10, width=120, height=20)
        btnGrafica.config(font=font)

        btnRaiz = tk.Button(self.parent,
                            text="Obtener raices",
                            command=lambda: self.raiz())
        btnRaiz.place(x=10, y=130, width=200, height=20)
        btnRaiz.config(font=font)

        self.tree = ttk.Treeview(self.parent)
        vsb = ttk.Scrollbar(self.parent,
                            orient="vertical",
                            command=self.tree.yview)
        vsb.place(x=775, y=210, height=380)
        self.tree.configure(yscrollcommand=vsb.set)
        self.tree["columns"] = ("Xi", "f(Xi)", "f'(Xi)", "g(x)")
        self.tree.column("#0", width=50)
        self.tree.column("Xi", width=170)
        self.tree.column("f(Xi)", width=180)
        self.tree.column("f'(Xi)", width=180)
        self.tree.column("g(x)", width=185)
        self.tree.heading("Xi", text="Xi")
        self.tree.heading("f(Xi)", text="f(Xi)")
        self.tree.heading("f'(Xi)", text="F'(Xi)")
        self.tree.heading("g(x)", text="g(x)")
        self.tree.place(x=10, y=210, width=765, height=380)
        self.tree.insert("", 0, text="1", values=("", "", "", ""))
Ejemplo n.º 19
0
    def Populate_Frame(self):

        #############################################
        #Load the container frames
        self.Padding = '10p'

        #this will be the treeframe
        self.FolderFrame = ttk.Frame(self.Frame, padding=self.Padding)

        self.FilterFrame = ttk.Frame(self.Frame, padding=self.Padding)

        self.TreeFrame = ttk.Frame(self.Frame, padding=self.Padding)

        self.LogFrame = ttk.Frame(self.Frame, padding=self.Padding)

        #############################################
        #############################################
        #Top Path select frame
        self.FolderLabel = ttk.Label(self.FolderFrame,
                                     text='Selected Folder: ')

        self.FolderEntry = ttk.Entry(self.FolderFrame)

        self.FolderButton = ttk.Button(self.FolderFrame,
                                       text='...',
                                       command=self.Browse)

        self.Run = ttk.Button(self.FolderFrame, text='Run', command=self.Run)

        self.FolderLabel.grid(row=0,
                              column=0,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.FolderEntry.grid(row=0,
                              column=1,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.FolderButton.grid(row=0,
                               column=2,
                               sticky=tk.N + tk.S + tk.E + tk.W)

        self.Run.grid(row=0, column=3, sticky=tk.N + tk.S + tk.E + tk.W)

        self.FolderFrame.grid_columnconfigure(1, weight=1)

        #############################################
        #############################################
        #Top selector frame
        #initialise the variable
        self.SetFilters()

        #############################################
        #############################################
        # create a treeview with dual scrollbars

        #create the header array
        self.Header = [
            'Type', 'Laser', 'Power', 'Grating', 'Objectif', 'Time', 'N. x',
            'Sam ID', 'Sample', 'Substrate', 'Sam. Info.', 'Sub. Info.'
        ]

        #create the tree
        self.tree = ttk.Treeview(self.TreeFrame,
                                 columns=self.Header,
                                 show="headings")

        for col in self.Header:

            self.tree.heading(
                col,
                text=col.title(),
                command=lambda c=col: self.SortBy(self.tree, c, 0))

            # adjust the column's width to the header string
            self.tree.column(col,
                             width=tkFont.Font().measure(col.title()) + 20)

        #set the scrollbars
        vsb = ttk.Scrollbar(self.TreeFrame,
                            orient="vertical",
                            command=self.tree.yview)

        hsb = ttk.Scrollbar(self.TreeFrame,
                            orient="horizontal",
                            command=self.tree.xview)

        #link the scrollbar
        self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)

        self.tree.bind("<1>", self.OnClick)
        self.tree.bind(File.RightClickStr(), self.rClick)

        #grid it all
        self.tree.grid(column=0, row=0, sticky='nsew')
        vsb.grid(column=1, row=0, sticky='ns')
        hsb.grid(column=0, row=1, sticky='ew')

        #cofigure the treeframe
        self.TreeFrame.grid_columnconfigure(0, weight=1)
        self.TreeFrame.grid_rowconfigure(0, weight=1)

        #############################################
        #############################################
        #Bottom scrolled text

        #insert the textfield
        self.LogField = ScrolledText.ScrolledText(master=self.LogFrame,
                                                  wrap=tk.WORD,
                                                  height=12)

        #grid it
        self.LogField.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S)

        self.LogFrame.grid_columnconfigure(0, weight=1)
        self.LogFrame.grid_rowconfigure(0, weight=1)

        #############################################
        #############################################
        #grid and configure
        self.FolderFrame.grid(row=0,
                              column=0,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.FilterFrame.grid(row=1,
                              column=0,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.TreeFrame.grid(row=2, column=0, sticky=tk.N + tk.S + tk.E + tk.W)

        self.LogFrame.grid(row=3, column=0, sticky=tk.N + tk.S + tk.E + tk.W)

        self.Root.grid_rowconfigure(2, weight=1)

        self.Root.grid_columnconfigure(0, weight=1)
Ejemplo n.º 20
0
 def setUp(self):
     support.root_deiconify()
     self.tv = ttk.Treeview(padding=0)
    def frame_main(self):
        frame = tk.Frame(self.container)
        frame.grid()
        frame.grid_rowconfigure(0, weight=1)
        frame.grid_columnconfigure(0, weight=1)

        # create list treeview
        self.list_tree = ttk.Treeview(frame,
                                      columns=self.list_headers,
                                      show="headings",
                                      height=30)
        self.list_tree.grid(column=0,
                            row=0,
                            sticky=tk.E + tk.W + tk.N + tk.S,
                            rowspan=4)
        list_vsb = ttk.Scrollbar(frame,
                                 orient="vertical",
                                 command=self.list_tree.yview)
        list_vsb.grid(column=1,
                      row=0,
                      sticky=tk.E + tk.W + tk.N + tk.S,
                      rowspan=4)
        self.list_tree.configure(yscrollcommand=list_vsb.set)
        self.list_tree.bind("<Double-Button-1>",
                            self._action_list_double_click)

        # create detail treeview
        detail_tree = ttk.Treeview(frame,
                                   columns=self.detail_headers,
                                   show="headings",
                                   height=30)
        detail_tree.grid(column=2,
                         row=0,
                         sticky=tk.E + tk.W + tk.N + tk.S,
                         rowspan=4)
        detail_vsb = ttk.Scrollbar(frame,
                                   orient="vertical",
                                   command=detail_tree.yview)
        detail_vsb.grid(column=3,
                        row=0,
                        sticky=tk.E + tk.W + tk.N + tk.S,
                        rowspan=4)
        detail_tree.configure(yscrollcommand=detail_vsb.set)
        detail_tree.bind("<Double-Button-1>", self._action_detail_double_click)
        self.detail_tree = detail_tree

        # Buttons
        bt_create = tk.Button(frame,
                              text="Show",
                              width=8,
                              command=self._action_button_show)
        bt_create.grid(column=4, row=0, sticky=tk.E + tk.W + tk.N + tk.S)

        bt_create = tk.Button(frame,
                              text="Create",
                              width=8,
                              command=self._action_button_create)
        bt_create.grid(column=4, row=1, sticky=tk.E + tk.W + tk.N + tk.S)

        bt_update = tk.Button(frame,
                              text="Update",
                              width=8,
                              command=self._action_button_update)
        bt_update.grid(column=4, row=2, sticky=tk.E + tk.W + tk.N + tk.S)

        bt_delete = tk.Button(frame,
                              text="Delete",
                              width=8,
                              command=self._action_button_delete)
        bt_delete.grid(column=4, row=3, sticky=tk.E + tk.W + tk.N + tk.S)
Ejemplo n.º 22
0
    def FTP_interface(self):
        Account = self.Username
        self.ReplyCode = ""
        self.TotalTransfer = "0"
        self.CurrentTransfer = "0"
        self.TotalElapsed = "0"
        self.CurrentElapsed = "0"
        self.fileName = ""
        self.fileNameClient = ""
        self.fileNameServer = ""

        #account - current account logged in with
        self.Account_Label = Tkinter.Label(self.parent,
                                           text="Account: " + str(Account))
        self.Account_Label.place(x=0, y=0, width=650, height=25)

        #serverport
        self.ServerPort_Label = Tkinter.Label(self.parent, text="Server port:")
        self.ServerPort_Label.place(x=350, y=75, width=150, height=25)
        self.ServerPort_Entry = Tkinter.Entry(self.parent)
        self.ServerPort_Entry.place(x=500, y=75, width=250, height=25)

        #Hostaddress
        self.HostAddress_Label = Tkinter.Label(self.parent,
                                               text="Host address:")
        self.HostAddress_Label.place(x=350, y=50, width=150, height=25)
        self.HostAddress_Entry = Tkinter.Entry(self.parent)
        self.HostAddress_Entry.place(x=500, y=50, width=250, height=25)

        #Mode, Type and Method
        self.Type_Selected = StringVar(self.parent)
        self.Type_Selected.set("ASCII")
        self.Mode_Selected = StringVar(self.parent)
        self.Mode_Selected.set("STREAM")
        self.Method_Selected = StringVar(self.parent)
        if self.ClientHost[0:3] == '192':
            self.Method_Selected.set("PORT")
        elif self.ClientHost[0:3] == '127':
            self.Method_Selected.set("PASV")
        self.Type_Menu = Tkinter.OptionMenu(self.parent,
                                            self.Type_Selected,
                                            "ASCII",
                                            "EDCBIC",
                                            "IMAGE/BINARY",
                                            command=self.TypeSet)
        self.Type_Menu.place(x=0, y=125, width=350, height=25)
        self.Mode_Menu = Tkinter.OptionMenu(self.parent,
                                            self.Mode_Selected,
                                            "STREAM",
                                            "BLOCK",
                                            "COMPRESSION",
                                            command=self.ModeSet)
        self.Mode_Menu.place(x=350, y=125, width=350, height=25)
        self.Method_Menu = Tkinter.OptionMenu(self.parent,
                                              self.Method_Selected,
                                              "PASV",
                                              "PORT",
                                              command=self.MethodSet)
        self.Method_Menu.place(x=350, y=25, width=300, height=25)

        #logout - button and show other screen
        self.Logout_Button = Tkinter.Button(self.parent,
                                            text="Logout",
                                            command=self.Clear_Interface)
        self.Logout_Button.place(x=650, y=25, width=50, height=25)

        #Exit - close
        self.Exit_Button = Tkinter.Button(self.parent,
                                          text="Exit",
                                          command=self.parent.quit)
        self.Exit_Button.place(x=650, y=0, width=50, height=25)

        #Amount of data transferred - for current transfer and total
        self.DataTransferTotal_Label = Tkinter.Label(
            self.parent,
            text="Total data transferred (Bytes): " + str(self.TotalTransfer))
        self.DataTransferTotal_Label.place(x=0, y=25, width=350, height=25)
        self.DataTransferCurrent_Label = Tkinter.Label(
            self.parent,
            text="Data transferred in this session (Bytes): " +
            str(self.CurrentTransfer))
        self.DataTransferCurrent_Label.place(x=0, y=50, width=350, height=25)

        #time elapsed - for current transfer
        self.TotalElapsed_Label = Tkinter.Label(
            self.parent,
            text="Total elapsed transfer time (s): " + str(self.TotalElapsed))
        self.TotalElapsed_Label.place(x=0, y=75, width=350, height=25)
        self.CurrentElapsed_Label = Tkinter.Label(
            self.parent,
            text="Elapsed transfer time in this session (s): " +
            str(self.CurrentElapsed))
        self.CurrentElapsed_Label.place(x=0, y=100, width=350, height=25)

        #transfer buttons
        self.Server_To_Client_Button = Tkinter.Button(
            self.parent, text=">>", command=self.Server_to_Client)
        self.Server_To_Client_Button.place(x=150, y=175, width=200, height=25)
        self.Client_To_Server_Button = Tkinter.Button(
            self.parent, text="<<", command=self.Client_to_Server)
        self.Client_To_Server_Button.place(x=350, y=175, width=200, height=25)

        #navigation buttons
        self.Previous_Button = Tkinter.Button(self.parent,
                                              text="<",
                                              command=self.Navigate_P)
        self.Previous_Button.place(x=0, y=175, width=75, height=25)
        self.Next_Button = Tkinter.Button(self.parent,
                                          text=">",
                                          command=self.Navigate_N)
        self.Next_Button.place(x=75, y=175, width=75, height=25)

        #reply code
        self.Reply_Code_Label = Tkinter.Label(self.parent,
                                              text="Server reply code")
        self.Reply_Code_Label.place(x=550, y=175, width=150, height=25)

        #Directory buttons
        self.Parent_Button = Tkinter.Button(self.parent,
                                            text="Parent directory",
                                            command=self.Navigate_Parent)
        self.Parent_Button.place(x=0, y=150, width=175, height=25)
        self.Remove_Button = Tkinter.Button(self.parent,
                                            text="Remove directory",
                                            command=self.Remove_directory)
        self.Remove_Button.place(x=175, y=150, width=175, height=25)
        self.Delete_Button = Tkinter.Button(self.parent,
                                            text="Delete file",
                                            command=self.Delete_file)
        self.Delete_Button.place(x=350, y=150, width=175, height=25)
        self.Make_Button = Tkinter.Button(self.parent,
                                          text="Make directory",
                                          command=self.Make_directory)
        self.Make_Button.place(x=350, y=100, width=175, height=25)
        self.Make_Entry = Tkinter.Entry(self.parent)
        self.Make_Entry.place(x=525, y=100, width=175, height=25)

        #No operation button
        self.NOOP_Button = Tkinter.Button(self.parent,
                                          text="NOOP",
                                          command=self.No_operation)
        self.NOOP_Button.place(x=525, y=150, width=175, height=25)

        #Server Tree view
        self.ServerTree = ttk.Treeview(self.parent,
                                       columns=('Server File Name'))
        self.ServerTree['show'] = 'headings'
        self.ServerTree.heading('#1', text='Server - File Name')
        self.ServerTree.column('#1', width=350)
        self.ServerTree.place(x=0, y=200, width=350, height=500)
        self.ServerTreeview = self.ServerTree
        self.ServerTree.bind('<ButtonRelease-1>', self.selectServerItem)

        #Client Tree view
        self.ClientTree = ttk.Treeview(self.parent,
                                       columns=('Client File Name'))
        self.ClientTree['show'] = 'headings'
        self.ClientTree.heading('#1', text='Client - File Name')
        self.ClientTree.column('#1', width=350)
        self.ClientTree.place(x=350, y=200, width=350, height=500)
        self.ClientTreeview = self.ClientTree
        self.ClientTree.bind('<ButtonRelease-1>', self.selectClientItem)

        #Initial setting of tree
        self.setClientTree()
        self.setServerTree()
Ejemplo n.º 23
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'

        top.geometry("960x788+300+00")
        top.title("Mise à jour des groupes")
        top.configure(background="#EFF0EF")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.Labelframe1 = LabelFrame(top)
        self.Labelframe1.place(relx=0.04,
                               rely=0.1,
                               relheight=0.44,
                               relwidth=0.92)
        self.Labelframe1.configure(relief=GROOVE)
        self.Labelframe1.configure(foreground="black")
        self.Labelframe1.configure(text='''Info/Groupe''')
        self.Labelframe1.configure(background="#EFF0EF")
        self.Labelframe1.configure(highlightbackground="#d9d9d9")
        self.Labelframe1.configure(highlightcolor="black")
        self.Labelframe1.configure(width=920)

        self.Label1 = Label(self.Labelframe1)
        self.Label1.place(relx=0.05, rely=0.42, height=26, width=75)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#EFF0EF")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''N° groupe''')

        self.Label2 = Label(self.Labelframe1)
        self.Label2.place(relx=0.65, rely=0.43, height=26, width=61)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(background="#EFF0EF")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Libéllé''')

        self.Entry1 = Entry(self.Labelframe1)
        self.Entry1.place(relx=0.17, rely=0.42, relheight=0.07, relwidth=0.16)
        self.Entry1.configure(background="white")
        self.Entry1.configure(disabledforeground="#a3a3a3")
        self.Entry1.configure(font="TkFixedFont")
        self.Entry1.configure(foreground="#000000")
        self.Entry1.configure(highlightbackground="#d9d9d9")
        self.Entry1.configure(highlightcolor="black")
        self.Entry1.configure(insertbackground="black")
        self.Entry1.configure(selectbackground="#c4c4c4")
        self.Entry1.configure(selectforeground="black")

        self.Entry2 = Entry(self.Labelframe1)
        self.Entry2.place(relx=0.76, rely=0.43, relheight=0.07, relwidth=0.16)
        self.Entry2.configure(background="white")
        self.Entry2.configure(disabledforeground="#a3a3a3")
        self.Entry2.configure(font="TkFixedFont")
        self.Entry2.configure(foreground="#000000")
        self.Entry2.configure(highlightbackground="#d9d9d9")
        self.Entry2.configure(highlightcolor="black")
        self.Entry2.configure(insertbackground="black")
        self.Entry2.configure(selectbackground="#c4c4c4")
        self.Entry2.configure(selectforeground="black")

        self.Button1 = Button(top)
        self.Button1.place(relx=0.4, rely=0.6, height=33, width=156)
        self.Button1.configure(activebackground="#218DF2")
        self.Button1.configure(activeforeground="white")
        self.Button1.configure(activeforeground="white")
        self.Button1.configure(background="#218DF2")
        self.Button1.configure(disabledforeground="#a3a3a3")
        self.Button1.configure(foreground="white")
        self.Button1.configure(highlightbackground="#d9d9d9")
        self.Button1.configure(highlightcolor="black")
        self.Button1.configure(pady="0")
        self.Button1.configure(text='''VALIDER''')
        self.Button1.bind('<Button-1>', lambda e: Groupes_support.Valider(e))

        self.Labelframe4 = LabelFrame(top)
        self.Labelframe4.place(relx=0.03,
                               rely=0.68,
                               relheight=0.24,
                               relwidth=0.93)
        self.Labelframe4.configure(relief=GROOVE)
        self.Labelframe4.configure(foreground="black")
        self.Labelframe4.configure(text='''Liste des groupes''')
        self.Labelframe4.configure(background="#EFF0EF")
        self.Labelframe4.configure(highlightbackground="#d9d9d9")
        self.Labelframe4.configure(highlightcolor="black")
        self.Labelframe4.configure(width=930)

        self.listead = ttk.Treeview(self.Labelframe4, columns=('', 'Libéllé'))
        self.listead.column('#0', width=0)
        self.listead.column('#1', width=250)
        self.listead.column('#2', width=450)
        self.listead.heading('#1', text='', anchor=CENTER)
        self.listead.heading('#2', text='Libéllé', anchor=CENTER)
        self.listead.grid(row=0)

        self.Button3 = Button(self.Labelframe4)
        self.Button3.place(relx=0.84, rely=0.26, height=33, width=89)
        self.Button3.configure(activebackground="#218DF2")
        self.Button3.configure(activeforeground="white")
        self.Button3.configure(activeforeground="white")
        self.Button3.configure(background="#218DF2")
        self.Button3.configure(disabledforeground="#a3a3a3")
        self.Button3.configure(foreground="white")
        self.Button3.configure(highlightbackground="#d9d9d9")
        self.Button3.configure(highlightcolor="black")
        self.Button3.configure(pady="0")
        self.Button3.configure(text='''Modifier''')
        self.Button3.configure(width=89)

        self.Button4 = Button(self.Labelframe4)
        self.Button4.place(relx=0.84, rely=0.52, height=33, width=89)
        self.Button4.configure(activebackground="#EA8144")
        self.Button4.configure(activeforeground="white")
        self.Button4.configure(background="#EA8144")
        self.Button4.configure(disabledforeground="#a3a3a3")
        self.Button4.configure(foreground="white")
        self.Button4.configure(highlightbackground="#d9d9d9")
        self.Button4.configure(highlightcolor="black")
        self.Button4.configure(pady="0")
        self.Button4.configure(text='''Supprimer''')

        self.Labelframe5 = LabelFrame(top)
        self.Labelframe5.place(relx=0.04,
                               rely=0.01,
                               relheight=0.08,
                               relwidth=0.92)
        self.Labelframe5.configure(relief=GROOVE)
        self.Labelframe5.configure(foreground="black")
        self.Labelframe5.configure(text='''Information/système''')
        self.Labelframe5.configure(background="#EFF0EF")
        self.Labelframe5.configure(highlightbackground="#d9d9d9")
        self.Labelframe5.configure(highlightcolor="black")
        self.Labelframe5.configure(width=920)

        self.Label8 = Label(self.Labelframe5)
        self.Label8.place(relx=0.82, rely=0.4, height=26, width=92)
        self.Label8.configure(activebackground="#f9f9f9")
        self.Label8.configure(activeforeground="black")
        self.Label8.configure(background="#EFF0EF")
        self.Label8.configure(disabledforeground="#a3a3a3")
        self.Label8.configure(foreground="#000000")
        self.Label8.configure(highlightbackground="#d9d9d9")
        self.Label8.configure(highlightcolor="black")
        self.Label8.configure(text='''Heure''')
        self.Label8.configure(textvariable=Groupes_support.heure)
        Mise_à_jour_des_groupes.maj()

        self.Label9 = Label(self.Labelframe5)
        self.Label9.place(relx=0.77, rely=0.4, height=26, width=53)
        self.Label9.configure(activebackground="#f9f9f9")
        self.Label9.configure(activeforeground="black")
        self.Label9.configure(background="#EFF0EF")
        self.Label9.configure(disabledforeground="#a3a3a3")
        self.Label9.configure(foreground="#000000")
        self.Label9.configure(highlightbackground="#d9d9d9")
        self.Label9.configure(highlightcolor="black")
        self.Label9.configure(text='''Heure :''')

        self.Label10 = Label(self.Labelframe5)
        self.Label10.place(relx=0.77, rely=0.0, height=26, width=45)
        self.Label10.configure(activebackground="#f9f9f9")
        self.Label10.configure(activeforeground="black")
        self.Label10.configure(background="#EFF0EF")
        self.Label10.configure(disabledforeground="#a3a3a3")
        self.Label10.configure(foreground="#000000")
        self.Label10.configure(highlightbackground="#d9d9d9")
        self.Label10.configure(highlightcolor="black")
        self.Label10.configure(text='''Date :''')

        self.Label11 = Label(self.Labelframe5)
        self.Label11.place(relx=0.82, rely=0.0, height=26, width=82)
        self.Label11.configure(background="#EFF0EF")
        self.Label11.configure(disabledforeground="#a3a3a3")
        self.Label11.configure(foreground="#000000")
        self.Label11.configure(
            text="{0} /{1} /{2}".format(date.day, mois[m], date.year))
        self.Label11.configure(width=82)
Ejemplo n.º 24
0
 def _MakeTreeView(self, parent):
     self.tree = ttk.Treeview(parent, columns=('type', ))
     self.tree.column('type', width=50, anchor='e')
     self.tree.heading('type', text='Type')
     self.tree.pack(fill=tk.BOTH, expand=True)
     self.tree.bind("<Double-1>", self.TreeView_OnDoubleClick)
Ejemplo n.º 25
0
 def __init__(self, master, manifold):
     self.manifold = manifold
     self.num = 0  # make the superclass happy
     self.max_segments = 6
     self.result = []
     style = SnapPyStyle(master)
     self.root = root = Tk_.Toplevel(master,
                                     class_='SnapPy',
                                     bg=style.WindowBG)
     title = 'Drill'
     root.title(title)
     root.iconname(title)
     root.bind('<Return>', self.handle_return)
     top_frame = Tk_.Frame(self.root, bg=style.WindowBG)
     top_frame.grid_columnconfigure(0, weight=1)
     top_frame.grid_rowconfigure(2, weight=1)
     msg_font = Font(family=style.font_info['family'],
                     weight='bold',
                     size=int(style.font_info['size'] * 1.2))
     msg = ttk.Label(top_frame,
                     font=msg_font,
                     text='Choose which curves to drill out:')
     msg.grid(row=0, column=0, pady=10)
     segment_frame = Tk_.Frame(top_frame, bg=style.WindowBG)
     self.segment_var = segment_var = Tk_.StringVar(root)
     segment_var.set(str(self.max_segments))
     ttk.Label(segment_frame, text='Max segments: ').pack(side=Tk_.LEFT,
                                                          padx=4)
     self.segment_entry = segment_entry = ttk.Entry(
         segment_frame,
         takefocus=False,
         width=2,
         textvariable=segment_var,
         validate='focusout',
         validatecommand=(root.register(self.validate_segments), '%P'))
     segment_entry.pack(side=Tk_.LEFT)
     segment_frame.grid(row=1, column=0, pady=2)
     self.curves = curves = ttk.Treeview(
         top_frame,
         selectmode='extended',
         columns=['index', 'parity', 'length'],
         show='headings')
     curves.heading('index', text='#')
     curves.column('index', stretch=False, width=20)
     curves.heading('parity', text='Parity')
     curves.column('parity', stretch=False, width=80)
     curves.heading('length', text='Length')
     curves.column('length', stretch=True, width=460)
     curves.bind('<Double-Button-1>', self.drill)
     self.curves.grid(row=2, column=0, padx=6, pady=6, sticky=Tk_.NSEW)
     self.show_curves()
     top_frame.pack(fill=Tk_.BOTH, expand=1)
     button_frame = Tk_.Frame(self.root, bg=style.WindowBG)
     button = ttk.Button(button_frame,
                         text='Drill',
                         command=self.drill,
                         default='active')
     button.pack(side=Tk_.LEFT, padx=6)
     button = ttk.Button(button_frame, text='Cancel', command=self.cancel)
     button.pack(side=Tk_.LEFT, padx=6)
     button_frame.pack(pady=6)
     self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)
     self._set_transient(master)
Ejemplo n.º 26
0
    def __init__(self, master=None):
        """
		Class properties initialization. This also
		creates the GUI widgets 
		"""
        ttk.Frame.__init__(self, master)
        self.grid()

        # allow the GUI to strech
        self.columnconfigure(0, weight=1, pad=2)
        self.columnconfigure(1, weight=1, pad=2)
        self.columnconfigure(2, weight=1, pad=2)
        self.columnconfigure(3, weight=1, pad=2)
        self.columnconfigure(4, weight=1, pad=2)
        self.columnconfigure(5, weight=1, pad=2)
        self.columnconfigure(6, weight=1, pad=2)
        self.columnconfigure(7, weight=1, pad=2)
        self.columnconfigure(8, weight=1, pad=2)
        self.columnconfigure(9, weight=1, pad=2)
        self.columnconfigure(10, weight=1, pad=2)
        self.columnconfigure(11, weight=1, pad=2)
        self.rowconfigure(0, weight=1, pad=2)  # contains the text labels
        self.rowconfigure(1, weight=4,
                          pad=2)  # contains the tree and properties
        self.rowconfigure(2, weight=1, pad=2)  # contains the buttons

        # create the GUI elements
        self.tree_label = ttk.Label(self, text='Objects Tree')
        self.properties_label = ttk.Label(self, text='Object Properties')

        self.objects_tree = ttk.Treeview(self, columns=('id'))
        self.property_list = ttk.Treeview(self, columns=('Writable', 'Value'))

        self.tree_scroll = ttk.Scrollbar(orient=tk.VERTICAL,
                                         command=self.objects_tree.yview)
        self.property_scroll = ttk.Scrollbar(orient=tk.VERTICAL,
                                             command=self.property_list.yview)

        self.refresh_tree_button = ttk.Button(self,
                                              text='Refresh Tree',
                                              command=self.refresh_tree)
        self.refresh_object_button = ttk.Button(self,
                                                text='Refresh Object',
                                                command=self.refresh_object)
        self.screenshot_button = ttk.Button(self,
                                            text='Screenshot',
                                            command=self.screenshot)

        self.objects_tree.heading('id', text='ID')
        self.objects_tree.heading('#0', text='Object')
        self.objects_tree.column('#0', anchor='e')
        self.objects_tree.column('id', anchor='w')
        self.objects_tree['yscroll'] = self.tree_scroll.set

        self.property_list.heading('#0', text='Property')
        self.property_list.heading('Writable', text='Writable')
        self.property_list.heading('Value', text='Value')
        self.property_list.column('#0', anchor='e')
        self.property_list.column('Writable', anchor='center')
        self.property_list.column('Value', anchor='w')
        self.property_list['yscroll'] = self.property_scroll.set

        # place them on the GUI
        self.tree_label.grid(column=2, row=0, columnspan=2)
        self.properties_label.grid(column=7, row=0, columnspan=2)

        self.objects_tree.grid(column=0, row=1, columnspan=4)
        self.property_list.grid(column=5, row=1, columnspan=6)

        self.tree_scroll.grid(column=5, row=1)
        self.property_scroll.grid(column=11, row=1)

        self.refresh_tree_button.grid(column=2, row=2, columnspan=2)
        self.screenshot_button.grid(column=5, row=2, columnspan=2)
        self.refresh_object_button.grid(column=8, row=2, columnspan=2)

        # add event handlers
        self.objects_tree.bind('<<TreeviewSelect>>', self.object_selected)

        # create the properties for communicating with the server
        self.client = client.Client()
        self.current_selection = ''
Ejemplo n.º 27
0
    def __init__(self, parent, *args, **kwargs):
        Tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent

        self.login_object = LoginPopUp(self.parent)

        # gui = uni_page + display_page
        self.uni_page = Tk.Frame(self.parent, bd=2, relief=Tk.RIDGE)
        self.uni_page.pack(side=Tk.LEFT, fill=Tk.Y, ipadx=20, ipady=20)
        self.display_page = Tk.Frame(self.parent)
        self.display_page.pack(side=Tk.LEFT, fill=Tk.BOTH, expand=True, padx=10, pady=20)

        # uni_page = uni_content + management page
        self.uni_content = Tk.Frame(self.uni_page)
        self.uni_content.pack(side=Tk.TOP, fill=Tk.Y, expand=True, pady=(20, 0))
        self.uni_management = Tk.Frame(self.uni_page)
        self.uni_management.pack(side=Tk.BOTTOM)

        # uni_content page
        self.uni_canvas = Tk.Canvas(self.uni_content)
        self.uni_canvas.config(width=130)
        self.uni_canvas.pack(side=Tk.LEFT, fill=Tk.BOTH, expand=True)
        self.uni_scrollbar = Tk.Scrollbar(self.uni_content, command=self.uni_canvas.yview)
        self.uni_scrollbar.pack(side=Tk.LEFT, fill=Tk.Y)
        self.uni_canvas.configure(yscrollcommand=self.uni_scrollbar.set)

        self.uni_canvas.bind('<Configure>', self._on_frame_configure)
        self.uni_canvas.bind('<Enter>', self._bound_to_mousewheel)
        self.uni_canvas.bind('<Leave>', self._unbound_to_mousewheel)

        self.uni_list_frame = Tk.Frame(self.uni_canvas)
        self.uni_list_frame.bind("<Configure>", self._reset_scrollregion)
        self.uni_canvas.create_window((0, 0), window=self.uni_list_frame, anchor='nw')
        # add sth
        self.university_list = []   # sorted at start, remain the same after edit and add new
        self.university_list_sorted = []  # always sorted in rank
        self.candidates = []
        self.load_universities()

        # Uni_management page
        self.uni_add_button = Tk.Button(self.uni_management, text=Add_New_University, command=self.popup_new_uni_window)
        self.uni_add_button.pack(pady=20)

        # -------------------------------------
        # display page = search + filters + table
        self.search_frame = Tk.Frame(self.display_page)
        self.search_frame.pack(side=Tk.TOP, fill=Tk.X)
        self.display_filters = Tk.Frame(self.display_page)
        self.display_filters.pack(side=Tk.TOP, fill=Tk.X)
        self.display_table = Tk.Frame(self.display_page, bd=1, relief=Tk.RIDGE)
        self.display_table.pack(side=Tk.TOP, fill=Tk.BOTH, expand=True)

        # search frame
        self.search_label = Tk.Label(self.search_frame, text=Search_Keyword)
        self.search_label.pack(side=Tk.LEFT, padx=(25, 0))
        self.search_entry = Tk.Entry(self.search_frame)
        self.search_entry.pack(side=Tk.LEFT, fill=Tk.X, expand=True, padx=(20, 40))

        # display filters: two class and 4 types + refresh button
        self.filter_content = Tk.Frame(self.display_filters)
        self.filter_content.pack(side=Tk.LEFT, fill=Tk.X, expand=True)
        self.filter_button_frame = Tk.Frame(self.display_filters)
        self.filter_button_frame.pack(side=Tk.LEFT)

        self.filter_class = Tk.Frame(self.filter_content)
        self.filter_class.pack(side=Tk.TOP, fill=Tk.X)
        self.filter_types = Tk.Frame(self.filter_content)
        self.filter_types.pack(side=Tk.TOP, fill=Tk.X)

        self.filter_refresh_button = Tk.Button(self.filter_button_frame, text=Refresh, width=10,
                                               command=self.refresh_table)
        self.filter_refresh_button.pack(side=Tk.LEFT)
        self.export_button = Tk.Button(self.filter_button_frame, text=Export, width=10, command=self.export_csv)
        self.export_button.pack(side=Tk.LEFT, padx=30)

        # filter class
        self.class_value = Tk.IntVar()
        self.class_value.set(Class_Science_Index)  # default is science
        self.science_button = Tk.Radiobutton(self.filter_class, text=Class_Science, variable=self.class_value,
                                             value=Class_Science_Index, command=self.update_class)
        self.science_button.pack(side=Tk.LEFT, padx=(20, 10), pady=(10, 2))
        self.art_button = Tk.Radiobutton(self.filter_class, text=Class_Art, variable=self.class_value,
                                         value=Class_Art_Index, command=self.update_class)
        self.art_button.pack(side=Tk.LEFT, padx=10, pady=(10, 2))

        # filter types
        # type all
        self.type_all_value = Tk.IntVar()
        self.type_all_value.set(1)
        self.type_all = Tk.Checkbutton(self.filter_types, text=Type_All, variable=self.type_all_value,
                                       command=self.update_all_types)
        self.type_all.pack(side=Tk.LEFT, padx=(20, 10), pady=(3, 10))
        # type 985
        self.type_985_value = Tk.IntVar()
        self.type_985_value.set(1)
        self.type_985 = Tk.Checkbutton(self.filter_types, text=Type_985, variable=self.type_985_value,
                                       command=self.update_individual_type)
        self.type_985.pack(side=Tk.LEFT, padx=10, pady=(3, 10))
        # type 211
        self.type_211_value = Tk.IntVar()
        self.type_211_value.set(1)
        self.type_211 = Tk.Checkbutton(self.filter_types, text=Type_211, variable=self.type_211_value,
                                       command=self.update_individual_type)
        self.type_211.pack(side=Tk.LEFT, padx=10, pady=(3, 10))
        # type lead uni
        self.type_lead_uni_value = Tk.IntVar()
        self.type_lead_uni_value.set(1)
        self.type_lead_uni = Tk.Checkbutton(self.filter_types, text=Type_Leading_Uni,
                                            variable=self.type_lead_uni_value, command=self.update_individual_type)
        self.type_lead_uni.pack(side=Tk.LEFT, padx=10, pady=(3, 10))
        # type lead sub
        self.type_lead_sub_value = Tk.IntVar()
        self.type_lead_sub_value.set(1)
        self.type_lead_sub = Tk.Checkbutton(self.filter_types, text=Type_Leading_Sub,
                                            variable=self.type_lead_sub_value, command=self.update_individual_type)
        self.type_lead_sub.pack(side=Tk.LEFT, padx=10, pady=(3, 10))
        # type others
        self.type_others_value = Tk.IntVar()
        self.type_others_value.set(1)
        self.type_others_checkButton = Tk.Checkbutton(self.filter_types, text=Type_Others,
                                                      variable=self.type_others_value,
                                                      command=self.update_individual_type)
        self.type_others_checkButton.pack(side=Tk.LEFT, padx=10, pady=(2, 10))

        # display table
        self.current_year = date.today().year
        self.headers = [Table_Header[0], Table_Header[1], Table_Header[2], Table_Header[3], Table_Header[4],
                        Table_Pre_Batch, Table_First_Batch, str(self.current_year-3) + Table_Accumulate,
                        Table_Pre_Batch, Table_First_Batch, str(self.current_year-2) + Table_Accumulate,
                        Table_Pre_Batch, Table_First_Batch, str(self.current_year-1) + Table_Accumulate,
                        Table_Pre_Batch, Table_First_Batch, str(self.current_year) + Table_Accumulate]
        self.tree = ttk.Treeview(columns=range(len(self.headers)), show="headings")
        self.tree_vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview)
        self.tree_hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview)
        self.tree.configure(yscrollcommand=self.tree_vsb.set,
                            xscrollcommand=self.tree_hsb.set)

        self.tree.grid(column=0, row=0, sticky='nsew', in_=self.display_table)
        self.tree_vsb.grid(column=1, row=0, sticky='ns', in_=self.display_table)
        self.tree_hsb.grid(column=0, row=1, sticky='ew', in_=self.display_table)

        self.display_table.grid_columnconfigure(0, weight=1)
        self.display_table.grid_rowconfigure(0, weight=1)

        self.tree.bind('<Enter>', self._bound_to_mousewheel_table)
        self.tree.bind('<Leave>', self._unbound_to_mousewheel_table)
        self.tree.bind('<Double-1>', self.popup_details)

        self.fill_table()
Ejemplo n.º 28
0
def reset():
    tree.delete(*tree.get_children())
    cursor = conexion.cursor()
    sql = """ select * from users """  # Sql string
    cursor.execute(sql)
    result = cursor.fetchall()
    for item in result:
        tree.insert('',
                    'end',
                    values=(item[0], item[1], item[2], item[7],
                            item[8]))  #inserting in treeview or grid
        cursor.close()


# ----------------- Creation of Grid or Treeview -----------------------------------
tree = ttk.Treeview(v0)  # ttk library for object treeview
tree["columns"] = ("one", "two", "three", "four", "five")  # numbers of columns
tree.column("one", width=80)
tree.column("two", width=80)
tree.column("three", width=80)
tree.column("four", width=80)
tree.column("five", width=80)
# Heading, columns's name
tree.heading("one", text="User-Code")
tree.heading("two", text="Name")
tree.heading("three", text="Lastname")
tree.heading("four", text="Password")
tree.heading("five", text="Status")

#Data base connection
Ejemplo n.º 29
0
import ttk
import Tkinter as tk

win = tk.Tk()
win.resizable(width=0, height=0)

tree = ttk.Treeview(win, selectmode='browse')
tree.pack(side='left')

vsb = ttk.Scrollbar(win, orient="vertical", command=tree.yview)
vsb.pack(side='right', fill='y')

tree.configure(yscrollcommand=vsb.set)

tree["columns"] = ("1", "2", "3")
tree['show'] = 'headings'
tree.column("1", width=100, anchor='c')
tree.column("2", width=110, anchor='c')
tree.column("3", width=100, anchor='c')
tree.heading("1", text="Time")
tree.heading("2", text="Tweet")
tree.heading("3", text="Sentiment")
tree.insert("",'end',text="L1",values=("4am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("5am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("6am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("7am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("8am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("9am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("10am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("11am","Best in the world", ".4"))
tree.insert("",'end',text="L1",values=("12am","Best in the world", ".4"))
Ejemplo n.º 30
0
 def __init__(self, obj, name, master, cnf={}, **kwargs):
     ttk.Frame.__init__(self, master, **kwargs)
     self['padding'] = 1
     self.tree = ttk.Treeview(self)
     setattr(obj, name, self.tree)
     self._configMe(cnf)