Exemple #1
0
    def KeyDown(
        self, event
    ):  ##default keydown,every inherited page class should have it's own KeyDown
        if IsKeyMenuOrB(event.key):
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Right"]:
            if self.MoveIconIndexNext() == True:
                if self._IconIndex == (self._IconNumbers -
                                       1) or self._PrevIconIndex == 0:
                    self.IconSmoothUp(icon_width + self._PageIconMargin)
                else:
                    self.IconsEasingLeft(icon_width + self._PageIconMargin)
            else:
                screen_icons = int(
                    math.floor(self._Screen._Width /
                               (icon_width + self._PageIconMargin)))
                if self._IconNumbers > screen_icons:
                    self.IconsEasingRight((icon_width + self._PageIconMargin) *
                                          (self._IconNumbers - screen_icons))
                elif self._IconNumbers > 0:
                    self.IconSmoothUp(icon_width + self._PageIconMargin)

            self._PsIndex = self._IconIndex
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Left"]:
            if self.MoveIconIndexPrev() == True:
                if self._IconIndex == 0 or self._PrevIconIndex == (
                        self._IconNumbers - 1):
                    self.IconSmoothUp(icon_width + self._PageIconMargin)
                else:
                    self.IconsEasingRight(icon_width + self._PageIconMargin)
            else:
                screen_icons = int(
                    math.floor(self._Screen._Width /
                               (icon_width + self._PageIconMargin)))
                if self._IconNumbers > screen_icons:
                    self.IconsEasingLeft((icon_width + self._PageIconMargin) *
                                         (self._IconNumbers - screen_icons))
                elif self._IconNumbers > 0:
                    self.IconSmoothUp(icon_width + self._PageIconMargin)

            self._PsIndex = self._IconIndex
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            self.IconClick()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
Exemple #2
0
    def KeyDown(
        self, event
    ):  ##default keydown,every inherited page class should have it's own KeyDown
        if IsKeyMenuOrB(event.key):
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Right"]:
            if self.MoveIconIndexNext() == True:
                if self._IconIndex == (self._IconNumbers -
                                       1) or self._PrevIconIndex == 0:
                    self.IconSmoothUp(
                        icon_width + self._PageIconMargin
                    )  # only move up selected icon,no horizontal translation
                else:
                    self.IconsEasingLeft(icon_width + self._PageIconMargin)

                self._PsIndex = self._IconIndex
                self._Screen.Draw()
                self._Screen.SwapAndShow()

        if event.key == CurKeys["Left"]:
            if self.MoveIconIndexPrev() == True:
                if self._IconIndex == 0 or self._PrevIconIndex == (
                        self._IconNumbers - 1):
                    self.IconSmoothUp(icon_width + self._PageIconMargin)
                else:
                    self.IconsEasingRight(icon_width + self._PageIconMargin)

                self._PsIndex = self._IconIndex
                self._Screen.Draw()
                self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            self.IconClick()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
    def KeyDown(self, event):

        if IsKeyMenuOrB(event.key):

            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            try:
                os.remove(self._TrashDir + "/" +
                          os.path.basename(self._FileName))
            except:
                pass

            try:
                shutil.move(self._FileName, self._TrashDir)
            except shutil.Error as e:
                if "already exists" in str(e):
                    self._Screen._MsgBox.SetText("AlreadyExisted")
                else:
                    self._Screen._MsgBox.SetText("Error")

                self._Screen._MsgBox.Draw()
                self._Screen.SwapAndShow()
            else:
                self.SnapMsg(MyLangManager.Tr("Deleting"))
                self._Screen.Draw()
                self._Screen.SwapAndShow()
                self.Reset()

                pygame.time.delay(300)
                self.ReturnToUpLevelPage()
                self._Screen.Draw()
                self._Screen.SwapAndShow()

            print(self._FileName)
Exemple #4
0
    def KeyDown(self, event, fast = False):##default keydown, every inherited page class should have it's own KeyDown

        if IsKeyMenuOrB(event.key):
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Right"]:
            if self.MoveIconIndexNext() == True:
                if self._IconIndex == (self._IconNumbers -1) or self._PrevIconIndex == 0:
                    # self.IconSmoothUp(icon_width + self._PageIconMargin)
                    self.IconSmoothUp(icon_width + self._PageIconMargin, fast)
                else:
                    # self.IconsEasingLeft(icon_width + self._PageIconMargin)
                    self.IconsEasingLeft(icon_width + self._PageIconMargin, fast)
            else:
                screen_icons = int(math.floor(self._Screen._Width / (icon_width + self._PageIconMargin)))
                if self._IconNumbers > screen_icons:
                    # self.IconsEasingRight((icon_width + self._PageIconMargin) * (self._IconNumbers - screen_icons))
                    self.IconsEasingRight((icon_width + self._PageIconMargin) * (self._IconNumbers - screen_icons), fast)
                elif self._IconNumbers > 0:
                    # self.IconSmoothUp(icon_width+ self._PageIconMargin)
                    self.IconSmoothUp(icon_width+ self._PageIconMargin, fast)

            self._PsIndex  = self._IconIndex
            # self._Screen.Draw()
            # self._Screen.SwapAndShow()
            if not fast:
                self._Screen.Draw()
                self._Screen.SwapAndShow()
            
        if event.key == CurKeys["Left"]:
            if self.MoveIconIndexPrev() == True:
                if self._IconIndex == 0 or self._PrevIconIndex == (self._IconNumbers -1):
                    # self.IconSmoothUp(icon_width + self._PageIconMargin)
                    self.IconSmoothUp(icon_width + self._PageIconMargin, fast)
                else:
                    # self.IconsEasingRight(icon_width + self._PageIconMargin)
                    self.IconsEasingRight(icon_width + self._PageIconMargin, fast)
            else:
                screen_icons = int(math.floor(self._Screen._Width / (icon_width + self._PageIconMargin)))
                if self._IconNumbers > screen_icons:
                    # self.IconsEasingLeft((icon_width + self._PageIconMargin) * (self._IconNumbers - screen_icons))
                    self.IconsEasingLeft((icon_width + self._PageIconMargin) * (self._IconNumbers - screen_icons), fast)
                elif self._IconNumbers > 0:
                    # self.IconSmoothUp(icon_width+ self._PageIconMargin)
                    self.IconSmoothUp(icon_width+ self._PageIconMargin, fast)

            self._PsIndex = self._IconIndex
            # self._Screen.Draw()
            # self._Screen.SwapAndShow()
            if not fast:
                self._Screen.Draw()
                self._Screen.SwapAndShow()

        if event.key == CurKeys["Up"]:
            move = 3
            pageup = pygame.event.Event(pygame.KEYDOWN, key = CurKeys["Left"])

            for i in range(move):
                self.KeyDown(pageup, True)

            self.DrawIcons()            # redraw icons
            self._Screen.Draw()         # show selected icon
            self._Screen.SwapAndShow()

        if event.key == CurKeys["Down"]:
            move = 3
            pagedown = pygame.event.Event(pygame.KEYDOWN, key = CurKeys["Right"])
            
            for i in range(move):
                self.KeyDown(pagedown, True)

            self.DrawIcons()            # redraw icons
            self._Screen.Draw()         # show selected icon
            self._Screen.SwapAndShow()

        if IsKeyStartOrA(event.key):
            self.IconClick()
            self._Screen.Draw()
            self._Screen.SwapAndShow()