Can't remove tkinter root window





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-1















EDIT:
I realize that this question was ambiguous and incorrectly asked so I have tried to simplify.



I was having trouble trying to use a tkinter app to do multiple ploops due to not correctly destroying the window. My fix (which I'm quite sure is incorrect) was to create an integer loop, and nest my class within this:



for i in range(1, 1000):

if i >= 2:
root.destroy()

class App(tkinter.Frame): *app code here*


to quit the app:



def OnButtonClick2(self):

i = -1
app.destroy()
root.destroy()
sys.exit()


otherwise:



i+=1


For some reason, if I instructed the app to destroy after the first iteration, it would leave a blank root window up and then when creating the app again the buttons would be unclickable and nested in a different window. This got rid of the problem, but I know it's not the correct solution.










share|improve this question




















  • 1





    I'm not the downvoter, but I can certainly understand why somebody would downvote You've not really explained what your problem is, nor where in your code it lives. You've shown a lot of code (which is certainly better than no code at all, but not nearly as good as a smaller amount). Please try to shrink it down to a Minimal, Complete, and Verifiable example, that is, the smallest amount of code that can demonstrate the issue. And explain what that issue is, so we can have some idea of what you're trying to do and how you're running into trouble before we even start reading the code!

    – Blckknght
    Nov 17 '18 at 0:07











  • Expanding on @Blckknght's answer, you're essentially trying to restart a tkinter app. What the app actually does is not relevant at all to the question. You can leave only the bare minimum, "hello world" app, try to restart it, and tell us about your efforts. Then, we can point you in the right direction. I hope you don't expect any of us to volunteer to read 156 lines of code and debug your application for you.

    – roeen30
    Nov 17 '18 at 0:11











  • @roeen30 I certainly don't, and thanks for the input. I've tried to put a call function before the init , but I don't think that I was writing it correctly. I'm bad with the terminology and I'm still very new, so I don't quite know how to explain what else I've tried. I've also just tried to directly reference an instance after mail.Display(True) so that when the email window is gone it continues. That didn't work either. Please see my edits and let me know if that's more acceptable.

    – visualnotsobasic
    Nov 17 '18 at 0:18











  • @Blckknght thanks for the input. Please see edits.

    – visualnotsobasic
    Nov 17 '18 at 0:19











  • This is better but I still don't understand enough of what's going on. Where does the second code sample fit with the tkinter app? Additionally, please post the code of everything you tried so far.

    – roeen30
    Nov 17 '18 at 0:26




















-1















EDIT:
I realize that this question was ambiguous and incorrectly asked so I have tried to simplify.



I was having trouble trying to use a tkinter app to do multiple ploops due to not correctly destroying the window. My fix (which I'm quite sure is incorrect) was to create an integer loop, and nest my class within this:



for i in range(1, 1000):

if i >= 2:
root.destroy()

class App(tkinter.Frame): *app code here*


to quit the app:



def OnButtonClick2(self):

i = -1
app.destroy()
root.destroy()
sys.exit()


otherwise:



i+=1


For some reason, if I instructed the app to destroy after the first iteration, it would leave a blank root window up and then when creating the app again the buttons would be unclickable and nested in a different window. This got rid of the problem, but I know it's not the correct solution.










share|improve this question




















  • 1





    I'm not the downvoter, but I can certainly understand why somebody would downvote You've not really explained what your problem is, nor where in your code it lives. You've shown a lot of code (which is certainly better than no code at all, but not nearly as good as a smaller amount). Please try to shrink it down to a Minimal, Complete, and Verifiable example, that is, the smallest amount of code that can demonstrate the issue. And explain what that issue is, so we can have some idea of what you're trying to do and how you're running into trouble before we even start reading the code!

    – Blckknght
    Nov 17 '18 at 0:07











  • Expanding on @Blckknght's answer, you're essentially trying to restart a tkinter app. What the app actually does is not relevant at all to the question. You can leave only the bare minimum, "hello world" app, try to restart it, and tell us about your efforts. Then, we can point you in the right direction. I hope you don't expect any of us to volunteer to read 156 lines of code and debug your application for you.

    – roeen30
    Nov 17 '18 at 0:11











  • @roeen30 I certainly don't, and thanks for the input. I've tried to put a call function before the init , but I don't think that I was writing it correctly. I'm bad with the terminology and I'm still very new, so I don't quite know how to explain what else I've tried. I've also just tried to directly reference an instance after mail.Display(True) so that when the email window is gone it continues. That didn't work either. Please see my edits and let me know if that's more acceptable.

    – visualnotsobasic
    Nov 17 '18 at 0:18











  • @Blckknght thanks for the input. Please see edits.

    – visualnotsobasic
    Nov 17 '18 at 0:19











  • This is better but I still don't understand enough of what's going on. Where does the second code sample fit with the tkinter app? Additionally, please post the code of everything you tried so far.

    – roeen30
    Nov 17 '18 at 0:26
















-1












-1








-1








EDIT:
I realize that this question was ambiguous and incorrectly asked so I have tried to simplify.



I was having trouble trying to use a tkinter app to do multiple ploops due to not correctly destroying the window. My fix (which I'm quite sure is incorrect) was to create an integer loop, and nest my class within this:



for i in range(1, 1000):

if i >= 2:
root.destroy()

class App(tkinter.Frame): *app code here*


to quit the app:



def OnButtonClick2(self):

i = -1
app.destroy()
root.destroy()
sys.exit()


otherwise:



i+=1


For some reason, if I instructed the app to destroy after the first iteration, it would leave a blank root window up and then when creating the app again the buttons would be unclickable and nested in a different window. This got rid of the problem, but I know it's not the correct solution.










share|improve this question
















EDIT:
I realize that this question was ambiguous and incorrectly asked so I have tried to simplify.



I was having trouble trying to use a tkinter app to do multiple ploops due to not correctly destroying the window. My fix (which I'm quite sure is incorrect) was to create an integer loop, and nest my class within this:



for i in range(1, 1000):

if i >= 2:
root.destroy()

class App(tkinter.Frame): *app code here*


to quit the app:



def OnButtonClick2(self):

i = -1
app.destroy()
root.destroy()
sys.exit()


otherwise:



i+=1


For some reason, if I instructed the app to destroy after the first iteration, it would leave a blank root window up and then when creating the app again the buttons would be unclickable and nested in a different window. This got rid of the problem, but I know it's not the correct solution.







python loops class tkinter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 15 at 18:25







visualnotsobasic

















asked Nov 16 '18 at 23:17









visualnotsobasicvisualnotsobasic

579




579








  • 1





    I'm not the downvoter, but I can certainly understand why somebody would downvote You've not really explained what your problem is, nor where in your code it lives. You've shown a lot of code (which is certainly better than no code at all, but not nearly as good as a smaller amount). Please try to shrink it down to a Minimal, Complete, and Verifiable example, that is, the smallest amount of code that can demonstrate the issue. And explain what that issue is, so we can have some idea of what you're trying to do and how you're running into trouble before we even start reading the code!

    – Blckknght
    Nov 17 '18 at 0:07











  • Expanding on @Blckknght's answer, you're essentially trying to restart a tkinter app. What the app actually does is not relevant at all to the question. You can leave only the bare minimum, "hello world" app, try to restart it, and tell us about your efforts. Then, we can point you in the right direction. I hope you don't expect any of us to volunteer to read 156 lines of code and debug your application for you.

    – roeen30
    Nov 17 '18 at 0:11











  • @roeen30 I certainly don't, and thanks for the input. I've tried to put a call function before the init , but I don't think that I was writing it correctly. I'm bad with the terminology and I'm still very new, so I don't quite know how to explain what else I've tried. I've also just tried to directly reference an instance after mail.Display(True) so that when the email window is gone it continues. That didn't work either. Please see my edits and let me know if that's more acceptable.

    – visualnotsobasic
    Nov 17 '18 at 0:18











  • @Blckknght thanks for the input. Please see edits.

    – visualnotsobasic
    Nov 17 '18 at 0:19











  • This is better but I still don't understand enough of what's going on. Where does the second code sample fit with the tkinter app? Additionally, please post the code of everything you tried so far.

    – roeen30
    Nov 17 '18 at 0:26
















  • 1





    I'm not the downvoter, but I can certainly understand why somebody would downvote You've not really explained what your problem is, nor where in your code it lives. You've shown a lot of code (which is certainly better than no code at all, but not nearly as good as a smaller amount). Please try to shrink it down to a Minimal, Complete, and Verifiable example, that is, the smallest amount of code that can demonstrate the issue. And explain what that issue is, so we can have some idea of what you're trying to do and how you're running into trouble before we even start reading the code!

    – Blckknght
    Nov 17 '18 at 0:07











  • Expanding on @Blckknght's answer, you're essentially trying to restart a tkinter app. What the app actually does is not relevant at all to the question. You can leave only the bare minimum, "hello world" app, try to restart it, and tell us about your efforts. Then, we can point you in the right direction. I hope you don't expect any of us to volunteer to read 156 lines of code and debug your application for you.

    – roeen30
    Nov 17 '18 at 0:11











  • @roeen30 I certainly don't, and thanks for the input. I've tried to put a call function before the init , but I don't think that I was writing it correctly. I'm bad with the terminology and I'm still very new, so I don't quite know how to explain what else I've tried. I've also just tried to directly reference an instance after mail.Display(True) so that when the email window is gone it continues. That didn't work either. Please see my edits and let me know if that's more acceptable.

    – visualnotsobasic
    Nov 17 '18 at 0:18











  • @Blckknght thanks for the input. Please see edits.

    – visualnotsobasic
    Nov 17 '18 at 0:19











  • This is better but I still don't understand enough of what's going on. Where does the second code sample fit with the tkinter app? Additionally, please post the code of everything you tried so far.

    – roeen30
    Nov 17 '18 at 0:26










1




1





I'm not the downvoter, but I can certainly understand why somebody would downvote You've not really explained what your problem is, nor where in your code it lives. You've shown a lot of code (which is certainly better than no code at all, but not nearly as good as a smaller amount). Please try to shrink it down to a Minimal, Complete, and Verifiable example, that is, the smallest amount of code that can demonstrate the issue. And explain what that issue is, so we can have some idea of what you're trying to do and how you're running into trouble before we even start reading the code!

– Blckknght
Nov 17 '18 at 0:07





I'm not the downvoter, but I can certainly understand why somebody would downvote You've not really explained what your problem is, nor where in your code it lives. You've shown a lot of code (which is certainly better than no code at all, but not nearly as good as a smaller amount). Please try to shrink it down to a Minimal, Complete, and Verifiable example, that is, the smallest amount of code that can demonstrate the issue. And explain what that issue is, so we can have some idea of what you're trying to do and how you're running into trouble before we even start reading the code!

– Blckknght
Nov 17 '18 at 0:07













Expanding on @Blckknght's answer, you're essentially trying to restart a tkinter app. What the app actually does is not relevant at all to the question. You can leave only the bare minimum, "hello world" app, try to restart it, and tell us about your efforts. Then, we can point you in the right direction. I hope you don't expect any of us to volunteer to read 156 lines of code and debug your application for you.

– roeen30
Nov 17 '18 at 0:11





Expanding on @Blckknght's answer, you're essentially trying to restart a tkinter app. What the app actually does is not relevant at all to the question. You can leave only the bare minimum, "hello world" app, try to restart it, and tell us about your efforts. Then, we can point you in the right direction. I hope you don't expect any of us to volunteer to read 156 lines of code and debug your application for you.

– roeen30
Nov 17 '18 at 0:11













@roeen30 I certainly don't, and thanks for the input. I've tried to put a call function before the init , but I don't think that I was writing it correctly. I'm bad with the terminology and I'm still very new, so I don't quite know how to explain what else I've tried. I've also just tried to directly reference an instance after mail.Display(True) so that when the email window is gone it continues. That didn't work either. Please see my edits and let me know if that's more acceptable.

– visualnotsobasic
Nov 17 '18 at 0:18





@roeen30 I certainly don't, and thanks for the input. I've tried to put a call function before the init , but I don't think that I was writing it correctly. I'm bad with the terminology and I'm still very new, so I don't quite know how to explain what else I've tried. I've also just tried to directly reference an instance after mail.Display(True) so that when the email window is gone it continues. That didn't work either. Please see my edits and let me know if that's more acceptable.

– visualnotsobasic
Nov 17 '18 at 0:18













@Blckknght thanks for the input. Please see edits.

– visualnotsobasic
Nov 17 '18 at 0:19





@Blckknght thanks for the input. Please see edits.

– visualnotsobasic
Nov 17 '18 at 0:19













This is better but I still don't understand enough of what's going on. Where does the second code sample fit with the tkinter app? Additionally, please post the code of everything you tried so far.

– roeen30
Nov 17 '18 at 0:26







This is better but I still don't understand enough of what's going on. Where does the second code sample fit with the tkinter app? Additionally, please post the code of everything you tried so far.

– roeen30
Nov 17 '18 at 0:26














1 Answer
1






active

oldest

votes


















0














Either arrange the logic you wish to repeat as a class method or put everything under if __name__ == '__main__' in a function. Whether a method or a function, call it in a loop.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346609%2fcant-remove-tkinter-root-window%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Either arrange the logic you wish to repeat as a class method or put everything under if __name__ == '__main__' in a function. Whether a method or a function, call it in a loop.






    share|improve this answer




























      0














      Either arrange the logic you wish to repeat as a class method or put everything under if __name__ == '__main__' in a function. Whether a method or a function, call it in a loop.






      share|improve this answer


























        0












        0








        0







        Either arrange the logic you wish to repeat as a class method or put everything under if __name__ == '__main__' in a function. Whether a method or a function, call it in a loop.






        share|improve this answer













        Either arrange the logic you wish to repeat as a class method or put everything under if __name__ == '__main__' in a function. Whether a method or a function, call it in a loop.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 21:14









        roeen30roeen30

        56629




        56629
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346609%2fcant-remove-tkinter-root-window%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python