本文整理汇总了Python中Actions.get_action_from_name方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.get_action_from_name方法的具体用法?Python Actions.get_action_from_name怎么用?Python Actions.get_action_from_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actions
的用法示例。
在下文中一共展示了Actions.get_action_from_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_action_from_name [as 别名]
def __init__(self):
"""
Parse the list of action names in the toolbar list.
Look up the action for each name in the action list and add it to the toolbar.
"""
gtk.Toolbar.__init__(self)
self.set_style(gtk.TOOLBAR_ICONS)
for action_name in TOOLBAR_LIST:
if action_name: #add a tool item
action = Actions.get_action_from_name(action_name)
self.add(action.create_tool_item())
#this reset of the tooltip property is required (after creating the tool item) for the tooltip to show
action.set_property('tooltip', action.get_property('tooltip'))
else: self.add(gtk.SeparatorToolItem())
示例2: update_exec_stop
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_action_from_name [as 别名]
def update_exec_stop(self):
"""
Update the exec and stop buttons.
Lock and unlock the mutex for race conditions with exec flow graph threads.
"""
sensitive = self.get_flow_graph().is_valid() and not self.get_page().get_pid()
Actions.get_action_from_name(Actions.FLOW_GRAPH_GEN).set_sensitive(sensitive)
Actions.get_action_from_name(Actions.FLOW_GRAPH_EXEC).set_sensitive(sensitive)
Actions.get_action_from_name(Actions.FLOW_GRAPH_KILL).set_sensitive(self.get_page().get_pid() != None)
示例3: handle_states
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import get_action_from_name [as 别名]
def handle_states(self, state=''):
"""
Handle the state changes in the GUI.
Handle all of the state changes that arise from the action handler or other gui and
inputs in the application. The state passed to the handle_states method is a string descriping
the change. A series of if/elif statements handle the state by greying out action buttons, causing
changes in the flow graph, saving/opening files... The handle_states method is passed to the
contructors of many of the classes used in this application enabling them to report any state change.
@param state a string describing the state change
"""
#print state
##################################################
# Initalize/Quit
##################################################
if state == Actions.APPLICATION_INITIALIZE:
for action in Actions.get_all_actions(): action.set_sensitive(False) #set all actions disabled
# enable a select few actions
for action in (
Actions.APPLICATION_QUIT, Actions.FLOW_GRAPH_NEW,
Actions.FLOW_GRAPH_OPEN, Actions.FLOW_GRAPH_SAVE_AS,
Actions.FLOW_GRAPH_CLOSE, Actions.ABOUT_WINDOW_DISPLAY,
Actions.FLOW_GRAPH_SCREEN_CAPTURE, Actions.HELP_WINDOW_DISPLAY,
Actions.COLORS_WINDOW_DISPLAY,
): Actions.get_action_from_name(action).set_sensitive(True)
if not self.init_file_paths:
self.init_file_paths = Preferences.files_open()
if not self.init_file_paths: self.init_file_paths = ['']
for file_path in self.init_file_paths:
if file_path: self.main_window.new_page(file_path) #load pages from file paths
if Preferences.file_open() in self.init_file_paths:
self.main_window.new_page(Preferences.file_open(), show=True)
if not self.get_page(): self.main_window.new_page() #ensure that at least a blank page exists
elif state == Actions.APPLICATION_QUIT:
if self.main_window.close_pages():
gtk.main_quit()
exit(0)
##################################################
# Selections
##################################################
elif state == Actions.ELEMENT_SELECT:
pass #do nothing, update routines below
elif state == Actions.NOTHING_SELECT:
self.get_flow_graph().unselect()
##################################################
# Enable/Disable
##################################################
elif state == Actions.BLOCK_ENABLE:
if self.get_flow_graph().enable_selected(True):
self.get_flow_graph().update()
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
elif state == Actions.BLOCK_DISABLE:
if self.get_flow_graph().enable_selected(False):
self.get_flow_graph().update()
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##################################################
# Cut/Copy/Paste
##################################################
elif state == Actions.BLOCK_CUT:
self.handle_states(Actions.BLOCK_COPY)
self.handle_states(Actions.ELEMENT_DELETE)
elif state == Actions.BLOCK_COPY:
self.clipboard = self.get_flow_graph().copy_to_clipboard()
elif state == Actions.BLOCK_PASTE:
if self.clipboard:
self.get_flow_graph().paste_from_clipboard(self.clipboard)
self.get_flow_graph().update()
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
##################################################
# Move/Rotate/Delete/Create
##################################################
elif state == Actions.BLOCK_MOVE:
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
elif state == Actions.BLOCK_ROTATE_CCW:
if self.get_flow_graph().rotate_selected(90):
self.get_flow_graph().update()
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
elif state == Actions.BLOCK_ROTATE_CW:
if self.get_flow_graph().rotate_selected(-90):
self.get_flow_graph().update()
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.get_page().set_saved(False)
elif state == Actions.ELEMENT_DELETE:
if self.get_flow_graph().remove_selected():
self.get_flow_graph().update()
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.handle_states(Actions.NOTHING_SELECT)
self.get_page().set_saved(False)
elif state == Actions.ELEMENT_CREATE:
self.get_flow_graph().update()
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data())
self.handle_states(Actions.NOTHING_SELECT)
self.get_page().set_saved(False)
elif state == Actions.BLOCK_INC_TYPE:
if self.get_flow_graph().type_controller_modify_selected(1):
self.get_flow_graph().update()
#.........这里部分代码省略.........