[Python] restart once screenlock has been unlocked
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[Python] restart once screenlock has been unlocked
I want to add the ability once the screenlock has been unlocked, it will spawn me back into lockscreen so I can guess the combination again ( the list of possible combinations is already there but not visible in the code snippet)
It's line 25 and onwards
Code:
def draw(self):
if not self.unlocked:
screen.blit(self.points_surf, (DRAW_OFFSET[0]-POINT_RADIUS, DRAW_OFFSET[1]-POINT_RADIUS))
combo = self.wrong_pattern if self.wrong_pattern else self.current_combination
combo = [self.get_pos(p) for p in combo]
for p in combo:
screen.blit(self.selected_point_surf, (p[0]-SELECTION_RADIUS, p[1]-SELECTION_RADIUS))
if self.wrong_pattern:
try:
pygame.draw.lines(screen, (200, 80, 20), False, combo, POINT_RADIUS)
except ValueError: pass
else:
combo.append((pygame.mouse.get_pos()))
try:
pygame.draw.lines(screen, (10, 200, 55), False, combo, POINT_RADIUS)
except ValueError: pass
if self.wait:
screen.blit(font.render(f"Try again in {self.wait_time} seconds", True, (255, 255, 255)), (180, 100))
# Line 25
else:
screen.fill('#7A36B1')
screen.blit(font.render("Unlocked", True, (255, 255, 255)), (245, 400))
I tought about using the break function but not sure if it would help. Tried and no success so far.
Thanks for reposting your question with minimal example code, much appreciated. Per your request to delete this thread: It is a complete question which has been visible for four days so it is possible others are now considering a response and it would be disrespectful of their time to remove the question, so let's keep it open.
My own python skills are nearly non-existent so I am unable to offer help myself - good luck!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.