本文整理汇总了Python中MainWindow.MainWindow.update方法的典型用法代码示例。如果您正苦于以下问题:Python MainWindow.update方法的具体用法?Python MainWindow.update怎么用?Python MainWindow.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWindow.MainWindow
的用法示例。
在下文中一共展示了MainWindow.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from MainWindow import MainWindow [as 别名]
# 或者: from MainWindow.MainWindow import update [as 别名]
class ActionHandler:
"""
The action handler will setup all the major window components,
and handle button presses and flow graph operations from the GUI.
"""
def __init__(self, file_paths, platform):
"""
ActionHandler constructor.
Create the main window, setup the message handler, import the preferences,
and connect all of the action handlers. Finally, enter the gtk main loop and block.
@param file_paths a list of flow graph file passed from command line
@param platform platform module
"""
self.clipboard = None
for action in Actions.get_all_actions(): action.connect('activate', self._handle_action)
#setup the main window
self.main_window = MainWindow(platform)
self.main_window.connect('delete-event', self._quit)
self.main_window.connect('key-press-event', self._handle_key_press)
self.get_page = self.main_window.get_page
self.get_flow_graph = self.main_window.get_flow_graph
self.get_focus_flag = self.main_window.get_focus_flag
#setup the messages
Messages.register_messenger(self.main_window.add_report_line)
Messages.send_init(platform)
#initialize
self.init_file_paths = file_paths
Actions.APPLICATION_INITIALIZE()
#enter the mainloop
gtk.main()
def _handle_key_press(self, widget, event):
"""
Handle key presses from the keyboard and translate key combinations into actions.
This key press handler is called prior to the gtk key press handler.
This handler bypasses built in accelerator key handling when in focus because
* some keys are ignored by the accelerators like the direction keys,
* some keys are not registered to any accelerators but are still used.
When not in focus, gtk and the accelerators handle the the key press.
@return false to let gtk handle the key action
"""
try: assert self.get_focus_flag()
except AssertionError: return False
return Actions.handle_key_press(event)
def _quit(self, window, event):
"""
Handle the delete event from the main window.
Generated by pressing X to close, alt+f4, or right click+close.
This method in turns calls the state handler to quit.
@return true
"""
Actions.APPLICATION_QUIT()
return True
def _handle_action(self, action):
#print action
##################################################
# Initalize/Quit
##################################################
if action == 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.TYPES_WINDOW_DISPLAY,
): 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 action == Actions.APPLICATION_QUIT:
if self.main_window.close_pages():
gtk.main_quit()
exit(0)
##################################################
# Selections
##################################################
elif action == Actions.ELEMENT_SELECT:
pass #do nothing, update routines below
elif action == Actions.NOTHING_SELECT:
self.get_flow_graph().unselect()
##################################################
# Enable/Disable
##################################################
elif action == 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 action == Actions.BLOCK_DISABLE:
if self.get_flow_graph().enable_selected(False):
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from MainWindow import MainWindow [as 别名]
# 或者: from MainWindow.MainWindow import update [as 别名]
#.........这里部分代码省略.........
#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.TYPES_WINDOW_DISPLAY, Actions.TOGGLE_BLOCKS_WINDOW,
Actions.TOGGLE_REPORTS_WINDOW,
): action.set_sensitive(True)
if ParseXML.xml_failures:
Messages.send_xml_errors_if_any(ParseXML.xml_failures)
Actions.XML_PARSER_ERRORS_DISPLAY.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
self.main_window.btwin.search_entry.hide()
Actions.TOGGLE_REPORTS_WINDOW.set_active(Preferences.reports_window_visibility())
Actions.TOGGLE_BLOCKS_WINDOW.set_active(Preferences.blocks_window_visibility())
elif action == Actions.APPLICATION_QUIT:
if self.main_window.close_pages():
gtk.main_quit()
exit(0)
##################################################
# Selections
##################################################
elif action == Actions.ELEMENT_SELECT:
pass #do nothing, update routines below
elif action == Actions.NOTHING_SELECT:
self.get_flow_graph().unselect()
##################################################
# Enable/Disable
##################################################
elif action == 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 action == 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 action == Actions.BLOCK_CUT:
Actions.BLOCK_COPY()
Actions.ELEMENT_DELETE()
elif action == Actions.BLOCK_COPY:
self.clipboard = self.get_flow_graph().copy_to_clipboard()
elif action == 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)
##################################################
# Create heir block
##################################################