Skip to content

Commit

Permalink
cleanup and make the tooltips working on nodeviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo [hdd] Angeli committed Apr 26, 2011
1 parent 98d418a commit 3feb567
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 29 deletions.
18 changes: 10 additions & 8 deletions src/drQt.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

import sys
import os
import logging

os.environ["DEBUG"]="1"

try:
# https://github.com/hdd/hlog
import hlog as log
except:
import logging as log


import PyQt4.QtGui as QtGui
import PyQt4.QtCore as QtCore
Expand All @@ -21,11 +29,6 @@

import lib.ui.drQt_UI as drQtUI

logging.basicConfig()
log = logging.getLogger("drQt")
log.setLevel(logging.DEBUG)


class AboutDialog(QtGui.QDialog):
def __init__(self,parent=None):
super(AboutDialog,self).__init__(parent)
Expand Down Expand Up @@ -174,7 +177,6 @@ def init_jobs_tabs(self):
job_tab.add_to_table(self.TW_job, i)
self.connect(job_tab, QtCore.SIGNAL('update'), self.refresh)
self.jobs_tab_list.append(job_tab)


def init_slaves_tabs(self):
self.nodes_tab_list=[]
Expand All @@ -183,6 +185,7 @@ def init_slaves_tabs(self):
num_nodes = len(nodes)
self.TW_node.setRowCount(num_nodes)
for i in range(num_nodes):
log.debug("create slave Node Tab : %s"%type(nodes[i]))
node_tab = SlaveNodeTab(nodes[i],parent=self.TW_node)
node_tab.add_to_table(self.TW_node, i)
self.connect(node_tab, QtCore.SIGNAL('update'), self.refresh)
Expand All @@ -199,7 +202,6 @@ def _get_all_jobs(self):

def _get_all_slaves(self):
computer_list = drqueue.request_computer_list(drqueue.CLIENT)
print computer_list
return computer_list

def _create_context(self,QPoint):
Expand Down
14 changes: 12 additions & 2 deletions src/drQtNewJob.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@

from lib.utils import KojsConfigParser


os.environ["DEBUG"]="1"

try:
# https://github.com/hdd/hlog
import hlog as log
except:
import logging as log


#try:
# import drqueue.base.libdrqueue as drqueue
#except:
Expand Down Expand Up @@ -102,7 +112,7 @@ def get_widget(self,widget_name):
if self._widget_list.has_key(widget_name):
return self._widget_list[widget_name]
else:
print "%s not found in widget list"%widget_name
log.debug("%s not found in widget list"%widget_name)
return None

def set_info_line(self,value):
Expand Down Expand Up @@ -172,7 +182,7 @@ def init_from_dict(self,engine_dict):

def _flat_list(self,input_list):
result = ",".join(input_list)
print "result" ,str(result)
log.debug("flat list result %s"%str(result))
return result


Expand Down
Binary file removed src/lib/__init__.pyc
Binary file not shown.
19 changes: 11 additions & 8 deletions src/lib/jobTab.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import sys
import os

import logging
from pprint import pformat

os.environ["DEBUG"]="1"

try:
# https://github.com/hdd/hlog
import hlog as log
except:
import logging as log

import PyQt4.QtGui as QtGui
import PyQt4.QtCore as QtCore

import drqueue.base.libdrqueue as drqueue

from utils import icons_path
from utils import tooltips_path
from lib.newNodeViewer import NodeViewer

logging.basicConfig()
log = logging.getLogger("job_tab")
log.setLevel(logging.DEBUG)
from lib.nodeViewer import NodeViewer

class JobTab(QtGui.QWidget):

Expand Down Expand Up @@ -73,9 +76,9 @@ def __init__(self,drq_job_object=None,parent=None):
def _node_view_show(self):
log.debug("starting node view")
NW_widget=NodeViewer(self)
NW_widget.add_node(self._drq_job_object)
NW_widget.show()

NW_widget.add_node(self._drq_job_object)


def _set_values(self):
"""
Expand Down
26 changes: 15 additions & 11 deletions src/lib/nodeViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,25 @@ class NodeItem(QtGui.QGraphicsItem ):

def __init__(self,drq_job_object=None,parent=None):
super(NodeItem,self).__init__(parent)

self._drq_job_object = drq_job_object

self.setFlag(QtGui.QGraphicsItem.ItemIsFocusable)
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
if drq_job_object:
self.name="Job:#%d\nName: %s"%(drq_job_object.id,drq_job_object.name)
if self._drq_job_object:
self.name="Job:#%d\nName: %s"%(self._drq_job_object.id,self._drq_job_object.name)
else:
self.name="Virtual Node"

self.setScale(1.4)
self.rect=QtCore.QRectF(-self.xsize/2,-self.ysize/2,self.xsize,self.ysize)

self.create_attrs()
self._set_tooltip()

self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
self.setFlag(QtGui.QGraphicsItem.ItemIsFocusable)

def create_attrs(self):
in_attributes=["in_id"]
out_attributes=["out_id"]
self._drq_job_object = drq_job_object

offset=10

Expand All @@ -157,7 +161,6 @@ def __init__(self,drq_job_object=None,parent=None):
attr.setPos(pos)
out_attributes.append(attr)

self._set_tooltip()

def set_name(self,name="Node"):
self.name=name
Expand All @@ -181,7 +184,7 @@ def _set_tooltip(self):
build up the tooltip using the drq job object
bind the tooltip to all the columns
"""

log.debug("setting tooltips for object %s"%self._drq_job_object)
if self._drq_job_object:
html_tooltip=open(os.path.join(tooltips_path,"job_info.html"),"r")
tooltipData ={}
Expand All @@ -190,6 +193,7 @@ def _set_tooltip(self):
tooltipData["dependid"]=self._drq_job_object.dependid

formattedTolltip=str(html_tooltip.read()).format(**tooltipData)

self.setToolTip(formattedTolltip)

class NodeScene(QtGui.QGraphicsScene):
Expand Down Expand Up @@ -338,7 +342,8 @@ def scaleView(self, scaleFactor):
self.scale(scaleFactor, scaleFactor)

def add_node(self,drq_job_object):
job_node = NodeItem(drq_job_object=drq_job_object,parent=self)
log.debug("adding node...%s"%drq_job_object)
job_node = NodeItem(drq_job_object=drq_job_object)
self.scene.addItem(job_node)


Expand All @@ -347,7 +352,7 @@ def __init__(self,parent=None):
super(NodeViewer,self).__init__(parent)
self.layout = QtGui.QVBoxLayout()
self.setLayout(self.layout)
self.view = NodeView()
self.view = NodeView(self)
self.layout.addWidget(self.view)

def add_node(self,drq_job_object):
Expand All @@ -362,7 +367,6 @@ def main():
splash.show()

app.processEvents()


dialog = NodeViewer()
dialog.show()
Expand Down
Binary file removed src/lib/ui/__init__.pyc
Binary file not shown.
Binary file removed src/lib/ui/drQt_UI.pyc
Binary file not shown.
Binary file removed src/lib/utils.pyc
Binary file not shown.

0 comments on commit 3feb567

Please sign in to comment.