treenode.py
Go to the documentation of this file.
1 '''
2  Copyright (C) 1997-2017 JDERobot Developers Team
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Library General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, see <http://www.gnu.org/licenses/>.
16 
17  Authors : Okan Asik (asik.okan@gmail.com)
18 
19  '''
20 from PyQt5.QtWidgets import QTreeWidgetItem
21 from PyQt5.QtGui import QColor
22 
23 class TreeNode(QTreeWidgetItem):
24  def __init__(self, id, name, color, parent=None):
25  super(QTreeWidgetItem, self).__init__(parent)
26 
27  self.parentItem = parent
28  self.id = id
29  self.name = name
30  self.color = color
31  self.childItems = []
32 
33  def background(self):
34  background = QColor(self.color)
35  return background
36 
37  def appendChild(self, item):
38  self.childItems.append(item)
39 
40  def removeChild(self, item):
41  self.childItems.remove(item)
42 
43  def child(self, row):
44  return self.childItems[row]
45 
46  def childCount(self):
47  return len(self.childItems)
48 
49  def columnCount(self):
50  return 2
51 
52  def data(self, column):
53  if column == 0:
54  return self.id
55  if column == 1:
56  return self.name
57 
58  def parent(self):
59  return self.parentItem
60 
61  def row(self):
62  if self.parentItem:
63  return self.parentItem.childItems.index(self)
64  return 0
65 
66  def getChildren(self):
67  return self.childItems
68 
69  def setColor(self, color):
70  self.color = color
71 
72  def removeChildren(self):
73  del self.childItems[:]
74 
75  def myClicked(self, item, column):
76  # print('clicked:' + str(item))
77  pass
def __init__(self, id, name, color, parent=None)
Definition: treenode.py:24
def myClicked(self, item, column)
Definition: treenode.py:75


visualstates
Author(s):
autogenerated on Thu Apr 1 2021 02:42:20