示例#1
0
    def build_results(self, results, main_frame):
        """
        Insert tracks found with search term into Treeview.
        """
        tree = ttk.Treeview(main_frame, selectmode='browse')

        labels = ["Title", "Artist", "Album", "Release Date", "Track No."]
        tree["columns"] = labels[1:]
        for i in range(len(labels)):
            tree.heading("#" + str(i), text=labels[i])
            tree.column("#" + str(i), stretch="yes")

        for res in results:
            artists = "".join(res["artists"][i]["name"] + ", "
                              for i in range(len(res["artists"])))
            artists = artists[:-2]
            tree.insert("",
                        "end",
                        text=res["name"],
                        values=(artists, res["album"]["name"],
                                res["album"]["release_date"],
                                res["track_number"],
                                res["album"]["images"][0]["url"]))

        tree.bind('<ButtonRelease-1>',
                  lambda event, t=tree: self.select_item(event, t))
        tree.pack(fill="both")
示例#2
0
    def __init__(self, master):
        self.master = master
        self.active = {
            'count': '',  # number of files count
            'index': 0,  # currentindex of selection
            'location': '',
            'mode': tk.IntVar(value=0),  # errorlog value active
            'stats': '',  # information panel
            'value': '',  # 
        }
        self.await_load = False
        self.btn = {}
        self.data = {}  # holds currently loaded object
        self.form = {}  # holds all GUI components (except radiobuttons and buttons)
        self.list = {}
        self.mode_opts = {}
        
        # ===================== (Main Menu + controls)
        self.form['location'] = tk.Label(self.master, text='Location : {0}'.format(self.active['location']))
        self.mode_opts['mode1'] = tk.Radiobutton(self.master, text='Data Viewer', value=0, variable=self.active['mode'], command=self.sm)
        self.mode_opts['mode2'] = tk.Radiobutton(self.master, text='Data editor', value=1, variable=self.active['mode'], command=self.sm)
        
        self.form['location'].grid(row=0, column=0, columnspan=2, sticky='w')
        self.mode_opts['mode1'].grid(row=0, column=4)
        self.mode_opts['mode2'].grid(row=0, column=5)
        
        # ===================== (Button Menu)
        self.btn['open'] = tk.Button(self.master, text='open', command=self.sm)
        self.btn['expt'] = tk.Button(self.master, text='export', command=self.export)
        self.btn['prev'] = tk.Button(self.master, text='<', command=self.prev)
        self.btn['save'] = tk.Button(self.master, text='save')  # editing not yet implemented
        self.btn['next'] = tk.Button(self.master, text='>', command=self.next)
        self.btn['exit'] = tk.Button(self.master, text='quit', command=self.quit)
        self.btn['open'].grid(row=1, column=0, pady=5, sticky='nsew')
        self.btn['expt'].grid(row=1, column=1, pady=5, sticky='nsew')
        self.btn['prev'].grid(row=1, column=2, pady=5, sticky='nsew')
        self.btn['save'].grid(row=1, column=3, pady=5, sticky='nsew')
        self.btn['next'].grid(row=1, column=4, pady=5, sticky='nsew')
        self.btn['exit'].grid(row=1, column=5, pady=5, sticky='nsew')
        
        # ===================== (Tables list)
        self.list['box'] = tk.Listbox(self.master, height=3)
        self.list['box'].bind('<<ListboxSelect>>', self.on_select)
        self.list['scroll'] = tk.Scrollbar(self.master, orient='vertical')
        self.list['box']['yscrollcommand'] = self.list['scroll'].set
        self.list['scroll']['command'] = self.list['box'].yview
        self.list['box'].grid(row=2, column=0, rowspan=7, columnspan=1, sticky='nse', pady=(5, 5), padx=(5, 5))
        self.list['scroll'].grid(row=2, column=0, rowspan=7, columnspan=1, sticky='nse', pady=(5, 5), padx=(5, 5))
        self.list['values'] = {}
        
        # ===================== (Fields list)
        self.form['content'] = ttk.Treeview(master, show='headings', selectmode='browse', height=4)
        self.form['content'].grid(row=2, column=1, columnspan=7, rowspan=7)
        self.form['content'].bind("<Return>", lambda e: self.on_select())

        # ===================== (Comment line)
        self.form['stats'] = tk.Label(self.master, text='Total : {0} records'.format(self.active['count']))
        self.form['stats'].grid(row=9, column=0, columnspan=7, sticky='w')
        self.refresh()
示例#3
0
def plugin_app(parent):
    global treeview
    treeview = ttk.Treeview(parent, columns=2)
    treeview.heading("#0", text="Faction")
    treeview.heading(0, text="Credits")
    treeview.column(0, anchor=tk.E)  # right align numbers

    #bounties["foo"] = 12345678
    #update_treeview(bounties)
    #treeview.set_children("", "Recent bounties", "Recent combat bonds")
    return treeview
示例#4
0
    def __place_widgets(self):
        # header frame and its widgets
        hframe = ttk.Frame(self)
        lbtn = ttk.Button(hframe, style='L.TButton', command=self._prev_month)
        rbtn = ttk.Button(hframe, style='R.TButton', command=self._next_month)
        self._header = ttk.Label(hframe, width=15, anchor='center')
        # the calendar
        self._calendar = ttk.Treeview(self, show='', selectmode='none', height=7)

        # pack the widgets
        hframe.pack(in_=self, side='top', pady=4, anchor='center')
        lbtn.grid(in_=hframe)
        self._header.grid(in_=hframe, column=1, row=0, padx=12)
        rbtn.grid(in_=hframe, column=2, row=0)
        self._calendar.pack(in_=self, expand=1, fill='both', side='bottom')
示例#5
0
def show_data():
    global w, view
    if w:
        try:
            w.lift()
            return
        except:
            pass
    w = tk.Toplevel()
    w.title("EDMC Data")
    #text = tk.Text(w)
    view = ttk.Treeview(w, columns=1)
    update_data(data)
    sb = ttk.Scrollbar(w, command=view.yview)
    view.configure(yscrollcommand=sb.set)
    sb.pack(fill=tk.Y, expand=0, side=tk.RIGHT)
    view.pack(fill=tk.BOTH, expand=1)
示例#6
0
    def _setup_widgets(self):
        s = """\
click on header to sort by that column
to change width of column drag boundary
        """
        msg = ttk.Label(wraplength="4i",
                        justify="left",
                        anchor="n",
                        padding=(10, 2, 10, 6),
                        text=s)
        msg.pack(fill='x')
        container = ttk.Frame()
        container.pack(fill='both', expand=True)
        # create a treeview with dual scrollbars
        self.tree = ttk.Treeview(columns=car_header, show="headings")
        vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview)
        hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview)
        self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
        self.tree.grid(column=0, row=0, sticky='nsew', in_=container)
        vsb.grid(column=1, row=0, sticky='ns', in_=container)
        hsb.grid(column=0, row=1, sticky='ew', in_=container)
        container.grid_columnconfigure(0, weight=1)
        container.grid_rowconfigure(0, weight=1)
示例#7
0
 def AddTree(self, parent, name, columns):
     self.Widgets[name] = ttk.Treeview(parent, columns=columns)