parent
318d571c24
commit
3f12f1efa7
@ -0,0 +1,313 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from PySide import QtGui, QtCore
|
||||
from PySide.QtGui import QLabel, QLineEdit, QPushButton, QCheckBox, QGroupBox
|
||||
from calculate.api.client.function import create_obj, get_sid, switch
|
||||
from more import _, show_msg
|
||||
|
||||
import sys, time
|
||||
|
||||
class MainFrameResWgt(QtGui.QWidget):
|
||||
work_layout = QtGui.QVBoxLayout()
|
||||
|
||||
def __init__(self, parent, ClientObj, method_name, meth_result):
|
||||
super(MainFrameResWgt, self).__init__()
|
||||
self.ClientObj = ClientObj
|
||||
self.method_name = method_name
|
||||
self.meth_result = meth_result
|
||||
self.client = ClientObj.client
|
||||
|
||||
# self.analysis(self.ClientObj.sid, meth_result)
|
||||
|
||||
# self.work_layout = QtGui.QVBoxLayout()
|
||||
self.title_lbl = QLabel(method_name)
|
||||
self.work_layout.addWidget(self.title_lbl)
|
||||
# self.work_layout.SizeConstraint.SetDefaultConstraint
|
||||
# self.work_layout.setGeometry()
|
||||
self.initUI()
|
||||
|
||||
# Start analisys method
|
||||
self.analysis(self.ClientObj.sid, meth_result)
|
||||
|
||||
#################API FUNCTION###############################
|
||||
def show_view(self, view):
|
||||
print "+====== show view! ======+"
|
||||
def show_table(self, table, item):
|
||||
# print "+============== %-13s===========+" %item.message
|
||||
#
|
||||
# sys.stdout.flush()
|
||||
#
|
||||
# sys.stdout.write ("=========")
|
||||
# for i in range (1, len(table.head[0])):
|
||||
# sys.stdout.write ("===========")
|
||||
# print
|
||||
# # print head table
|
||||
# for head in table.head[0]:
|
||||
# sys.stdout.write(" %-6s | " %head)
|
||||
# sys.stdout.write("\n")
|
||||
#
|
||||
# sys.stdout.write ("+=======+")
|
||||
# for i in range (1, len(table.head[0])):
|
||||
# sys.stdout.write ("==========+")
|
||||
# print
|
||||
#
|
||||
# # print body table
|
||||
# for line in table.body[0]:
|
||||
# for i in line[0]:
|
||||
# sys.stdout.write("%6s | " %i)
|
||||
# sys.stdout.write("\n")
|
||||
#
|
||||
# sys.stdout.write ("+=======+")
|
||||
# for i in range (1, len(table.head[0])):
|
||||
# sys.stdout.write ("==========+")
|
||||
# print
|
||||
|
||||
mytable = QtGui.QTableWidget(len(table.head[0]), len(table.body[0]))
|
||||
|
||||
list_head = table.head[0]
|
||||
mytable.setHorizontalHeaderLabels(list_head)
|
||||
# mytable.setVerticalHeaderLabels (list_head)
|
||||
|
||||
for head in range(len(table.head[0])):
|
||||
tablewidgetitem = QtGui.QTableWidgetItem(table.head[0][head])
|
||||
mytable.setItem(0, head, tablewidgetitem)
|
||||
|
||||
for line in range(len(table.body[0])):
|
||||
for i in range(len(table.body[0][line][0])):
|
||||
tablewidgetitem = QtGui.QTableWidgetItem(table.body[0][line][0][i])
|
||||
mytable.setItem(line, i, tablewidgetitem)
|
||||
|
||||
# for i in range(len(table.head[0])):
|
||||
# for j in range(len(table.body[0])):
|
||||
# tablewidgetitem = QtGui.QTableWidgetItem("%d,%d" %(i+1,j+1))
|
||||
# mytable.setItem(i, j, tablewidgetitem)
|
||||
|
||||
# header = "item.message"
|
||||
#
|
||||
# data = [QtGui.QCheckBox("item 1"),
|
||||
# QtGui.QCheckBox("item 2"),
|
||||
# QtGui.QCheckBox("item 3"),
|
||||
# QtGui.QCheckBox("item 4"),
|
||||
# QtGui.QCheckBox("item 5")]
|
||||
#
|
||||
# model = TableModel(data, header)
|
||||
# table.setModel(model)
|
||||
|
||||
self.work_layout.addWidget(mytable)
|
||||
self.initUI()
|
||||
|
||||
|
||||
def show_normal(self, item):
|
||||
self.work_layout.addWidget(QLabel(item.message))
|
||||
self.work_layout.addWidget(QLabel("tttttterrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeee"))
|
||||
|
||||
self.initUI()
|
||||
|
||||
def show_error(self, item):
|
||||
self.work_layout.addWidget(QLabel("ERROR!\n" + item.message))
|
||||
self.initUI()
|
||||
show_msg("ERROR!\n" + item.message)
|
||||
|
||||
def show_warning(self, item):
|
||||
self.work_layout.addWidget(QLabel("WARNING!\n" + item.message))
|
||||
self.initUI()
|
||||
|
||||
def show_group(self, item):
|
||||
print "Group"
|
||||
print item.message
|
||||
|
||||
def show_result(self, result):
|
||||
print "Result = ", result.message
|
||||
|
||||
def startTask(self, item):
|
||||
print "start Task"
|
||||
print item.message
|
||||
|
||||
def endTask(self, item):
|
||||
print item.message
|
||||
print "end Task\n\n"
|
||||
|
||||
def beginFrame(self, item):
|
||||
pass
|
||||
|
||||
def endFrame(self, item):
|
||||
pass
|
||||
|
||||
def startGroup(self, item):
|
||||
pass
|
||||
|
||||
def endGruop(self, item):
|
||||
pass
|
||||
|
||||
def callView(self, item, sid):
|
||||
print "\n\n",item.message
|
||||
try:
|
||||
view = self.client.service[0][item.message] (sid)
|
||||
self.show_view (view)
|
||||
except:
|
||||
pass
|
||||
|
||||
###############################################################################
|
||||
|
||||
def analysis(self, sid, s):
|
||||
""" analysis of the bounced message method """
|
||||
messages = s[0]
|
||||
for mess in messages:
|
||||
if mess.type == 'pid':
|
||||
self.get_messages(sid, mess.message)
|
||||
if mess.type == 'error':
|
||||
self.show_error(mess)
|
||||
if mess.type == 'warning':
|
||||
self.show_warning(mess)
|
||||
def get_message(self, item, sid, pid):
|
||||
""" get one message by its type """
|
||||
for case in switch(item.type):
|
||||
if case('normal'):
|
||||
|
||||
self.show_normal(item)
|
||||
return 1
|
||||
if case('progress'):
|
||||
self.get_Progress(sid, pid, item.id)
|
||||
return 1
|
||||
if case('error'):
|
||||
self.show_error(item)
|
||||
if item.message == "403 Forbidden":
|
||||
return 0
|
||||
return 1
|
||||
if case('warning'):
|
||||
self.show_warning(item)
|
||||
return 1
|
||||
if case('table'):
|
||||
self.get_Table(sid, pid, item)
|
||||
return 1
|
||||
if case('group'):
|
||||
self.show_group(sid, pid, item)
|
||||
return 1
|
||||
if case('question'):
|
||||
self.send_Message(sid, pid, item)
|
||||
return 1
|
||||
if case('password'):
|
||||
self.send_Password(sid, pid, item)
|
||||
return 1
|
||||
if case('startTask'):
|
||||
self.startTask(item)
|
||||
return 1
|
||||
if case('endTask'):
|
||||
self.endTask(item)
|
||||
return 1
|
||||
if case('beginFrame'):
|
||||
self.beginFrame(item)
|
||||
return 1
|
||||
if case('endFrame'):
|
||||
self.endFrame(item)
|
||||
return 0
|
||||
if case('startGroup'):
|
||||
self.startGroup(item)
|
||||
return 1
|
||||
if case('endGruop'):
|
||||
self.endGruop(item)
|
||||
return 1
|
||||
if case('briefParams'):
|
||||
self.callView(item, sid)
|
||||
if case(): # default, could also just omit condition or 'if True'
|
||||
return 1
|
||||
|
||||
def get_messages(self, sid, pid):
|
||||
""" get frame in a separate thread """
|
||||
#thread_messages = threading.Thread(target=get_Frame,\
|
||||
#args = (client, sid, pid))
|
||||
#thread_messages.start()
|
||||
self.get_Frame(sid, pid)
|
||||
|
||||
|
||||
def get_Frame(self, sid, pid):
|
||||
""" get all messages, until type is not endFrame (or Error) """
|
||||
end_frame = 1
|
||||
while end_frame:
|
||||
current_frame = self.client.service.get_frame(sid, pid)
|
||||
while current_frame in [None, [], ""]:
|
||||
time.sleep(float(self.client.frame_period))
|
||||
current_frame = self.client.service.get_frame(sid, pid)
|
||||
for item in current_frame[0]:
|
||||
end_frame = self.get_message(item, sid, pid)
|
||||
|
||||
def get_entire_frame(self):
|
||||
""" get entire frame, from beginning (if client disconnected) """
|
||||
sid = get_sid(self.client.SID_FILE)
|
||||
list_pid = self.client.service.list_pid(sid = sid)
|
||||
|
||||
if list_pid[0] == [0]:
|
||||
return 0
|
||||
for pid in list_pid[0]:
|
||||
end_frame = 1
|
||||
while end_frame:
|
||||
current_frame = self.client.service.get_entire_frame(sid, pid)
|
||||
while current_frame in [None, [], ""]:
|
||||
time.sleep(1)
|
||||
current_frame = self.client.service.get_frame(sid, pid)
|
||||
for item in current_frame[0]:
|
||||
end_frame = self.get_message(item, sid, pid)
|
||||
|
||||
def get_Progress(self, sid, pid, id):
|
||||
""" get progress for the current job """
|
||||
percent = self.client.service.get_progress(sid, pid, id)
|
||||
temp_progress = -1
|
||||
while percent < 100 and percent >= 0 :
|
||||
if temp_progress != percent:
|
||||
|
||||
# print _("Percent = %s") %percent
|
||||
temp_progress = percent
|
||||
time.sleep(1)
|
||||
percent = self.client.service.get_progress(sid, pid, id)
|
||||
if percent < 0:
|
||||
pass
|
||||
# print _("Error task by %d") %(0 - percent) + "%"
|
||||
else:
|
||||
pass
|
||||
# print _("Percent = %s") %percent
|
||||
|
||||
def get_Table(self, sid, pid, item):
|
||||
table = self.client.service.get_table(sid, pid, item.id)
|
||||
self.show_table(table, item)
|
||||
|
||||
def send_Message(self, sid, pid, item):
|
||||
""" send answer to the question """
|
||||
answer = raw_input (item.message)
|
||||
result = self.client.service.send_message(sid, pid, answer)
|
||||
self.show_result(result)
|
||||
|
||||
def send_Password(self, sid, pid, item):
|
||||
""" send password """
|
||||
from getpass import getpass
|
||||
password = getpass(prompt=item.message)
|
||||
result = self.client.service.send_message(sid, pid, password)
|
||||
self.show_result(result)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def initUI(self):
|
||||
self.setLayout(self.work_layout)
|
||||
self.setFixedSize(self.width()-20, self.height())
|
||||
|
||||
# self.show()
|
||||
self.update()
|
||||
|
||||
def calling(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
class MainFrameRes (QtGui.QScrollArea):
|
||||
def __init__(self, parent, ClientObj, method_name, meth_result):
|
||||
QtGui.QScrollArea.__init__(self)
|
||||
# верхнее правое
|
||||
self.MainFrameWgt = MainFrameResWgt(self, ClientObj, method_name, \
|
||||
meth_result)
|
||||
self.setWidget(self.MainFrameWgt)
|
@ -0,0 +1,248 @@
|
||||
#-*- 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.
|
||||
|
||||
import time, sys
|
||||
from calculate.api.client.function import switch, get_sid
|
||||
#t = time
|
||||
|
||||
|
||||
#################API FUNCTION###############################
|
||||
def show_view(view):
|
||||
print "+====== show view! ======+"
|
||||
def show_table(table, item):
|
||||
print "+============== %-13s===========+" %item.message
|
||||
|
||||
sys.stdout.flush()
|
||||
|
||||
sys.stdout.write ("=========")
|
||||
for i in range (1, len(table.head[0])):
|
||||
sys.stdout.write ("===========")
|
||||
print
|
||||
# print head table
|
||||
for head in table.head[0]:
|
||||
sys.stdout.write(" %-6s | " %head)
|
||||
sys.stdout.write("\n")
|
||||
|
||||
sys.stdout.write ("+=======+")
|
||||
for i in range (1, len(table.head[0])):
|
||||
sys.stdout.write ("==========+")
|
||||
print
|
||||
|
||||
# print body table
|
||||
for line in table.body[0]:
|
||||
for i in line[0]:
|
||||
sys.stdout.write("%6s | " %i)
|
||||
sys.stdout.write("\n")
|
||||
|
||||
sys.stdout.write ("+=======+")
|
||||
for i in range (1, len(table.head[0])):
|
||||
sys.stdout.write ("==========+")
|
||||
print
|
||||
|
||||
|
||||
#HEADER = '\033[95m'
|
||||
#OKBLUE = '\033[94m'
|
||||
#OKGREEN = '\033[92m'
|
||||
#ENDC = '\033[0m'
|
||||
def show_error(item):
|
||||
FAIL = '\033[31m'
|
||||
ENDC = '\033[0m'
|
||||
print FAIL + "ERROR"
|
||||
print FAIL + item.message
|
||||
print ENDC
|
||||
|
||||
def show_warning(item):
|
||||
WARNING = '\033[91m'
|
||||
print WARNING + "Warning"
|
||||
print WARNING + item.message
|
||||
ENDC = '\033[0m'
|
||||
print ENDC
|
||||
|
||||
def show_group(item):
|
||||
print "Group"
|
||||
print item.message
|
||||
|
||||
def show_result(result):
|
||||
print "Result = ", result.message
|
||||
|
||||
def startTask(item):
|
||||
print "start Task"
|
||||
print item.message
|
||||
|
||||
def endTask(item):
|
||||
print item.message
|
||||
print "end Task\n\n"
|
||||
|
||||
def beginFrame(item):
|
||||
pass
|
||||
|
||||
def endFrame(item):
|
||||
pass
|
||||
|
||||
def startGroup(item):
|
||||
pass
|
||||
|
||||
def endGruop(item):
|
||||
pass
|
||||
|
||||
def callView(item, sid, client):
|
||||
print "\n\n",item.message
|
||||
try:
|
||||
view = client.service[0][item.message] (sid)
|
||||
show_view (view)
|
||||
except:
|
||||
pass
|
||||
# print _("This view not found!!!")
|
||||
|
||||
#################MESSAGE####################################
|
||||
|
||||
def analysis(client, sid, s):
|
||||
""" analysis of the bounced message method """
|
||||
messages = s[0]
|
||||
for mess in messages:
|
||||
if mess.type == 'pid':
|
||||
get_messages(client, sid, mess.message)
|
||||
if mess.type == 'error':
|
||||
show_error(mess)
|
||||
if mess.type == 'warning':
|
||||
show_warning(mess)
|
||||
|
||||
def get_message(client, item, sid, pid):
|
||||
""" get one message by its type """
|
||||
for case in switch(item.type):
|
||||
if case('normal'):
|
||||
|
||||
sys.stdout.flush()
|
||||
sys.stdout.write('\x1b[1;33m' + item.message + '\033[0m')
|
||||
#print item.message
|
||||
return 1
|
||||
if case('progress'):
|
||||
get_Progress(client, sid, pid, item.id)
|
||||
return 1
|
||||
if case('error'):
|
||||
show_error(item)
|
||||
if item.message == "403 Forbidden":
|
||||
return 0
|
||||
return 1
|
||||
if case('warning'):
|
||||
show_warning(item)
|
||||
return 1
|
||||
if case('table'):
|
||||
get_Table(client, sid, pid, item)
|
||||
return 1
|
||||
if case('group'):
|
||||
show_group(client, sid, pid, item)
|
||||
return 1
|
||||
if case('question'):
|
||||
send_Message(client, sid, pid, item)
|
||||
return 1
|
||||
if case('password'):
|
||||
send_Password(client, sid, pid, item)
|
||||
return 1
|
||||
if case('startTask'):
|
||||
startTask(item)
|
||||
return 1
|
||||
if case('endTask'):
|
||||
endTask(item)
|
||||
return 1
|
||||
if case('beginFrame'):
|
||||
beginFrame(item)
|
||||
return 1
|
||||
if case('endFrame'):
|
||||
endFrame(item)
|
||||
return 0
|
||||
if case('startGroup'):
|
||||
startGroup(item)
|
||||
return 1
|
||||
if case('endGruop'):
|
||||
endGruop(item)
|
||||
return 1
|
||||
if case('briefParams'):
|
||||
callView(item, sid)
|
||||
if case(): # default, could also just omit condition or 'if True'
|
||||
return 1
|
||||
|
||||
def get_messages(client, sid, pid):
|
||||
""" get frame in a separate thread """
|
||||
#thread_messages = threading.Thread(target=get_Frame,\
|
||||
#args = (client, sid, pid))
|
||||
#thread_messages.start()
|
||||
get_Frame(client, sid, pid)
|
||||
|
||||
|
||||
def get_Frame(client, sid, pid):
|
||||
""" get all messages, until type is not endFrame (or Error) """
|
||||
end_frame = 1
|
||||
while end_frame:
|
||||
current_frame = client.service.get_frame(sid, pid)
|
||||
while current_frame in [None, [], ""]:
|
||||
time.sleep(float(client.frame_period))
|
||||
current_frame = client.service.get_frame(sid, pid)
|
||||
for item in current_frame[0]:
|
||||
end_frame = get_message(client, item, sid, pid)
|
||||
|
||||
def get_entire_frame(client):
|
||||
""" get entire frame, from beginning (if client disconnected) """
|
||||
sid = get_sid(client.SID_FILE)
|
||||
list_pid = client.service.list_pid(sid = sid)
|
||||
|
||||
if list_pid[0] == [0]:
|
||||
return 0
|
||||
for pid in list_pid[0]:
|
||||
end_frame = 1
|
||||
while end_frame:
|
||||
current_frame = client.service.get_entire_frame(sid, pid)
|
||||
while current_frame in [None, [], ""]:
|
||||
time.sleep(1)
|
||||
current_frame = client.service.get_frame(sid, pid)
|
||||
for item in current_frame[0]:
|
||||
end_frame = get_message(client, item, sid, pid)
|
||||
|
||||
def get_Progress(client, sid, pid, id):
|
||||
""" get progress for the current job """
|
||||
percent = client.service.get_progress(sid, pid, id)
|
||||
temp_progress = -1
|
||||
while percent < 100 and percent >= 0 :
|
||||
if temp_progress != percent:
|
||||
|
||||
# print _("Percent = %s") %percent
|
||||
temp_progress = percent
|
||||
time.sleep(1)
|
||||
percent = client.service.get_progress(sid, pid, id)
|
||||
if percent < 0:
|
||||
pass
|
||||
# print _("Error task by %d") %(0 - percent) + "%"
|
||||
else:
|
||||
pass
|
||||
# print _("Percent = %s") %percent
|
||||
|
||||
def get_Table(client, sid, pid, item):
|
||||
table = client.service.get_table(sid, pid, item.id)
|
||||
show_table(table, item)
|
||||
|
||||
def send_Message(client, sid, pid, item):
|
||||
""" send answer to the question """
|
||||
answer = raw_input (item.message)
|
||||
result = client.service.send_message(sid, pid, answer)
|
||||
show_result(result)
|
||||
|
||||
def send_Password(client, sid, pid, item):
|
||||
""" send password """
|
||||
from getpass import getpass
|
||||
password = getpass(prompt=item.message)
|
||||
result = client.service.send_message(sid, pid, password)
|
||||
show_result(result)
|
||||
|
@ -1,48 +1,168 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from PySide import QtGui
|
||||
from PySide.QtGui import QLabel, QLineEdit, QPushButton, QCheckBox, QGroupBox
|
||||
from calculate.api.client.function import create_obj, get_sid
|
||||
#import analysis
|
||||
from more import _
|
||||
|
||||
class Check(QtGui.QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super(Check, self).__init__()
|
||||
class MFWgt(QtGui.QWidget):
|
||||
def __init__(self, parent, ClientObj, view, method_name):
|
||||
super(MFWgt, self).__init__()
|
||||
self.ClientObj = ClientObj
|
||||
self.view = view
|
||||
self.method_name = method_name
|
||||
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
def initUI(self):
|
||||
self.grid = QtGui.QGridLayout()
|
||||
self.grid.setSpacing(10)
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
self.view_dict = {}
|
||||
|
||||
self.param_object = create_obj(self.ClientObj.client, self.method_name)
|
||||
|
||||
list_param = dir (self.param_object)
|
||||
|
||||
self.lbl = QtGui.QLabel("Ubuntu", self)
|
||||
combo = QtGui.QComboBox(self)
|
||||
combo.addItem("Ubuntu")
|
||||
combo.addItem("Mandriva")
|
||||
combo.addItem("Fedora")
|
||||
combo.addItem("Red Hat")
|
||||
combo.addItem("Gentoo")
|
||||
param_list = []
|
||||
for param in list_param:
|
||||
if not param.startswith('_'):
|
||||
param_list.append(param)
|
||||
|
||||
for Group in self.view.groups.GroupField:
|
||||
|
||||
self.grid.addWidget(QLabel(Group.name), x, y+2)
|
||||
x += 1
|
||||
##############################
|
||||
# from calculate.api.server.api_types import ChoiceValue, Table, Option, Field
|
||||
# Group.fields.append(Field(
|
||||
# name = "Выбор",
|
||||
# label = _("Выберите: "),
|
||||
# type = "bool",
|
||||
# opt = Option(shortopt="-n",
|
||||
# longopt="--name",
|
||||
# metavalue="NAME"),
|
||||
# help = \
|
||||
# _("Please, enter cl-template arguments"),
|
||||
# element = "input"))
|
||||
##############################
|
||||
for field in Group.fields.Field:
|
||||
if field.element == 'input':
|
||||
self.grid.addWidget(QLabel(field.name), x, y)
|
||||
self.view_dict[field.name] = QLineEdit()
|
||||
self.grid.addWidget(self.view_dict[field.name], x, y+1)
|
||||
x += 1
|
||||
# if field.type == 'str':
|
||||
#
|
||||
# self.param_object[field.name] = raw_input(field.label)
|
||||
# if field.type == 'int':
|
||||
# while True:
|
||||
# try:
|
||||
# var = raw_input(field.label)
|
||||
# self.param_object[field.name] = int (var)
|
||||
# break
|
||||
# except (TypeError, ValueError):
|
||||
# print _('Это не целое число')
|
||||
|
||||
combo.move(50, 50)
|
||||
self.lbl.move(50, 150)
|
||||
elif field.element == 'bool':
|
||||
self.view_dict[field.name] = QCheckBox(field.name, self)
|
||||
self.grid.addWidget(self.view_dict[field.name], x, y+1)
|
||||
x += 1
|
||||
# while 1:
|
||||
# bool_var = raw_input(field.label+' (y/n): ')
|
||||
# if bool_var.lower() in ['y','yes']:
|
||||
# self.param_object[field.name] = True
|
||||
# break
|
||||
# if bool_var.lower() in ['n','no']:
|
||||
# self.param_object[field.name] = False
|
||||
# break
|
||||
# print _('Enter "Yes" or "No"!')
|
||||
#
|
||||
elif field.element == 'radio':
|
||||
choice = field.choice[0]
|
||||
|
||||
self.GroupBox = QGroupBox(field.name)
|
||||
layout = QtGui.QVBoxLayout()
|
||||
radiolist = []
|
||||
|
||||
for i in range(0,len(choice)):
|
||||
radiolist.append (QtGui.QRadioButton(choice[i]))
|
||||
layout.addWidget(radiolist[i])
|
||||
radiolist[0].setChecked(True)
|
||||
layout.addStretch(1)
|
||||
self.GroupBox.setLayout(layout)
|
||||
|
||||
combo.activated[str].connect(self.onActivated)
|
||||
|
||||
self.setGeometry(0, 0, 150, 180)
|
||||
self.view_dict[field.name] = self.GroupBox
|
||||
self.grid.addWidget(self.view_dict[field.name], x, y+1)
|
||||
x += 1
|
||||
|
||||
# choice = field.choice[0]
|
||||
# while 1:
|
||||
# print _('Select one: ')
|
||||
# for i in range(1,len(choice)+1):
|
||||
# print choice[i-1], ' - %d' %i
|
||||
# try:
|
||||
# bool_var = int (raw_input(field.label))
|
||||
# if bool_var > 0:
|
||||
# self.param_object[field.name] = choice[bool_var - 1]
|
||||
# print 'your choice %s' %self.param_object[field.name]
|
||||
# break
|
||||
# except:
|
||||
# pass
|
||||
button_call = QPushButton(_('Call Method'))
|
||||
self.grid.addWidget(button_call, x, y+2)
|
||||
button_call.clicked.connect(self.calling)
|
||||
|
||||
self.setLayout(self.grid)
|
||||
|
||||
self.show()
|
||||
self.update()
|
||||
|
||||
def calling(self):
|
||||
for field_name in self.view_dict:
|
||||
print field_name
|
||||
print type (self.view_dict[field_name])
|
||||
|
||||
if type (self.view_dict[field_name]) == QGroupBox:
|
||||
print 11111
|
||||
# w = self.view_dict[field_name]
|
||||
# import ipdb
|
||||
# ipdb.set_trace()
|
||||
|
||||
if type (self.view_dict[field_name]) == QCheckBox:
|
||||
self.param_object[field_name] = \
|
||||
self.view_dict[field_name].isChecked()
|
||||
print self.param_object[field_name]
|
||||
|
||||
if type (self.view_dict[field_name]) == QLineEdit:
|
||||
self.param_object[field_name] = \
|
||||
str(self.view_dict[field_name].text())
|
||||
# print type(self.param_object[field_name])
|
||||
# print type (str)
|
||||
|
||||
|
||||
# self.param_object[field.name]
|
||||
# self.view_dict[field.name]
|
||||
|
||||
print self.method_name, "$$$$$$$$$$$$$$$$"
|
||||
self.ClientObj.sid = get_sid(self.ClientObj.client.SID_FILE)
|
||||
meth_result = self.ClientObj.client.service[0][self.method_name] \
|
||||
(self.ClientObj.sid, self.param_object)
|
||||
|
||||
def onActivated(self, text):
|
||||
if text == 'Gentoo':
|
||||
if hasattr (self, 'lbl'): #if 'lbl' in self:
|
||||
self.lbl.hide()
|
||||
del self.lbl
|
||||
else:
|
||||
if not hasattr (self, 'lbl'):
|
||||
self.lbl = QtGui.QLabel(text, self)
|
||||
self.lbl.move(50, 150)
|
||||
self.lbl.show()
|
||||
self.lbl.setText(text)
|
||||
self.lbl.adjustSize()
|
||||
# Вызвать метод вывода результатов процесса
|
||||
self.ClientObj.MainWidget.main_frame_res(self.method_name, meth_result)
|
||||
# analysis.analysis(self.ClientObj.client, sid, meth_result)
|
||||
|
||||
|
||||
|
||||
|
||||
class MainFrame (QtGui.QScrollArea):
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent, ClientObj, view, method_name):
|
||||
self.ClientObj = ClientObj
|
||||
QtGui.QScrollArea.__init__(self)
|
||||
# верхнее правое
|
||||
check2 = Check()
|
||||
self.setWidget(check2)
|
||||
# self.resize(700,900)
|
||||
self.MainFrameWgt = MFWgt(self, ClientObj, view, method_name)
|
||||
self.setWidget(self.MainFrameWgt)
|
||||
# self.show()
|
Loading…
Reference in new issue