Esempio n. 1
0
def main():
    terminal.open()

    # generate opening scene
    UIManager.push(TitleScene())
    key = 0
    shift_down = False

    # main game loop
    while key != terminal.TK_CLOSE:
        terminal.clear()
        UIManager.render()
        terminal.refresh()
        GAME.scheduler.process()
        key = terminal.read()
        shift_down = bool(terminal.check(terminal.TK_SHIFT))
        player_cmd = UIManager.peek().handle_input(key, shift_down)
        GAME.player.push_player_action(player_cmd)

        # if no UIs to show, game is closed
        if UIManager.empty:
            break

    # cleanup
    UIManager.clear()  # if the close button was clicked with UIs on the stack
    terminal.close()
Esempio n. 2
0
class MenuState(State):
    def __init__(self):
        super().__init__()
        self.ui_manager = UIManager()
        self.ui_manager.add(
            UIObject(100, 100, 50, 50, (255, 0, 0), (0, 255, 0), (0, 0, 255),
                     lambda: print('o_O')))

    def tick(self):
        self.ui_manager.tick()

    def draw(self, screen):
        self.ui_manager.draw(screen)
Esempio n. 3
0
    def __init__(self, **kwargs):
        super(ShowWebManage_ui, self).__init__()
        #def __init__(self,**kwargs):
        #    QtGui.QWidget.__init__(self)
        try:
            try:
                self.main_ui = UIManager.get_ui('main_ui')  #主程序UI
                #self.shell_sql=UIManager.shell_sql
                self.ShowWeb_ui = uic.loadUi("ui/ShowWebManage.ui",
                                             self)  #动态加标签
                # uic.loadUi("ui/ShowWebManage.ui", self)
                # self.setWindowIcon(QtGui.QIcon("system/main.ico"))
                # flags = 0  #设置禁止最大化
                # flags|= Qt.WindowMinimizeButtonHint  #设置禁止最大化
                # self.setWindowFlags(flags)  #设置禁止最大化
                # #禁止最大化按钮
                # self.setWindowFlags(Qt.WindowMinimizeButtonHint)
                # #禁止拉伸窗口大小
                # self.setFixedSize(self.width(), self.height())
            except BaseException, e:
                log.logging.debug("except:%s" % (str(e)))
            self.url_comboBox.setMouseTracking(False)
            self.url_comboBox.setAcceptDrops(False)
            self.url_comboBox.setEditable(True)
            self.url_comboBox.setMaxVisibleItems(15)  #设置下拉最大选项数为15
            Title = str('%s' % (kwargs['Title']))
            self.main_ui.tabWidget.addTab(self.ShowWeb_ui,
                                          QIcon('system/web.ico'), Title)
            if "form" in kwargs:  #名称
                if int(kwargs['form']):
                    self.main_ui.tabWidget.setCurrentIndex(
                        self.main_ui.tabWidget.count() - 1)  #显示当前页

            self.webView_look(str(Title))  #浏览网站

            self.url_comboBox.setEditText(_fromUtf8(Title))  #设置当前内容
            self.url_comboBox.addItem(_fromUtf8(Title))  #添加到下拉列表

            self.url_comboBox.installEventFilter(self)  #在窗体上为self.edit安装过滤器
            #=========================
            self.look_pushButton.clicked.connect(self.look_Button)  #浏览网页
Esempio n. 4
0
    def __init__(self,**kwargs):
        super(ShowWebManage_ui, self).__init__()
    #def __init__(self,**kwargs):
    #    QtGui.QWidget.__init__(self)
        try:
            try:
                self.main_ui=UIManager.get_ui('main_ui') #主程序UI
                #self.shell_sql=UIManager.shell_sql
                self.ShowWeb_ui = uic.loadUi("ui/ShowWebManage.ui", self)#动态加标签
                # uic.loadUi("ui/ShowWebManage.ui", self)
                # self.setWindowIcon(QtGui.QIcon("system/main.ico"))
                # flags = 0  #设置禁止最大化
                # flags|= Qt.WindowMinimizeButtonHint  #设置禁止最大化
                # self.setWindowFlags(flags)  #设置禁止最大化
                # #禁止最大化按钮
                # self.setWindowFlags(Qt.WindowMinimizeButtonHint)
                # #禁止拉伸窗口大小
                # self.setFixedSize(self.width(), self.height())
            except BaseException, e:
                log.logging.debug("except:%s"%(str(e)))
            self.url_comboBox.setMouseTracking(False)
            self.url_comboBox.setAcceptDrops(False)
            self.url_comboBox.setEditable(True)
            self.url_comboBox.setMaxVisibleItems(15)#设置下拉最大选项数为15
            Title=str('%s'%(kwargs['Title']))
            self.main_ui.tabWidget.addTab(self.ShowWeb_ui,QIcon('system/web.ico'),Title)
            if "form" in kwargs:  #名称
                if int(kwargs['form']):
                    self.main_ui.tabWidget.setCurrentIndex(self.main_ui.tabWidget.count()-1)#显示当前页

            self.webView_look(str(Title))  #浏览网站

            self.url_comboBox.setEditText(_fromUtf8(Title))  #设置当前内容
            self.url_comboBox.addItem(_fromUtf8(Title))  #添加到下拉列表

            self.url_comboBox.installEventFilter(self)#在窗体上为self.edit安装过滤器
            #=========================
            self.look_pushButton.clicked.connect(self.look_Button)    #浏览网页
Esempio n. 5
0
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
        #uic.loadUi("ui/file.ui", self)
        self.main_ui=UIManager.get_ui('main_ui') #主程序UI
        self.shell_sql=UIManager.shell_sql
        self.ShowFile_ui = uic.loadUi("ui/Import_export.ui", self)#动态加标签
        self.setWindowIcon(QtGui.QIcon("system/main.ico"))  #设置图标
        flags = 0  #设置禁止最大化
        flags|= Qt.WindowMinimizeButtonHint  #设置禁止最大化
        self.setWindowFlags(flags)  #设置禁止最大化
        #禁止最大化按钮
        self.setWindowFlags(Qt.WindowMinimizeButtonHint)
        #禁止拉伸窗口大小
        self.setFixedSize(self.width(), self.height())
        try:
            self.path_Edit.setEnabled(0)  #给改成禁用
            #self.textEdit.setEnabled(0)  #给改成禁用
            self.radioButton_1.setChecked(True)
            self.Import_export=0  #操作方式
            self.radio_id="|"  #分割符号
            self.list_data=[]

            self.log_edit_shell(self.radio_id)  #注释
            self.path_Edit.setText(_fromUtf8(str("file Utf-8")))  #设置当前内容
            self.link_Button.setEnabled(0)  #给改成禁用
            ###################################################
            self.path_Button.clicked.connect(self.open_path_Button)    #读取文件
            self.link_Button.clicked.connect(self.open_link_Button)    #导入

            self.radioButton_1.clicked.connect(self.radioButton_id)    #
            self.radioButton_2.clicked.connect(self.radioButton_id)    #
            self.radioButton_3.clicked.connect(self.radioButton_id)    #
            self.radioButton_4.clicked.connect(self.radioButton_id)    #
            self.radioButton_5.clicked.connect(self.radioButton_id)    #
            ###################################################
        except BaseException, e:
            log.logging.debug("except:%s"%(str(e)))
Esempio n. 6
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        #uic.loadUi("ui/file.ui", self)
        self.main_ui = UIManager.get_ui('main_ui')  #主程序UI
        self.shell_sql = UIManager.shell_sql
        self.ShowFile_ui = uic.loadUi("ui/Import_export.ui", self)  #动态加标签
        self.setWindowIcon(QtGui.QIcon("system/main.ico"))  #设置图标
        flags = 0  #设置禁止最大化
        flags |= Qt.WindowMinimizeButtonHint  #设置禁止最大化
        self.setWindowFlags(flags)  #设置禁止最大化
        #禁止最大化按钮
        self.setWindowFlags(Qt.WindowMinimizeButtonHint)
        #禁止拉伸窗口大小
        self.setFixedSize(self.width(), self.height())
        try:
            self.path_Edit.setEnabled(0)  #给改成禁用
            #self.textEdit.setEnabled(0)  #给改成禁用
            self.radioButton_1.setChecked(True)
            self.Import_export = 0  #操作方式
            self.radio_id = "|"  #分割符号
            self.list_data = []

            self.log_edit_shell(self.radio_id)  #注释
            self.path_Edit.setText(_fromUtf8(str("file Utf-8")))  #设置当前内容
            self.link_Button.setEnabled(0)  #给改成禁用
            ###################################################
            self.path_Button.clicked.connect(self.open_path_Button)  #读取文件
            self.link_Button.clicked.connect(self.open_link_Button)  #导入

            self.radioButton_1.clicked.connect(self.radioButton_id)  #
            self.radioButton_2.clicked.connect(self.radioButton_id)  #
            self.radioButton_3.clicked.connect(self.radioButton_id)  #
            self.radioButton_4.clicked.connect(self.radioButton_id)  #
            self.radioButton_5.clicked.connect(self.radioButton_id)  #
            ###################################################
        except BaseException, e:
            log.logging.debug("except:%s" % (str(e)))
Esempio n. 7
0
 def __init__(self):
     super().__init__()
     self.ui_manager = UIManager()
     self.ui_manager.add(
         UIObject(100, 100, 50, 50, (255, 0, 0), (0, 255, 0), (0, 0, 255),
                  lambda: print('o_O')))
Esempio n. 8
0
def main():
    parse_args() # Sets CONFIG options.
                 # Must be called before UIManager instantiated.
    
    pygame.init()
    pygame.display.set_caption('Flippyflap Wivs')
    environ['SDL_VIDEO_WINDOW_POS'] = 'center'

    # Load high score
    pd = PersistentData(DATA_PATH)
    if path.exists(DATA_PATH):
        pd.load()
    else:
        pd.high_score = 0
    
    clock = pygame.time.Clock()
    dt = 1
    gdt = 60 / CONFIG.FPS_LIMIT
    gs = GameState()
    gd = GameData(pd.high_score)
    uim = UIManager(gd.n_columns, gdt*gd.scroll_speed)
    end = False

    # Prep for game loop
    pygame.mouse.set_visible(0)
    pygame.event.set_allowed(None)
    pygame.event.set_allowed(
        (pygame.KEYDOWN, pygame.QUIT, pygame.MOUSEBUTTONDOWN)
    )

    # Game loop
    while not end:
        # Transition state
        gs.transition_state()
        
        # Handle Events
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                end = True
            elif event.type == pygame.KEYDOWN:
                handle_event_keydown(gs, event)
            elif event.type == pygame.MOUSEBUTTONDOWN:
                handle_event_mousebuttondown(gs, event)

        if gs.state == gs.QUIT:
            end = True

        if gs.state != gs.PAUSE:
            # Update
            gd.update(gs, gdt)
            uim.update(gs, gd, dt)
            gd.postupdate(gs, gdt)

            # Draw
            uim.draw()

        # Cleanup
        clock.tick(CONFIG.FPS_LIMIT)
        fps = clock.get_fps()
        gdt = 60 / (fps if fps > 15 else CONFIG.FPS_LIMIT)                                       
        dt = fps / CONFIG.FPS_LIMIT
        pygame.event.pump()


    # Save high score
    pd.high_score = gd.high_score
    pd.save()
    pygame.quit()
Esempio n. 9
0
 def handle_input(self, key: int, shift_down: bool):
     UIManager.pop()
     UIManager.push(PlayScene())