本文整理汇总了Python中tkinter.ttk.Treeview.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Treeview.bind方法的具体用法?Python Treeview.bind怎么用?Python Treeview.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Treeview
的用法示例。
在下文中一共展示了Treeview.bind方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DialogPluginManager
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [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.modelClassesChanged = False
self.disclosureSystemTypesChanged = False
self.hostSystemFeaturesChanged = 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)
#.........这里部分代码省略.........
示例2: ReplayTutor2
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [as 别名]
class ReplayTutor2(Tutor):
"""
ReplayTutor: a tutor for testing/backup purposes, that re-sends messages to plugins.
"""
def __init__(self, entity_id, api_key, logger, run_once=None, args=None):
super().__init__(entity_id, api_key, self.main_callback, run_once=run_once)
self.run_once = run_once
self.logger = logger
self.student_id_value = None
self.session_id_value = None
self.root = None
self.status = None
self.student_id = None
self.session_id = None
self.problem_name = None
self.step_name = None
self.transaction_id = None
self.outcome = None
self.skillbox = None
self.button = None
self.import_button = None
self.kt_button = None
self.attr_name = None
self.attr_value = None
self.attr_button = None
self.skill_id = None
self.kt_button = None
self.response_box = None
self.json_in = None
def post_connect(self):
self.send("tutorgen.add_student",{},self.new_student_callback)
def setup_gui(self):
#main window
self.root = Tk()
self.root.wm_title("Transaction Replay Tutor")
self.root.minsize(400,400)
#menu
menubar = Menu(self.root)
menubar.add_command(label="Import Datashop File", command=self.import_datashop_file)
menubar.add_command(label="Quit", command=self.root.quit)
self.root.config(menu=menubar)
#listbox
w = Label(self.root, text="Transaction")
w.pack(fill=X)
frame = Frame()
scrollbar = Scrollbar(frame, orient=VERTICAL)
self.treeview = Treeview(frame,yscrollcommand=scrollbar.set)
self.treeview["columns"] = ("problem_name","step_text","transaction_text","skill_names","outcome")
self.treeview.heading("problem_name",text="Problem Name")
self.treeview.heading("step_text",text="Step Text")
self.treeview.heading("transaction_text",text="Transaction Text")
self.treeview.heading("skill_names",text="Skill Names")
self.treeview.heading("outcome",text="Outcome")
self.treeview.bind('<<TreeviewSelect>>', self.populate_form)
scrollbar.config(command=self.treeview.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.treeview.pack(side=LEFT, fill=BOTH, expand=1)
frame.pack(fill=BOTH)
#spacer frame
separator = Frame(height=2, bd=1, relief=SUNKEN)
separator.pack(fill=X, padx=5, pady=5)
#student id
w = Label(self.root, text="Student ID")
w.pack(fill=X)
self.student_id = Entry(self.root,state=DISABLED)
self.student_id.pack(fill=X)
#ssession id
w = Label(self.root, text="Session ID")
w.pack(fill=X)
self.session_id = Entry(self.root,state=DISABLED)
self.session_id.pack(fill=X)
bigframe = Frame()
bigframe.pack(fill=X,padx =5, ipady=5)
leftframe = Frame(bigframe)
leftframe.pack(side=LEFT,fill=X,expand=1)
rightframe= Frame(bigframe)
rightframe.pack(side=RIGHT,fill=X,expand=1)
#Entry fields
##problem name
w = Label(leftframe, text="Problem Name")
w.pack(fill=X)
self.problem_name = Entry(leftframe)
#.........这里部分代码省略.........
示例3: DialogPackageManager
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [as 别名]
class DialogPackageManager(Toplevel):
def __init__(self, mainWin, packageNamesWithNewerFileDates):
super(DialogPackageManager, self).__init__(mainWin.parent)
self.ENABLE = _("Enable")
self.DISABLE = _("Disable")
self.parent = mainWin.parent
self.cntlr = mainWin
# copy plugins for temporary display
self.packagesConfig = PackageManager.packagesConfig
self.packagesConfigChanged = False
self.packageNamesWithNewerFileDates = packageNamesWithNewerFileDates
parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", self.parent.geometry())
dialogX = int(parentGeometry.group(3))
dialogY = int(parentGeometry.group(4))
self.title(_("Taxonomy Packages Manager"))
frame = Frame(self)
# left button frame
buttonFrame = Frame(frame, width=40)
buttonFrame.columnconfigure(0, weight=1)
addLabel = Label(buttonFrame, text=_("Find taxonomy packages:"), wraplength=64, justify="center")
addLocalButton = Button(buttonFrame, text=_("Locally"), command=self.findLocally)
ToolTip(addLocalButton, text=_("File chooser allows selecting taxonomy packages to add (or reload), from the local file system. "
"Select either a taxonomy package zip file, or a taxonomy manifest (.taxonomyPackage.xml) within an unzipped taxonomy package. "), wraplength=240)
addWebButton = Button(buttonFrame, text=_("On Web"), command=self.findOnWeb)
ToolTip(addWebButton, text=_("Dialog to enter URL full path to load (or reload) package, from the web or local file system. "
"URL may be either a taxonomy package zip file, or a taxonomy manifest (.taxonomyPackage.xml) within an unzipped taxonomy package. "), wraplength=240)
manifestNameButton = Button(buttonFrame, text=_("Manifest"), command=self.manifestName)
ToolTip(manifestNameButton, text=_("Provide non-standard archive manifest file name pattern (e.g., *taxonomyPackage.xml). "
"Uses unix file name pattern matching. "
"Multiple manifest files are supported in archive (such as oasis catalogs). "
"(Replaces search for either .taxonomyPackage.xml or catalog.xml). "), wraplength=240)
self.manifestNamePattern = ""
addLabel.grid(row=0, column=0, pady=4)
addLocalButton.grid(row=1, column=0, pady=4)
addWebButton.grid(row=2, column=0, pady=4)
manifestNameButton.grid(row=3, column=0, pady=4)
buttonFrame.grid(row=0, column=0, rowspan=3, sticky=(N, S, W), padx=3, pady=3)
# right tree frame (packages already known to arelle)
packagesFrame = Frame(frame, width=700)
vScrollbar = Scrollbar(packagesFrame, orient=VERTICAL)
hScrollbar = Scrollbar(packagesFrame, orient=HORIZONTAL)
self.packagesView = Treeview(packagesFrame, xscrollcommand=hScrollbar.set, yscrollcommand=vScrollbar.set, height=7)
self.packagesView.grid(row=0, column=0, sticky=(N, S, E, W))
self.packagesView.bind('<<TreeviewSelect>>', self.packageSelect)
hScrollbar["command"] = self.packagesView.xview
hScrollbar.grid(row=1, column=0, sticky=(E,W))
vScrollbar["command"] = self.packagesView.yview
vScrollbar.grid(row=0, column=1, sticky=(N,S))
packagesFrame.columnconfigure(0, weight=1)
packagesFrame.rowconfigure(0, weight=1)
packagesFrame.grid(row=0, column=1, columnspan=4, sticky=(N, S, E, W), padx=3, pady=3)
self.packagesView.focus_set()
self.packagesView.column("#0", width=120, anchor="w")
self.packagesView.heading("#0", text=_("Name"))
self.packagesView["columns"] = ("ver", "status", "date", "update", "descr")
self.packagesView.column("ver", width=150, anchor="w", stretch=False)
self.packagesView.heading("ver", text=_("Version"))
self.packagesView.column("status", width=50, anchor="w", stretch=False)
self.packagesView.heading("status", text=_("Status"))
self.packagesView.column("date", width=170, anchor="w", stretch=False)
self.packagesView.heading("date", text=_("File Date"))
self.packagesView.column("update", width=50, anchor="w", stretch=False)
self.packagesView.heading("update", text=_("Update"))
self.packagesView.column("descr", width=200, anchor="w", stretch=False)
self.packagesView.heading("descr", text=_("Description"))
remappingsFrame = Frame(frame)
vScrollbar = Scrollbar(remappingsFrame, orient=VERTICAL)
hScrollbar = Scrollbar(remappingsFrame, orient=HORIZONTAL)
self.remappingsView = Treeview(remappingsFrame, xscrollcommand=hScrollbar.set, yscrollcommand=vScrollbar.set, height=5)
self.remappingsView.grid(row=0, column=0, sticky=(N, S, E, W))
hScrollbar["command"] = self.remappingsView.xview
hScrollbar.grid(row=1, column=0, sticky=(E,W))
vScrollbar["command"] = self.remappingsView.yview
vScrollbar.grid(row=0, column=1, sticky=(N,S))
remappingsFrame.columnconfigure(0, weight=1)
remappingsFrame.rowconfigure(0, weight=1)
remappingsFrame.grid(row=1, column=1, columnspan=4, sticky=(N, S, E, W), padx=3, pady=3)
self.remappingsView.focus_set()
self.remappingsView.column("#0", width=200, anchor="w")
self.remappingsView.heading("#0", text=_("Prefix"))
self.remappingsView["columns"] = ("remapping")
self.remappingsView.column("remapping", width=500, anchor="w", stretch=False)
self.remappingsView.heading("remapping", text=_("Remapping"))
# bottom frame package info details
packageInfoFrame = Frame(frame, width=700)
packageInfoFrame.columnconfigure(1, weight=1)
self.packageNameLabel = Label(packageInfoFrame, wraplength=600, justify="left",
font=font.Font(family='Helvetica', size=12, weight='bold'))
self.packageNameLabel.grid(row=0, column=0, columnspan=6, sticky=W)
#.........这里部分代码省略.........
示例4: DialogOpenArchive
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [as 别名]
class DialogOpenArchive(Toplevel):
def __init__(self, mainWin, openType, filesource, filenames, title, colHeader, showAltViewButton=False):
parent = mainWin.parent
super(DialogOpenArchive, self).__init__(parent)
self.parent = parent
self.showAltViewButton = showAltViewButton
parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
dialogX = int(parentGeometry.group(3))
dialogY = int(parentGeometry.group(4))
self.accepted = False
self.transient(self.parent)
frame = Frame(self)
treeFrame = Frame(frame, width=500)
vScrollbar = Scrollbar(treeFrame, orient=VERTICAL)
hScrollbar = Scrollbar(treeFrame, orient=HORIZONTAL)
self.treeView = Treeview(treeFrame, xscrollcommand=hScrollbar.set, yscrollcommand=vScrollbar.set)
self.treeView.grid(row=0, column=0, sticky=(N, S, E, W))
hScrollbar["command"] = self.treeView.xview
hScrollbar.grid(row=1, column=0, sticky=(E,W))
vScrollbar["command"] = self.treeView.yview
vScrollbar.grid(row=0, column=1, sticky=(N,S))
treeFrame.columnconfigure(0, weight=1)
treeFrame.rowconfigure(0, weight=1)
treeFrame.grid(row=0, column=0, columnspan=4, sticky=(N, S, E, W), padx=3, pady=3)
self.treeView.focus_set()
mainWin.showStatus(_("loading archive {0}").format(filesource.url))
self.filesource = filesource
self.filenames = filenames
self.selection = filesource.selection
self.hasToolTip = False
selectedNode = None
if openType == ENTRY_POINTS:
try:
metadataFiles = filesource.taxonomyPackageMetadataFiles
if len(metadataFiles) > 1:
raise IOError(_("Taxonomy package contained more than one metadata file: {0}.")
.format(', '.join(metadataFiles)))
metadataFile = metadataFiles[0]
metadata = filesource.file(filesource.url + os.sep + metadataFile)[0]
self.metadataFilePrefix = os.sep.join(os.path.split(metadataFile)[:-1])
if self.metadataFilePrefix:
self.metadataFilePrefix += os.sep
self.nameToUrls, self.remappings = parseTxmyPkg(mainWin, metadata)
except Exception as e:
self.close()
err = _("Failed to parse metadata; the underlying error was: {0}").format(e)
messagebox.showerror(_("Malformed taxonomy package"), err)
mainWin.addToLog(err)
return
mainWin.showStatus(None)
if openType == DISCLOSURE_SYSTEM:
y = 3
else:
y = 1
okButton = Button(frame, text=_("OK"), command=self.ok)
cancelButton = Button(frame, text=_("Cancel"), command=self.close)
okButton.grid(row=y, column=2, sticky=(S,E,W), pady=3)
cancelButton.grid(row=y, column=3, sticky=(S,E,W), pady=3, padx=3)
if showAltViewButton:
self.altViewButton = Button(frame, command=self.showAltView)
self.altViewButton.grid(row=y, column=0, sticky=(S,W), pady=3, padx=3)
self.loadTreeView(openType, colHeader, title)
frame.grid(row=0, column=0, sticky=(N,S,E,W))
frame.columnconfigure(0, weight=1)
window = self.winfo_toplevel()
window.columnconfigure(0, weight=1)
self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
self.bind("<Return>", self.ok)
self.bind("<Escape>", self.close)
self.toolTipText = StringVar()
if self.hasToolTip:
self.treeView.bind("<Motion>", self.motion, '+')
self.treeView.bind("<Leave>", self.leave, '+')
self.toolTipText = StringVar()
self.toolTip = ToolTip(self.treeView,
textvariable=self.toolTipText,
wraplength=640,
follow_mouse=True,
state="disabled")
self.toolTipRowId = None
self.protocol("WM_DELETE_WINDOW", self.close)
self.grab_set()
self.wait_window(self)
def loadTreeView(self, openType, title, colHeader):
#.........这里部分代码省略.........
示例5: DialogPluginManager
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [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)
#.........这里部分代码省略.........
示例6: Expenses
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [as 别名]
#.........这里部分代码省略.........
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)
backButton = Button(root, text="Back", command=lambda: self.sequence(self.viewInveroty)) # This button will return the user to the main page. Still working on it.
backButton.place(x = 50, y = 350)
# Creates table when an entry is double clicked
def displayDetailedInventory(self, event):
# The selected item's tag are extracted and assigned to name and type
itemSelected = self.tree.selection()
name = self.tree.item(itemSelected,"tag")[0]
type = self.tree.item(itemSelected, "tag")[1]
for child in root.winfo_children():
child.destroy()
self.createDisplayTable()
self.obtainDetailedData(name, type)
# Adds detailed database data to the inventory table
def obtainDetailedData(self,name, type):
for row in (self.inventoryDB.getDetailedInventory(type, name)):
name = row[0]
purchaseDate = row[1]
Quantity = row[3]
Price = row[4]
self.tree.insert("", "end", values = (name,purchaseDate,Quantity, Price))
backButton = Button(root, text="Back", command=lambda: self.sequence(self.backFunction))
backButton.place(x = 50, y = 350)
# Creates the view total cost by month and year buttons
def viewTotalCost(self):
示例7: ElementListWidget
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [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)
#.........这里部分代码省略.........
示例8: DialogOpenArchive
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [as 别名]
#.........这里部分代码省略.........
self.close()
err = _("Failed to parse metadata; the underlying error was: {0}").format(e)
messagebox.showerror(_("Malformed taxonomy package"), err)
cntlr.addToLog(err)
return
if openType not in (PLUGIN, PACKAGE):
cntlr.showStatus(None)
if openType in (DISCLOSURE_SYSTEM, PLUGIN, PACKAGE):
y = 3
else:
y = 1
okButton = Button(frame, text=_("OK"), command=self.ok)
cancelButton = Button(frame, text=_("Cancel"), command=self.close)
okButton.grid(row=y, column=2, sticky=(S,E,W), pady=3)
cancelButton.grid(row=y, column=3, sticky=(S,E,W), pady=3, padx=3)
if self.showAltViewButton:
self.altViewButton = Button(frame, command=self.showAltView)
self.altViewButton.grid(row=y, column=0, sticky=(S,W), pady=3, padx=3)
self.loadTreeView(openType, colHeader, title)
self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
frame.grid(row=0, column=0, sticky=(N,S,E,W))
frame.columnconfigure(0, weight=1)
frame.rowconfigure(0, weight=1)
window = self.winfo_toplevel()
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)
self.bind("<Return>", self.ok)
self.bind("<Escape>", self.close)
self.toolTipText = StringVar()
if self.hasToolTip:
self.treeView.bind("<Motion>", self.motion, '+')
self.treeView.bind("<Leave>", self.leave, '+')
self.toolTipText = StringVar()
self.toolTip = ToolTip(self.treeView,
textvariable=self.toolTipText,
wraplength=640,
follow_mouse=True,
state="disabled")
self.toolTipRowId = None
self.protocol("WM_DELETE_WINDOW", self.close)
self.grab_set()
self.wait_window(self)
def loadTreeView(self, openType, title, colHeader):
self.title(title)
self.openType = openType
selectedNode = None
# clear previous treeview entries
for previousNode in self.treeView.get_children(""):
self.treeView.delete(previousNode)
# set up treeView widget and tabbed pane
示例9: fillTree
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [as 别名]
class Window:
def fillTree(self,path, parent, list):
for file in os.listdir(path):
abspath = os.path.join(path,file)
color = ""
treelist = None
for mini in list:
if abspath in mini:
color = 'red'
treelist = mini
else:
for lk in mini:
if abspath in lk:
color = 'purple'
child = None
if color == 'red':
child = self.tree.insert(parent,'end',text=file,open=False,tags=(abspath,'red',str(treelist)),)
elif color == 'purple':
child = self.tree.insert(parent,'end',text=file,open=False,tags=(abspath,'purple'))
else:
child = self.tree.insert(parent,'end',text=file,open=False,tags=(abspath,'white'))
if(os.path.isdir(abspath)):
self.tree.insert(child,'end',text='',open=False)
def __init__(self,list,dirlist):
self.root = Tk()
self.root.wm_title("Duplicate_Files")
self.min = None
self.list = list
self.root.geometry('600x600+0+0')
self.tree = Treeview(self.root ,height=15)
self.tree.pack(expand='yes',fill='both')
self.tree.heading('#0',text="files")
self.tree.tag_configure('red',foreground='red')
self.tree.tag_configure('purple',foreground='#cc00ff')
self.tree.bind("<Double-1>",self.onDoubleClick)
self.tree.bind("<<TreeviewOpen>>",self.onOpen)
self.tree.bind("<<TreeviewClose>>",self.onClose)
for path in dirlist:
branch = self.tree.insert('','end',text=path,open=True,tags=(path,'white'))
self.fillTree(path,branch,list)
self.root.mainloop()
def onDoubleClick(self,event):
item = self.tree.selection()[0]
print ("clicked" + str(self.tree.item(item,'tags')[0]))
if str(self.tree.item(item,'tags')[1]) == "red":
list_of_files = ast.literal_eval(str(self.tree.item(item,'tags')[2]))
if self.min != None:
if self.min.mini.winfo_exists():
self.min.mini.destroy()
self.min = MiniWindow(self.root,list_of_files)
def onOpen(self,event):
item = self.tree.selection()[0]
if self.tree.parent(item) != '':
if len(self.tree.get_children(item))>0:
self.tree.delete(self.tree.get_children(item))
abspath = str(self.tree.item(item,'tags')[0])
if(os.path.isdir(abspath)):
self.fillTree(abspath, item,self.list)
def onClose(self,event):
item = self.tree.selection()[0]
if self.tree.parent(item) != '':
if len(self.tree.get_children(item))>0:
self.tree.delete(self.tree.get_children(item))
示例10: MainWindow
# 需要导入模块: from tkinter.ttk import Treeview [as 别名]
# 或者: from tkinter.ttk.Treeview import bind [as 别名]
class MainWindow(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.eventHandler = EventHandler(self)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("File synchronizer")
Style().configure("TButton", padding=(0, 5, 0, 5), font="serif 10")
# 3X3 Grid
self.columnconfigure(0, pad=3, weight=1)
self.columnconfigure(1, pad=3)
self.columnconfigure(2, pad=3, weight=1)
self.rowconfigure(0, pad=3)
self.rowconfigure(1, pad=3, weight=1)
self.rowconfigure(2, pad=3)
ltf = Frame(self)
ltf.grid(row=0, column=0, sticky=W + E)
# 1X4 Grid
ltf.columnconfigure(0, pad=3)
ltf.columnconfigure(1, pad=3, weight=1)
ltf.columnconfigure(2, pad=3, weight=1)
ltf.columnconfigure(3, pad=3)
ltf.rowconfigure(0, pad=3, weight=1)
llabel = Label(ltf, text="Direcotry:")
llabel.grid(row=0, column=0, sticky=W + E)
self.leftDir = Entry(ltf)
self.leftDir.bind("<Return>", self.eventHandler.leftDirChanged)
self.leftDir.grid(row=0, column=1, columnspan=2, sticky=W + E)
# Left browse button
lBtn = Button(ltf, text="browse...", command=self.eventHandler.chooseLeftDirectory)
lBtn.grid(row=0, column=3, sticky=E)
rtf = Frame(self)
rtf.grid(row=0, column=2, sticky=W + E)
# 1X4 Grid
rtf.columnconfigure(0, pad=3)
rtf.columnconfigure(1, pad=3, weight=1)
rtf.columnconfigure(2, pad=3, weight=1)
rtf.columnconfigure(3, pad=3)
rtf.rowconfigure(0, pad=3, weight=1)
rlabel = Label(rtf, text="Direcotry:")
rlabel.grid(row=0, column=0, sticky=W + E)
self.rightDir = Entry(rtf)
self.rightDir.bind("<Return>", self.eventHandler.rightDirChanged)
self.rightDir.grid(row=0, column=1, columnspan=2, sticky=W + E)
# Right browse button
rBtn = Button(rtf, text="browse...", command=self.eventHandler.chooseRightDirectory)
rBtn.grid(row=0, column=3, sticky=E)
# Left TreeView frame
ltf1 = Frame(self)
ltf1.grid(row=1, column=0, sticky=N + S + W + E)
# 2 X 2 Grid
ltf1.columnconfigure(0, pad=3, weight=1)
ltf1.columnconfigure(1, pad=3)
ltf1.rowconfigure(0, pad=3, weight=1)
ltf1.rowconfigure(1, pad=3)
self.ltree = Treeview(ltf1, columns=("fullpath", "type", "size"), displaycolumns="size")
self.ltree.grid(row=0, column=0, sticky=E + W + S + N)
lysb = ttk.Scrollbar(ltf1, orient=VERTICAL, command=self.ltree.yview)
lysb.grid(row=0, column=1, sticky=NS)
lxsb = ttk.Scrollbar(ltf1, orient=HORIZONTAL, command=self.ltree.xview)
lxsb.grid(row=1, column=0, columnspan=3, sticky=EW)
self.ltree["yscroll"] = lysb.set
self.ltree["xscroll"] = lxsb.set
self.ltree.heading("#0", text="Directory Structure", anchor="w")
self.ltree.heading("size", text="File Size", anchor="w")
self.ltree.column("size", stretch=0, width=100)
self.ltree.bind("<<TreeviewOpen>>", self.eventHandler.openTree)
# Right TreeView frame
rtf1 = Frame(self)
rtf1.grid(row=1, column=2, sticky=N + S + W + E)
# 2 X 2 Grid
rtf1.columnconfigure(0, pad=3, weight=1)
rtf1.columnconfigure(1, pad=3)
rtf1.rowconfigure(0, pad=3, weight=1)
rtf1.rowconfigure(1, pad=3)
self.rtree = Treeview(rtf1, columns=("fullpath", "type", "size"), displaycolumns="size")
self.rtree.grid(row=0, column=0, sticky=E + W + S + N)
rysb = ttk.Scrollbar(rtf1, orient=VERTICAL, command=self.ltree.yview)
rysb.grid(row=0, column=1, sticky=NS)
rxsb = ttk.Scrollbar(rtf1, orient=HORIZONTAL, command=self.ltree.xview)
rxsb.grid(row=1, column=0, columnspan=3, sticky=EW)
self.rtree["yscroll"] = rysb.set
self.rtree["xscroll"] = rxsb.set
self.rtree.heading("#0", text="Directory Structure", anchor="w")
self.rtree.heading("size", text="File Size", anchor="w")
self.rtree.column("size", stretch=0, width=100)
self.rtree.bind("<<TreeviewOpen>>", self.eventHandler.openTree)
# Command Button frame
btnf = Frame(self)
btnf.grid(row=1, column=1, sticky=W + E + N + S)
#.........这里部分代码省略.........