Jump to content

Slide function


Go to solution Solved by ѕeмa™,

Recommended Posts

  • Solution
import ui 

movement = 0 
startness = 0 

class movement_test(ui.ThinBoard): 
    def __init__(self): 
        ui.ThinBoard.__init__(self) 
        self.Loadmovement_test() 
         
    def __del__(self): 
        ui.ThinBoard.__del__(self) 

    def Destroy(self): 
        self.Hide() 
        return TRUE 

    def Loadmovement_test(self): 
        self.SetPosition(-250,120) 
        self.SetSize(300, 300) 
        self.Show() 
        self.AddFlag("movable") 
        self.AddFlag("float") 
        self.LoadButtons() 
     
    def LoadButtons(self): 
        self.down_button = ui.Button() 
        self.down_button.SetParent(self) 
        self.down_button.SetPosition(285, 150) 
        self.down_button.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub") 
        self.down_button.SetOverVisual("d:/ymir work/ui/public/Large_Button_02.sub") 
        self.down_button.SetDownVisual("d:/ymir work/ui/public/Large_Button_03.sub") 
        self.down_button.SetText("Abrir") 
        self.down_button.SetEvent(ui.__mem_func__(self.start)) 
        self.down_button.Show() 
         
        self.up_button = ui.Button() 
        self.up_button.SetParent(self) 
        self.up_button.SetPosition(285, 150)
        self.up_button.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub") 
        self.up_button.SetOverVisual("d:/ymir work/ui/public/Large_Button_02.sub") 
        self.up_button.SetDownVisual("d:/ymir work/ui/public/Large_Button_03.sub") 
        self.up_button.SetText("Cerrar") 
        self.up_button.SetEvent(ui.__mem_func__(self.end)) 
        self.up_button.Hide() 
         
    def start(self): 
        global startness 
        startness = 1 
        self.up_button.Show() 
        self.down_button.Hide() 

    def end(self): 
        global startness 
        startness = 2 
        self.up_button.Hide() 
        self.down_button.Show() 

    def OnUpdate(self): 
        global startness 
        global movement 
        if movement < 250 and startness == 1:  # Movement <250, ponemos el ancho de la board
            movement += 4 # Velocidad de movimiento
            self.SetPosition(-250+movement,120) 
        elif not movement < 250 and startness == 1:  # -250 posiion normal , 250 posicion abierto
            startness = 0 
        elif movement > 0 and startness == 2: 
            movement -= 4 # Velocidad de movimiento
            self.SetPosition(-250+movement,120) 
        elif not movement > 0 and startness == 2: 
            startness = 0 

    def Show(self): 
        ui.ThinBoard.Show(self) 

    def Minimize(self): 
        self.Hide() 
         
    def Close(self): 
        self.Hide() 
        return TRUE 
         
    def OnPressEscapeKey(self): 
        self.Hide() 
        return TRUE 

aaaa= movement_test() 
aaaa.Show()  

try it. have fun

  • Love 2
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.