本文整理汇总了Python中tkinter.ttk.Treeview.heading方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.heading方法的具体用法?Python Treeview.heading怎么用?Python Treeview.heading使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.heading方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Mk_Book_display
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
def Mk_Book_display(book, name):
w = book.page(name)
disp = Frame(w)
tree_columns = ('book_no', 'book_name', 'book_author', 'book_publisher', 'in_out_status')
Entries=Treeview( disp,
columns=tree_columns,
show="headings"
)
global_bucket['book_shelf'] = Entries
vsb = Scrollbar ( disp,
orient="vertical",
command=Entries.yview)
Entries.configure(yscrollcommand=vsb.set)
for col,width in zip(tree_columns,(4,20,10,5,6)):
Entries.heading(col, text=col.title(), anchor='w')
Entries.column(col, width=1)
vsb.pack(side=RIGHT,fill=Y)
Entries.pack(fill=BOTH, expand=1)
disp.pack(fill=BOTH, expand=1)
update()
示例2: per
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class per():
def __init__(self,data,y,v='план'):
w=Toplevel()
w.wm_title('Доп')
w.columnconfigure(0,weight=1)
w.rowconfigure(0,weight=1)
years=sorted(data.keys())
cols=data['2013']['degurs'] # ЗАГЛУШКА : список дежурных
self.t=Treeview(w,columns=cols)
for c in cols:
self.t.heading(c,text=c)
self.t.column(c,width=65,anchor='center')
self.t.tag_configure('табель',background='green')
self.t.tag_configure('ош',background='red')
#self.t.tag_configure('табель',background='green')
self.scrX=Scrollbar(w,orient='horizontal',command=self.t.xview)
self.scrY=Scrollbar(w,orient='vertical',command=self.t.yview)
self.t['xscrollcommand']=self.scrX.set
self.t['yscrollcommand']=self.scrY.set
self.t.grid(row=0,column=0,sticky=N+S+E+W)
self.scrX.grid(row=1,column=0,sticky=E+W)
self.scrY.grid(row=0,column=1,sticky=N+S)
for y in years:
x=self.t.insert('','end',text=y)
eeY=[]
for m in ['01','02','03','04','05','06','07','08','09','10','11','12']:
d0=data[y]
if m not in d0: continue
d=d0[m]
rez=dict()
tag=''
if v=='авто':
if 'табель' in d['degur']:
vv='табель'
tag=vv
else:
vv='план'
elif v=='табель':
if 'табель' not in d['degur']:
vv='план'
tag='ош'
else:
vv=v
tag=vv
else:
vv=v
for j,s in d['degur'][vv].items():
rez[j]=analyse2(s,d)
NUL=(0,0,0,0,0,0,0)
ee=[rez.get(j,NUL)[0]-rez.get(j,NUL)[3]+rez.get(j,NUL)[4] for j in cols]
eeY.append(ee)
self.t.insert(x,'end',text=m,values=[x or '-' for x in ee],tag=tag)
eeY=[sum(x) for x in zip(*eeY)]
self.t.insert(x,'end',text='итого',values=eeY,tag='Y')
示例3: CreateUI
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
def CreateUI(self, classInstance):
self.headers = [
"Customers",
"Inter-arrival time",
"Arrival time",
"Service time",
"Waiting time in queue",
"Time when service begins",
"Time when service ends",
"Time customer spends in system",
"Idle time of server"
]
self.contents =[]
# populates the table from other class to generate the tkinter table
def compilelist(classInstance):
self.contents.append(classInstance.intarrival())
self.contents.append(classInstance.arrival())
self.contents.append(classInstance.service())
self.contents.append(classInstance.queuewait())
self.contents.append(classInstance.servbegin())
self.contents.append(classInstance.servend())
self.contents.append(classInstance.custspend())
self.contents.append(classInstance.idle())
return self.contents
# Calling the function
compilelist(classInstance)
self.rearrange = []
for row in zip(*self.contents):
self.rearrange.append(row)
self.headdata = []
for x in range(len(self.contents[0])):
self.headdata.append(x+1)
header_lists = []
tv = Treeview(self)
tv['columns'] = (self.headers)
for x in range(len(self.headers)):
tv.heading("#%s"%x, text=self.headers[x], anchor='center')
tv.column ("#%s"%x, anchor='center', width="150")
tv.grid(sticky = (N,S,W,E))
self.treeview = tv
self.grid_rowconfigure(0, weight = 1)
self.grid_columnconfigure(0, weight = 1)
示例4: DeviceToFrame
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class DeviceToFrame(CopilotInnerFrame):
def __init__(self, master, config, state):
super(DeviceToFrame, self).__init__(master, config)
self._state = state
if self._state.action == 'copy':
self._frame_lbl['text'] = 'Copy To Directory'
elif self._state.action == 'delete':
self._frame_lbl['text'] = 'Delete From Directory'
self._next_btn['command'] = self._next_cmd
self._tree = Treeview(self._master, columns=('size'))
self._tree.heading('size', text='Size')
self._tree.grid(row=1, column=0, columnspan=3, sticky='nsew')
self._tree.configure(yscrollcommand=self._sb.set)
self._sb['command'] = self._tree.yview
self._item_paths = {}
self._populate_tree(self._state.to_device.part().mount())
def _next_cmd(self):
cur_item = self._tree.focus()
cur_path = self._item_paths.get(cur_item, '')
if cur_path != '':
self._state.device_to_path = cur_path
self._new_state_window(CopyFileFrame, self._state)
def _populate_tree(self, tree_root):
self._item_paths = {}
def insert_path(tree, path, parent_id):
dirs = [e for e in scandir(path) if e.is_dir()]
dirs.sort(key=lambda e: e.name)
for d in dirs:
dir_name = d.name
dir_id = '{}-{}'.format(parent_id, dir_name)
dir_path = os.path.join(path, dir_name)
tree.insert(parent_id, 'end', dir_id, text=dir_name, tags=('dir'))
self._item_paths[dir_id] = dir_path
try:
insert_path(tree, dir_path, dir_id)
except:
pass
insert_path(self._tree, tree_root, '')
tree = self._tree
tree.tag_configure('dir', font=self._config.item_font)
tree.tag_configure('file', font=self._config.item_font)
tree.tag_configure('file_odd', background='light grey')
示例5: Table
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class Table(Frame):
def __init__(self, parent, title, columns):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.title_lbl = Label(self, text=title, font=GENERAL_FONT)
self.table_tree = Treeview(self, columns=columns)
# добавить Scrollbar
self.scroll = Scroll(self, orient=VERTICAL, command=self.table_tree.yview)
self.table_tree['yscroll'] = self.scroll.set
for i in range(len(columns)):
self.table_tree.heading(columns[i], text=columns[i])
self.place_widgets()
def place_widgets(self):
self.title_lbl.pack(side=TOP, fill=X, expand=YES)
self.table_tree.pack(side=LEFT, fill=BOTH, expand=YES)
self.scroll.pack(side=RIGHT, fill=Y, expand=YES)
示例6: Mk_Status_display
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
def Mk_Status_display(book, name):
w = book.page(name)
disp = Frame(w)
tree_columns = ('book_no', 'book_name', 'date', 'staff_id', 'staff_name', 'note')
Entries=Treeview( disp,
columns=tree_columns,
show="headings",
)
global_bucket['status_register'] = Entries
vsb = Scrollbar ( disp,
orient="vertical",
command=Entries.yview)
Entries.configure(yscrollcommand=vsb.set)
for col in tree_columns:
Entries.heading(col, text=col.title(), anchor='w')
Entries.column(col, width=0)
vsb.pack(side=RIGHT,fill=Y)
Entries.pack(fill=BOTH, expand=1)
disp.pack(fill=BOTH, expand=1)
update()
示例7: BioInfo
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class BioInfo(Tk):
def __init__(self):
Tk.__init__(self)
self.wm_title("BioInfo : comparaison des listes")
self.resizable(width=FALSE, height=FALSE)
self.SortDir = False
# Lists Types
self.typeList1 = None
self.typeList2 = None
# Frame content
self.frameContent = Frame(self)
self.frameContent.pack(side=TOP, fill=X)
# ScrollBar
scrollbar = Scrollbar(self.frameContent, orient=VERTICAL)
scrollbar.pack(side=RIGHT, fill=Y)
# Result Content
self.dataCols = ('microArn_A', 'microArn_B', 'FoldC', 'p-Value', 'Note')
self.tree = Treeview(self.frameContent, columns=self.dataCols, show = 'headings', yscrollcommand=scrollbar.set)
# configure column headings
for c in self.dataCols:
self.tree.heading(c, text=c, command=lambda c=c: self.columnSort(c, self.SortDir))
self.tree.column(c, width=10)
self.tree.pack(side=LEFT, fill=X, expand="yes")
scrollbar.config(command=self.tree.yview)
# Frame Lists
self.frameLists = Frame(self)
self.frameLists.pack(side=LEFT)
# Frame Forms
self.frameForms = Frame(self)
self.frameForms.pack(side=LEFT, padx=20)
#Liste n°1 selection
self.frameList1 = Frame(self.frameLists)
self.frameList1.pack()
self.typeListStr1 = StringVar(self.frameList1)
self.typeListStr1.set(str(ListBioType.TypeA))
self.buttonTypeList1 = OptionMenu(self.frameList1, self.typeListStr1, str(ListBioType.TypeA), str(ListBioType.TypeB)).pack(side=LEFT)
self.entrylist1 = Entry(self.frameList1, width=30)
self.entrylist1.pack(side=LEFT)
self.buttonBrowseList1 = Button(self.frameList1, text="Parcourir", command=self.load_fileList1, width=10)
self.buttonBrowseList1.pack(side=LEFT, padx=5)
# List n°2 selection
self.frameList2 = Frame(self.frameLists)
self.frameList2.pack(side=BOTTOM)
self.typeListStr2 = StringVar(self.frameList2)
self.typeListStr2.set(str(ListBioType.TypeB))
self.buttonTypeList2 = OptionMenu(self.frameList2, self.typeListStr2, str(ListBioType.TypeA), str(ListBioType.TypeB)).pack(side=LEFT)
self.entrylist2 = Entry(self.frameList2, width=30)
self.entrylist2.pack(side=LEFT)
self.buttonBrowseList2 = Button(self.frameList2, text="Parcourir", command=self.load_fileList2, width=10)
self.buttonBrowseList2.pack(side=LEFT, padx=5)
# Form pValue
self.framePVal = Frame(self.frameForms)
self.framePVal.pack()
Label(self.framePVal, text="pValue").pack(side=LEFT)
self.entryPVal = Entry(self.framePVal, width=6)
self.entryPVal.pack(side=LEFT)
# Form foldC
self.frameFoldC = Frame(self.frameForms)
self.frameFoldC.pack()
Label(self.frameFoldC, text="foldCh").pack(side=LEFT)
self.entryFoldC = Entry(self.frameFoldC, width=6)
self.entryFoldC.pack(side=LEFT)
# Form note
self.frameNote = Frame(self.frameForms)
self.frameNote.pack()
Label(self.frameNote, text="note ").pack(side=LEFT)
self.entryNote = Entry(self.frameNote, width=6)
self.entryNote.pack(side=LEFT)
# Bouton comparer
self.buttonComparer = Button(self, text="Comparer", command=self.compare, width=10, state=DISABLED)
self.buttonComparer.pack(fill= X, expand="yes", padx=20, pady=(10,0))
#Bouton exporter
self.buttonExport = Button(self, text="Exporter", command=self.export, width=10, state=DISABLED)
#.........这里部分代码省略.........
示例8: Expenses
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
#.........这里部分代码省略.........
return self.successful()
# Displays a success message when the item is added
def successful(self):
self.master.title("%s was added successfully!" % self.item.name)
succMessage = Message(root, text = "%s was successfully added to the %s list!" % (self.item.name, self.item.itemType))
succMessage.place(x = 150, y = 150)
startOverButton = Button(root, text = "Start Over", command=lambda: self.sequence(self.createOptionButtons))#self.saveNameAndType(itemName)))#(self.saveNameAndType(itemName))) # (itemName)))# lambda: self.sequence(self.test)) #This button will send the user to the add inventory page
startOverButton.place(x = 150, y = 350)
# Used to view the inventory
def viewInveroty(self):
# Creates the label called chooseTypeLabel and a drop down menu called chooseItemType
chooseTypeLabel = Label(root, text = "Item's type: ")
chooseTypeLabel.place(x = 110, y = 160)
self.chooseItemType = StringVar(root) # The drop down menu is created and assigned to chooseItemType
self.chooseItemType.set("Tree") # Tree is set to the default option in the drop down menu
typeChoices = OptionMenu(root, self.chooseItemType, "Tree", "Animal", "Machine", "All") # Options Tree, Animal, Machine, and ALL are added to the drop down menu
typeChoices.place(x = 190, y = 160)
backButton = Button(root, text = "Back", command=lambda: self.sequence(self.createOptionButtons)) # This button will return the user to the expenses option page
backButton.place(x = 50, y = 350)
nextButton = Button(root, text = "Next", command=lambda: self.sequence(self.displayGeneralInventory))#self.saveNameAndType(itemName)))#(self.saveNameAndType(itemName))) # (itemName)))# lambda: self.sequence(self.test)) #This button will send the user to the add inventory page
nextButton.place(x = 350, y = 350)
# Used to create the inventory table
def displayGeneralInventory(self):
# This creates a table using the function Treeview
self.tree = Treeview(height="20", columns=("Name", "Current Quantity"))
self.tree.pack()
self.tree.heading('#1', text = "Name", anchor = CENTER)
self.tree.heading('#2', text = "Current Quantity", anchor = CENTER)
self.tree.column('#1', minwidth=0, width = 100)
self.tree.column('#2', minwidth=0, width = 100)
self.tree.column('#0', minwidth=0, width = 0)
itemType = self.chooseItemType.get()
if(itemType == "All"):
self.obtainData("Tree")
self.obtainData("Animal")
self.obtainData("Machine")
else:
self.obtainData(itemType)
# Adds database data to the inventory table
def obtainData(self, type):
for row in (self.inventoryDB.getOverviewInventory(type)):
name = row[0]
totalQuantity = row[1]
# Inserts data into the table. Each entry is tagged with the name and the type
# This is done in order to make identifying the entries easier for when detailed
# tables are requested
self.tree.insert("", "end", values = (name,totalQuantity), tag= [name, type])
# Creates a bak function that is used in the displayGeneralInventory functions
self.backFunction = self.displayGeneralInventory
# Binds a double click function to the Treeview table. If an entry is double clicked,
# the function displayGeneralInventory is ran
self.tree.bind("<Double-1>", self.displayDetailedInventory)
示例9: Gui
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class Gui(Interface):
"""The GUI interface uses the tkinter module to generate
a window using tk
"""
TREE_COLUMNS = ("Number of probes : {nProbes}", "Probe address", "Status")
RESULT_DIPLAY_HEIGHT = 10
def __init__(self, ip):
Interface.__init__(self, ip)
self.commandHistory = []
self.mainWin = Tk()
self.command = StringVar(self.mainWin)
self.status = StringVar(self.mainWin, value="Waiting for command ...")
self.text = StringVar(self.mainWin, value="Enter a command :")
self.result = None
self.probesDisplay = None
self.mainWin.title("Commander for probe with ip : " + ip)
self.isRunning = True
self.mainWin.protocol("WM_DELETE_WINDOW", self.quit)
# define the threads
self.thProbe = Thread(target=self.updateProbes, name="Probe updater", daemon=True)
self.thResults = Thread(target=self.updateResults, name="Results Updater", daemon=True)
def start(self):
"""Starts (opens) the commander window"""
self.mainWin.geometry("800x600")
txtText = Label(self.mainWin, textvariable=self.text)
txtText.grid(row=0, column=0, sticky=W)
txtInput = Entry(self.mainWin, textvariable=self.command, width=30)
txtInput.grid(row=0, column=1, sticky=E + W)
txtInput.bind("<Return>", self.doCommand)
txtInput.bind("<Up>", self.recallCommand)
button = Button(self.mainWin, text="Refresh", fg="blue", command=self.triggerFetchProbes)
button.grid(row=1, column=0, sticky=N + S + E + W)
txtStatus = Label(self.mainWin, textvariable=self.status, wraplength=600, justify=CENTER)
txtStatus.grid(row=1, column=1, sticky=N + S + E + W)
self.probesDisplay = Treeview(self.mainWin, columns=self.TREE_COLUMNS, show="headings")
self.probesDisplay.grid(row=2, columnspan=2, sticky=N + S + E + W)
for i in range(0, len(self.TREE_COLUMNS)):
self.updateHeading(i, nProbes=0)
self.result = Text(self.mainWin, textvariable=self.result, height=self.RESULT_DIPLAY_HEIGHT, wrap=WORD)
self.result.configure(state=DISABLED)
self.result.grid(row=3, columnspan=2, sticky=N + S + E + W)
self.addResult("Awaiting results .... ")
self.mainWin.grid_rowconfigure(2, weight=1)
self.mainWin.grid_columnconfigure(1, weight=1)
self.probeFetcherScheduler()
self.thProbe.start()
self.resultFetcherScheduler()
self.thResults.start()
self.logger.info("Commander : Starting main window")
self.mainWin.mainloop()
self.logger.debug("Commander : mainloop over")
def recallCommand(self, event):
"""Function to rewrite previous command in box"""
if len(self.commandHistory) != 0:
self.command.set(self.commandHistory[-1])
return "break"
def doCommand(self, event):
"""Executes user command"""
self.commandHistory.append(self.command.get())
self.logger.info("Commander : executing command")
cmd = super().doCommand(self.command.get())
# cmd.join()
self.command.set("")
def updateStatus(self, status):
"""Update status of the probe in status label
:param status: new status"""
self.status.set(status)
self.mainWin.update_idletasks()
def addResult(self, result):
"""Add (prepend) a result in the result test area
:param result: the result to add
"""
self.result.configure(state=NORMAL)
self.result.insert("1.0", result + "\n")
self.result.configure(state=DISABLED)
def setResult(self, result):
"""Put this result in the result area
:param result: result to put
"""
self.result.configure(state=NORMAL)
#.........这里部分代码省略.........
示例10: hyGUI
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
#.........这里部分代码省略.........
self._worstItemButton = Button(self, text="Worst Item Sold", command=self._worstItem)
self._worstItemButton.pack()
self._resultVar = StringVar()
self._resultLabel = Label(self, text=" \n ", textvariable=self._resultVar)
self._resultLabel.pack()
## Best sales per game button
self._itemButton = Button(self, text="Game for best Sales", command=self._item)
self._itemButton.pack()
## this button is not packed but, it is needed to populate the table
self._tableButton = Button(self, text = "Show the Complete table", command =self._maketable())
self._resultVar = StringVar()
self._resultLabel = Label(self, text=" \n ", textvariable=self._resultVar)
self._resultLabel.pack()
## Using empty sting label to display the different text on GUI Frame when clicking button
self.resultBestLabel = Label(self, text = "")
self.resultBestLabel.pack()
self._treeview['columns']=('location', 'date', 'no_hats', 'val_hats', 'no_jerseys', 'val_jerseys',
'no_hockstick', 'val_hockstick', 'no_posters', 'val_posters','total_sales')
## Creating a columns name heading for the table
self._treeview.heading('location', text = "Location")
self._treeview.column('#0', width = 0)
self._treeview.heading('date', text = "Date")
self._treeview.heading('no_hats', text = "# hats")
self._treeview.heading('val_hats', text = "$ hats")
self._treeview.heading('no_jerseys', text = "# jerseys")
self._treeview.heading('val_jerseys', text = "$ jerseys")
self._treeview.heading('no_hockstick', text = "# hockey stick")
self._treeview.heading('val_hockstick', text = "$ hockey stick")
self._treeview.heading('no_posters', text = "# posters")
self._treeview.heading('val_posters', text = "$ posters")
self._treeview.heading('total_sales', text = "Total Sales")
## The column size is 100
for item in self._treeview['columns']:
self._treeview.column(item, width = 100)
self._treeview.pack()
## Calling for database table to be displayed on GUI frame
def _maketable(self):
makeTableDatabase(self)
## when clicking add button with the user input, it will get the user input and add the data to the database
示例11: DialogPluginManager
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class DialogPluginManager(Toplevel):
def __init__(self, mainWin, modulesWithNewerFileDates):
super(DialogPluginManager, self).__init__(mainWin.parent)
self.ENABLE = _("Enable")
self.DISABLE = _("Disable")
self.parent = mainWin.parent
self.cntlr = mainWin
# copy plugins for temporary display
self.pluginConfig = PluginManager.pluginConfig
self.pluginConfigChanged = False
self.uiClassMethodsChanged = False
self.modulesWithNewerFileDates = modulesWithNewerFileDates
parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", self.parent.geometry())
dialogX = int(parentGeometry.group(3))
dialogY = int(parentGeometry.group(4))
self.title(_("Plug-in Manager"))
frame = Frame(self)
# left button frame
buttonFrame = Frame(frame, width=40)
buttonFrame.columnconfigure(0, weight=1)
addLabel = Label(buttonFrame, text=_("Find plug-in modules:"), wraplength=60, justify="center")
addLocalButton = Button(buttonFrame, text=_("Locally"), command=self.findLocally)
ToolTip(addLocalButton, text=_("File chooser allows selecting python module files to add (or reload) plug-ins, from the local file system."), wraplength=240)
addWebButton = Button(buttonFrame, text=_("On Web"), command=self.findOnWeb)
ToolTip(addWebButton, text=_("Dialog to enter URL full path to load (or reload) plug-ins, from the web or local file system."), wraplength=240)
addLabel.grid(row=0, column=0, pady=4)
addLocalButton.grid(row=1, column=0, pady=4)
addWebButton.grid(row=2, column=0, pady=4)
buttonFrame.grid(row=0, column=0, rowspan=2, sticky=(N, S, W), padx=3, pady=3)
# right tree frame (plugins already known to arelle)
modulesFrame = Frame(frame, width=700)
vScrollbar = Scrollbar(modulesFrame, orient=VERTICAL)
hScrollbar = Scrollbar(modulesFrame, orient=HORIZONTAL)
self.modulesView = Treeview(modulesFrame, xscrollcommand=hScrollbar.set, yscrollcommand=vScrollbar.set, height=7)
self.modulesView.grid(row=0, column=0, sticky=(N, S, E, W))
self.modulesView.bind('<<TreeviewSelect>>', self.moduleSelect)
hScrollbar["command"] = self.modulesView.xview
hScrollbar.grid(row=1, column=0, sticky=(E,W))
vScrollbar["command"] = self.modulesView.yview
vScrollbar.grid(row=0, column=1, sticky=(N,S))
modulesFrame.columnconfigure(0, weight=1)
modulesFrame.rowconfigure(0, weight=1)
modulesFrame.grid(row=0, column=1, columnspan=4, sticky=(N, S, E, W), padx=3, pady=3)
self.modulesView.focus_set()
self.modulesView.column("#0", width=120, anchor="w")
self.modulesView.heading("#0", text=_("Name"))
self.modulesView["columns"] = ("author", "ver", "status", "date", "update", "descr", "license")
self.modulesView.column("author", width=100, anchor="w", stretch=False)
self.modulesView.heading("author", text=_("Author"))
self.modulesView.column("ver", width=50, anchor="w", stretch=False)
self.modulesView.heading("ver", text=_("Version"))
self.modulesView.column("status", width=50, anchor="w", stretch=False)
self.modulesView.heading("status", text=_("Status"))
self.modulesView.column("date", width=70, anchor="w", stretch=False)
self.modulesView.heading("date", text=_("File Date"))
self.modulesView.column("update", width=50, anchor="w", stretch=False)
self.modulesView.heading("update", text=_("Update"))
self.modulesView.column("descr", width=200, anchor="w", stretch=False)
self.modulesView.heading("descr", text=_("Description"))
self.modulesView.column("license", width=70, anchor="w", stretch=False)
self.modulesView.heading("license", text=_("License"))
classesFrame = Frame(frame)
vScrollbar = Scrollbar(classesFrame, orient=VERTICAL)
hScrollbar = Scrollbar(classesFrame, orient=HORIZONTAL)
self.classesView = Treeview(classesFrame, xscrollcommand=hScrollbar.set, yscrollcommand=vScrollbar.set, height=5)
self.classesView.grid(row=0, column=0, sticky=(N, S, E, W))
hScrollbar["command"] = self.classesView.xview
hScrollbar.grid(row=1, column=0, sticky=(E,W))
vScrollbar["command"] = self.classesView.yview
vScrollbar.grid(row=0, column=1, sticky=(N,S))
classesFrame.columnconfigure(0, weight=1)
classesFrame.rowconfigure(0, weight=1)
classesFrame.grid(row=1, column=1, columnspan=4, sticky=(N, S, E, W), padx=3, pady=3)
self.classesView.focus_set()
self.classesView.column("#0", width=200, anchor="w")
self.classesView.heading("#0", text=_("Class"))
self.classesView["columns"] = ("modules")
self.classesView.column("modules", width=500, anchor="w", stretch=False)
self.classesView.heading("modules", text=_("Modules"))
# bottom frame module info details
moduleInfoFrame = Frame(frame, width=700)
moduleInfoFrame.columnconfigure(1, weight=1)
self.moduleNameLabel = Label(moduleInfoFrame, wraplength=600, justify="left",
font=font.Font(family='Helvetica', size=12, weight='bold'))
self.moduleNameLabel.grid(row=0, column=0, columnspan=4, sticky=W)
self.moduleAuthorHdr = Label(moduleInfoFrame, text=_("author:"), state=DISABLED)
self.moduleAuthorHdr.grid(row=1, column=0, sticky=W)
self.moduleAuthorLabel = Label(moduleInfoFrame, wraplength=600, justify="left")
self.moduleAuthorLabel.grid(row=1, column=1, columnspan=3, sticky=W)
#.........这里部分代码省略.........
示例12: statistic_q
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class statistic_q():
def __init__(self,data,y,v='план'):
w=Toplevel()
w.wm_title('Поквартальная статистика за {0} год ({1})'.format(y,v))
w.columnconfigure(0,weight=1)
w.rowconfigure(0,weight=1)
cols=data[y]['degurs'] # ЗАГЛУШКА : список дежурных
self.t=Treeview(w,columns=cols)
self.t.column('#0',width=120)
for c in cols:
self.t.heading(c,text=c)
self.t.column(c,width=65,anchor='center')
self.t.tag_configure('табель',background='green')
self.t.tag_configure('ош',background='red')
self.scrX=Scrollbar(w,orient='horizontal',command=self.t.xview)
self.scrY=Scrollbar(w,orient='vertical',command=self.t.yview)
self.t['xscrollcommand']=self.scrX.set
self.t['yscrollcommand']=self.scrY.set
self.t.grid(row=0,column=0,sticky=N+S+E+W)
self.scrX.grid(row=1,column=0,sticky=E+W)
self.scrY.grid(row=0,column=1,sticky=N+S)
r=self.t.insert('','end',text='рабочих')
w=self.t.insert('','end',text='отработано')
e=self.t.insert('','end',text='дополнительные')
n=self.t.insert('','end',text='ночные')
h=self.t.insert('','end',text='праздничные')
x=self.t.insert('','end',text='xxx')
rz_root=self.t.insert('','end',text='резерв')
rez=dict()
wwY=[]
rrY=[]
eeY=[]
xxY=[]
nnY=[]
hhY=[]
rzY=[]
for mm in [1,2,3,4]:
mmm=[str((mm-1)*3+x).zfill(2) for x in [1,2,3]]
mmm=[x for x in mmm if x in data[y]]
tag=''
k=['табель' in data[y][m]['degur'] for m in mmm]
#print(k)
if v=='авто':
if k==[True, True, True]:
vv='табель'
tag=vv
else:
vv='план'
elif v=='табель':
if k!=[True, True, True]:
vv='план'
tag='ош'
else:
vv=v
tag=vv
else:
vv=v
ww=[]
rr=[]
ee=[]
xx=[]
nn=[]
hh=[]
rz=[]
for m in mmm:
d=data[y][m]
for j in cols:
s=d['degur'][vv].get(j,'*ООООООООООООООООООООООООООООООО*')
rez[j]=analyse2(s,d)
NUL=(0,0,0,0,0,0,0)
ww.append([rez.get(j,NUL)[0] for j in cols])
ee.append([rez.get(j,NUL)[0]-rez.get(j,NUL)[3] + \
rez.get(j,NUL)[4] for j in cols])
xx.append([rez.get(j,NUL)[0]-rez.get(j,NUL)[3] for j in cols])
rr.append([rez.get(j,NUL)[3]-rez.get(j,NUL)[4] for j in cols])
nn.append([rez.get(j,NUL)[1] for j in cols])
hh.append([rez.get(j,NUL)[2] for j in cols])
rz.append([rez.get(j,NUL)[5] for j in cols])
ww=[sum(x) for x in zip(*ww)]
rr=[sum(x) for x in zip(*rr)]
ee=[sum(x) for x in zip(*ee)]
xx=[sum(x) for x in zip(*xx)]
nn=[sum(x) for x in zip(*nn)]
hh=[sum(x) for x in zip(*hh)]
rz=[sum(x) for x in zip(*rz)]
wwY.append(ww)
rrY.append(rr)
eeY.append(ee)
xxY.append(xx)
nnY.append(nn)
hhY.append(hh)
rzY.append(rz)
self.t.insert(w,'end',text=mm,values=ww,tag=tag)
self.t.insert(r,'end',text=mm,values=rr,tag=tag)
#.........这里部分代码省略.........
示例13: statistic_xx
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class statistic_xx():
def __init__(self,data,y,v='план'):
w=Toplevel()
w.wm_title('Итоги по месяцам за {0} год ({1}) '.format(y,v))
w.columnconfigure(0,weight=1)
w.rowconfigure(0,weight=1)
cols=data[y]['degurs'] # ЗАГЛУШКА : список дежурных
self.t=Treeview(w,columns=cols)
self.t.column('#0',width=120)
for c in cols:
self.t.heading(c,text=c)
self.t.column(c,width=65,anchor='center')
self.t.tag_configure('табель',background='green')
self.t.tag_configure('ош',background='red')
self.scrX=Scrollbar(w,orient='horizontal',command=self.t.xview)
self.scrY=Scrollbar(w,orient='vertical',command=self.t.yview)
self.t['xscrollcommand']=self.scrX.set
self.t['yscrollcommand']=self.scrY.set
self.t.grid(row=0,column=0,sticky=N+S+E+W)
self.scrX.grid(row=1,column=0,sticky=E+W)
self.scrY.grid(row=0,column=1,sticky=N+S)
roots=dict()
for m in ['01','02','03','04','05','06','07','08','09','10','11','12']:
d0=data[y]
if m not in d0: continue
roots[m]=self.t.insert('','end',text=m+' ('+data[y][m]['month']+')')
#r=self.t.insert('','end',text='рабочих')
#x=self.t.insert('','end',text='xxx')
#w=self.t.insert('','end',text='отработано')
#e=self.t.insert('','end',text='дополнительные')
#n=self.t.insert('','end',text='ночные')
#h=self.t.insert('','end',text='праздничные')
#rz_root=self.t.insert('','end',text='резерв')
for m in ['01','02','03','04','05','06','07','08','09','10','11','12']:
d0=data[y]
if m not in d0: continue
d=d0[m]
rez=dict()
tag=''
if v=='авто':
if 'табель' in d['degur']:
vv='табель'
tag=vv
else:
vv='план'
elif v=='табель':
if 'табель' not in d['degur']:
vv='план'
tag='ош'
else:
vv=v
tag=vv
else:
vv=v
for j,s in d['degur'][vv].items():
rez[j]=analyse2(s,d)
NUL=(0,0,0,0,0,0,0)
ww=[rez.get(j,NUL)[0] for j in cols]
ee=[rez.get(j,NUL)[0]-rez.get(j,NUL)[3]+rez.get(j,NUL)[4] for j in cols]
xx=[rez.get(j,NUL)[0]-rez.get(j,NUL)[3] for j in cols]
nn=[rez.get(j,NUL)[1] for j in cols]
hh=[rez.get(j,NUL)[2] for j in cols]
rr=[rez.get(j,NUL)[3]-rez.get(j,NUL)[4] for j in cols]
rz=[rez.get(j,NUL)[5] for j in cols]
self.t.insert(roots[m],'end',text='отработано',values=ww,tag=tag)
self.t.insert(roots[m],'end',text='рабочие',values=rr,tag=tag)
self.t.insert(roots[m],'end',text='дополнительные',values=ee,tag=tag)
self.t.insert(roots[m],'end',text='ночные',values=nn,tag=tag)
self.t.insert(roots[m],'end',text='праздничные',values=hh,tag=tag)
示例14: Gr
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class Gr():
def __init__(self,root,data,SCRY=None):
self.data=data
self.columns=[x for x in range(1,8)]+['day']
root.rowconfigure(1,weight=1)
root.columnconfigure(0,weight=1)
root.columnconfigure(1,weight=1)
root.columnconfigure(2,weight=1)
f=Frame(root)
f.columnconfigure(0,weight=1)
f.rowconfigure(1,weight=1)
self.v=Combobox(root)
self.v.grid(row=0,column=0)
self.v.bind('<<ComboboxSelected>>',self.select_ver)
f.grid(row=1,column=0,columnspan=3,sticky=N+S)
self.tree=Treeview(f,
columns=self.columns,
displaycolumns=['day']+self.columns[:-1],
show='headings')
#self.tree.tag_configure('odd',background='white')
#self.tree.tag_configure('even',background='gray')
self.tree.tag_configure('dif',foreground='brown')
self.tree.tag_configure('work',background='white')
self.tree.tag_configure('short',background='#F5EFE0')
self.tree.tag_configure('rest',background='#E0B0B0')
self.tree.tag_configure('holyday',background='#E7B7A4')
for c in self.columns:
self.tree.heading(c,text=c)
self.tree.column(c,width=65,anchor='center')
self.tree.column('day',width=30)
scrX=Scrollbar(f,orient='horizontal',command=self.tree.xview)
self.tree['xscrollcommand']=scrX.set
if not SCRY:
self.scrY=Scrollbar(f,orient='vertical',command=self.yview)
self.tree['yscrollcommand']=self.scrY.set
else:
self.tree['yscrollcommand']=SCRY.set
self.tree.grid(row=1,column=0,sticky=N+S)
if not SCRY:
self.scrY.grid(row=1,column=1,sticky=N+S)
scrX.grid(row=2,column=0,sticky=E+W)
def set(self,y,m):
self.y=y
self.m=m
self.show()
def yview(self,*args):
self.tree.yview(*args)
self.yview2(*args)
def yview2(self,*args):
pass
def show(self):
d=self.data[self.y][self.m]
V=list(d['degur'].keys())
self.v['values']=V
self.v.set(V[0])
self.select_ver()
def select_ver(self,*e):
self.tree.delete(*self.tree.get_children())
d=self.data[self.y][self.m]
offset=d['offset']
v=self.v.get()
col=[]
for i,deg in enumerate(d['degurs']):
self.tree.heading(i+1,text=deg)
col.append(i+1)
self.tree.configure(displaycolumns=['day']+col)
items=dict()
if 'табель' in d['degur']:
a=[''.join(x) for x in zip(*[[x for x in d['degur']['план'][j]] \
for j in d['degurs']])]
b=[''.join(x) for x in zip(*[[x for x in d['degur']['табель'][j]] \
for j in d['degurs']])]
c=[x!=y for x,y in zip(a,b)]
else:
c=[False]*32
for i in range(1,d['days']+1):
tag = (i+offset) % 7 in [0,6] and 'rest' or 'work'
if i in d['holydays'] : tag='holyday'
elif i in d['restdays'] : tag='rest'
elif i in d['shortdays'] : tag='short'
elif i in d['workdays'] : tag='work'
if c[i]: tag=[tag,'dif']
ii=self.tree.insert('','end',values=['-','-','-','-','-'],tag=tag)
self.tree.set(ii,column='day',value=i)
items[i]=ii
for j,s in d['degur'][v].items(): # j-degur
if not s: continue
for i,val in enumerate(s[1:-1]):
if val=='J':
val='до'
elif val=='j':
val='од'
elif val=='a':
val='10'
self.tree.set(items[i+1],column=d['degurs'].index(j)+1,value=val)
if s[0]=='Н':
#.........这里部分代码省略.........
示例15: ElementListWidget
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import heading [as 别名]
class ElementListWidget(Frame):
def __init__(self, parent, label, columns, showError):
Frame.__init__(self, parent)
self.showError = showError
self.columnconfigure(0, weight = 1)
self.rowconfigure(1, weight = 1)
# Название таблицы
self.titleLabel = Label(self, text = label)
self.titleLabel.grid(column = 0, row = 0, sticky = W + E)
# Таблица значений
columns = ("Метка", "№") + columns
self.tree = Treeview(self, columns = columns, displaycolumns = columns,
selectmode = "browse")
self.tree.grid(column = 0, row = 1, sticky = W + N + E + S)
# Настраиваем внешний вид таблицы (первые колонки)
self.tree.column("#0", width = 0, stretch = 0) # Прячем колонку с иконкой
self.tree.column( columns[0], anchor = W, width = 150)
self.tree.heading(columns[0], anchor = W, text = columns[0])
self.tree.column( columns[1], anchor = E, width = 80)
self.tree.heading(columns[1], anchor = E, text = columns[1])
self.tree.bind("<<TreeviewSelect>>", self.onSelectionChanged)
# Панель с кнопками
self.buttonPanel = Frame(self)
self.buttonPanel.grid(column = 0, row = 2, sticky = W + E)
self.buttonPanel.columnconfigure(0, weight = 1)
self.buttonPanel.columnconfigure(3, minsize = emptySpaceSize, weight = 0)
self.buttonPanel.columnconfigure(6, minsize = emptySpaceSize, weight = 0)
self.buttonPanel.columnconfigure(9, weight = 1)
# Кнопки добавления/удаления элемента
self.buttonAdd = Button(self.buttonPanel, text = "+", width = 3,
command = self.onButtonAddClicked)
self.buttonAdd.grid(column = 1, row = 0)
self.buttonRemove = Button(self.buttonPanel, text = "-", width = 3, state = DISABLED,
command = self.onButtonRemoveClicked)
self.buttonRemove.grid(column = 2, row = 0)
# Кнопки перемещения элемента
self.buttonUp = Button(self.buttonPanel, text = "↑", width = 3, state = DISABLED,
command = self.onButtonUpClicked)
self.buttonUp.grid(column = 4, row = 0)
self.buttonDown = Button(self.buttonPanel, text = "↓", width = 3, state = DISABLED,
command = self.onButtonDownClicked)
self.buttonDown.grid(column = 5, row = 0)
# Кнопки применить/отменить (для выбранного элемента)
self.buttonCancel = Button(self.buttonPanel, text = "✗", width = 3,
command = self.updateSelectedFrame)
self.buttonCancel.grid(column = 7, row = 0)
self.buttonApply = Button(self.buttonPanel, text = "✓", width = 3,
command = self.onButtonApplyClicked)
self.buttonApply.grid(column = 8, row = 0)
# Редактирование выделенного элемента
self.i = StringVar()
self.label = (StringVar(), StringVar())
self.selectedFrame = Frame(self)
self.selectedFrame.grid(column = 0, row = 3, sticky = W + E)
# Номер
Label(self.selectedFrame, text = "№:") \
.grid(column = 0, row = 0)
Label(self.selectedFrame, textvariable = self.i, width = 3, justify = RIGHT) \
.grid(column = 1, row = 0)
# Пустое пространство
self.selectedFrame.columnconfigure(2, minsize = emptySpaceSize, weight = 0)
# Метка
Entry(self.selectedFrame, textvariable = self.label[0]) \
.grid(column = 3, row = 0, sticky = W + E)
Entry(self.selectedFrame, textvariable = self.label[1], bg = defaultValueBG) \
.grid(column = 4, row = 0, sticky = W + E)
# Виджет для элементов классов-потомков
self.detailFrame = Frame(self.selectedFrame)
self.detailFrame.grid(column = 3, row = 1, columnspan = 2, sticky = W + N + E + S)
self.selectedFrame.columnconfigure(3, weight = 1)
self.selectedFrame.columnconfigure(4, weight = 1)
self.selectedFrame.rowconfigure(1, weight = 1)
#.........这里部分代码省略.........