ttk.Treeview

TTK的目的。

TreeView控件的呈现层次结构,用户可以使用鼠标动作来显示或隐藏结构的任何部分。

与术语“树”的关联是由于编程实践:树结构是一个常见的程序设计。严格地说,在一个TreeView控件显示的层次结构是一个森林:没有一个根,只是一个收集的顶级节点,每个可能包含二级节点,每个节点可以包含第三级,等等。

您可能已经遇到了这个特定的演示文稿作为浏览目录或文件夹层次结构的一种方式。整个层次结构显示像一个锯齿状的轮廓,其中每个目录是一个单独的行,并显示每个目录的子目录下面,缩进:

用户可以点击一个目录的图标崩溃(关闭)它,隐藏在它的所有项目。他们也可以再次点击图标来展开(打开)它,以便目录或文件夹中的项目被显示出来。

yòng用   户   可   以   diǎn点   击   一   个   目   录   de的   图   biāo标   bēng崩   kuì溃   (   guān关   闭   )   它   ,   yǐn隐   cáng藏   zài在   它   de的   suǒ所   yǒu有   xiàng项   目   。   他   men们   也   可   以   zài再   次   diǎn点   击   图   biāo标   lái来   zhǎn展   kāi开   (   打   kāi开   )   它   ,   以   biàn便   目   录   huò或   wén文   jiàn件   jiā夹   zhōng中   de的   xiàng项   目   bèi被   xiǎn显   shì示   chū出   lái来   。

The Treeview widget generalizes this concept so that you can use it to display any hierarchical structure, and the reader can collapse or expand subtrees of this structure with the mouse.

的TreeView控件的推广这个概念,你可以用它来显示任何层次结构,和读者可以折叠或展开这一结构子树与鼠标。

de的   T   r   e   e   V   i   e   w   kòng控   jiàn件   de的   tuī推   guǎng广   zhè这   ge个   gài概   niàn念   ,   你   可   以   yòng用   它   lái来   xiǎn显   shì示   rèn任   何   céng层   次   jié结   gòu构   ,   和   读   zhě者   可   以   zhé折   dié叠   huò或   zhǎn展   kāi开   zhè这   一   jié结   gòu构   子   shù树   与   shǔ鼠   biāo标   。

First, some definitions:

首先,一些定义:

shǒu首   xiān先   ,   一   xiē些   dìng定   义   :

item

item

xiàng项  

One of the entities being displayed in the widget. For a file browser, an item might be either a directory or a file.

正在显示的部件中的一个实体。对于一个文件浏览器,一个项目可能是一个目录或一个文件。

zhèng正   zài在   xiǎn显   shì示   de的   部   jiàn件   zhōng中   de的   一   个   shí实   体   。   duì对   于   一   个   wén文   jiàn件   liú浏   lǎn览   器   ,   一   个   xiàng项   目   可   néng能   shì是   一   个   目   录   huò或   一   个   wén文   jiàn件   。

Each item is associated with a textual label, and may also be associated with an image.

每个项目都与文本标签相关联的,也可以与图像相关联的。

měi每   个   xiàng项   目   dōu都   与   wén文   běn本   biāo标   qiān签   xiāng相   guān关   lián联   de的   ,   也   可   以   与   图   xiàng像   xiāng相   guān关   lián联   de的   。

iid

IID

I   I   D

Every item in the tree has a unique identifier string called the iid. You can supply the iid values yourself, or you can let ttk generate them.

在树的每一个项目都有一个唯一的标识符字符串称为IID。你们能提供的IID值你自己,或者你可以让这些生成。

zài在   shù树   de的   měi每   一   个   xiàng项   目   dōu都   yǒu有   一   个   wéi唯   一   de的   biāo标   shí识   符   字   符   chuàn串   chēng称   wéi为   I   I   D   。   你   men们   néng能   提   gōng供   de的   I   I   D   zhí值   你   自   己   ,   huò或   zhě者   你   可   以   ràng让   zhè这   xiē些   shēng生   chéng成   。

child

child

xiǎo小   hái

The items directly below a given item in a hierarchy. A directory, for example, may have two kinds of children: files and subdirectories.

在层次结构中的一个给定项目下的项目。例如,一个目录,,可能有两种孩子:文件和子目录。

zài在   céng层   次   jié结   gòu构   zhōng中   de的   一   个   gěi给   dìng定   xiàng项   目   xià下   de的   xiàng项   目   。   例   如   ,   一   个   目   录   ,   ,   可   néng能   yǒu有   liǎng两   zhǒng种   hái孩   zi子   :   wén文   jiàn件   和   子   目   录   。

parent

parent

起   yuán

For a given item, if it is at the top of the hierarchy it is said to have no parent; if it is not at the top level, the parent is the item that contains it.

对于一个给定的项目,如果它是在层次结构的顶部,它被称为没有父;如果它不是在顶层,父是包含它的项目。

duì对   于   一   个   gěi给   dìng定   de的   xiàng项   目   ,   如   guǒ果   它   shì是   zài在   céng层   次   jié结   gòu构   de的   dǐng顶   部   ,   它   bèi被   chēng称   wéi为   méi没   yǒu有   父   ;   如   guǒ果   它   不   shì是   zài在   dǐng顶   céng层   ,   父   shì是   bāo包   hán含   它   de的   xiàng项   目   。

ancestor

ancestor

祖   xiān

The ancestors of an item include its parent, its parent‘s parent, and so on up to the top level of the tree.

一个项目的祖先包括它的父母,它的父母的父母,所以在树的最高水平。

一   个   xiàng项   目   de的   祖   xiān先   bāo包   kuò括   它   de的   父   母   ,   它   de的   父   母   de的   父   母   ,   suǒ所   以   zài在   shù树   de的   zuì最   gāo高   shuǐ水   píng平   。

visible

visible

kàn看   de得   jiàn见   de

Top-level items are always visible. Otherwise, an item is visible only if all its ancestors are expanded.

顶层项目总是可见的。否则,只有当所有的祖先都被扩展时,一个项目是可见的。

dǐng顶   céng层   xiàng项   目   zǒng总   shì是   可   jiàn见   de的   。   fǒu否   则   ,   zhǐ只   yǒu有   dāng当   suǒ所   yǒu有   de的   祖   xiān先   dōu都   bèi被   kuò扩   zhǎn展   shí时   ,   一   个   xiàng项   目   shì是   可   jiàn见   de的   。

descendant

descendant

hòu后  

The descendants of an item include its children, its childrens‘ children, and so on. Another way of saying this is that the subtree of an item includes all its descendants.

一个项目的后代包括它的孩子,它的孩子的孩子,等等。另一种说法是,一个项目的子树包含所有它的后代。

一   个   xiàng项   目   de的   hòu后   dài代   bāo包   kuò括   它   de的   hái孩   zi子   ,   它   de的   hái孩   zi子   de的   hái孩   zi子   ,   děng等   děng等   。   lìng另   一   zhǒng种   shuō说   法   shì是   ,   一   个   xiàng项   目   de的   子   shù树   bāo包   hán含   suǒ所   yǒu有   它   de的   hòu后   dài代   。

tag

tag

biāo标   qiān

Your program can associate one or more tag strings with each item. You can use these tags to control the appearance of an item. For example, you could tag directories with the tag ‘d‘ and files with the tag ‘f‘, and then specify that items with tag ‘d‘ use a boldface font.

您的程序可以将一个或多个标记字符串与每个项目关联。您可以使用这些标签来控制项目的外观。例如,你可以使用标签的“D”和“F”文件的标签标签的目录,然后指定物品的标签“D”用黑体字体。

nín您   de的   chéng程   序   可   以   jiāng将   一   个   huò或   duō多   个   biāo标   记   字   符   chuàn串   与   měi每   个   xiàng项   目   guān关   lián联   。   nín您   可   以   shǐ使   yòng用   zhè这   xiē些   biāo标   qiān签   lái来   kòng控   zhì制   xiàng项   目   de的   wài外   guān观   。   例   如   ,   你   可   以   shǐ使   yòng用   biāo标   qiān签   de的   “   D   ”   和   “   F   ”   wén文   jiàn件   de的   biāo标   qiān签   biāo标   qiān签   de的   目   录   ,   rán然   hòu后   zhǐ指   dìng定   物   pǐn品   de的   biāo标   qiān签   “   D   ”   yòng用   hēi黑   体   字   体   。

You may also associate events with tags, so that certain events will cause certain handlers to be called for all items that have that tag. For example, you could set up a file browser so that when a user clicks on a directory, the browser updated its contents to reflect the current file structure.

您也可以将事件与标签关联,以便某些事件将导致某些处理程序被调用具有该标记的所有项目。例如,您可以设置一个文件浏览器,以便当用户点击一个目录时,浏览器更新其内容以反映当前的文件结构。

nín您   也   可   以   jiāng将   shì事   jiàn件   与   biāo标   qiān签   guān关   lián联   ,   以   biàn便   mǒu某   xiē些   shì事   jiàn件   jiāng将   dǎo导   zhì致   mǒu某   xiē些   chǔ处   理   chéng程   序   bèi被   diào调   yòng用   具   yǒu有   gāi该   biāo标   记   de的   suǒ所   yǒu有   xiàng项   目   。   例   如   ,   nín您   可   以   shè设   zhì置   一   个   wén文   jiàn件   liú浏   lǎn览   器   ,   以   biàn便   dāng当   yòng用   户   diǎn点   击   一   个   目   录   shí时   ,   liú浏   lǎn览   器   gēng更   xīn新   其   nèi内   róng容   以   fǎn反   yìng映   dāng当   qián前   de的   wén文   jiàn件   jié结   gòu构   。

Your Treeview widget will be structured with multiple columns. The first column, which we‘ll call the icon column, displays the icons that collapse or expand items. In the remaining columns, you may display whatever information you like.

你的TreeView控件的结构将与多个列。我们将称为“图标”列的第一列,显示折叠或展开项目的图标。在剩下的栏目中,你可以展示你喜欢的任何信息。

你   de的   T   r   e   e   V   i   e   w   kòng控   jiàn件   de的   jié结   gòu构   jiāng将   与   duō多   个   liè列   。   我   men们   jiāng将   chēng称   wéi为   “   图   biāo标   ”   liè列   de的   第   一   liè列   ,   xiǎn显   shì示   zhé折   dié叠   huò或   zhǎn展   kāi开   xiàng项   目   de的   图   biāo标   。   zài在   shèng剩   xià下   de的   lán栏   目   zhōng中   ,   你   可   以   zhǎn展   shì示   你   喜   huan欢   de的   rèn任   何   xìn信   息   。

For example, a simple file browser widget might use two columns, with the directory icons in the first column and the directory or file name in the second columns. Or you might wish to display file sizes, permissions, and other related data in additional columns.

例如,一个简单的文件浏览器组件可能使用两个列,在第一列中的目录图标和第二列中的目录或文件名。或者您可能希望显示其他列的文件大小、权限和其他相关数据。

例   如   ,   一   个   jiǎn简   dān单   de的   wén文   jiàn件   liú浏   lǎn览   器   组   jiàn件   可   néng能   shǐ使   yòng用   liǎng两   个   liè列   ,   zài在   第   一   liè列   zhōng中   de的   目   录   图   biāo标   和   第   èr二   liè列   zhōng中   de的   目   录   huò或   wén文   jiàn件   míng名   。   huò或   zhě者   nín您   可   néng能   希   wàng望   xiǎn显   shì示   其   他   liè列   de的   wén文   jiàn件   大   xiǎo小   、   quán权   xiàn限   和   其   他   xiāng相   guān关   shù数   据   。

The operations of the Treeview widget even allow you to use it as a tree editor. Your program can remove an entire subtree from its location in the main tree and then attach it later at an entirely different point.

在TreeView控件的操作,甚至允许你使用它作为一个树编辑。你的程序可以删除整个子树从它的位置在主树,然后将它之后在一个完全不同的角度。

zài在   T   r   e   e   V   i   e   w   kòng控   jiàn件   de的   cāo操   zuò作   ,   shèn甚   zhì至   yǔn允   许   你   shǐ使   yòng用   它   zuò作   wéi为   一   个   shù树   biān编   辑   。   你   de的   chéng程   序   可   以   shān删   chú除   zhěng整   个   子   shù树   cóng从   它   de的   wèi位   zhi置   zài在   zhǔ主   shù树   ,   rán然   hòu后   jiāng将   它   zhī之   hòu后   zài在   一   个   wán完   quán全   不   tóng同   de的   jiǎo角   度   。

Here is the general procedure for setting up a Treeview widget.

这里是设置TreeView控件的一般程序。

zhè这   里   shì是   shè设   zhì置   T   r   e   e   V   i   e   w   kòng控   jiàn件   de的   一   bān般   chéng程   序   。

1. Create the widget with the ttk.Treeview constructor. Use the columns keyword argument to specify the number of columns to be displayed and to assign symbolic names to each column.

1。创建TTK TreeView的构造函数的部件。使用列关键字参数来指定要显示的列数,并为每个列分配符号名。

1   。   chuàng创   jiàn建   T   T   K   T   r   e   e   V   i   e   w   de的   gòu构   zào造   hán函   shù数   de的   部   jiàn件   。   shǐ使   yòng用   liè列   guān关   jiàn键   字   cān参   shù数   lái来   zhǐ指   dìng定   yào要   xiǎn显   shì示   de的   liè列   shǔ数   ,   bìng并   wèi为   měi每   个   liè列   fēn分   pèi配   符   hào号   míng名   。

2. Use the .column() and .heading() methods to set up column headings (if you want them) and configure column properties such as size and stretchability.

2。使用。column()和。heading()方法设置列标题(如果你想)和配置列属性如大小和拉伸性。

2   。   shǐ使   yòng用   。   c   o   l   u   m   n   (   )   和   。   h   e   a   d   i   n   g   (   )   fāng方   法   shè设   zhì置   liè列   biāo标   题   (   如   guǒ果   你   xiǎng想   )   和   pèi配   zhì置   liè列   shǔ属   xìng性   如   大   xiǎo小   和   拉   shēn伸   xìng性   。

3. Starting with the top-level entries, use the .insert() method to populate the tree. Each call to this method adds one item to the tree. Use the open keyword argument of this method to specify whether the item is initially expanded or collapsed.

三.从顶层的条目,使用方法。insert()填充树。每个对该方法的调用将一个项目添加到树中。使用此方法的打开关键字参数来指定项目是否最初是扩展或折叠的。

sān三   .   cóng从   dǐng顶   céng层   de的   tiáo条   目   ,   shǐ使   yòng用   fāng方   法   。   i   n   s   e   r   t   (   )   tián填   chōng充   shù树   。   měi每   个   duì对   gāi该   fāng方   法   de的   diào调   yòng用   jiāng将   一   个   xiàng项   目   tiān添   jiā加   dào到   shù树   zhōng中   。   shǐ使   yòng用   此   fāng方   法   de的   打   kāi开   guān关   jiàn键   字   cān参   shù数   lái来   zhǐ指   dìng定   xiàng项   目   shì是   fǒu否   zuì最   chū初   shì是   kuò扩   zhǎn展   huò或   zhé折   dié叠   de的   。

If you want to supply the iid value for this item, use the iid keyword argument. If you omit this argument, ttk will make one up and return it as the result of the .insert() method call.

如果你想为这个项目提供的ID值,使用IID关键字参数。如果省略此参数,将使一个TTK并返回它的结果。insert()方法调用。

如   guǒ果   你   xiǎng想   wèi为   zhè这   ge个   xiàng项   目   提   gōng供   de的   I   D   zhí值   ,   shǐ使   yòng用   I   I   D   guān关   jiàn键   字   cān参   shù数   。   如   guǒ果   shěng省   lvè略   此   cān参   shù数   ,   jiāng将   shǐ使   一   个   T   T   K   bìng并   fǎn返   huí回   它   de的   jié结   guǒ果   。   i   n   s   e   r   t   (   )   fāng方   法   diào调   yòng用   。

Use the values keyword argument of this method to specify what should appear in each column of this item when it is visible.

使用此方法的值关键字参数指定在该项目的每个列中应出现的什么时,它是可见的。

shǐ使   yòng用   此   fāng方   法   de的   zhí值   guān关   jiàn键   字   cān参   shù数   zhǐ指   dìng定   zài在   gāi该   xiàng项   目   的   měi每   个   liè列   zhōng中   yīng应   chū出   xiàn现   de的   shén什   me么   shí时   ,   它   shì是   可   jiàn见   de的   。

To create a Treeview widget within a given parent widget:

在一个给定的父控件创建一个TreeView控件:

w = ttk.Treeview(parent, option=value, ...)

构造函数返回新的TreeView控件。它的选项包括:

class_

当您创建这个小部件时,您可以提供一个小部件的名称。此名称可用于自定义小部件的外观;请参见第27节“标准外观”。一旦创建了小部件,则无法更改小部件的名称。

columns

列标识符字符串的序列。这些字符串在内部使用,以确定控件中的列。图标栏,其标识符总是“# 0”,包含折叠/展开的图标总是第一列。

liè列   biāo标   shí识   符   字   符   chuàn串   de的   序   liè列   。   zhè这   xiē些   字   符   chuàn串   zài在   nèi内   部   shǐ使   yòng用   ,   以   què确   dìng定   kòng控   jiàn件   zhōng中   de的   liè列   。   图   biāo标   lán栏   ,   其   biāo标   shí识   符   zǒng总   shì是   “   #   0   ”   ,   bāo包   hán含   zhé折   dié叠   /   zhǎn展   kāi开   de的   图   biāo标   zǒng总   shì是   第   一   liè列   。

The columns you specify with the columns argument are in addition to the icon column.

您指定的列参数的列除了图标列之外。

nín您   zhǐ指   dìng定   de的   liè列   cān参   shù数   de的   liè列   chú除   le了   图   biāo标   liè列   zhī之   wài外   。

For example, if you specified columns=(‘Name‘, ‘Size‘), three columns would appear in the widget: first the icon column, then two more columns whose internal identifiers are ‘Name‘ and ‘Size‘.

例如,如果你指定的列=(‘name‘,‘大小‘),三列将出现在窗口的图标:第一列,然后两柱内部标识符的名称和大小。

cursor

使用该选项指定鼠标光标的外观,当它在窗口;参见5.8节,“光标”。指定的默认值(一个空字符串)指定从父控件继承的光标。

displaycolumns

选择实际上显示的列,并确定它们的演示文稿的顺序。价值观可能:

xuǎn选   择   shí实   际   shang上   xiǎn显   shì示   de的   liè列   ,   bìng并   què确   dìng定   它   men们   de的   yǎn演   shì示   wén文   gǎo稿   de的   shùn顺   序   。   jià价   zhí值   guān观   可   néng能   :

• ‘#all‘ to select all columns and display them in the order defined by the columns argument.

•”#所有选择所有列的列参数定义的顺序显示。

•   ”   #   suǒ所   yǒu有   xuǎn选   择   suǒ所   yǒu有   liè列   de的   liè列   cān参   shù数   dìng定   义   de的   shùn顺   序   xiǎn显   shì示   。

• A list of column numbers (integer positions, counting from 0) or column identifiers from the columns argument.

A列数(整数的位置,从0计数)或列标识符从列参数列表。

A   liè列   shǔ数   (   zhěng整   shù数   de的   wèi位   zhi置   ,   cóng从   0   计   shù数   )   huò或   liè列   biāo标   shí识   符   cóng从   liè列   cān参   shù数   liè列   biǎo表   。

For example, suppose you specify columns=(‘Name‘, ‘Size‘, ‘Date‘). This means each call to the .insert() method will require an argument values=(name, size, date) to supply the values that will be displayed. Let‘s call this sequence the logical column sequence.

例如,假设你指定列=(‘name‘,‘大小‘,‘日‘)。这意味着每个电话。insert()方法需要一个参数值=(名称、大小、日期)提供的值将被显示。让我们将此序列称为“逻辑列”序列。

例   如   ,   jiǎ假   shè设   你   zhǐ指   dìng定   liè列   =   (   ‘   n   a   m   e   ‘   ,   ‘   大   xiǎo小   ‘   ,   ‘   日   ‘   )   。   zhè这   意   wèi味   zhe着   měi每   个   diàn电   huà话   。   i   n   s   e   r   t   (   )   fāng方   法   需   yào要   一   个   cān参   shù数   zhí值   =   (   míng名   chēng称   、   大   xiǎo小   、   日   期   )   提   gōng供   de的   zhí值   jiāng将   bèi被   xiǎn显   shì示   。   ràng让   我   men们   jiāng将   此   序   liè列   chēng称   wéi为   “   luó逻   辑   liè列   ”   序   liè列   。

Further suppose that in the constructor you specify columns=(2,0). The physical column sequence, the columns that will actually appear in the widget, will be three: the icon column will be first, followed by the date column (index 2 in the logical column sequence), followed by the name column (logical column index 0). The size column will not appear.

进一步假设你指定列=构造函数(2,0)。物理列的顺序,将实际出现在小部件中的列,将是三:图标列将是第一个,然后是数据列(逻辑列序列中的索引2),然后是“名称”列(逻辑列索引0)。大小列将不会出现。

jìn进   一   步   jiǎ假   shè设   你   zhǐ指   dìng定   liè列   =   gòu构   zào造   hán函   shù数   (   2   ,   0   )   。   物   理   liè列   de的   shùn顺   序   ,   jiāng将   shí实   际   chū出   xiàn现   zài在   xiǎo小   部   jiàn件   zhōng中   de的   liè列   ,   jiāng将   shì是   sān三   :   图   biāo标   liè列   jiāng将   shì是   第   一   个   ,   rán然   hòu后   shì是   shù数   据   liè列   (   luó逻   辑   liè列   序   liè列   zhōng中   de的   suǒ索   yǐn引   2   )   ,   rán然   hòu后   shì是   “   míng名   chēng称   ”   liè列   (   luó逻   辑   liè列   suǒ索   yǐn引   0   )   。   大   xiǎo小   liè列   jiāng将   不   huì会   chū出   xiàn现   。

You could get the same effect by specifying column identifiers instead of logical column positions: columns=(‘Date‘, ‘Name‘).

你可以通过指定列的标识符,而不是逻辑列位置得到同样的效果:柱=(‘date ‘,‘名‘)。

height

使用此参数可以将额外的空间放在小部件内部的内容周围。您可以提供一个单一的维度或一个高达四个维度的序列,根据本表解释:

Values given Left Top Right Bottom
a a a a a
a b a b a b
a b c a c b c
a b c d a b c d

selectmode

此选项可以控制用户允许使用鼠标选择什么。可以值:

selectmode=‘browse‘                                                   The user may select only one item at a time.                        
selectmode=‘extended‘                                                   The user may select multiple items at once.                        
selectmode=‘none‘                        
The user cannot select items with the mouse.

show

抑制标签在每一列的顶部,指定显示=‘树’。默认是显示列标签。

style

时间: 2024-08-28 16:17:07

ttk.Treeview的相关文章

python tkinter用Treeview实现ListView效果

先上图 再上代码: import ttk from Tkinter import * root = Tk() tree = ttk.Treeview(root, columns=('col1','col2','col3')) tree.column('col1', width=100, anchor='center') tree.column('col2', width=100, anchor='center') tree.column('col3', width=100, anchor='ce

Python GUI 之 Treeview 学习

例子1 from tkinter import *import tkinter.ttk as ttk win = Tk()win.title("Treeview 学习") col = [1,2,3,4]data = {"item0":["1a","2a","3a","4a"], "item1":{"num0":["1n", &q

python gui之tkinter事件处理

事件一览表 事件 代码 备注 鼠标左键单击按下 1/Button-1/ButtonPress-1   鼠标左键单击松开 ButtonRelease-1   鼠标右键单击 3   鼠标左键双击 Double-1/Double-Button-1   鼠标右键双击 Double-3   鼠标滚轮单击 2   鼠标滚轮双击 Double-2   鼠标移动 B1-Motion   鼠标移动到区域 Enter   鼠标离开区域 Leave   获得键盘焦点 FocusIn   失去键盘焦点 FocusOut

tkinter菜单图标,工具栏

所用的图片: import tkinter as tk from tkinter import messagebox, filedialog, simpledialog, colorchooser from tkinter import ttk from PIL import Image, ImageTk import time import threading def showdialog(): '''各种窗口''' #res = messagebox.askokcancel(title='标

双色球小助手

500w.py from pyCyp import * from tkinter import * from tkinter import ttk #from tkinter import messagebox import itertools urlNewqi = 'http://kaijiang.500.com/' newqi = getNewqi(urlNewqi) url = 'http://datachart.500.com/ssq/history/newinc/history.php

家康粮油蔬菜水果超市--用户管理系统

from tkinter import * from tkinter import ttk import time from tkinter import messagebox win = Tk() win.title('家康粮油蔬菜水果超市--用户管理系统') win.geometry('800x600+400+200') win.resizable(width=False,height=False) #win.attributes('-topmost',-1) #会员查询 group1 =

python gui之tkinter语法杂记

随手写的,后续整理. 1. Entry如何调用父类的__init__? 以下错,原因后续分析 super(Your_Entry_Class, self).__init__(self,**kw) 报错:TypeError: must be type, not instance . 莫名其妙 谷歌了下,解决方案如下 apply(Entry.__init__, (self, parent), **kw) 2. 如何将ttk treeview 的某一行转入编辑状态 事实上,(python 3)treev

tkinter中表格的建立(十三)

表格的建立 1 import tkinter 2 from tkinter import ttk 3 4 wuya = tkinter.Tk() 5 wuya.title("wuya") 6 wuya.geometry("300x200+10+20") 7 8 # 创建表格 9 tree_date = ttk.Treeview(wuya) 10 11 # 定义列 12 tree_date['columns'] = ['name','age','weight','nu

python连接Mysql数据库写的小电话本

先不说了,先把代码放这,等有时间再说明程序里的问题, 这个小程序知识把功能实现,并没有对布局方面有太多追求 有些注释掉的也没有删除,也没有个函数包起来,整体看着 应该是有点乱 以下是完整代码, import tkinter import pymysql from tkinter import * from tkinter import ttk window=tkinter.Tk()#创建窗口 window.title("电话簿")#设置标题 window.geometry('500x5