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


Python Trainer.startNewSession方法代码示例

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


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

示例1: MainWindow

# 需要导入模块: from trainer import Trainer [as 别名]
# 或者: from trainer.Trainer import startNewSession [as 别名]
class MainWindow(QtGui.QMainWindow):
    
    def __init__(self):
        super(MainWindow, self).__init__()        
        
        self.setWindowTitle("Algae Count Estimator")
        
        self.setSizePolicy(QtGui.QSizePolicy.Fixed,
                           QtGui.QSizePolicy.Fixed)
        
        self.setFixedSize(QtCore.QSize(800,620))
        
        self.initPages()
        self.initMenuBar()       
        
        self.show()
    
    """
    initPages():
        Creates and populates a QStackedWidget that contains the different
        modes (i.e. pages) of the application.
    """
    def initPages(self):
        self.mode_stack = QtGui.QStackedWidget()

        main_menu = MainMenu(self) #0
        self.stats = Statistics(self) #1
        self.trainer = Trainer(self,self.stats) #2
        self.generator = Generator(self) #3
        
        self.mode_stack.addWidget(main_menu)
        self.mode_stack.addWidget(self.stats)
        self.mode_stack.addWidget(self.trainer)
        self.mode_stack.addWidget(self.generator)
        
        self.setCentralWidget(self.mode_stack)
    
    """
    initMenuBar():
        Creates a menu bar that is visible from any mode of the application.
        The options under the menus are called "actions".
    """
    def initMenuBar(self):
        menu_bar = self.menuBar()
        
        #Create File menu and actions.
        file_menu = menu_bar.addMenu('&File')
        
        to_menu_action = QtGui.QAction('Main Menu', self)
        to_menu_action.triggered.connect(lambda: self.changeMode(ModeEnum.MENU))
        
        exit_action = QtGui.QAction('Exit', self)
        exit_action.triggered.connect(self.exitProgram )
        
        file_menu.addAction(to_menu_action)
        file_menu.addAction(exit_action)
        
        #Create Help menu and actions.
        help_menu = menu_bar.addMenu('&Help')

        about_action = QtGui.QAction('About', self)
        about_action.triggered.connect(self.aboutMenu)
        help_menu.addAction(about_action)
        
    """
    changeMode(page_num):
        Changes the view of the user to the mode associated with page_num.
        page_num is an integer defined by ModeEnum. (see enum module).
        
        Special conditions that need to be met before switching to a mode
        may be addressed here.
    """
    def changeMode(self, page_num):
        #Perform any work that needs to be done before switching modes.
        if page_num == ModeEnum.STATS:
            #Update the stats page before switching the view.
            self.stats.updateStatsUI()

        elif page_num == ModeEnum.TRAINER:
            #Attempt to start a new Trainer session if there is not
            #an active session.
            if (not self.trainer.has_active_session):
                if (not self.trainer.startNewSession()):
                    return

        #Switch the mode.
        self.mode_stack.setCurrentIndex(page_num)

    """
    exitProgram():
    This exit routine is called when the user exits via File->Exit.
    Writes the stats to disk and closes the application.
    """
    def exitProgram(self):
        self.mode_stack.widget(ModeEnum.STATS).writeStatsToFile()
        QtGui.qApp.quit()
    
        
    """
    closeEvent(event):
#.........这里部分代码省略.........
开发者ID:gate23,项目名称:ace,代码行数:103,代码来源:mainwindow.py


注:本文中的trainer.Trainer.startNewSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。