本文整理汇总了Python中cylc.gui.dot_maker.DotMaker类的典型用法代码示例。如果您正苦于以下问题:Python DotMaker类的具体用法?Python DotMaker怎么用?Python DotMaker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DotMaker类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, cfg, updater, ttreeview, ttree_paths, info_bar, theme,
dot_size):
super(TreeUpdater, self).__init__()
self.action_required = False
self.quit = False
self.cleared = True
self.autoexpand = True
self.count = 0
self.cfg = cfg
self.updater = updater
self.info_bar = info_bar
self.last_update_time = None
self.ancestors = {}
self.descendants = []
self.fam_state_summary = {}
self._prev_id_named_paths = {}
self._prev_data = {}
self._prev_fam_data = {}
self.autoexpand_states = [
'queued', 'ready', 'expired', 'submitted', 'running', 'failed']
self._last_autoexpand_me = []
# Dict of paths vs all descendant node states
self.ttree_paths = ttree_paths
self.should_group_families = ("text" not in self.cfg.ungrouped_views)
self.ttreeview = ttreeview
# Hierarchy of models: view <- sorted <- filtered <- base model
self.ttreestore = ttreeview.get_model().get_model().get_model()
self._prev_tooltip_task_id = None
if hasattr(self.ttreeview, "set_has_tooltip"):
self.ttreeview.set_has_tooltip(True)
try:
self.ttreeview.connect('query-tooltip',
self.on_query_tooltip)
except TypeError:
# Lower PyGTK version.
pass
# Cache the latest ETC calculation for active ids.
self._id_tetc_cache = {}
# Generate task state icons.
dotm = DotMaker(theme, size=dot_size)
self.dots = dotm.get_dots()
示例2: __init__
def __init__(self, cfg, updater, treeview, info_bar, theme, dot_size):
super(DotUpdater, self).__init__()
self.quit = False
self.cleared = True
self.action_required = False
self.autoexpand = True
self.should_hide_headings = False
self.should_group_families = ("dot" not in cfg.ungrouped_views)
self.should_transpose_view = False
self.is_transposed = False
self.defn_order_on = True
self.cfg = cfg
self.updater = updater
self.theme = theme
self.info_bar = info_bar
self.last_update_time = None
self.state_summary = {}
self.fam_state_summary = {}
self.ancestors_pruned = {}
self.descendants = []
self.point_strings = []
self.led_headings = []
self.led_treeview = treeview
self.led_treestore = treeview.get_model()
self._prev_tooltip_task_id = None
if hasattr(self.led_treeview, "set_has_tooltip"):
self.led_treeview.set_has_tooltip(True)
try:
self.led_treeview.connect('query-tooltip',
self.on_query_tooltip)
except TypeError:
# Lower PyGTK version.
pass
self.task_list = []
self.family_tree = {}
self.expanded_rows = []
self.selected_rows = []
# generate task state icons
dotm = DotMaker(theme, size=dot_size)
self.dots = dotm.get_dots()
示例3: __init__
def __init__(self, hosts, dot_hbox, gcylc_image, is_compact, owner=None,
poll_interval=None):
self.quit = True
self.dot_hbox = dot_hbox
self.gcylc_image = gcylc_image
self.is_compact = is_compact
self._set_gcylc_image_tooltip()
self.gcylc_image.set_sensitive(False)
self.theme_name = gcfg.get(['use theme'])
self.theme = gcfg.get(['themes', self.theme_name])
self.dots = DotMaker(self.theme)
self.hosts_suites_info = {}
self.stopped_hosts_suites_info = {}
self._set_exception_hook()
super(ScanPanelAppletUpdater, self).__init__(
hosts, owner=owner, poll_interval=poll_interval)
示例4: __init__
def __init__(self, dot_hbox, gcylc_image, is_compact):
self.hosts = []
self.dot_hbox = dot_hbox
self.gcylc_image = gcylc_image
self.is_compact = is_compact
self.prev_full_update = None
self.prev_norm_update = None
self.quit = True
self._set_gcylc_image_tooltip()
self.gcylc_image.set_sensitive(False)
self.interval_full = gsfg.get(['suite listing update interval'])
self.interval_part = gsfg.get(['suite status update interval'])
self.theme_name = gcfg.get(['use theme'])
self.theme = gcfg.get(['themes', self.theme_name])
self.dots = DotMaker(self.theme)
self.suite_info_map = {}
self._set_exception_hook()
self.owner_pattern = None
示例5: _set_theme
def _set_theme(self, new_theme_name):
self.theme_name = new_theme_name
self.theme = gcfg.get(['themes', self.theme_name])
self.dots = DotMaker(self.theme)
示例6: ScanPanelAppletUpdater
class ScanPanelAppletUpdater(BaseScanTimeoutUpdater):
"""Update the scan panel applet - subclass of gscan equivalent."""
IDLE_STOPPED_TIME = 3600 # 1 hour.
MAX_INDIVIDUAL_SUITES = 5
def __init__(self, hosts, dot_hbox, gcylc_image, is_compact, owner=None,
poll_interval=None):
self.quit = True
self.dot_hbox = dot_hbox
self.gcylc_image = gcylc_image
self.is_compact = is_compact
self._set_gcylc_image_tooltip()
self.gcylc_image.set_sensitive(False)
self.theme_name = gcfg.get(['use theme'])
self.theme = gcfg.get(['themes', self.theme_name])
self.dots = DotMaker(self.theme)
self.hosts_suites_info = {}
self.stopped_hosts_suites_info = {}
self._set_exception_hook()
super(ScanPanelAppletUpdater, self).__init__(
hosts, owner=owner, poll_interval=poll_interval)
def clear_stopped_suites(self):
"""Clear stopped suite information that may have built up."""
self.stopped_hosts_suites_info.clear()
gobject.idle_add(self.update)
def start(self):
self.gcylc_image.set_sensitive(True)
super(ScanPanelAppletUpdater, self).start()
self._set_gcylc_image_tooltip()
def stop(self):
self.gcylc_image.set_sensitive(False)
super(ScanPanelAppletUpdater, self).stop()
self._set_gcylc_image_tooltip()
def launch_context_menu(self, event, suite_host_tuples=None,
extra_items=None):
has_stopped_suites = bool(self.stopped_hosts_suites_info)
if suite_host_tuples is None:
suite_host_tuples = []
if extra_items is None:
extra_items = []
gscan_item = gtk.ImageMenuItem("Launch cylc gscan")
img = gtk.image_new_from_stock("gcylc", gtk.ICON_SIZE_MENU)
gscan_item.set_image(img)
gscan_item.show()
gscan_item.connect("button-press-event",
self._on_button_press_event_gscan)
extra_items.append(gscan_item)
menu = get_scan_menu(suite_host_tuples,
self.theme_name, self._set_theme,
has_stopped_suites,
self.clear_stopped_suites,
self.hosts,
self.set_hosts,
self.update_now,
self.start,
program_name="cylc gpanel",
extra_items=extra_items,
owner=self.owner,
is_stopped=self.quit)
menu.popup(None, None, None, event.button, event.time)
return False
def update(self):
"""Update the Applet."""
info = copy.deepcopy(self.hosts_suites_info)
stop_info = copy.deepcopy(self.stopped_hosts_suites_info)
suite_host_tuples = []
for host in self.hosts:
suites = (info.get(host, {}).keys() +
stop_info.get(host, {}).keys())
for suite in suites:
if (suite, host) not in suite_host_tuples:
suite_host_tuples.append((suite, host))
suite_host_tuples.sort()
for child in self.dot_hbox.get_children():
self.dot_hbox.remove(child)
number_mode = (not self.is_compact and
len(suite_host_tuples) > self.MAX_INDIVIDUAL_SUITES)
suite_statuses = {}
compact_suite_statuses = []
for suite, host in suite_host_tuples:
if suite in info.get(host, {}):
suite_info = info[host][suite]
is_stopped = False
else:
suite_info = stop_info[host][suite]
is_stopped = True
if "states" not in suite_info:
#.........这里部分代码省略.........
示例7: _set_key_liststore
def _set_key_liststore(self):
dotm = DotMaker(self._theme, self._dot_size)
self._key_liststore.clear()
for state in task_state.legal:
dot = dotm.get_icon(state)
self._key_liststore.append([state, dot])
示例8: ScanApp
#.........这里部分代码省略.........
hosts_item.set_image(img)
hosts_item.show()
hosts_item.connect(
"button-press-event",
lambda b, e: launch_hosts_dialog(
self.hosts, self.updater.set_hosts))
view_menu.append(hosts_item)
sep_item = gtk.SeparatorMenuItem()
sep_item.show()
help_menu = gtk.Menu()
help_menu_root = gtk.MenuItem('_Help')
help_menu_root.set_submenu(help_menu)
self.menu_bar.append(file_menu_root)
self.menu_bar.append(view_menu_root)
self.menu_bar.append(help_menu_root)
# Construct an about dialog item.
info_item = gtk.ImageMenuItem("About")
img = gtk.image_new_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_MENU)
info_item.set_image(img)
info_item.show()
info_item.connect(
"button-press-event",
lambda b, e: launch_about_dialog("cylc gscan", self.hosts)
)
help_menu.append(info_item)
self.menu_bar.show_all()
def _set_dots(self):
self.dots = DotMaker(self.theme, size=self.dot_size)
def create_tool_bar(self):
"""Create the tool bar for the GUI."""
self.tool_bar = gtk.Toolbar()
update_now_button = gtk.ToolButton(
icon_widget=gtk.image_new_from_stock(
gtk.STOCK_REFRESH, gtk.ICON_SIZE_SMALL_TOOLBAR))
update_now_button.set_label("Update")
tooltip = gtk.Tooltips()
tooltip.enable()
tooltip.set_tip(update_now_button, "Update now")
update_now_button.connect("clicked",
self.updater.update_now)
clear_stopped_button = gtk.ToolButton(
icon_widget=gtk.image_new_from_stock(
gtk.STOCK_CLEAR, gtk.ICON_SIZE_SMALL_TOOLBAR))
clear_stopped_button.set_label("Clear")
tooltip = gtk.Tooltips()
tooltip.enable()
tooltip.set_tip(clear_stopped_button, "Clear stopped suites")
clear_stopped_button.connect("clicked",
self.updater.clear_stopped_suites)
expand_button = gtk.ToolButton(
icon_widget=gtk.image_new_from_stock(
gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR))
expand_button.set_label("Expand all")
tooltip = gtk.Tooltips()
tooltip.enable()
tooltip.set_tip(expand_button, "Expand all rows")
示例9: _set_dots
def _set_dots(self):
self.dots = DotMaker(self.theme, size=self.dot_size)
示例10: ScanPanelAppletUpdater
class ScanPanelAppletUpdater(object):
"""Update the scan panel applet - subclass of gscan equivalent."""
IDLE_STOPPED_TIME = 3600 # 1 hour.
MAX_INDIVIDUAL_SUITES = 5
def __init__(self, dot_hbox, gcylc_image, is_compact):
self.hosts = []
self.dot_hbox = dot_hbox
self.gcylc_image = gcylc_image
self.is_compact = is_compact
self.prev_full_update = None
self.prev_norm_update = None
self.quit = True
self._set_gcylc_image_tooltip()
self.gcylc_image.set_sensitive(False)
self.interval_full = gsfg.get(['suite listing update interval'])
self.interval_part = gsfg.get(['suite status update interval'])
self.theme_name = gcfg.get(['use theme'])
self.theme = gcfg.get(['themes', self.theme_name])
self.dots = DotMaker(self.theme)
self.suite_info_map = {}
self._set_exception_hook()
self.owner_pattern = None
def clear_stopped_suites(self):
"""Clear stopped suite information that may have built up."""
for key, result in self.suite_info_map.copy().items():
if KEY_PORT not in result:
del self.suite_info_map[key]
gobject.idle_add(self.update)
def has_stopped_suites(self):
"""Return True if we have any stopped suite information."""
for result in self.suite_info_map.copy().values():
if KEY_PORT not in result:
return True
return False
def run(self):
"""Extract running suite information at particular intervals."""
if self.quit:
return False
now = time()
if (self.prev_norm_update is not None and
self.IDLE_STOPPED_TIME is not None and
now > self.prev_norm_update + self.IDLE_STOPPED_TIME):
self.stop()
return True
full_mode = (
self.prev_full_update is None or
now >= self.prev_full_update + self.interval_full)
if (full_mode or
self.prev_norm_update is None or
now >= self.prev_norm_update + self.interval_part):
# Get new information.
self.suite_info_map = update_suites_info(self, full_mode=True)
self.prev_norm_update = time()
if full_mode:
self.prev_full_update = self.prev_norm_update
gobject.idle_add(self.update)
return True
def set_hosts(self, new_hosts):
del self.hosts[:]
self.hosts.extend(new_hosts)
self.update_now()
def start(self):
self.gcylc_image.set_sensitive(True)
self.quit = False
self.prev_full_update = None
self.prev_norm_update = None
gobject.timeout_add(1000, self.run)
self._set_gcylc_image_tooltip()
def stop(self):
self.gcylc_image.set_sensitive(False)
self.quit = True
self._set_gcylc_image_tooltip()
def launch_context_menu(self, event, suite_keys=None, extra_items=None):
if suite_keys is None:
suite_keys = []
if extra_items is None:
extra_items = []
gscan_item = gtk.ImageMenuItem("Launch cylc gscan")
img = gtk.image_new_from_stock("gcylc", gtk.ICON_SIZE_MENU)
gscan_item.set_image(img)
gscan_item.show()
gscan_item.connect("button-press-event",
self._on_button_press_event_gscan)
extra_items.append(gscan_item)
menu = get_gpanel_scan_menu(suite_keys,
#.........这里部分代码省略.........
示例11: __init__
def __init__(self, hosts=None, owner=None, poll_interval=None):
gobject.threads_init()
set_exception_hook_dialog("cylc gscan")
setup_icons()
if not hosts:
hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"])
self.hosts = hosts
if owner is None:
owner = USER
self.owner = owner
self.window = gtk.Window()
self.window.set_title("cylc gscan")
self.window.set_icon(get_icon())
self.vbox = gtk.VBox()
self.vbox.show()
self.warnings = {}
self.theme_name = gcfg.get(['use theme'])
self.theme = gcfg.get(['themes', self.theme_name])
self.dots = DotMaker(self.theme)
suite_treemodel = gtk.TreeStore(
str, str, bool, str, int, str, str, str)
self._prev_tooltip_location_id = None
self.suite_treeview = gtk.TreeView(suite_treemodel)
# Construct the host column.
host_name_column = gtk.TreeViewColumn("Host")
cell_text_host = gtk.CellRendererText()
host_name_column.pack_start(cell_text_host, expand=False)
host_name_column.set_cell_data_func(
cell_text_host, self._set_cell_text_host)
host_name_column.set_sort_column_id(0)
host_name_column.set_visible("host" in gsfg.get(["columns"]))
host_name_column.set_resizable(True)
# Construct the suite name column.
suite_name_column = gtk.TreeViewColumn("Suite")
cell_text_name = gtk.CellRendererText()
suite_name_column.pack_start(cell_text_name, expand=False)
suite_name_column.set_cell_data_func(
cell_text_name, self._set_cell_text_name)
suite_name_column.set_sort_column_id(1)
suite_name_column.set_visible("suite" in gsfg.get(["columns"]))
suite_name_column.set_resizable(True)
# Construct the suite title column.
suite_title_column = gtk.TreeViewColumn("Title")
cell_text_title = gtk.CellRendererText()
suite_title_column.pack_start(cell_text_title, expand=False)
suite_title_column.set_cell_data_func(
cell_text_title, self._set_cell_text_title)
suite_title_column.set_sort_column_id(3)
suite_title_column.set_visible("title" in gsfg.get(
["columns"]))
suite_title_column.set_resizable(True)
# Construct the update time column.
time_column = gtk.TreeViewColumn("Updated")
cell_text_time = gtk.CellRendererText()
time_column.pack_start(cell_text_time, expand=False)
time_column.set_cell_data_func(
cell_text_time, self._set_cell_text_time)
time_column.set_sort_column_id(4)
time_column.set_visible("updated" in gsfg.get(["columns"]))
time_column.set_resizable(True)
self.suite_treeview.append_column(host_name_column)
self.suite_treeview.append_column(suite_name_column)
self.suite_treeview.append_column(suite_title_column)
self.suite_treeview.append_column(time_column)
# Construct the status column.
status_column = gtk.TreeViewColumn("Status")
status_column.set_sort_column_id(5)
status_column.set_visible("status" in gsfg.get(["columns"]))
status_column.set_resizable(True)
cell_text_cycle = gtk.CellRendererText()
status_column.pack_start(cell_text_cycle, expand=False)
status_column.set_cell_data_func(
cell_text_cycle, self._set_cell_text_cycle, self.CYCLE_COLUMN)
self.suite_treeview.append_column(status_column)
# Warning icon.
warn_icon = gtk.CellRendererPixbuf()
image = gtk.Image()
pixbuf = image.render_icon(
gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_LARGE_TOOLBAR)
self.warn_icon_colour = pixbuf.scale_simple( # colour warn icon pixbuf
self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER)
self.warn_icon_grey = pixbuf.scale_simple(
self.ICON_SIZE, self.ICON_SIZE, gtk.gdk.INTERP_HYPER)
self.warn_icon_colour.saturate_and_pixelate(
self.warn_icon_grey, 0, False) # b&w warn icon pixbuf
status_column.pack_start(warn_icon, expand=False)
status_column.set_cell_data_func(warn_icon, self._set_error_icon_state)
self.warn_icon_blank = gtk.gdk.Pixbuf( # Transparent pixbuff.
gtk.gdk.COLORSPACE_RGB, True, 8, self.ICON_SIZE, self.ICON_SIZE
).fill(0x00000000)
#.........这里部分代码省略.........
示例12: ScanApp
class ScanApp(object):
"""Summarize running suite statuses for a given set of hosts."""
WARNINGS_COLUMN = 7
STATUS_COLUMN = 6
CYCLE_COLUMN = 5
UPDATE_TIME_COLUMN = 4
TITLE_COLUMN = 3
STOPPED_COLUMN = 2
SUITE_COLUMN = 1
HOST_COLUMN = 0
ICON_SIZE = 17
def __init__(self, hosts=None, owner=None, poll_interval=None):
gobject.threads_init()
set_exception_hook_dialog("cylc gscan")
setup_icons()
if not hosts:
hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"])
self.hosts = hosts
if owner is None:
owner = USER
self.owner = owner
self.window = gtk.Window()
self.window.set_title("cylc gscan")
self.window.set_icon(get_icon())
self.vbox = gtk.VBox()
self.vbox.show()
self.warnings = {}
self.theme_name = gcfg.get(['use theme'])
self.theme = gcfg.get(['themes', self.theme_name])
self.dots = DotMaker(self.theme)
suite_treemodel = gtk.TreeStore(
str, str, bool, str, int, str, str, str)
self._prev_tooltip_location_id = None
self.suite_treeview = gtk.TreeView(suite_treemodel)
# Construct the host column.
host_name_column = gtk.TreeViewColumn("Host")
cell_text_host = gtk.CellRendererText()
host_name_column.pack_start(cell_text_host, expand=False)
host_name_column.set_cell_data_func(
cell_text_host, self._set_cell_text_host)
host_name_column.set_sort_column_id(0)
host_name_column.set_visible("host" in gsfg.get(["columns"]))
host_name_column.set_resizable(True)
# Construct the suite name column.
suite_name_column = gtk.TreeViewColumn("Suite")
cell_text_name = gtk.CellRendererText()
suite_name_column.pack_start(cell_text_name, expand=False)
suite_name_column.set_cell_data_func(
cell_text_name, self._set_cell_text_name)
suite_name_column.set_sort_column_id(1)
suite_name_column.set_visible("suite" in gsfg.get(["columns"]))
suite_name_column.set_resizable(True)
# Construct the suite title column.
suite_title_column = gtk.TreeViewColumn("Title")
cell_text_title = gtk.CellRendererText()
suite_title_column.pack_start(cell_text_title, expand=False)
suite_title_column.set_cell_data_func(
cell_text_title, self._set_cell_text_title)
suite_title_column.set_sort_column_id(3)
suite_title_column.set_visible("title" in gsfg.get(
["columns"]))
suite_title_column.set_resizable(True)
# Construct the update time column.
time_column = gtk.TreeViewColumn("Updated")
cell_text_time = gtk.CellRendererText()
time_column.pack_start(cell_text_time, expand=False)
time_column.set_cell_data_func(
cell_text_time, self._set_cell_text_time)
time_column.set_sort_column_id(4)
time_column.set_visible("updated" in gsfg.get(["columns"]))
time_column.set_resizable(True)
self.suite_treeview.append_column(host_name_column)
self.suite_treeview.append_column(suite_name_column)
self.suite_treeview.append_column(suite_title_column)
self.suite_treeview.append_column(time_column)
# Construct the status column.
status_column = gtk.TreeViewColumn("Status")
status_column.set_sort_column_id(5)
status_column.set_visible("status" in gsfg.get(["columns"]))
status_column.set_resizable(True)
cell_text_cycle = gtk.CellRendererText()
status_column.pack_start(cell_text_cycle, expand=False)
status_column.set_cell_data_func(
cell_text_cycle, self._set_cell_text_cycle, self.CYCLE_COLUMN)
self.suite_treeview.append_column(status_column)
# Warning icon.
warn_icon = gtk.CellRendererPixbuf()
#.........这里部分代码省略.........
示例13: _set_key_liststore
def _set_key_liststore(self):
dotm = DotMaker(self._theme, self._dot_size)
self._key_liststore.clear()
for state in TASK_STATUSES_ORDERED:
dot = dotm.get_icon(state)
self._key_liststore.append([state, dot])