You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.8 KiB
101 lines
3.8 KiB
#!/usr/bin/python
|
|
#-*- coding: utf-8 -*-
|
|
|
|
# Copyright 2012 Calculate Ltd. http://www.calculate-linux.org
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
from PySide import QtGui, QtCore
|
|
|
|
from pid_information import client_list_pid, client_pid_info
|
|
from more import LabelWordWrap
|
|
|
|
class ViewProcClass(QtGui.QWidget):
|
|
|
|
def __init__(self, parent, ClientObj):
|
|
super(ViewProcClass, self).__init__()
|
|
self.parent = parent
|
|
self.ClientObj = ClientObj
|
|
self.client = ClientObj.client
|
|
self.pid = 0
|
|
client_pid_info(ClientObj, ClientObj.client, 0)
|
|
list_pid = client_list_pid(self.ClientObj.client)
|
|
|
|
self.lable_list = []
|
|
self.button_list = []
|
|
self.layout = QtGui.QGridLayout()
|
|
self.helpLabel = LabelWordWrap('View information about running processes:')
|
|
self.layout.addWidget(self.helpLabel, 0, 0, 1, 0)
|
|
|
|
if not list_pid:
|
|
list_pid = []
|
|
|
|
for num in range (0, len(list_pid)):
|
|
try:
|
|
method_name = self.ClientObj.process_dict[str(list_pid[num])]['name']
|
|
self.lable_list.append(LabelWordWrap('-- '+ str(method_name)))
|
|
self.layout.addWidget(self.lable_list[num], num+1,0)
|
|
except:
|
|
pass
|
|
|
|
button_text = str(list_pid[num])
|
|
Button = QtGui.QPushButton(button_text)
|
|
|
|
Button.clicked.connect(self.onActivated)
|
|
|
|
self.button_list.append(Button)
|
|
self.layout.addWidget(self.button_list[num], num+1,1)
|
|
|
|
if not len(list_pid):
|
|
self.layout.addWidget(LabelWordWrap('No running processes in current session.'))
|
|
|
|
# for clear memory after closed this window
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
self.layout.setAlignment(QtCore.Qt.AlignTop)
|
|
|
|
self.setLayout(self.layout)
|
|
self.show()
|
|
|
|
|
|
def onActivated(self):
|
|
pid = self.sender().text()
|
|
for i in self.ClientObj.process_dict:
|
|
print "+++++>>", type(i),i, pid, type(pid)
|
|
if i == pid:
|
|
# try:
|
|
# self.ClientObj.process_dict[i]['result']
|
|
# except:
|
|
# self.ClientObj.process_dict[i]['result'] = {}
|
|
self.ClientObj.MainWidget.main_view_process\
|
|
(self.ClientObj.process_dict[i]['name'], \
|
|
self.ClientObj.process_dict[i]['result'], str(i))
|
|
self.ClientObj.app.processEvents()
|
|
self.ClientObj.MainWidget.main_frame.verticalScrollBar().setValue \
|
|
(self.ClientObj.MainWidget.main_frame.verticalScrollBar().maximum())
|
|
break
|
|
|
|
class ViewProc (QtGui.QScrollArea):
|
|
def __init__(self, parent, ClientObj):
|
|
QtGui.QScrollArea.__init__(self)
|
|
self.parent = parent
|
|
# верхнее правое
|
|
self.MainFrameWgt = ViewProcClass(self, ClientObj)
|
|
self.setWidget(self.MainFrameWgt)
|
|
self.setWidgetResizable(True)
|
|
|
|
# def resizeEvent(self, resize_var):
|
|
# self.parent.set_wid (self.size().width())
|
|
# if self.size().width() > 30:
|
|
# self.MainFrameWgt.setFixedWidth(self.parent.mainwidth - 30)
|