双击QTreeWidget(PyQt)中的项目时没有输出

时间:2016-04-16 13:46:47

标签: python qt pyqt qtreewidget

我创建了一个包含名为StudentTreeWidget的QTreeWidget的窗口,当双击Tree Widget中的一个项目时,它应该打开另一个名为StudentEnterprisePassport的窗口:

2016-04-16 20:05:41.162   .DynamicServerListLoadBalancer     DynamicServerListLoadBalancer for client useraccount initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=useraccount,current list of Servers=[192.168.1.101:useraccount:d3fb971b6fe30dc5e9cbfdf0e713cd12],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone;  Instance count:1;   Active connections count: 0;    Circuit breaker tripped count: 0;   Active connections per server: 0.0;]
},Server stats: [[Server:192.168.1.101:useraccount:d3fb971b6fe30dc5e9cbfdf0e713cd12;    Zone:defaultZone;   Total Requests:0;   Successive connection failure:0;    Total blackout seconds:0;   Last connection made:Thu Jan 01 08:00:00 CST 1970;  First connection made: Thu Jan 01 08:00:00 CST 1970;    Active Connections:0;   total failure count in last (1000) msecs:0; average resp time:0.0;  90 percentile resp time:0.0;    95 percentile resp time:0.0;    min resp time:0.0;  max resp time:0.0;  stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@19c54b19
2016-04-16 20:05:41.836[2m[nio-8002-exec-4][36mo.a.c.c.C.[.[.[/].[dispatcherServlet]  [0;39m Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: createUser timed-out and no fallback available.] with root cause

java.util.concurrent.TimeoutException: null
    at com.netflix.hystrix.AbstractCommand$9.call(AbstractCommand.java:600) ~[hystrix-core-1.5.1.jar:1.5.1]
    at com.netflix.hystrix.AbstractCommand$9.call(AbstractCommand.java:580) ~[hystrix-core-1.5.1.jar:1.5.1]
    at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:99) ~[rxjava-1.0.14.jar:1.0.14]
    at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.14.jar:1.0.14]
    at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.14.jar:1.0.14]
    at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$1.run(AbstractCommand.java:955) ~[hystrix-core-1.5.1.jar:1.5.1]
    at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:41) ~[hystrix-core-1.5.1.jar:1.5.1]
    at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:37) ~[hystrix-core-1.5.1.jar:1.5.1]
    at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable.run(HystrixContextRunnable.java:57) ~[hystrix-core-1.5.1.jar:1.5.1]
    at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$2.tick(AbstractCommand.java:972) ~[hystrix-core-1.5.1.jar:1.5.1]
    at com.netflix.hystrix.util.HystrixTimer$1.run(HystrixTimer.java:99) ~[hystrix-core-1.5.1.jar:1.5.1]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_40]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[na:1.8.0_40]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_40]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[na:1.8.0_40]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_40]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_40]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]

运行代码时没有输出错误,但是当我双击Tree Widget中的项目时没有任何反应。正在从Qt Designer创建和转换的Ui文件中导入QTreeWidget窗口。

class Student_search(Ui_Student_search):
    def __init__(self, database, tableName, parent=None):
        QtGui.QWidget.__init__(self)
        self.dbu = DB_manager_students.DatabaseUtility(database, tableName)
        self.connect(self, QtCore.SIGNAL('itemClicked(QTreeWidgetItem*, int)'), self.handleButton)
        self.setupUi(self)
        self.UpdateTree()
        self.window4 = None

    def handleButton(self):
        if self.window4 is None:
            database = 'EnterprisePassport'
            tablename = 'students'
            self.window4 = StudentEnterprisePassport(database, tablename)
            self.window4.show()

class StudentEnterprisePassport(Ui_StudentEnterprisePassport):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.setupUi(self)
        self.sessionTracker_btn.clicked.connect(self.handleButton)

将数据输入TreeWidget的代码:

from PyQt4 import QtCore, QtGui
import DB_manager_students, sys
(....)

class Ui_Student_search(QtGui.QWidget):
    def __init__(self, database, tableName):
        QtGui.QWidget.__init__(self)
        self.dbu = DB_manager_students.DatabaseUtility(database, tableName)
        self.setupUi(self)
        self.UpdateTree()

    def setupUi(self, Student_search):
        Student_search.setObjectName(_fromUtf8("Student_search"))
        Student_search.resize(1299, 856)
        self.gridLayout = QtGui.QGridLayout(Student_search)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.verticalLayout_2 = QtGui.QVBoxLayout()
        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
        self.StudentTreeWidget = QtGui.QTreeWidget(Student_search)
        self.StudentTreeWidget.setObjectName(_fromUtf8("StudentTreeWidget"))
        self.verticalLayout_2.addWidget(self.StudentTreeWidget)
        self.gridLayout.addLayout(self.verticalLayout_2, 0, 0, 1, 1)

0 个答案:

没有答案