当前位置: 首页>>代码示例>>Python>>正文


Python Terminal.prompt方法代码示例

本文整理汇总了Python中terminal.Terminal.prompt方法的典型用法代码示例。如果您正苦于以下问题:Python Terminal.prompt方法的具体用法?Python Terminal.prompt怎么用?Python Terminal.prompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在terminal.Terminal的用法示例。


在下文中一共展示了Terminal.prompt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from terminal import Terminal [as 别名]
# 或者: from terminal.Terminal import prompt [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.prompt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。