Exemple #1
0
class Application(App):
    def build(self):
        Window.clearcolor = (1, 1, 1, 0)
        Window.size = (320, 480)
        self.connection = Connection()
        self.img = Image(source='net.jpeg')
        self.img.allow_stretch = True
        self.img.opacity = 1
        self.password = TextInput(text="Ravikiran@ms1",
                                  multiline=False,
                                  height=10,
                                  size_hint=(None, None))
        self.loginbutton = Button(text="Unlock")
        self.loginbutton.bind(on_press=self.login)
        self.registerbutton = Button(text="Register")
        self.registerbutton.bind(on_press=self.register)
        #creating layout based on conditions
        cols = self.connection.size("pwmanager")
        self.master = BoxLayout(orientation="vertical")
        self.master.add_widget(self.img)
        self.master.add_widget(self.password)
        if cols is not 1:
            self.master.add_widget(self.registerbutton)
        else:
            self.master.add_widget(self.loginbutton)
        return self.master

    def login(self, event):
        passwordtext = self.connection.getvalues("*", "pwmanager")
        userentry = ""
        for i in passwordtext.fetchone():
            userentry = i
        if (userentry == self.password.text):
            self.master.remove_widget(self.loginbutton)
            self.master.remove_widget(self.img)
            self.master.remove_widget(self.password)
            self.connection.conn.close()
        else:
            self.password.text = "Retry"

    def register(self, event):
        if (self.password.text is not ""):
            values = "('{}')".format(str(self.password.text))
            columnname = "('{}')".format("password")
            self.connection.insertintotable("pwmanager", columnname, values)
            self.master.remove_widget(self.registerbutton)
            self.master.add_widget(self.loginbutton)
            self.password.text = ""
Exemple #2
0
class Application(App):
    def build(self):
        Window.clearcolor = (1, 1, 1, 0)
        #Window.size=(320,480)
        self.connection = Connection()
        self.img = Image(source='net.jpeg', size_hint=(None, None))
        self.img.allow_stretch = True
        self.img.opacity = 1
        self.password = TextInput(text="password",
                                  multiline=False,
                                  size_hint=(None, None))
        self.loginbutton = Button(text="Unlock", size_hint=(None, None))
        self.loginbutton.bind(on_press=self.login)
        self.registerbutton = Button(text="Register", size_hint=(None, None))
        self.registerbutton.bind(on_press=self.register)
        #creating layout based on conditions
        cols = self.connection.size("pwmanager")
        self.master = FloatLayout()
        if cols is not 1:
            self.master.add_widget(self.registerbutton)
        else:
            self.master.add_widget(self.loginbutton)
        self.master.add_widget(self.img)
        self.master.add_widget(self.password)
        self.master.bind(size=self.on_rotate)
        return self.master

    def login(self, event):
        passwordtext = self.connection.getvalues("*", "pwmanager")
        userentry = ""
        for i in passwordtext.fetchone():
            userentry = i
        if (userentry == self.password.text):
            self.master.remove_widget(self.loginbutton)
            self.master.remove_widget(self.img)
            self.master.remove_widget(self.password)
            self.connection.conn.close()
            self.viewer = Viewer(self.master)
        else:
            self.password.text = "Retry"
        global choice
        choice = 2

    def register(self, event):
        if (self.password.text is not ""):
            values = "('{}')".format(str(self.password.text))
            columnname = "('{}')".format("password")
            self.connection.insertintotable("pwmanager", columnname, values)
            self.master.remove_widget(self.registerbutton)
            self.master.add_widget(self.loginbutton)
            self.password.text = ""

    def on_rotate(self, event, event1):
        global screenheight
        global screenwidth
        global choice
        screenheight = Window.height
        screenwidth = Window.width
        if (choice == 1):
            self.img.pos = (WXY(60), HXY(263))
            self.img.width = WXY(207)
            self.img.height = HXY(164)

            self.password.pos = (WXY(53), HXY(180))
            self.password.width = WXY(208)
            self.password.height = HXY(37)
            self.password.font_size = HXY(18)

            self.loginbutton.pos = (WXY(82), HXY(117))
            self.loginbutton.width = WXY(146)
            self.loginbutton.height = HXY(40)
            self.loginbutton.font_size = HXY(18)

            self.registerbutton.pos = (WXY(82), HXY(117))
            self.registerbutton.width = WXY(146)
            self.registerbutton.height = HXY(40)
        elif (choice == 2):
            self.viewer.on_rotate()
        elif (choice == 3):
            self.viewer.notepad.on_rotate()