Пример #1
0
def handle_valid_command(command: MenuCommand, session: Session,
                         args: Dict[str, Any]) -> None:
    session.clear()
    exit_code = command.execute(session, args)  # type: ExitCode
    session.get_io().output('Command "{}" completed with exit code {}'.format(
        command.name(), exit_code.name))
    time.sleep(1)
Пример #2
0
 def update_actions(self, *unused):
     MenuCommand.update_actions(self)
     if self.dont_update_entry:
         return
     if not (self.info.selection_recurrence is None):
         text = self.info.selection_recurrence.toEnglish()
     elif not (self.info.selected is None):
         text = self.weekview.timed.get_occurence_event(
             self.info.selected).recurrence.toEnglish()
     else:
         text = ""
     self.selection_buffer.set_text(text)
Пример #3
0
 def end(self):
     """End the game with a win."""
     self.board._reveal_board()
     print(self.board)
     print('Enter "new" for a new game or "quit" to quit.')
     while True:
         command = MenuCommand()
         if command.action == 'new':
             self.start()
         elif command.action == 'quit':
             self.exit()
         else:
             self.usage()
Пример #4
0
    def __init__(self):
        self.undo = UndoStack()
        self.history = UndoStack(
            gtk.Action("Back", None, None, gtk.STOCK_GO_BACK),
            gtk.Action("Forward", None, None, gtk.STOCK_GO_FORWARD))
        w = gtk.Window()
        w.connect("destroy", gtk.main_quit)
        vbox = gtk.VBox()
        self.model = Schedule("schedule.csv")
        self.info = CalendarInfo(self.model)
        self.weekview = WeekView(self.info, self.undo, self.history)
        self.monthview = MonthView(self.info, self.undo, self.history)

        uiman = gtk.UIManager ()
        actiongroup = MenuCommand.create_action_group(self)
        actiongroup.add_action(self.undo.undo_action)
        actiongroup.add_action(self.undo.redo_action)
        actiongroup.add_action(self.history.undo_action)
        actiongroup.add_action(self.history.redo_action)

        self.undo.undo_action.connect("activate", self.update_actions)
        self.undo.redo_action.connect("activate", self.update_actions)
        uiman.insert_action_group(actiongroup)
        uiman.add_ui_from_string(self.ui)
        toolbar = uiman.get_widget("/upperToolbar")
        vbox.pack_start (toolbar, False, False)

        vbox.pack_start(self.weekview, True, True)
        vbox.pack_start(self.monthview, True, True)

        toolbar = uiman.get_widget("/lowerToolbar")

        self.selection_buffer = gtk.TextBuffer()
        self.selection_buffer.create_tag("error",
                                         underline=pango.UNDERLINE_SINGLE)
        self.selection_entry = gtk.TextView(self.selection_buffer)
        
        self.pack_toolbar_widget(toolbar, self.selection_entry)
        vbox.pack_end (toolbar, False, False)

        w.add(vbox)
        w.show()
        vbox.show()
        self.monthview.hide()
        self.window = w
        self.weekview.connect("notify::selected", self.update_actions)
        self.info.connect("selection-recurrence-changed", self.update_actions)
        self.selection_entry.connect("key-press-event", self.selection_entry_key_press_cb)
Пример #5
0
def handle_valid_command(command: MenuCommand, session: Session, args: Dict[str, Any]) -> None:
    session.clear()
    exit_code = command.execute(session, args)  # type: ExitCode
    session.get_io().output('Command "{}" completed with exit code {}'.format(command.name(), exit_code.name))
    time.sleep(1)