当前位置: 首页>>代码示例>>Python>>正文


Python Treeview.insert方法代码示例

本文整理汇总了Python中ttk.Treeview.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.insert方法的具体用法?Python Treeview.insert怎么用?Python Treeview.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ttk.Treeview的用法示例。


在下文中一共展示了Treeview.insert方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
    def show(frame, iterator):
        """Выводит на экран выборку, заданную в iterator"""

        scrollbar = Scrollbar(frame)
        tree = Treeview(frame, selectmode='none', padding=3,
                                style='Custom.Treeview', height=REPORT_HEIGHT,
                                yscrollcommand=scrollbar.set)
        tree.pack(side=LEFT, fill=BOTH, expand=YES)
        scrollbar.config(command=tree.yview)
        scrollbar.pack(side=LEFT, fill=Y)

        tree.tag_configure('1', font=('Verdana', FONT_SIZE_REPORT))
        tree.tag_configure('2', font=('Verdana', FONT_SIZE_REPORT),
                                                           background='#f5f5ff')

        Style().configure('Custom.Treeview', rowheight=FONT_SIZE_REPORT*2)

        columns = ['#' + str(x + 1) for x in range(8)]
        tree.configure(columns=columns)

        for q in range(len(header)):
            tree.heading('#%d' % (q + 1), text=header[q], anchor='w')
            tree.column('#%d' % (q + 1), width=REPORT_SCALE * col_width[q + 1],
                                                                     anchor='w')
        tree.heading('#0', text='', anchor='w')
        tree.column('#0', width=0, anchor='w', minwidth=0)

        flag = True
        summ = 0
        for item in iterator:

            value = item.quantity * item.price * (100 - item.discount) / 100
            summ += value

            col = []
            col.append(add_s(item.check.id))
            col.append(add_s(item.goods.cathegory.name))
            col.append(add_s(item.goods.name))
            col.append(add_s(item.quantity))
            col.append(add_s(item.discount) +'%' if item.discount else ' -- ')
            col.append(add_s(u'%6.2f грн.' % value))
            col.append(add_s(item.check.date_time.strftime('%d.%m.%Y')))
            col.append(add_s(item.check.date_time.time())[:8])

            flag = not flag
            if flag:
                tree.insert('', 'end', text='', values=col, tag='2')
            else:
                tree.insert('', 'end', text='', values=col, tag='1')

        return summ
开发者ID:sychov,项目名称:conditer,代码行数:53,代码来源:report_make.py

示例2: __init__

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
    def __init__(self, parent, process, x, y):
        Toplevel.__init__(self, parent)
        self.wm_overrideredirect(True)
        self.wm_geometry("+%d+%d" % (x+25,y+20))
        label = Label(self, text="", justify='left',
                       background='white', relief='solid', borderwidth=1,
                       font=("times", "12", "normal"))
        label.pack(ipadx=20)
        tree = Treeview(label)
        tree["columns"] = ("value")
        tree.column("#0", minwidth=0, width=100)
        tree.column("#1", minwidth=0, width=100)
        tree.heading("#0", text="Name")
        tree.heading("#1", text="Value")

        for A, state in process.state.items():
            if isinstance(A, Algorithm):
                tree.insert("", 0, iid=A, text=str(A), values=("",))
                for key, val in state.items():
                    tree.insert(A, 0, text=key, values=(val,))
        for key, val in process.state.items():
            if not isinstance(key, Algorithm):
                tree.insert("", 0, text=key, values=(val,))
        tree.insert("", 0, text="UID", values=(process.UID,))
        tree.pack()
开发者ID:amin10,项目名称:datk,代码行数:27,代码来源:simulator_tk.py

示例3: FilamentReport

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
class FilamentReport(Toplevel):
	def __init__(self, app, printer, settings, logger, *arg):
		self.app = app
		self.printer = printer
		self.settings = settings
		self.logger = logger
		
		layers = self.app.gcodeInfo.layerOrder
		usage = self.app.gcodeInfo.filLayers

		self.selection = None
		
		Toplevel.__init__(self, app, *arg)
		self.title("Layer by Layer Filament Usage")
		self.protocol("WM_DELETE_WINDOW", self.doCancel)

		f = Frame(self)
		f.grid(row=1, column=1, rowspan=1, padx=10)

		self.tree = Treeview(self, height=12, selectmode='browse')
		self.sb = Scrollbar(self)
		self.sb.config(command=self.tree.yview)
		self.tree.config(yscrollcommand=self.sb.set)

		ln = []
		for l in layerinfo:
			ln.append(l[0])
		del ln[0]
		self.tree.config(columns=ln)
		
		for l in layerinfo:
			self.tree.column(l[0], width=l[1], anchor=l[2])
			self.tree.heading(l[0], text=l[3])

		self.sb.pack(side=RIGHT, fill=Y)
		self.tree.pack(side=LEFT, fill=BOTH, expand=1)

		prev = 0.0	
		tl = layers[-1]
		total = usage[tl]		
		for l in layers:
			n = usage[l]
			self.tree.insert('', 'end', text=l, values=("%7.3f" % (n-prev), "%9.3f" % n, "%9.3f" % (total-n)))
			prev = n

	def doCancel(self):
		self.app.closeFilamentReport()
开发者ID:jbernardis,项目名称:repraphost,代码行数:49,代码来源:reports.py

示例4: new_point

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
    def new_point(self):
        window = Toplevel(self)
        tree = Treeview(window)
        tree["columns"]=("1","2","3","4","5")
        tree.column("1", width=50)
        tree.column("2", width=50)
        tree.column("3", width=50)
        tree.column("4", width=50)
        tree.column("5", width=50)
        tree.heading("1", text="Played")
        tree.heading("2", text="Won")
        tree.heading("3", text="Lost")
        tree.heading("4", text="Points")
        
        rows = cur.execute('''SELECT * FROM point_table ORDER BY points DESC''')
        c = 0
        for row in rows:        
            tree.insert("" , c,text=str(row[1]), values=(row[2],row[3],row[4],row[5]))
            c+=1

        tree.pack()
开发者ID:meetsha,项目名称:Twitter-IPL,代码行数:23,代码来源:guinewest.py

示例5: __init__

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
class Display:
    def __init__(self, controller):
        self.controller = controller

        self.currIndex = 0

        # initialize the GUI
        self.app = Tk()
        self.app.title('Jack Magee\'s Pub')

        self.tree = Treeview(self.app, height=30)
        
        # name the tree columns, not sure if they have to be named numbers but that's how the example did it
        self.tree["columns"]=("one", "two", "three", "four")
        
        # set the column widths
        self.tree.column("one", width=200)
        self.tree.column("two", width=300)
        self.tree.column("three", width=200)
        self.tree.column("four", width=200)

        # set the column headings
        self.tree.heading("#0", text= "ID")
        self.tree.heading("one", text="Name")
        self.tree.heading("two", text="Order")
        self.tree.heading("three", text="Price")
        self.tree.heading("four", text="Respond (double-click)")

        self.tree.pack()
        
        # register handler for double-clicks
        self.tree.bind("<Double-1>", self.OnDoubleClick)

    def mainloop(self):
        self.app.mainloop()

    # this is like making tree entries buttons
    def OnDoubleClick(self, event):
        # get the pressed item
        item = self.tree.selection()[0]
        # get the item's text
        response =  self.tree.item(item,"text")

        # this is the only response we are sending for now
        if response == 'rdy':
            # get the parent directory whose text is the customer id
            parent = self.tree.parent(item)
            customer_id = self.tree.item(parent,"text")
            # remove it from the tree
            self.tree.delete(parent)
            # send the message to the customer
            self.controller.send_msg(customer_id, response)

    # add a new order to the tree
    def takeOrder(self, customer_id, name, order, price):
        # just a row identifier
        thisRow = str(self.currIndex)

        # insert the i.d. and name at the top level
        self.tree.insert("", self.currIndex, thisRow, text=customer_id, values=(name, "", "", ""))
        # insert the "button" for sending notification to clients
        self.tree.insert(thisRow, 0, text='rdy', values=("", "", "", "Ready For Pick Up"))

        # this is a hacky solution to get multiline orders to appear because treeviews will 
        # crop anything more than 1 line so I just make a new entry for every line
        multiline_order = order.split('\n')
        this_line = 1
        for line in multiline_order[:-1]:   # exclude the last end line
            if this_line == 1:  # the first line has the name of the order and it's price
                self.tree.insert(thisRow, 1, text="order",values=("", order, price, ""))
            else: # just keep printing the extra options, sides, and add ons
                self.tree.insert(thisRow, this_line, text="order",values=("", line, "", ""))
            this_line += 1

        self.currIndex += 1
开发者ID:dnav6987,项目名称:PubApp,代码行数:77,代码来源:GUI.py

示例6: Multicolumn_Listbox

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
class Multicolumn_Listbox(object):
    _style_index = 0

    class List_Of_Rows(object):
        def __init__(self, multicolumn_listbox):
            self._multicolumn_listbox = multicolumn_listbox

        def data(self, index):
            return self._multicolumn_listbox.row_data(index)
            
        def get(self, index):
            return Row(self._multicolumn_listbox, index)

        def insert(self, data, index=None):
            self._multicolumn_listbox.insert_row(data, index)

        def delete(self, index):
            self._multicolumn_listbox.delete_row(index)

        def update(self, index, data):
            self._multicolumn_listbox.update_row(index, data)

        def select(self, index):
            self._multicolumn_listbox.select_row(index)

        def deselect(self, index):
            self._multicolumn_listbox.deselect_row(index)

        def set_selection(self, indices):
            self._multicolumn_listbox.set_selection(indices)

        def __getitem__(self, index): 
            return self.get(index)

        def __setitem__(self, index, value): 
            return self._multicolumn_listbox.update_row(index, value)

        def __delitem__(self, index): 
            self._multicolumn_listbox.delete_row(index)

        def __len__(self): 
            return self._multicolumn_listbox.number_of_rows

    class List_Of_Columns(object):
        def __init__(self, multicolumn_listbox):
            self._multicolumn_listbox = multicolumn_listbox
        
        def data(self, index):
            return self._multicolumn_listbox.get_column(index)

        def get(self, index):
            return Column(self._multicolumn_listbox, index)

        def delete(self, index):
            self._multicolumn_listbox.delete_column(index)

        def update(self, index, data):
            self._multicolumn_listbox.update_column(index, data)

        def __getitem__(self, index): 
            return self.get(index)

        def __setitem__(self, index, value): 
            return self._multicolumn_listbox.update_column(index, value)

        def __delitem__(self, index): 
            self._multicolumn_listbox.delete_column(index)

        def __len__(self): 
            return self._multicolumn_listbox.number_of_columns

    def __init__(self, master, columns, data=None, command=None, sort=True, select_mode=None, heading_anchor = CENTER, cell_anchor=W, style=None, height=None, padding=None, adjust_heading_to_content=False, stripped_rows=None, selection_background=None, selection_foreground=None, field_background=None, heading_font= None, heading_background=None, heading_foreground=None, cell_pady=2, cell_background=None, cell_foreground=None, cell_font=None, headers=True):

        self._stripped_rows = stripped_rows

        self._columns = columns
        
        self._number_of_rows = 0
        self._number_of_columns = len(columns)
        
        self.row = self.List_Of_Rows(self)
        self.column = self.List_Of_Columns(self)
        
        s = Style()

        if style is None:
            style_name = "Multicolumn_Listbox%s.Treeview"%self._style_index
            self._style_index += 1
        else:
            style_name = style
        
        style_map = {}
        if selection_background is not None:
            style_map["background"] = [('selected', selection_background)]
            
        if selection_foreground is not None:
            style_map["foeground"] = [('selected', selection_foreground)]

        if style_map:
            s.map(style_name, **style_map)
#.........这里部分代码省略.........
开发者ID:jacob-carrier,项目名称:code,代码行数:103,代码来源:recipe-580746.py

示例7: WaitingRoom

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]

#.........这里部分代码省略.........
    def test(self):
        if self.pumpit:
            self.send_to_server("test")

    def chatToAll(self, e = None):
        """Chat to every player in the wroom"""
        """Get the chat entry and add it to the local log"""
        msgList = [self.chatentry.get()]
        if len(msgList[0]) is 0: return
        """Send message to server"""
        self.sendChatToAll(msgList = msgList)
        """Clear chat entry"""
        self.chatentry.delete(0, 'end')
        self.chatentry.focus_set()


    def buildTree(self, tree_list):
        def sortby(tree, col, descending):
            """Sort tree contents when a column header is clicked on"""
            # grab values to sort
            data = [(tree.set(child, col), child) \
                for child in tree.get_children('')]
            # now sort the data in place
            data.sort(reverse=descending)
            for ix, item in enumerate(data):
                tree.move(item[1], '', ix)
            # switch the heading so it will sort in the opposite direction
            tree.heading(col, command=lambda col=col: sortby(tree, col, int(not descending)))

        for ind, col in enumerate(self.tree_headers):
            self.tree.heading(ind, text=col.title(),command=lambda c=col: sortby(self.tree, c, 0))#
            # adjust the column's width to the header string
            #self.tree.column(col, width=tkFont.Font().measure(col.title()))
        """Convert Status and Game to a better format, then insert in Treeview"""
        convert_status = {0: "Idle", 1: "Ready", -1: "Playing", -2: "Solitaire"}
        for item in tree_list:
            item[1] = convert_status[item[1]]
            if item[3] is None: item[3] = ""
            self.tree.insert('', 'end', values=item)
            # adjust column's width if necessary to fit each value
            #import Tkinter.font as tkFont
            #for ix, val in enumerate(item):
                #col_w = tkFont.Font().measure(val)
            #if self.tree.column(selfcfg.wroominstance.tree_headers[ix],width=None)<col_w:
                #self.tree.column(selfcfg.wroominstance.tree_headers[ix], width=col_w)

    def addToMessageLog(self, listToLog, fg = 'black'):
        """Add a line to the log listbox"""
        for item in listToLog:
            self.log.insert(END, item)
            self.log.itemconfig(END, {'fg': fg})
        self.log.select_set(END)
        self.log.yview(END)

    def searchTreeByHeader(self, val, header = 'Player'):
        """Return item in Treeview by player name"""
        val = str(val)
        items = self.tree.get_children()
        headerIndToSearchInto = cfg.wroominstance.tree_headers.index(header) # ['Player','Status','Address']
        for item in items:
            itemval = str(self.tree.item(item, 'values')[headerIndToSearchInto])
            if itemval.startswith(val):
                return item
        return None

    def editItemInTree(self, item, valList, headerList = ['Player']):
开发者ID:aless80,项目名称:tantrix,代码行数:70,代码来源:waitingRoom.py

示例8: XML_Viwer

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]

#.........这里部分代码省略.........
        
        # Without this line, horizontal scrolling doesn't work properly.
        self._treeview.column("#0", stretch= False)

        self._vsb['command'] = self._treeview.yview
        self._hsb['command'] = self._treeview.xview

        self._treeview.grid(column=0, row=0, sticky=N+S+W+E)
        self._vsb.grid(column=1, row=0, sticky=N+S)
        self._hsb.grid(column=0, row=1, sticky=E+W)
        
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self._element_tree = None
        self._item_ID_to_element = {}

        if xml is not None:
            self.parse_xml(xml)

    def _on_open(self, event):
        item_ID = self._treeview.focus()
        if item_ID not in self._item_ID_to_element: return

        node = self._item_ID_to_element[item_ID]

        self._treeview.item(item_ID, text = self._repr_of_openning_tag(node))
        
    def _on_close(self, event):
        item_ID = self._treeview.focus()
        if item_ID not in self._item_ID_to_element: return

        node = self._item_ID_to_element[item_ID]
        
        text = self._repr_of_openning_tag(node) + self._repr_of_closing_tag(node)
        self._treeview.item(item_ID, text = text)

    def parse_xml(self, xml):
        self._element_tree = ET.ElementTree(ET.fromstring(xml))
        
        self.clear()
        self._walk_xml(self._element_tree.getroot())
        
    @property
    def element_tree(self):
        return self._element_tree
    
    @element_tree.setter
    def element_tree(self, element_tree):
        self._element_tree = element_tree
        
        self.clear()
        self._walk_xml(element_tree.getroot())   
        
    def clear(self):
        self._item_ID_to_element = {}
        self._treeview.delete(*self._treeview.get_children())
        
    def _repr_of_openning_tag(self, node):
        text = "<" + node.tag

        attrs = node.attrib
        
        # list function is here necessary to provide support to Python 3
        a_names = list(attrs.keys())
        a_names.sort()

        for a_name in a_names:
            text += ' %s="' % a_name
            text += attrs[a_name]
            text += '"'

        text += ">"
        return text
        
    def _repr_of_closing_tag(self, node):
        return "</%s>"%node.tag

    def _walk_xml(self, node, depth=0, parent=""):
        text = self._repr_of_openning_tag(node) + self._repr_of_closing_tag(node)

        item = self._treeview.insert(parent, END, text = text)
        self._item_ID_to_element[item] = node
        
        if node.text:
            text = node.text.strip()
            if text != "":
                for line in text.splitlines():
                    self._treeview.insert(item, END, text = line)

        child_nodes = sorted(list(node), key=attrgetter('tag'))
        for child_node in node:
            self._walk_xml(child_node, depth+1, parent=item)

        
        if node.tail:
            tail = node.tail.strip()
            if tail != "":
                for line in tail.splitlines():
                    self._treeview.insert(parent, END, text = line)
开发者ID:jacob-carrier,项目名称:code,代码行数:104,代码来源:recipe-580752.py

示例9: CommSearch

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
class CommSearch(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent        
        self.initUI()
        
    def initUI(self):

        self.entries_found = []

        self.parent.title("Search your command cards")
        self.style = Style()
        self.style.theme_use("default")        
        self.pack()
        
        self.input_title = Label(self, text="Enter your command below")
        self.input_title.grid(row=0, columnspan=2)
        self.input_box = Entry(self, width=90)
        self.input_box.grid(row=1, column=0)
        self.input_box.focus()
        self.input_box.bind("<Key>", self.onUpdateSearch)
        self.search_btn = Button(self, text="Search", command=self.onSearch)
        self.search_btn.grid(row=1, column=1)
        self.output_box = Treeview(self, columns=("Example"))
        ysb = Scrollbar(self, orient='vertical', command=self.output_box.yview)
        xsb = Scrollbar(self, orient='horizontal', command=self.output_box.xview)
        self.output_box.configure(yscroll=ysb.set, xscroll=xsb.set)
        self.output_box.heading('Example', text='Example', anchor='w')
        self.output_box.column("#0",minwidth=0,width=0, stretch=NO)
        self.output_box.column("Example",minwidth=0,width=785)
        self.output_box.bind("<Button-1>", self.OnEntryClick)
        self.output_box.grid(row=3, columnspan=2)
        self.selected_box = Text(self, width=110, height=19)
        self.selected_box.grid(row=4, columnspan=2)
        self.gotoadd_btn = Button(self, text="Go to Add", command=self.onGoToAdd)
        self.gotoadd_btn.grid(row=5)

    def OnEntryClick(self, event):
        try:
            item = self.output_box.selection()[0]
        except IndexError:
            pass
        entry_title = self.output_box.item(item,"value")
        for item in self.entries_found:
            if str(entry_title) == str("('" + item.title.strip('\n') + "',)"):
                self.selected_box.delete(0.1, END)
                self.selected_box.insert(END, item.text + '\n')

    def onUpdateSearch(self, key):
    # Somehow calling self.onSearch() does not register last key
    # And we need to correct "special chars"
        global entries, entries_map
        text_entries = ""
        for item in self.output_box.get_children():
            self.output_box.delete(item)		
    # ...like, for instance, deleting last character
        if key.char == '\b':
            search_terms = str(self.input_box.get()[:-1])
        else: 
            search_terms = str(self.input_box.get() + key.char)
        self.entries_found = []
        self.entries_found = data.Search(search_terms,entries,entries_map)
        for item in range(len(self.entries_found)):
            aux = self.output_box.insert('', 'end', '', value=[self.entries_found[item].title.split('\n')[0]])

			
    def onSearch(self):
        global entries, entries_map
        text_entries = ""
        for item in self.output_box.get_children():
            self.output_box.delete(item)
        search_terms = str(self.input_box.get())
        for item in data.Search(search_terms,entries,entries_map):
            self.output_box.insert('', 'end', '', value=[self.entries_found[item].title.split('\n')[0]])
			
    def onGoToAdd(self):
        newroot = Tk()
        newcomm = CommAdd(newroot)
        newroot.geometry("800x600+0+0")
        newroot.mainloop()
开发者ID:angelalonso,项目名称:comm,代码行数:84,代码来源:comm.py

示例10: Style

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
keywords=Treeview(rightPan)
keywords["columns"]=["Frequency"]
style = Style(root)
style.configure('Treeview', rowheight=29,font='arial 10 bold')

keywords.heading("#0", text="Word")
keywords.heading("Frequency", text="Frequency")
keywords.column("#0", anchor=tk.CENTER)
keywords.column("Frequency", anchor=tk.CENTER)
keywordIndex={}
top10Words=topWords[-10:]

tree_i=0
for index,row in top10Words.iteritems():
    treeind=keywords.insert(parent="",index=0,text=str(index), values=(str(row)))
    keywordIndex[tree_i]=treeind
    tree_i+=1
    
rightPan.add(keywords)
keywords.pack()


#Sample    
lab4 =tk.Label(rightPan, text="Categorization Sample",font='arial 10 bold')
rightPan.add(lab4)
lab4.pack()


scrollbar = tk.Scrollbar(rightPan)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
开发者ID:ght438,项目名称:Loki,代码行数:32,代码来源:gui_kristen.py

示例11: __init__

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
class SDCard: 
	def __init__(self, root, prtr, settings, log):
		self.app = root
		self.printer = prtr
		self.settings = settings
		self.log = log
		self.top = None

	def isActive(self):
		return self.top != None

	def start(self):
		self.app.sdchecking = True
		self.printer.send_now("M21")
		
	def sdCheckComplete(self, ready):
		if not ready:
			self.log.logMsg("Error initializing SD card")
		else:
			self.app.sdlisting = True
			self.printer.send_now("M20")
			
	def refresh(self):
		self.top.destroy()
		self.app.sdlisting = True
		self.printer.send_now("M20")
			
	def sdListComplete(self, sdlist):
		top = self.top = Toplevel(self.app) 
		top.title("SD Card Control")
		top.protocol('WM_DELETE_WINDOW', self.delTop)
		f = Frame(top, height=150, width=150)
		f.grid(row=1, column=1);
		self.tree = Treeview(f, height=12, selectmode='browse') 
		self.tree.column("#0", minwidth=100)
		self.tree.bind("<<TreeviewSelect>>", self.treeSelect)
		self.sb = Scrollbar(f)
		self.sb.config(command=self.tree.yview)
		self.tree.config(yscrollcommand=self.sb.set)
			
		self.sb.pack(side=RIGHT, fill=Y)
		self.tree.pack(side=LEFT, fill=BOTH, expand=1)

		SDroot = SDDir('')
		for item in sdlist:
			if item.startswith('/'):
				cd = SDroot
				l = item[1:].split('/')
				for d in l[:-1]:
					ncd = cd.getDir(d)
					if ncd == None:
						ncd = cd.addDir(d)
			
					cd = ncd
				cd.addFile(l[-1], fqn=item)
					
			else:
				SDroot.addFile(item)
				
		SDroot.sortAll()
		
		self.fileMap = {}
		self.startFile = None
		self.loadDir(SDroot, '')
		bf = Frame(top, width=50)
		bf.grid(column=3, row=1)
		
		blf = LabelFrame(bf, text="Print from SD Card", width=48, height=40)
		
		self.bPrint = Button(blf, text='Print', command=self.doPrint, width = 6) 
		self.bPrint.pack()
		blf.pack(fill='x')
		
		blf = LabelFrame(bf, text="Delete from SD Card", width=48, height=40)
		
		self.bDelete = Button(blf, text="Delete", command=self.doDelete, width=6)
		self.bDelete.pack()
		blf.pack(fill='x')
		
		blf = LabelFrame(bf, text="Upload to SD Card", width=48, height=180)

		self.upDir = Label(blf, text="Dir:", justify=LEFT)
		self.upDir.pack()

		ef = Frame(blf)

		l = Label(ef, text="File:", justify=LEFT)
		l.pack(side=LEFT)

		self.entry = Entry(ef, width=12)
		self.entry.pack(side=LEFT)
		fn = 'untitled.g'
		if self.app.GCodeFile:
			fn = os.path.basename(self.app.GCodeFile)
			if len(fn) > 8:
				fn = fn[0:8]
			fn += ".g"
		self.entry.delete(0, END)
		self.entry.insert(0, fn)
		ef.pack()
#.........这里部分代码省略.........
开发者ID:jbernardis,项目名称:repraphost,代码行数:103,代码来源:sdcard.py

示例12: SnakeLog

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
class SnakeLog(Frame):

    def createMenubar(self, master):
        self.menubar = Menu(root)

        self.filemenu = Menu(self.menubar, tearoff=0)

        self.importmenu = Menu(self.filemenu)
        self.importmenu.add_command(label="from ADIF...", command=None)

        self.exportmenu = Menu(self.filemenu)
        self.exportmenu.add_command(label="to ADIF...", command=None)
        self.exportmenu.add_command(label="to Cabrillo...", command=None)

        self.filemenu.add_command(label="Open log...", command=None)
        self.filemenu.add_command(label="Save log as...", command=None)
        self.filemenu.add_separator()
        self.filemenu.add_cascade(label="Export", menu=self.exportmenu)
        self.filemenu.add_cascade(label="Import", menu=self.importmenu)
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Exit", command=None)

        self.menubar.add_cascade(label="File", menu=self.filemenu)

        master.config(menu=self.menubar)

    def createQSOView(self, master):
        self.qsoviewScrollbar = Scrollbar(master)
        self.qsoview = Treeview(master, show=('headings'),
                                yscrollcommand=self.qsoviewScrollbar.set)


        self.qsoviewfields = {'day':            {'name': "D", 'width': 10},
                              'month':          {'name': "M", 'width': 10},
                              'year':           {'name': "Y", 'width': 20},
                              'timeon':         {'name': "Time", 'width': 30},
                              'timeoff':        {'name': "Timeoff", 'width': 30},
                              'band':           {'name': "Band", 'width': 20},
                              'freq':           {'name': "Frequency", 'width': 50},
                              'mode':           {'name': "Mode", 'width': 25},
                              'call':           {'name': "Call", 'width': 50},
                              'srst':           {'name': "S RST", 'width': 25},
                              'rrst':           {'name': "R RST",'width': 25},
                              'name':           {'name': "Name",'width': 40},
                              'grid':           {'name': "Gridsquare",'width': 30},
                              'iota':           {'name': "IOTA", 'width': 30},
                              'qsls':           {'name': "Q S",'width': 25},
                              'qsls_date':      {'name': "Q S D",'width': 50},
                              'qslr':           {'name': "Q R",'width': 25},
                              'qslr_date':      {'name': "Q R D",'width': 50},
                              'lotw_qsls':      {'name': "LQ S",'width': 25},
                              'lotw_qsls_date': {'name': "LQ S D",'width': 50},
                              'lotw_qslr':      {'name': "LQ R",'width': 25},
                              'lotw_qslr_date': {'name': "LQ R D",'width': 50}}


        self.qsoviewdisplayesfields = ('day', 'month', 'year', 'timeon',
                                       'band', 'freq', 'mode', 'call',
                                       'srst', 'rrst', 'name', 'grid',
                                       'iota', 'qsls', 'qsls_date', 'qslr',
                                       'qslr_date', 'lotw_qsls', 'lotw_qsls_date', 'lotw_qslr',
                                       'lotw_qslr_date')


        self.qsoview["columns"] = self.qsoviewfields.keys()
        self.qsoview["displaycolumns"] = self.qsoviewdisplayesfields


        self.qsoview.column(0, width=40)
        for columnname, data in self.qsoviewfields.items():
            # set columnwidth for QSOView
            self.qsoview.column(columnname, width=data['width'])
            # set QSOView headers
            self.qsoview.heading(columnname, text=data['name'])

        for i in range(400):
            self.qsoview.insert('', 'end', str(i), values=(str(i), 'bar'+str(i)))

        self.qsoviewScrollbar.config(command=self.qsoview.yview)

        self.qsoviewScrollbar.grid(column=1, row=0, sticky=(N,S))
        self.qsoview.grid(column=0, row=0, sticky=(N,S,E,W))

        master.columnconfigure(0, weight=1)
        master.rowconfigure(0, weight=1)

    def __init__(self, master=None):

        master.columnconfigure(0, weight=1)
        master.rowconfigure(0, weight=1)

        self.mainFrame = Frame.__init__(self, master)

        self.grid(sticky=(N,S,E,W))
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        self.createMenubar(master)

        self.qsoFrame = Frame(self.mainFrame)
#.........这里部分代码省略.........
开发者ID:richtma,项目名称:snakeLog,代码行数:103,代码来源:snakeLog.py

示例13: MacroFrame

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]
class MacroFrame(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")
        self.parent = parent
        self.numStates = 0
        self.initUI()

    def initUI(self):
        self.columnconfigure(0, weight=0)
        self.columnconfigure(1, weight=0)
        self.columnconfigure(2, weight=1)
        self.columnconfigure(3, weight=1)

        self.rowconfigure(0, weight=1)

        self.commandFrame = Frame(self, background="white")
        self.commandFrame.grid(row=0, column=0, columnspan=5, sticky=W + E)
        self.commandFrame.columnconfigure(1, weight=1)

        self.btnCommand = Button(self.commandFrame, text="Run")
        self.btnCommand.grid(row=0, column=0)

        self.strCommand = StringVar()
        self.entCommand = Entry(self.commandFrame, textvariable=self.strCommand)
        self.entCommand.grid(row=0, column=1, sticky=W + E)

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

        self.treeview = Treeview(self, columns=("Angle"), displaycolumns="#all", selectmode="browse")
        self.treeview.grid(row=1, column=1, columnspan=4, sticky=N + S + W + E)
        self.treeScrollbar = Scrollbar(self)
        self.treeScrollbar.grid(row=1, column=5, sticky=N + S)
        self.treeview.config(yscrollcommand=self.treeScrollbar.set)
        self.treeScrollbar.config(command=self.treeview.yview)

        self.btnFrame = Frame(self, background="white")
        self.btnFrame.grid(row=2, column=0, columnspan=5, sticky=W + E)

        self.btnRun = Button(self.btnFrame, text="Run", command=self.runMacro)
        self.btnRun.grid(row=0, column=0)

        self.btnStop = Button(self.btnFrame, text="Stop")
        self.btnStop.grid(row=0, column=1)

        self.btnSaveMacro = Button(self.btnFrame, text="Save Macro", command=self.saveMacro)
        self.btnSaveMacro.grid(row=0, column=2)

        self.btnDeleteMacro = Button(self.btnFrame, text="Delete Macro")
        self.btnDeleteMacro.grid(row=0, column=3)

        self.btnDeleteState = Button(self.btnFrame, text="Delete State")
        self.btnDeleteState.grid(row=0, column=4)

    def addState(self, robot):
        stateName = "state" + str(self.numStates)
        self.treeview.insert("", END, iid=stateName, text=stateName)
        limbNum = 0
        for limb in robot.getLimbs():
            limbName = "limb" + str(limbNum)
            self.treeview.insert(stateName, END, iid=stateName + "_" + limbName, text=limbName)
            partNum = 0
            for part in limb.getComponents():
                partName = "joint" + str(partNum)
                if isinstance(part, Joint):
                    self.treeview.insert(
                        stateName + "_" + limbName,
                        END,
                        iid=stateName + "_" + limbName + "_" + partName,
                        text=partName,
                        values=[part.angle],
                    )
                    partNum += 1
            limbNum += 1
        self.numStates += 1

    def getState(self, stateNum, robot):
        stateName = "state" + str(stateNum)
        limbNum = 0
        for limb in robot.getLimbs():
            limbName = "limb" + str(limbNum)
            partNum = 0
            for part in limb.getComponents():
                partName = "joint" + str(partNum)
                if isinstance(part, Joint):
                    part.setAngle(int(self.treeview.item(stateName + "_" + limbName + "_" + partName, "values")[0]))
                    partNum += 1
            limbNum += 1

    def runMacro(self):
        thread = threading.Thread(target=self.updateState)
        thread.start()

    def updateState(self):
        for i in range(self.numStates):
            self.getState(i, self.parent.robotFrame.robot)
            time.sleep(0.1)

    def saveMacro(self):
        pass
开发者ID:demetraux,项目名称:Octopod,代码行数:102,代码来源:gui.py

示例14: Statistics

# 需要导入模块: from ttk import Treeview [as 别名]
# 或者: from ttk.Treeview import insert [as 别名]

#.........这里部分代码省略.........
		
		self.orderby = orderby		

		Button(paramframe,text="Вывести",command=(lambda: self.getStatistics())).grid(row=6,column=0,columnspan=2)		

		Label(paramframe,text="Итого: ",height=20).grid(row=7,column=0)
		self.summarylbl = Label(paramframe,text='0.0',height=20)
		self.summarylbl.grid(row=7,column=1)


	#end ------------------------------------------------------------------------------------------------------------------
		
	#table -------------------------------------------------------------------------------------------------------------
		
		self.viewframe = Frame(self,relief=GROOVE,width=200,bd=1)
		self.viewframe.pack(side=RIGHT,fill=BOTH,expand=YES)

	#end ------------------------------------------------------------------------------------------------------------------

		self.geometry("%dx%d+%d+%d" % (1000,500,225,125))
		self.wait_window(self)
	
	def getStatistics(self):
		when = self.when.current()
		dateRange = ''
		
		if when == 0:
		#today
			dateRange = datetime.date.today()
		elif when == 1:
		#3 days
			dateRange = datetime.date.today() - datetime.timedelta(days=3)
		elif when == 2:
		#5 days
			dateRange = datetime.date.today() - datetime.timedelta(days=5)
		elif when == 3:
		#1 week
			dateRange = datetime.date.today() - datetime.timedelta(weeks=1)
		elif when == 4:
		#3 weeks
			dateRange = datetime.date.today() - datetime.timedelta(weeks=3)
		elif when == 5:
		#1 month
			dateRange = datetime.date.today() - datetime.timedelta(weeks=4)
		elif when == 6:
		#all 
			dateRange = '2012-01-01'
		
		orderby = self.orderby.current()
		if orderby == 0:
		#date
			orderby = 4
		elif orderby == 1:
		#summ
			orderby = 2
		elif orderby == 2:
		#c.title
			orderby = 6
			
		global payments
		payments.getPayments(1,str(dateRange))
		
		if hasattr(self, 'tree'):
			self.tree.destroy()
			
		self.tree = Treeview(self.viewframe,selectmode="extended",columns=('summ', 'comment', 'date','mul','category_title'))
		self.tree.heading('#0',text='№')
		self.tree.column('#0',width=15,anchor='center')
		
		
		self.tree.column('summ', width=60, anchor='center')
		self.tree.column('comment', anchor='center')
		self.tree.column('date', width=60, anchor='center')
		self.tree.column('mul', width=7, anchor='center')
		self.tree.column('category_title',  anchor='center')
		
		self.tree.heading('summ', text='Сумма')
		self.tree.heading('comment', text='Комметарий')
		self.tree.heading('date', text='Дата')
		self.tree.heading('mul', text='Количество')
		self.tree.heading('category_title', text='Категория')
		
		i=1
		summary = 0.0
		for row in payments.paymetsList:
			self.tree.insert('', i,str(i), text=str(i))
			self.tree.set(str(i),'summ',row['summ'])
			self.tree.set(str(i),'comment',row['comment'])
			self.tree.set(str(i),'date',row['date'])
			self.tree.set(str(i),'mul',row['mul'])
			self.tree.set(str(i),'category_title',row['category_title'])
			i+=1
			summary+=row['summ']*row['mul']
		
		self.summarylbl.config(text=str(summary))
		self.tree.pack(side=TOP, fill=BOTH, expand=YES)
		
		s = Scrollbar(self.tree, orient=VERTICAL, command=self.tree.yview)
		self.tree.configure(yscrollcommand=s.set)
		s.pack(side=RIGHT,fill=Y)
开发者ID:xenon4er,项目名称:trytkinter,代码行数:104,代码来源:tk.py


注:本文中的ttk.Treeview.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。