當前位置: 首頁>>代碼示例>>Python>>正文


Python Terminal.error方法代碼示例

本文整理匯總了Python中terminal.Terminal.error方法的典型用法代碼示例。如果您正苦於以下問題:Python Terminal.error方法的具體用法?Python Terminal.error怎麽用?Python Terminal.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在terminal.Terminal的用法示例。


在下文中一共展示了Terminal.error方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MainWindow

# 需要導入模塊: from terminal import Terminal [as 別名]
# 或者: from terminal.Terminal import error [as 別名]
class MainWindow(QtGui.QFrame):
    def __init__(self, file_to_open=''):
        super().__init__()
        self.setWindowTitle('New file')

        self.force_quit_flag = False

        self.config = read_config()
        self.setStyleSheet('background: '+self.config['theme']['background'])

        layout = QtGui.QVBoxLayout(self)
        common.kill_theming(layout)

        self.scene_container = QtGui.QScrollArea(self)
        layout.addWidget(self.scene_container, stretch=1)

        self.scene = Scene(self.config,
                self.scene_container.horizontalScrollBar().value,
                self.scene_container.verticalScrollBar().value)

        self.scene_container.setWidget(self.scene)
        self.scene_container.setDisabled(True)

        self.terminal = Terminal(self, lambda: self.scene.file_path)
        layout.addWidget(self.terminal)

        self.connect_signals(self.scene, self.terminal)

#        common.set_hotkey('Escape', self, self.terminal.toggle)
        common.set_hotkey('Ctrl+N', self, self.scene.request_new_file)
        common.set_hotkey('Ctrl+O', self, lambda:self.terminal.prompt('o '))
        common.set_hotkey('Ctrl+S', self, self.scene.request_save_file)
        common.set_hotkey('Ctrl+Shift+S', self,
                          lambda:self.terminal.prompt('s '))

        if file_to_open:
            self.scene.open_file(file_to_open)

        self.show()

    # Override
    def closeEvent(self, event):
        if not self.scene.is_modified() or self.force_quit_flag:
            event.accept()
        else:
            self.terminal.error('Unsaved changes! Force quit with q! or save first.')
            event.ignore()

    def quit(self, force):
        if force:
            self.force_quit_flag = True
            self.close()
        else:
            self.force_quit_flag = False
            self.close()

    def connect_signals(self, scene, term):
        connect = (
            (term.add_plotline, scene.add_plotline),
            (term.add_timeslot, scene.add_timeslot),
            (term.insert_plotline, scene.insert_plotline),
            (term.insert_timeslot, scene.insert_timeslot),
            (term.move_plotline, scene.move_plotline),
            (term.move_timeslot, scene.move_timeslot),
            (term.copy_plotline, scene.copy_plotline),
            (term.copy_timeslot, scene.copy_timeslot),
            (term.remove_plotline, scene.remove_plotline),
            (term.remove_timeslot, scene.remove_timeslot),
            (term.move_cell, scene.move_cell),
            (term.copy_cell, scene.copy_cell),
            (term.edit_cell, scene.edit_cell),
            (term.clear_cell, scene.clear_cell),
            (term.undo, scene.undo),
            (term.set_time_orientation, scene.set_time_orientation),
            (scene.window_title_changed, self.setWindowTitle),

            # Terminal actions
            (scene.prompt_sig, term.prompt),
            (scene.error_sig, term.error),
            (scene.print_, term.print_),
            (term.give_up_focus, scene.setFocus),
            (term.input_term.scroll_index, self.scene_container.event),

            # File operations
            (term.request_new_file, scene.request_new_file),
            (term.request_save_file, scene.request_save_file),
            (term.request_open_file, scene.request_open_file),
            (term.request_quit, self.quit)
        )
        for signal, slot in connect:
            signal.connect(slot)
開發者ID:cefyr,項目名稱:urd,代碼行數:93,代碼來源:urd.py


注:本文中的terminal.Terminal.error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。