How can I stack multiple frames in TkinterHow to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory in Python?How can I remove a trailing newline in Python?How can I make a time delay in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How do I list all files of a directory?Catch multiple exceptions in one line (except block)

Building a list of products from the elements in another list

Word for Food that's Gone 'Bad', but is Still Edible?

Will 700 more planes a day fly because of the Heathrow expansion?

How did the Venus Express detect lightning?

Should I mention being denied entry to UK due to a confusion in my Visa and Ticket bookings?

Point of the Dothraki's attack in GoT S8E3?

How to safely wipe a USB flash drive

IP addresses from public IP block in my LAN

How can I get a job without pushing my family's income into a higher tax bracket?

What to use instead of cling film to wrap pastry

Adding command shortcuts to bin

PWM 1Hz on solid state relay

How can I roleplay a follower-type character when I as a player have a leader-type personality?

Can a Tiefling have more than two horns?

Why wasn't the Night King naked in S08E03?

Find the cheapest shipping option based on item weight

Why aren't nationalizations in Russia described as socialist?

What does "Managed by Windows" do in the Power options for network connection?

A factorization game

Can I use a fetch land to shuffle my deck while the opponent has Ashiok, Dream Render in play?

Why does sound not move through a wall?

Where can I go to avoid planes overhead?

Should I dumb down my writing in a foreign country?

In Russian, how do you idiomatically express the idea of the figurative "overnight"?



How can I stack multiple frames in Tkinter


How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory in Python?How can I remove a trailing newline in Python?How can I make a time delay in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How do I list all files of a directory?Catch multiple exceptions in one line (except block)






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








0















For my project, I need to create a GUI using Tkinter. I wanted to divide it into 4 different frames, each with different background colors. However, when I do this, only the first frame's background color is shown. I attached my code below as well as a screenshot of the output I'm getting.



My Tkinter GUI



from Tkinter import *
import tkMessageBox

root = Tk()
root.geometry("950x800")
root.configure(background="black")

def test():
print("this is a test")

# *****Frames*****

fileFrame = Frame(root)
fileFrame.configure(background="yellow")
fileFrame.pack()
attributeFrame = Frame(root)
attributeFrame.configure(background="red")
attributeFrame.pack()
constraintFrame = Frame(root)
constraintFrame.configure(background="purple")
constraintFrame.pack()
preferenceFrame = Frame(root)
preferenceFrame.configure(background="blue")
preferenceFrame.pack()

# *****File Frame*****

label_1 = Label(fileFrame, text="Enter Attributes file name:", anchor="e",
bg="red", font="Times 25", width=25, height=1)
label_2 = Label(fileFrame, text="Enter hard constraints file name:",
anchor="e", bg="blue", fg="yellow", font="Times 25", width=25, height=1)
label_3 = Label(fileFrame, text="Enter preferences file name:",
anchor="e", bg="purple", fg="green", font="times 25", width=25, height=1)
entry_1 = Entry(fileFrame, font="Times 25")
entry_2 = Entry(fileFrame, font="Times 25")
entry_3 = Entry(fileFrame, font="Times 25")
button_1 = Button(fileFrame, text="Submit", bg="red", font="Times 20")
button_2 = Button(fileFrame, text="Submit", bg="blue", fg="yellow",
font="Times 20")
button_3 = Button(fileFrame, text="Submit", bg="purple", fg="green",
font="Times 20")
label_1.grid(row=0, padx=5, pady=5)
entry_1.grid(row=0, column=1)
button_1.grid(row=0, column=2, padx=5, pady=5)
label_2.grid(row=1, padx=5, pady=5)
entry_2.grid(row=1, column=1)
button_2.grid(row=1, column=2, padx=5, pady=5)
label_3.grid(row=2, padx=5, pady=5)
entry_3.grid(row=2, column=1)
button_3.grid(row=2, column=2, padx=5, pady=5)

# *****Attribute Frame*****

label_Attribute_header = Label(attributeFrame, text="Attributes:",
bg="red", font="Times 25", width=25, height=1)
label_Attribute_header.pack()

# *****Constraint Frame*****

label_Constraint_header = Label(constraintFrame, text="Hard Constraints:",
bg="purple", fg="green", font="Times 25", width=25, height=1)
label_Constraint_header.pack()

# *****Preference Frame*****

label_Preference_header = Label(preferenceFrame, text="Preferences:",
bg="blue", fg="yellow", font="Times 25", width=25, height=1)
label_Preference_header.pack()

root.mainloop()


I expect there to be 4 different frames, all stacked on top of each other with different background colors, but instead only the first frame has a background color. Can somebody explain to me why this is and how I should go about fixing this? Thanks










share|improve this question




























    0















    For my project, I need to create a GUI using Tkinter. I wanted to divide it into 4 different frames, each with different background colors. However, when I do this, only the first frame's background color is shown. I attached my code below as well as a screenshot of the output I'm getting.



    My Tkinter GUI



    from Tkinter import *
    import tkMessageBox

    root = Tk()
    root.geometry("950x800")
    root.configure(background="black")

    def test():
    print("this is a test")

    # *****Frames*****

    fileFrame = Frame(root)
    fileFrame.configure(background="yellow")
    fileFrame.pack()
    attributeFrame = Frame(root)
    attributeFrame.configure(background="red")
    attributeFrame.pack()
    constraintFrame = Frame(root)
    constraintFrame.configure(background="purple")
    constraintFrame.pack()
    preferenceFrame = Frame(root)
    preferenceFrame.configure(background="blue")
    preferenceFrame.pack()

    # *****File Frame*****

    label_1 = Label(fileFrame, text="Enter Attributes file name:", anchor="e",
    bg="red", font="Times 25", width=25, height=1)
    label_2 = Label(fileFrame, text="Enter hard constraints file name:",
    anchor="e", bg="blue", fg="yellow", font="Times 25", width=25, height=1)
    label_3 = Label(fileFrame, text="Enter preferences file name:",
    anchor="e", bg="purple", fg="green", font="times 25", width=25, height=1)
    entry_1 = Entry(fileFrame, font="Times 25")
    entry_2 = Entry(fileFrame, font="Times 25")
    entry_3 = Entry(fileFrame, font="Times 25")
    button_1 = Button(fileFrame, text="Submit", bg="red", font="Times 20")
    button_2 = Button(fileFrame, text="Submit", bg="blue", fg="yellow",
    font="Times 20")
    button_3 = Button(fileFrame, text="Submit", bg="purple", fg="green",
    font="Times 20")
    label_1.grid(row=0, padx=5, pady=5)
    entry_1.grid(row=0, column=1)
    button_1.grid(row=0, column=2, padx=5, pady=5)
    label_2.grid(row=1, padx=5, pady=5)
    entry_2.grid(row=1, column=1)
    button_2.grid(row=1, column=2, padx=5, pady=5)
    label_3.grid(row=2, padx=5, pady=5)
    entry_3.grid(row=2, column=1)
    button_3.grid(row=2, column=2, padx=5, pady=5)

    # *****Attribute Frame*****

    label_Attribute_header = Label(attributeFrame, text="Attributes:",
    bg="red", font="Times 25", width=25, height=1)
    label_Attribute_header.pack()

    # *****Constraint Frame*****

    label_Constraint_header = Label(constraintFrame, text="Hard Constraints:",
    bg="purple", fg="green", font="Times 25", width=25, height=1)
    label_Constraint_header.pack()

    # *****Preference Frame*****

    label_Preference_header = Label(preferenceFrame, text="Preferences:",
    bg="blue", fg="yellow", font="Times 25", width=25, height=1)
    label_Preference_header.pack()

    root.mainloop()


    I expect there to be 4 different frames, all stacked on top of each other with different background colors, but instead only the first frame has a background color. Can somebody explain to me why this is and how I should go about fixing this? Thanks










    share|improve this question
























      0












      0








      0








      For my project, I need to create a GUI using Tkinter. I wanted to divide it into 4 different frames, each with different background colors. However, when I do this, only the first frame's background color is shown. I attached my code below as well as a screenshot of the output I'm getting.



      My Tkinter GUI



      from Tkinter import *
      import tkMessageBox

      root = Tk()
      root.geometry("950x800")
      root.configure(background="black")

      def test():
      print("this is a test")

      # *****Frames*****

      fileFrame = Frame(root)
      fileFrame.configure(background="yellow")
      fileFrame.pack()
      attributeFrame = Frame(root)
      attributeFrame.configure(background="red")
      attributeFrame.pack()
      constraintFrame = Frame(root)
      constraintFrame.configure(background="purple")
      constraintFrame.pack()
      preferenceFrame = Frame(root)
      preferenceFrame.configure(background="blue")
      preferenceFrame.pack()

      # *****File Frame*****

      label_1 = Label(fileFrame, text="Enter Attributes file name:", anchor="e",
      bg="red", font="Times 25", width=25, height=1)
      label_2 = Label(fileFrame, text="Enter hard constraints file name:",
      anchor="e", bg="blue", fg="yellow", font="Times 25", width=25, height=1)
      label_3 = Label(fileFrame, text="Enter preferences file name:",
      anchor="e", bg="purple", fg="green", font="times 25", width=25, height=1)
      entry_1 = Entry(fileFrame, font="Times 25")
      entry_2 = Entry(fileFrame, font="Times 25")
      entry_3 = Entry(fileFrame, font="Times 25")
      button_1 = Button(fileFrame, text="Submit", bg="red", font="Times 20")
      button_2 = Button(fileFrame, text="Submit", bg="blue", fg="yellow",
      font="Times 20")
      button_3 = Button(fileFrame, text="Submit", bg="purple", fg="green",
      font="Times 20")
      label_1.grid(row=0, padx=5, pady=5)
      entry_1.grid(row=0, column=1)
      button_1.grid(row=0, column=2, padx=5, pady=5)
      label_2.grid(row=1, padx=5, pady=5)
      entry_2.grid(row=1, column=1)
      button_2.grid(row=1, column=2, padx=5, pady=5)
      label_3.grid(row=2, padx=5, pady=5)
      entry_3.grid(row=2, column=1)
      button_3.grid(row=2, column=2, padx=5, pady=5)

      # *****Attribute Frame*****

      label_Attribute_header = Label(attributeFrame, text="Attributes:",
      bg="red", font="Times 25", width=25, height=1)
      label_Attribute_header.pack()

      # *****Constraint Frame*****

      label_Constraint_header = Label(constraintFrame, text="Hard Constraints:",
      bg="purple", fg="green", font="Times 25", width=25, height=1)
      label_Constraint_header.pack()

      # *****Preference Frame*****

      label_Preference_header = Label(preferenceFrame, text="Preferences:",
      bg="blue", fg="yellow", font="Times 25", width=25, height=1)
      label_Preference_header.pack()

      root.mainloop()


      I expect there to be 4 different frames, all stacked on top of each other with different background colors, but instead only the first frame has a background color. Can somebody explain to me why this is and how I should go about fixing this? Thanks










      share|improve this question














      For my project, I need to create a GUI using Tkinter. I wanted to divide it into 4 different frames, each with different background colors. However, when I do this, only the first frame's background color is shown. I attached my code below as well as a screenshot of the output I'm getting.



      My Tkinter GUI



      from Tkinter import *
      import tkMessageBox

      root = Tk()
      root.geometry("950x800")
      root.configure(background="black")

      def test():
      print("this is a test")

      # *****Frames*****

      fileFrame = Frame(root)
      fileFrame.configure(background="yellow")
      fileFrame.pack()
      attributeFrame = Frame(root)
      attributeFrame.configure(background="red")
      attributeFrame.pack()
      constraintFrame = Frame(root)
      constraintFrame.configure(background="purple")
      constraintFrame.pack()
      preferenceFrame = Frame(root)
      preferenceFrame.configure(background="blue")
      preferenceFrame.pack()

      # *****File Frame*****

      label_1 = Label(fileFrame, text="Enter Attributes file name:", anchor="e",
      bg="red", font="Times 25", width=25, height=1)
      label_2 = Label(fileFrame, text="Enter hard constraints file name:",
      anchor="e", bg="blue", fg="yellow", font="Times 25", width=25, height=1)
      label_3 = Label(fileFrame, text="Enter preferences file name:",
      anchor="e", bg="purple", fg="green", font="times 25", width=25, height=1)
      entry_1 = Entry(fileFrame, font="Times 25")
      entry_2 = Entry(fileFrame, font="Times 25")
      entry_3 = Entry(fileFrame, font="Times 25")
      button_1 = Button(fileFrame, text="Submit", bg="red", font="Times 20")
      button_2 = Button(fileFrame, text="Submit", bg="blue", fg="yellow",
      font="Times 20")
      button_3 = Button(fileFrame, text="Submit", bg="purple", fg="green",
      font="Times 20")
      label_1.grid(row=0, padx=5, pady=5)
      entry_1.grid(row=0, column=1)
      button_1.grid(row=0, column=2, padx=5, pady=5)
      label_2.grid(row=1, padx=5, pady=5)
      entry_2.grid(row=1, column=1)
      button_2.grid(row=1, column=2, padx=5, pady=5)
      label_3.grid(row=2, padx=5, pady=5)
      entry_3.grid(row=2, column=1)
      button_3.grid(row=2, column=2, padx=5, pady=5)

      # *****Attribute Frame*****

      label_Attribute_header = Label(attributeFrame, text="Attributes:",
      bg="red", font="Times 25", width=25, height=1)
      label_Attribute_header.pack()

      # *****Constraint Frame*****

      label_Constraint_header = Label(constraintFrame, text="Hard Constraints:",
      bg="purple", fg="green", font="Times 25", width=25, height=1)
      label_Constraint_header.pack()

      # *****Preference Frame*****

      label_Preference_header = Label(preferenceFrame, text="Preferences:",
      bg="blue", fg="yellow", font="Times 25", width=25, height=1)
      label_Preference_header.pack()

      root.mainloop()


      I expect there to be 4 different frames, all stacked on top of each other with different background colors, but instead only the first frame has a background color. Can somebody explain to me why this is and how I should go about fixing this? Thanks







      python python-2.7 user-interface tkinter frame






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 23:56









      Ryan FosterRyan Foster

      183




      183






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Your frames are there. The bottom three frames have fewer things in them and you haven't given them any padding. The frame shrinks to fit, so when you just have one item, you won't see the frames.



          You can easily see the frames if you do one of two things:



          First, you can request that the frames fill their parent window in the x direction. When you do this, you'll see them:



          fileFrame.pack(fill="x")
          attributeFrame.pack(fill="x")
          constraintFrame.pack(fill="x")
          preferenceFrame.pack(fill="x")


          Second, instead of or in addition to that, you can give padding around the labels in the bottom frames. That will let the frame colors appear.



          label_Attribute_header.pack(padx=20, pady=20)
          ...
          label_Constraint_header.pack(padx=20, pady=20)
          ...
          label_Preference_header.pack(padx=20, pady=20)





          share|improve this answer























          • Thank you! That makes sense

            – Ryan Foster
            Mar 23 at 17:18











          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%2f55309231%2fhow-can-i-stack-multiple-frames-in-tkinter%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









          1














          Your frames are there. The bottom three frames have fewer things in them and you haven't given them any padding. The frame shrinks to fit, so when you just have one item, you won't see the frames.



          You can easily see the frames if you do one of two things:



          First, you can request that the frames fill their parent window in the x direction. When you do this, you'll see them:



          fileFrame.pack(fill="x")
          attributeFrame.pack(fill="x")
          constraintFrame.pack(fill="x")
          preferenceFrame.pack(fill="x")


          Second, instead of or in addition to that, you can give padding around the labels in the bottom frames. That will let the frame colors appear.



          label_Attribute_header.pack(padx=20, pady=20)
          ...
          label_Constraint_header.pack(padx=20, pady=20)
          ...
          label_Preference_header.pack(padx=20, pady=20)





          share|improve this answer























          • Thank you! That makes sense

            – Ryan Foster
            Mar 23 at 17:18















          1














          Your frames are there. The bottom three frames have fewer things in them and you haven't given them any padding. The frame shrinks to fit, so when you just have one item, you won't see the frames.



          You can easily see the frames if you do one of two things:



          First, you can request that the frames fill their parent window in the x direction. When you do this, you'll see them:



          fileFrame.pack(fill="x")
          attributeFrame.pack(fill="x")
          constraintFrame.pack(fill="x")
          preferenceFrame.pack(fill="x")


          Second, instead of or in addition to that, you can give padding around the labels in the bottom frames. That will let the frame colors appear.



          label_Attribute_header.pack(padx=20, pady=20)
          ...
          label_Constraint_header.pack(padx=20, pady=20)
          ...
          label_Preference_header.pack(padx=20, pady=20)





          share|improve this answer























          • Thank you! That makes sense

            – Ryan Foster
            Mar 23 at 17:18













          1












          1








          1







          Your frames are there. The bottom three frames have fewer things in them and you haven't given them any padding. The frame shrinks to fit, so when you just have one item, you won't see the frames.



          You can easily see the frames if you do one of two things:



          First, you can request that the frames fill their parent window in the x direction. When you do this, you'll see them:



          fileFrame.pack(fill="x")
          attributeFrame.pack(fill="x")
          constraintFrame.pack(fill="x")
          preferenceFrame.pack(fill="x")


          Second, instead of or in addition to that, you can give padding around the labels in the bottom frames. That will let the frame colors appear.



          label_Attribute_header.pack(padx=20, pady=20)
          ...
          label_Constraint_header.pack(padx=20, pady=20)
          ...
          label_Preference_header.pack(padx=20, pady=20)





          share|improve this answer













          Your frames are there. The bottom three frames have fewer things in them and you haven't given them any padding. The frame shrinks to fit, so when you just have one item, you won't see the frames.



          You can easily see the frames if you do one of two things:



          First, you can request that the frames fill their parent window in the x direction. When you do this, you'll see them:



          fileFrame.pack(fill="x")
          attributeFrame.pack(fill="x")
          constraintFrame.pack(fill="x")
          preferenceFrame.pack(fill="x")


          Second, instead of or in addition to that, you can give padding around the labels in the bottom frames. That will let the frame colors appear.



          label_Attribute_header.pack(padx=20, pady=20)
          ...
          label_Constraint_header.pack(padx=20, pady=20)
          ...
          label_Preference_header.pack(padx=20, pady=20)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 1:59









          Bryan OakleyBryan Oakley

          224k22282442




          224k22282442












          • Thank you! That makes sense

            – Ryan Foster
            Mar 23 at 17:18

















          • Thank you! That makes sense

            – Ryan Foster
            Mar 23 at 17:18
















          Thank you! That makes sense

          – Ryan Foster
          Mar 23 at 17:18





          Thank you! That makes sense

          – Ryan Foster
          Mar 23 at 17:18



















          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%2f55309231%2fhow-can-i-stack-multiple-frames-in-tkinter%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript