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.
calculate-utils-3-console-gui/console/gui/more.py

798 lines
28 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
import os, time, sys
from calculate.api.cl_api import DataVarsApi
from pid_information import client_list_methods
from calculate.api.client.sid_func import client_del_sid
#from calculate.api.client.function import get_sid
class TopMenu(QtGui.QPushButton):
def __init__(self, label, image, parent = None):
QtGui.QPushButton.__init__(self, parent)
self.layout = QtGui.QVBoxLayout(self)
self.image_lbl = QtGui.QLabel(self)
icon = QtGui.QIcon.fromTheme(image)
pm2 = icon.pixmap(24,24)
self.image_lbl.setPixmap(pm2)
self.image_lbl.setAlignment(QtCore.Qt.AlignCenter)
# add transparency
self.image_lbl.setAttribute(QtCore.Qt.WA_NoSystemBackground)
self.layout.addWidget(self.image_lbl)
self.setFlat(True)
self.lbl = QtGui.QLabel(label, self)
self.lbl.setAlignment(QtCore.Qt.AlignCenter)
# add transparency
self.lbl.setAttribute(QtCore.Qt.WA_NoSystemBackground)
self.layout.addWidget(self.lbl)
# self.layout.setContentsMargins(4,4,4,4)
self.layout.setSpacing(0)
# self.setFixedSize(48,40)
self.setFixedHeight(48)
if self.lbl.sizeHint().width() > 32:
self.setFixedWidth(self.lbl.sizeHint().width()+16)
else:
self.setFixedWidth(48)
self.updateGeometry()
def text(self):
return self.lbl.text()
class ButtonMenu(QtGui.QPushButton):
def __init__(self, name, label, image, parent = None):
QtGui.QPushButton.__init__(self, parent)
self.layout = QtGui.QVBoxLayout(self)
self.image_lbl = QtGui.QLabel(self)
if not image:
image = ''
icon = QtGui.QIcon.fromTheme(image)
if icon.isNull():
if os.path.isfile(image):
ir = QtGui.QImageReader(image)
ir.setScaledSize(QtCore.QSize(64, 64))
img = ir.read()
pm2 = QtGui.QPixmap().fromImage(img)
else:
icon = QtGui.QIcon.fromTheme('applications-utilities')
pm2 = icon.pixmap(64,64)
else:
pm2 = icon.pixmap(64,64)
self.image_lbl.setPixmap(pm2)
self.image_lbl.setAlignment(QtCore.Qt.AlignCenter)
# add transparency
self.image_lbl.setAttribute(QtCore.Qt.WA_NoSystemBackground)
self.layout.addWidget(self.image_lbl)
self.setFlat(True)
if not label:
label = name
self.lbl = LabelWordWrap(label, self)
self.lbl.setAlignment(QtCore.Qt.AlignCenter)
# add transparency
self.lbl.setAttribute(QtCore.Qt.WA_NoSystemBackground)
self.layout.addWidget(self.lbl)
self.setFixedSize(96,108)
self.setObjectName(name)
# for clear memory after closed this window
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.updateGeometry()
def text(self):
return self.lbl.text()
class ErrorLabel (QtGui.QLabel):
def __init__(self, parent = None):
QtGui.QLabel.__init__(self, parent)
self.parent = parent
self.setWordWrap(True)
self.hide()
# self.setAlignment(QtCore.Qt.AlignCenter)
# for clear memory after closed this window
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
class LabelWordWrap(QtGui.QLabel):
def __init__(self, name, parent = None):
try:
name = name.decode('utf-8')
except (UnicodeDecodeError, UnicodeEncodeError):
pass
QtGui.QLabel.__init__(self, name, parent)
self.parent = parent
self.setWordWrap(True)
# for clear memory after closed this window
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
class ClearLineEdit(QtGui.QLineEdit):
def __init__(self,parent=None):
QtGui.QLineEdit.__init__(self,parent)
self.parent = parent
self.button=QtGui.QToolButton(self)
self.button.setCursor(QtCore.Qt.ArrowCursor)
self.button.hide()
self.button.setFocusPolicy(QtCore.Qt.NoFocus)
try:
self.button.setIcon(QtGui.QIcon.fromTheme("edit-clear"))
except:
self.button.setText('clear')
self.button.setStyleSheet("border: none;")
self.textChanged.connect(self.changed)
self.button.clicked.connect(self.clear)
# for clear memory after closed this window
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
layout=QtGui.QVBoxLayout(self)
layout.addWidget(self.button,0,QtCore.Qt.AlignRight)
layout.setSpacing(0)
def changed(self,text):
if len(text)==0: self.button.hide()
else: self.button.show()
def focusInEvent(self, FocusEvent):
if self.text() == self.parent:
self.clear()
def focusOutEvent(self, FocusEvent):
if self.text() == '':
self.setText(self.parent)
class FileOpenWgt(QtGui.QLineEdit):
def __init__(self, parent, type, caption=None, directory=None, filter=None, \
hidden = False):
QtGui.QLineEdit.__init__(self,parent)
self.type = type
self.caption = caption
self.dir = directory
self.filter = filter
self.hidden = hidden
self.data = None
self.button=QtGui.QToolButton(self)
self.button.setCursor(QtCore.Qt.ArrowCursor)
self.button.setFocusPolicy(QtCore.Qt.NoFocus)
try:
self.button.setIcon(QtGui.QIcon.fromTheme("document-open"))
except:
self.button.setText(_('Open'))
self.button.setStyleSheet("border: none;")
self.button.clicked.connect(self.file_dialog)
# for clear memory after closed this window
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
layout=QtGui.QVBoxLayout(self)
layout.addWidget(self.button,0,QtCore.Qt.AlignRight)
layout.setSpacing(0)
if self.type == 'files':
self.setReadOnly(True)
def file_dialog(self):
if not self.filter:
self.filter = None
self.fd = QtGui.QFileDialog(self, self.caption, self.dir, self.filter)
if self.hidden:
print 'Hidden'
self.fd.setFilter(QtCore.QDir.Hidden)
# self.fd.setFilter(QtCore.QDir.Filter.AllEntries)
# self.fd.setFilter(QtCore.QDir.Filter.AllDirs)
# self.fd.setFilter(QtCore.QDir.Filter.System)
self.fd.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
if self.type == 'dir':
self.data = self.fd.getExistingDirectory()
if self.type == 'file':
data = self.fd.getOpenFileName()
self.data = data[0]
if self.type == 'files':
data = self.fd.getOpenFileNames()
self.data = data[0]
self.set_label()
def getFileName(self, filename):
self.setText(filename)
def set_label(self):
if type(self.data) in [str, unicode]:
self.setText(self.data)
elif type(self.data) == list:
lbl = ', '.join(self.data)
self.setText(lbl)
class CentralCheckBox (QtGui.QWidget):
def __init__(self, tristate, text = None, parent = None):
super(CentralCheckBox, self).__init__(parent)
self.lay = QtGui.QHBoxLayout(self)
self.pCheckB = QtGui.QCheckBox(self)
self.lay.addWidget(self.pCheckB)
self.lay.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
self.setLayout(self.lay)
self.pCheckB.clicked.connect(self.change_label)
if tristate:
self.pCheckB.setTristate()
self.change_label()
def setChecked(self, check = True):
self.pCheckB.setChecked(check)
self.change_label()
def isChecked(self):
return self.pCheckB.isChecked()
def set_label(self, text):
self.pCheckB.setText(text)
def change_label(self):
if self.pCheckB.checkState() == QtCore.Qt.CheckState.PartiallyChecked:
self.set_label('Auto')
elif self.pCheckB.checkState() == QtCore.Qt.CheckState.Checked:
self.set_label('Yes')
else:
self.set_label('No')
def setCheckState(self, CheckState):
self.pCheckB.setCheckState(CheckState)
self.change_label()
def getState(self):
if self.pCheckB.isTristate():
if self.pCheckB.checkState() == QtCore.Qt.CheckState.PartiallyChecked:
return 'auto'
elif self.pCheckB.checkState() == QtCore.Qt.CheckState.Checked:
return 'on'
else:
return 'off'
else:
if self.pCheckB.isChecked():
return 'on'
else:
return 'off'
class MultipleChoiceDialog (QtGui.QWidget):
""" Widget opens a dialog multiple select """
def __init__(self, parent, Available_list, Selected_list, add_ability):
super(MultipleChoiceDialog, self).__init__()
self.parent = parent
self.layout = QtGui.QGridLayout(self)
# if there is a possibility of adding
if add_ability:
# add "input new items" LineEdit
self.add_LineEdit = QtGui.QLineEdit(self)
self.layout.addWidget(self.add_LineEdit, 0,0,1,4)
# add "add new items" PushButton
self.add_Button = QtGui.QPushButton(self)
try:
self.add_Button.setIcon(QtGui.QIcon.fromTheme("list-add"))
except:
self.add_Button.setText('Add Item')
self.add_Button.clicked.connect(self.add_new_item)
self.layout.addWidget(self.add_Button, 0,4)
# add 2 labels
self.available_label = QtGui.QLabel('Available values', self)
self.layout.addWidget(self.available_label, 1,0,1,2)
self.selected_label = QtGui.QLabel('Selected values', self)
self.layout.addWidget(self.selected_label, 1,3,1,2)
#add left list
self.left_ListWidget = QtGui.QListWidget(self)
self.left_ListWidget.itemDoubleClicked.connect(self.plus_item)
self.layout.addWidget(self.left_ListWidget, 2,0,2,2)
# add '+' button
self.plus_Button = QtGui.QPushButton(self)
try:
self.plus_Button.setIcon(QtGui.QIcon.fromTheme("go-next-view"))
except:
self.plus_Button.setText('+')
self.plus_Button.clicked.connect(self.plus_item)
self.layout.addWidget(self.plus_Button, 2,2)
# add '-' button
self.minus_Button = QtGui.QPushButton(self)
try:
self.minus_Button.setIcon(QtGui.QIcon.fromTheme("go-previous-view"))
except:
self.minus_Button.setText('-')
self.minus_Button.clicked.connect(self.minus_item)
self.layout.addWidget(self.minus_Button, 3,2)
#add right list
self.right_ListWidget = QtGui.QListWidget(self)
self.right_ListWidget.itemDoubleClicked.connect(self.minus_item)
self.layout.addWidget(self.right_ListWidget, 2,3,2,2)
# add OK button
self.Ok_Button = QtGui.QPushButton('Ok', self)
self.Ok_Button.clicked.connect(self.ok_pressed)
self.layout.addWidget(self.Ok_Button, 4,3)
# add Cancel button
self.Cancel_Button = QtGui.QPushButton('Cancel', self)
self.Cancel_Button.clicked.connect(self.close)
self.layout.addWidget(self.Cancel_Button, 4,4)
#add Items in list
self.left_ListWidget.addItems(Available_list)
self.right_ListWidget.addItems(Selected_list)
self.setLayout(self.layout)
def add_new_item(self):
# Slot click event add_Button
if self.add_LineEdit.text() not in [None, '']:
self.right_ListWidget.addItem(self.add_LineEdit.text())
self.add_LineEdit.setText('')
self.add_LineEdit.setFocus()
def plus_item(self):
# get item in left_ListWidget and set this item in right_ListWidget
temp_item = self.left_ListWidget.takeItem(self.left_ListWidget.currentRow())
self.right_ListWidget.addItem(temp_item)
def minus_item(self):
# get item in right_ListWidget and set this item in left_ListWidget
temp_item = self.right_ListWidget.takeItem(self.right_ListWidget.currentRow())
self.left_ListWidget.addItem(temp_item)
def ok_pressed(self):
# save all lists and close this widget
self.parent.Selected = []
for i in range(self.right_ListWidget.count()):
self.parent.Selected.append(self.right_ListWidget.takeItem(0).text())
self.parent.avail = []
for i in range(self.left_ListWidget.count()):
self.parent.avail.append(self.left_ListWidget.takeItem(0).text())
# self.parent.Selected = ','.join(self.parent.select)
self.parent.change_value()
self.close()
def keyPressEvent(self, key):
if key.key() in [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]:
if hasattr (self, 'add_Button'):
self.add_new_item()
class MultipleChoice (QtGui.QWidget):
# multiple-choice widget displayed in the table
def __init__(self, parent, Available_list, Selected, comments, add_ability = False):
super(MultipleChoice, self).__init__()
# Available_list is string list, Selected_list is string, add_ability is boolean
self.avail = Available_list
self.Selected = Selected
self.Comments = comments
# self.select = Selected if Selected else []
self.ability = add_ability
self.value_dict = None
if self.Comments:
self.value_dict = {}
for i in range (len(self.Comments.string)):
self.value_dict[self.avail[i]] = self.Comments.string[i]
layout = QtGui.QHBoxLayout(self)
self.label_text = ','.join(self.Selected)
self.lbl = QtGui.QLineEdit(self.label_text, self)
self.lbl.setDisabled(True)
layout.addWidget(self.lbl)
self.button=QtGui.QToolButton(self)
self.button.setCursor(QtCore.Qt.ArrowCursor)
# self.button.hide()
self.button.setFocusPolicy(QtCore.Qt.NoFocus)
try:
self.button.setIcon(QtGui.QIcon.fromTheme("list-add"))
except:
self.button.setText('+')
self.button.setStyleSheet("border: none;")
self.button.clicked.connect(self.mousePressEvent)
layout.addWidget(self.button,QtCore.Qt.AlignRight)
self.setLayout(layout)
def mousePressEvent(self, button = None):
# call widget MultipleChoiceDialog in new window
self.MCD = MultipleChoiceDialog(self, self.avail, self.Selected, self.ability)
self.MCD.setAttribute(QtCore.Qt.WA_ShowModal)
self.MCD.move(QtGui.QCursor.pos ())
self.MCD.show()
def change_value(self):
# show values in label
# self.select = self.Selected.split(',') if self.Selected else []
self.label_text = ','.join(self.Selected)
self.lbl.setText(self.label_text)
def text(self):
return self.lbl.text()
def values(self):
if self.Comments:
result = []
for i in self.Selected:
if self.value_dict.has_key(i):
result.append(self.value_dict[i])
else:
result.append(i)
return result
else:
return self.Selected
class FlowLayout(QtGui.QLayout):
def __init__(self, parent=None, margin=0, spacing=-1):
super(FlowLayout, self).__init__(parent)
self.setSpacing(spacing)
self.itemList = []
def __del__(self):
item = self.takeAt(0)
while item:
item = self.takeAt(0)
def addItem(self, item):
self.itemList.append(item)
def count(self):
return len(self.itemList)
def itemAt(self, index):
if index >= 0 and index < len(self.itemList):
return self.itemList[index]
return None
def takeAt(self, index):
if index >= 0 and index < len(self.itemList):
return self.itemList.pop(index)
return None
def expandingDirections(self):
return QtCore.Qt.Orientations(QtCore.Qt.Orientation(0))
def hasHeightForWidth(self):
return True
def heightForWidth(self, width):
height = self.doLayout(QtCore.QRect(0, 0, width, 0), True)
return height
def setGeometry(self, rect):
super(FlowLayout, self).setGeometry(rect)
self.doLayout(rect, False)
def sizeHint(self):
return self.minimumSize()
def minimumSize(self):
size = QtCore.QSize()
for item in self.itemList:
size = size.expandedTo(item.minimumSize())
# size += QtCore.QSize(2 * self.margin(), 2 * self.margin())
return size
def doLayout(self, rect, testOnly):
x = rect.x()
y = rect.y()
lineHeight = 0
for item in self.itemList:
wid = item.widget()
spaceX = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Horizontal)
spaceY = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Vertical)
nextX = x + item.sizeHint().width() + spaceX
if nextX - spaceX > rect.right() and lineHeight > 0:
x = rect.x()
y = y + lineHeight + spaceY
nextX = x + item.sizeHint().width() + spaceX
lineHeight = 0
if not testOnly:
item.setGeometry(QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint()))
x = nextX
lineHeight = max(lineHeight, item.sizeHint().height())
return y + lineHeight - rect.y()
class PlusRow (QtGui.QWidget):
""" Widget opens a dialog multiple select """
def __init__(self, parent, table, field):
super(PlusRow, self).__init__()
# self.parent = parent
self.grid = QtGui.QGridLayout(self)
self.field = field
self.table = table
x = 0
y = 0
self.widget_dict = {}
for i in range (len(field.tablevalue.values.ChoiceValue)):
element = field.tablevalue.values.ChoiceValue[i].typefield
name = field.tablevalue.head.string[i]
# add element in frame
if element == 'input':
#add label
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
self.widget_dict[str(i)] = QtGui.QLineEdit(self)
if field.default:
self.widget_dict[str(i)].setText(field.default)
if field.type == 'int':
self.rx = QtCore.QRegExp ("^[\d]{1,50}$")
self.validator = QtGui.QRegExpValidator(self.rx, self)
self.widget_dict[str(i)].setValidator(self.validator)
elif field.type == 'float':
self.rx = QtCore.QRegExp ("^[\d]{1,50}[.][\d]{1,50}$")
self.validator = QtGui.QRegExpValidator(self.rx, self)
self.widget_dict[str(i)].setValidator(self.validator)
x += 1
elif element == 'check':
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
self.widget_dict[str(i)] = CentralCheckBox(_('Yes'),self)
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
x += 1
elif element == 'combo':
choice = field.tablevalue.values.ChoiceValue[i].values.string
#add label
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
self.ComboBox = QtGui.QComboBox(self)
for j in range(0,len(choice)):
self.ComboBox.addItem(choice[j])
self.widget_dict[str(i)] = self.ComboBox
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
x += 1
elif element == 'comboEdit':
choice = field.tablevalue.values.ChoiceValue[i].values.string
#add label
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
self.ComboBox = QtGui.QComboBox(self)
self.ComboBox.setDuplicatesEnabled(False)
self.ComboBox.setEditable(True)
self.ComboBox.setLineEdit(QtGui.QLineEdit(self))
for j in range(0,len(choice)):
self.ComboBox.addItem(choice[j])
self.widget_dict[str(i)] = self.ComboBox
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
x += 1
elif element in ['multichoice', 'multichoice_add']:
if field.element == 'multichoice_add':
add_ability = True
else:
add_ability = False
choice = field.tablevalue.values.ChoiceValue[i].values.string
default = ''
self.widget_dict[str(i)] = \
MultipleChoice(self, choice, default, add_ability)
#add label
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
x += 1
# add OK button
self.Ok_Button = QtGui.QPushButton('Ok', self)
self.Ok_Button.clicked.connect(self.ok_pressed)
self.grid.addWidget(self.Ok_Button, x,y)
# add Cancel button
self.Cancel_Button = QtGui.QPushButton('Cancel', self)
self.Cancel_Button.clicked.connect(self.close)
self.grid.addWidget(self.Cancel_Button, x,y+1)
self.move(parent.frameGeometry().x() + parent.size().width()/2 - 150,\
parent.frameGeometry().y() + parent.size().height()/2 - 100)
self.setLayout(self.grid)
def ok_pressed(self):
row = self.table.rowCount()
self.table.setRowCount(row + 1);
# add widgets in table
for i in range (len(self.field.tablevalue.values.ChoiceValue)):
if type(self.widget_dict[str(i)]) == QtGui.QCheckBox:
pass
# self.table.setCellWidget(row, i, self.widget_dict[str(i)])
elif type(self.widget_dict[str(i)]) == CentralCheckBox:
self.table.setCellWidget(row, i, self.widget_dict[str(i)])
elif type(self.widget_dict[str(i)]) == QtGui.QComboBox:
self.table.setCellWidget(row, i, self.widget_dict[str(i)])
elif type(self.widget_dict[str(i)]) == QtGui.QLineEdit:
self.table_widget.setItem(row, i, QtGui.QTableWidgetItem \
(self.widget_dict[str(i)].text()))
elif type(self.widget_dict[str(i)]) == MultipleChoice:
self.table.setCellWidget(row, i, self.widget_dict[str(i)])
# adding in table 'readonly' values
diff = self.table.columnCount() - len(self.field.tablevalue.values.ChoiceValue)
for j in range (diff):
column = i + j + 1
tablewidgetitem = QtGui.QTableWidgetItem()
self.table.setItem(row, column, tablewidgetitem)
self.table.item(row, column).setFlags(QtCore.Qt.ItemIsEditable)
font = self.table.item(row, column).font()
font.setWeight(QtGui.QFont.Black)
self.table.item(row, column).setFont(font)
self.close()
def show_msg(text, title = None):
msgBox = QtGui.QMessageBox()
if title:
msgBox.setWindowTitle(title)
if type(text) != str:
temp = ''
for i in text:
temp += str(i).decode('utf-8')
text = temp
msgBox.setText(text)
msgBox.setStandardButtons(QtGui.QMessageBox.Ok)
msgBox.exec_()
def show_question(parent, text, informative_text):
msgBox = QtGui.QMessageBox()
msgBox.setText(text)
msgBox.setInformativeText(informative_text)
msgBox.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
msgBox.setDefaultButton(QtGui.QMessageBox.No)
msgBox.move(parent.frameGeometry().x() + parent.size().width()/2 - 150,\
parent.frameGeometry().y() + parent.size().height()/2 - 100)
reply = msgBox.exec_()
return reply
#def uniq(seq):
# seen = set()
# seen_add = seen.add
# return [ x for x in seq if x not in seen and not seen_add(x)]
def uniq(seq):
seen = set()
return [ x for x in seq if x not in seen and not seen.add(x)]
def client_signal(client):
Vars = DataVarsApi()
Vars.importApi()
Vars.flIniFile()
try:
client_active = Vars.Get('cl_api_client_active_period')
except:
show_msg('Write cl_api_client_active_period Error!')
client_active = 15
while True:
if os.path.exists(client.SID_FILE) :
fi = open(client.SID_FILE, 'r')
temp = fi.read()
fi.close()
sid = int(temp)
else:
sid = 0
try:
reply = client.service.active_client(sid)
if reply:
print "Error 'active client' in server!"
return
except:
show_msg ('no connection to server!')
sys.exit()
time.sleep(float(client_active))
class VerifyError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def client_post_auth(client):
""" authorization client or post request """
try:
if os.path.exists(client.CERT_FILE) :
pass
else:
show_msg ("You do not have a certificate. Use certificates in toolbar "
"for generate new certificate or for get new certificate "
"from server.")
return 1
except VerifyError, e:
show_msg (e.value)
return 1
return 0
def https_server(client, signaling, ClientObj):
global url
if client_post_auth(client):
# Exit with closing session
client_del_sid(ClientObj.client)
ClientObj.client = None
ClientObj.MainWidget.process_dict = {}
return 1
signaling.start()
# Add Icons in MainMenu
icon_visible(ClientObj.MainWidget, 'Disconnect', True)
icon_visible(ClientObj.MainWidget, 'Processes', True)
icon_visible(ClientObj.MainWidget, 'Session', True)
icon_visible(ClientObj.MainWidget, 'Connect', False)
icon_visible(ClientObj.MainWidget, 'Certificates', False)
ClientObj.methods_list = client_list_methods(client)
if ClientObj.methods_list == 1:
show_msg ('No methods available!')
else:
RES = 0 # Access to result
COM = 0 # Getting command line
METH = 1 # Getting method line
for num in range (0, len(ClientObj.methods_list)):
print " %s - %s" % (ClientObj.methods_list[num][RES][COM],\
ClientObj.methods_list[num][RES][METH])
ClientObj.MainWidget.display_methods()
# ClientObj.MainWidget.main_frame.refresh(ClientObj.methods_list)
ClientObj.MainWidget.resize \
(ClientObj.MainWidget.size_x, ClientObj.MainWidget.size_y)
# ClientObj.MainWidget.topleft.menu.refresh(ClientObj.methods_list)
# get_entire_frame(client)
def icon_visible (mainwgt, name, action):
# show/hide Icon in MainMenu
if hasattr (mainwgt.topmenu, name):
getattr (mainwgt.topmenu, name).setVisible(action)