• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python My basic python script is not responding, please help.

Mettatone

New Coder
Python:
import pyautogui

import tkinter

import sys

from tkinter import *



def delete():

    while True:

        pyautogui.click()

        pyautogui.press('up')

        pyautogui.hotkey('ctrl', 'a')

        pyautogui.press('backspace')

        for x in range(3):

            pyautogui.press('enter')


        pyautogui.sleep(5)

        if not window:

            continue

        break



def stop():

    exit()



window = Tk()

button = Button(window, text='Stop running!', padx=50, pady=50, command=stop)

button.pack()


button2 = Button(window, text='Start running!', padx=50, pady=50, command=delete)

button2.pack()

window.mainloop()

So i tested both buttons on their own and they work perfectly but the only issue is, when i call the function "delete" when i press button2 and i go into a text box so it deletes messages and then i go back into the GUI it stops responding and winds up crashing the app, how do i fix this?
 
Last edited by a moderator:

Hassapiko

Coder
Hello there, @Mettatone.

First of all, I should mention I haven't got neither of the GUI modules imported into your program installed on my system, and quite frankly, the hassle that I've had with Python's pip tool in the past isn't worth it, so I may not be able to go far with you.

Anyways, I'm first going to reiterate on what Malcolm mentioned: error messages. You say that the program crashes, yet, you haven't provided us with an error message to work with. How do we know what's causing the problem then? The problem could lie in another part of your program for all we know. It would also be helpful to know what the program you're trying to build is - we know it's a GUI program, but is it a standalone one or one that interfaces with another program?

I've tried my best with finding documentation related to TkInter's button widget, but as is usual with documentation on the Internet, it's an absolute mess.

I hope that what I've got just now is helpful to you. If it isn't, please come back and let us know. Although, please remember this time to give us an error message - it helps a lot.
 

Mettatone

New Coder
Hello there, @Mettatone.

First of all, I should mention I haven't got neither of the GUI modules imported into your program installed on my system, and quite frankly, the hassle that I've had with Python's pip tool in the past isn't worth it, so I may not be able to go far with you.

Anyways, I'm first going to reiterate on what Malcolm mentioned: error messages. You say that the program crashes, yet, you haven't provided us with an error message to work with. How do we know what's causing the problem then? The problem could lie in another part of your program for all we know. It would also be helpful to know what the program you're trying to build is - we know it's a GUI program, but is it a standalone one or one that interfaces with another program?

I've tried my best with finding documentation related to TkInter's button widget, but as is usual with documentation on the Internet, it's an absolute mess.

I hope that what I've got just now is helpful to you. If it isn't, please come back and let us know. Although, please remember this time to give us an error message - it helps a lot.
Sorry for not providing more information at the start of the post, when i say it crashes i meant it just stops responding and then after about a minute just goes away and the program closes, no further problems. as far as the imports i have. I just use Pycharm and you can find all of these under packages accept for tkinter.

I found pip to be very easy to install i just watched a video on how to turn py to exe and it had a great tutorial. again i havnt solved this problem and i might just have to re write the program by using a different method which is not ideal.
 

Mettatone

New Coder
Hello there, @Mettatone.

First of all, I should mention I haven't got neither of the GUI modules imported into your program installed on my system, and quite frankly, the hassle that I've had with Python's pip tool in the past isn't worth it, so I may not be able to go far with you.

Anyways, I'm first going to reiterate on what Malcolm mentioned: error messages. You say that the program crashes, yet, you haven't provided us with an error message to work with. How do we know what's causing the problem then? The problem could lie in another part of your program for all we know. It would also be helpful to know what the program you're trying to build is - we know it's a GUI program, but is it a standalone one or one that interfaces with another program?

I've tried my best with finding documentation related to TkInter's button widget, but as is usual with documentation on the Internet, it's an absolute mess.

I hope that what I've got just now is helpful to you. If it isn't, please come back and let us know. Although, please remember this time to give us an error message - it helps a lot.
1625846635054.png
 

simong1993

Active Coder
Staff Team
Guardian
Hey ill chime in here :D

So the error you are getting is your cursor is moving to one of the four corners of the screen, its a fail safe to tell PyAutoGUI to stop if your program ever goes crazy. To solve this add:-

Python:
pyautogui.FAILSAFE = False

But honestly its not recommended
 

Mettatone

New Coder
Hey ill chime in here :D

So the error you are getting is your cursor is moving to one of the four corners of the screen, its a fail safe to tell PyAutoGUI to stop if your program ever goes crazy. To solve this add:-

Python:
pyautogui.FAILSAFE = False

But honestly its not recommended
I tried putting it everywhere but it doesnt seem to work, on top of that i didnt even put i cursor to the corner of the screen it just does that when it gets opened. Not sure if i doing something wrong i tried putting that line in the window, in both functions and even tried creating a function that called when i press the button as well and it keeps just "Not responding" and it says that "python has stopped responding" not just the app and whatnot.
 

Hassapiko

Coder
Hello again, @Mettatone.

Sorry for leaving you in the dark, however, it would be good if you could let any of us know if you still need help with the question.

I've also noticed that while you are getting errors related to PyAutoGUI, you are also getting TKinter errors too; so checking any of the code that uses TKinter may be helpful to fixing your problem(I doubt it though, as the image provided has only one TKinter-related error).

But again, please let us know if you still need help.
 

Top