def __init__(self, parent, manager, config): super(Button, self).__init__(parent) self.manager = manager self._config = config self.setText(self._config.get('text', 'Button')) icon_ref = self._config.get('icon') if icon_ref is not None: icon = resources.get_icon(icon_ref, for_widget=self) self.setIcon(icon)
def _workers_cmds_ready(self, data): self._worker_cmds = data self._worker_cmds.sort(cmp=lambda a, b: cmp(a['label'], b['label'])) self._run_menu.clear() for cmd_info in self._worker_cmds: action = self._run_menu.addAction( cmd_info['label'], lambda cmd_id=cmd_info['id']: self.run_worker(cmd_id)) try: icon = resources.get_icon( ('system_cmds.icons', cmd_info['icon'])) except resources.NotFoundError: pass else: action.setIcon(icon)
def show_ui(client, app_name, ui_setup=None, **options): app = QtGui.QApplication(sys.argv) app.setApplicationName(app_name) w = QtGui.QMainWindow(None) w.setWindowIcon(resources.get_icon(('gui.icons', 'kabaret_logo_32x32'))) main_window_manager = MainWindowManager(w, client) main_window_manager.install_standalone() w.setWindowTitle( 'Kabaret') # temporary title, will be updated after connection connection = main_window_manager.create_docked_view( u"\u20AD", 'Connection', ConnectionView, QtCore.Qt.RightDockWidgetArea, options.get('Connection'), None) work_queue = main_window_manager.create_docked_view( u"\u20AD", 'Work Queue', WorkQueueView, QtCore.Qt.RightDockWidgetArea, options.get('WorkQueue'), None) main_window_manager.tabify_docked_view(connection, work_queue) console = main_window_manager.create_docked_view( u"\u20AD", 'Console', ConsoleView, QtCore.Qt.BottomDockWidgetArea, options.get('Console'), None) listener = main_window_manager.create_docked_view( u"\u20AD", 'Listener', ListenerView, QtCore.Qt.BottomDockWidgetArea, options.get('Listener'), None) history = main_window_manager.create_docked_view( u"\u20AD", 'History', CommandHistoryView, QtCore.Qt.BottomDockWidgetArea, options.get('History'), None) script = main_window_manager.create_docked_view( u"\u20AD", 'Script', ScriptView, QtCore.Qt.BottomDockWidgetArea, options.get('Script'), None) workers = main_window_manager.create_docked_view( u"\u20AD", 'Workers', WorkersView, QtCore.Qt.BottomDockWidgetArea, options.get('Workers'), None) main_window_manager.tabify_docked_view(console, listener, history, script, workers) if ui_setup is not None: ui_setup(main_window_manager) w.resize(800, 600) w.show() try: client.connect_from_env() except ValueError, err: print err, 'Showing Connection Dialog...' main_window_manager.show_connect_dialog()
def set_items_with_icon(self, items, icon_folder_name=None): self.clear() self._cb.addItem(self._help_text) help_text_index = self._cb.model().index(0, self._cb.modelColumn(), self._cb.rootModelIndex()) help_text_item = self._cb.model().itemFromIndex(help_text_index) help_text_item.setSelectable(False) for label, icon_name, data in items: if icon_folder_name is not None and icon_name is not None: icon = resources.get_icon((icon_folder_name,icon_name), self._cb) self._cb.addItem(icon, label, data) self._label_to_data[label] = data else: self._cb.addItem(label, data) self._label_to_data[label] = data self.waitter.hide()
def _update_widget(self): if self.infos is not None: self._button.setText(self.infos['name']) try: self._button.setIcon( resources.get_icon( ('flow.icons.nodes', self.infos['icon']), self._button)) except resources.ResourcesError: pass self._button.setToolTip(self.infos['type']) self.setVisible(True) self.updateGeometry() self.to_shown.emit() else: self._button.setText('') self._button.setToolTip('') self.setVisible(False) self.updateGeometry()
def show_ui(client, app_name=None, ui_setup=None, **options): app_name = app_name or client.worker_type app = QtGui.QApplication(sys.argv) app.setApplicationName(app_name) w = QtGui.QMainWindow() w.setWindowTitle(app_name) w.setWindowIcon(resources.get_icon(('gui.icons', 'kabaret_logo_32x32'))) main_window_manager = MainWindowManager(w, client) main_window_manager.install_standalone() main_window_manager.create_docked_view(u"\u20AD", 'Console', ConsoleView, QtCore.Qt.LeftDockWidgetArea, options.get('Console'), None) main_window_manager.create_docked_view(u"\u20AD", 'Listener', ListenerView, QtCore.Qt.BottomDockWidgetArea, options.get('Listener'), None) main_window_manager.create_docked_view(u"\u20AD", 'Connection', ConnectionView, QtCore.Qt.RightDockWidgetArea, options.get('Connection'), None) main_window_manager.create_docked_view(u"\u20AD", 'Script', ScriptView, QtCore.Qt.BottomDockWidgetArea, options.get('Script'), None) main_window_manager.create_docked_view(u"\u20AD", 'Work Queue', WorkQueueView, QtCore.Qt.RightDockWidgetArea, options.get('Work Queue'), None) if ui_setup is not None: ui_setup(main_window_manager) w.resize(600, 400) w.show() try: client.connect_from_env() except ValueError, err: print err, 'Showing Connection Dialog...' main_window_manager.show_connect_dialog()