Python Tkinter GUI File Menu Not Displaying though GUI is operational





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







2















I'm relatively new to Python and I'm sure this is an error with the structure of my code, but I cannot seem to get the filemenu to display in my GUI. Can someone tell me what errors I have made with the filemenu inclusion? Also, I am sorry, but the spacing after copying and pasting is a little off. The class indentation level is proper on my side. I am using Python 3.71



Any other comments on better or more Pythonic ways to accomplish what I have here are also welcome and thank you for your help in advance!



from tkinter import *
from tkinter import ttk
import tkinter.scrolledtext as tkst
import os
import tkinter as tk
from functools import partial
from PIL import Image, ImageTk

class UserGui(tk.Tk):

def __init__(self,parent):
self.parent=parent
self.widgets()

def widgets(self):
self.parent.configure(bg='white')
self.frame1_style = ttk.Style()
self.frame1_style.configure('My.TFrame', background='white')
self.frame2_style = ttk.Style()
self.frame2_style.configure('My2.TFrame',background='white')
self.parent.title("TGUI")


self.frame1 = ttk.Frame(self.parent, style='My.TFrame') #Creating Total Window Frame 1
self.frame1.grid(row=0, column=0, sticky=(N, S, E, W))

self.frame2 = ttk.Frame(self.parent, width=100, height=20, style='My2.TFrame')
self.frame2.grid(row=0, column=6, padx=20, pady=5)


#Menu Creation
self.menu1 = tk.Menu(self.parent, tearoff=0)
self.parent.config(menu=self.menu1)
self.fileMenu = tk.Menu(self.menu1, tearoff=0)
self.fileMenu.add_command(label="Open", command=self.donothing)
self.fileMenu.add_command(label="Save", command=self.donothing)

self.fileMenu.add_separator()

self.fileMenu.add_command(label="Exit", command=self.parent.quit)
self.fileMenu.add_cascade(label="File", menu=self.menu1)

self.editMenu = tk.Menu(self.menu1, tearoff=0)
self.editMenu.add_command(label="Cut", command=self.donothing)
self.editMenu.add_command(label="Copy", command=self.donothing)
self.editMenu.add_command(label="Paste", command=self.donothing)
self.editMenu.add_cascade(label="Edit", menu=self.menu1)

def donothing(self):
filewin = Toplevel(self.parent)
button = Button(filewin, text="Do nothing button")
button.pack()



def main():
root=tk.Tk()
ug=UserGui(root)
root.mainloop()

if __name__ == '__main__':
main()


Edit 1,2,3: I have corrected the add_cascade option for menu with menu=self.menu1 and I still do not have a file menu displaying.










share|improve this question

























  • You are adding your File and Edit menus to themselves, rather than the top-level menu.

    – jasonharper
    Jan 4 at 0:30











  • You need to fix the indentation problems in your example code.

    – Bryan Oakley
    Jan 4 at 1:20











  • @jasonharper Thank you for your comment. Even when I switched the menu option pointer to menu=self.menu1 in the add_cascade lines for the fileMenu and editMenu, I still did not get the menu bar with "File" and "Edit" to populate.

    – whisperquiet
    Jan 4 at 18:37











  • That made it worse, actually. Try self.menu1.add_cascade(label="File", menu=self.fileMenu)

    – jasonharper
    Jan 4 at 19:42











  • @JasonHarper , that solved it. Thank you very much for your comment. That call makes way more sense. I had my dependencies completely flipped in my understanding. If you want to copy & paste that to an answer I will mark it as such so others can reference this.

    – whisperquiet
    Jan 4 at 19:49


















2















I'm relatively new to Python and I'm sure this is an error with the structure of my code, but I cannot seem to get the filemenu to display in my GUI. Can someone tell me what errors I have made with the filemenu inclusion? Also, I am sorry, but the spacing after copying and pasting is a little off. The class indentation level is proper on my side. I am using Python 3.71



Any other comments on better or more Pythonic ways to accomplish what I have here are also welcome and thank you for your help in advance!



from tkinter import *
from tkinter import ttk
import tkinter.scrolledtext as tkst
import os
import tkinter as tk
from functools import partial
from PIL import Image, ImageTk

class UserGui(tk.Tk):

def __init__(self,parent):
self.parent=parent
self.widgets()

def widgets(self):
self.parent.configure(bg='white')
self.frame1_style = ttk.Style()
self.frame1_style.configure('My.TFrame', background='white')
self.frame2_style = ttk.Style()
self.frame2_style.configure('My2.TFrame',background='white')
self.parent.title("TGUI")


self.frame1 = ttk.Frame(self.parent, style='My.TFrame') #Creating Total Window Frame 1
self.frame1.grid(row=0, column=0, sticky=(N, S, E, W))

self.frame2 = ttk.Frame(self.parent, width=100, height=20, style='My2.TFrame')
self.frame2.grid(row=0, column=6, padx=20, pady=5)


#Menu Creation
self.menu1 = tk.Menu(self.parent, tearoff=0)
self.parent.config(menu=self.menu1)
self.fileMenu = tk.Menu(self.menu1, tearoff=0)
self.fileMenu.add_command(label="Open", command=self.donothing)
self.fileMenu.add_command(label="Save", command=self.donothing)

self.fileMenu.add_separator()

self.fileMenu.add_command(label="Exit", command=self.parent.quit)
self.fileMenu.add_cascade(label="File", menu=self.menu1)

self.editMenu = tk.Menu(self.menu1, tearoff=0)
self.editMenu.add_command(label="Cut", command=self.donothing)
self.editMenu.add_command(label="Copy", command=self.donothing)
self.editMenu.add_command(label="Paste", command=self.donothing)
self.editMenu.add_cascade(label="Edit", menu=self.menu1)

def donothing(self):
filewin = Toplevel(self.parent)
button = Button(filewin, text="Do nothing button")
button.pack()



def main():
root=tk.Tk()
ug=UserGui(root)
root.mainloop()

if __name__ == '__main__':
main()


Edit 1,2,3: I have corrected the add_cascade option for menu with menu=self.menu1 and I still do not have a file menu displaying.










share|improve this question

























  • You are adding your File and Edit menus to themselves, rather than the top-level menu.

    – jasonharper
    Jan 4 at 0:30











  • You need to fix the indentation problems in your example code.

    – Bryan Oakley
    Jan 4 at 1:20











  • @jasonharper Thank you for your comment. Even when I switched the menu option pointer to menu=self.menu1 in the add_cascade lines for the fileMenu and editMenu, I still did not get the menu bar with "File" and "Edit" to populate.

    – whisperquiet
    Jan 4 at 18:37











  • That made it worse, actually. Try self.menu1.add_cascade(label="File", menu=self.fileMenu)

    – jasonharper
    Jan 4 at 19:42











  • @JasonHarper , that solved it. Thank you very much for your comment. That call makes way more sense. I had my dependencies completely flipped in my understanding. If you want to copy & paste that to an answer I will mark it as such so others can reference this.

    – whisperquiet
    Jan 4 at 19:49














2












2








2


1






I'm relatively new to Python and I'm sure this is an error with the structure of my code, but I cannot seem to get the filemenu to display in my GUI. Can someone tell me what errors I have made with the filemenu inclusion? Also, I am sorry, but the spacing after copying and pasting is a little off. The class indentation level is proper on my side. I am using Python 3.71



Any other comments on better or more Pythonic ways to accomplish what I have here are also welcome and thank you for your help in advance!



from tkinter import *
from tkinter import ttk
import tkinter.scrolledtext as tkst
import os
import tkinter as tk
from functools import partial
from PIL import Image, ImageTk

class UserGui(tk.Tk):

def __init__(self,parent):
self.parent=parent
self.widgets()

def widgets(self):
self.parent.configure(bg='white')
self.frame1_style = ttk.Style()
self.frame1_style.configure('My.TFrame', background='white')
self.frame2_style = ttk.Style()
self.frame2_style.configure('My2.TFrame',background='white')
self.parent.title("TGUI")


self.frame1 = ttk.Frame(self.parent, style='My.TFrame') #Creating Total Window Frame 1
self.frame1.grid(row=0, column=0, sticky=(N, S, E, W))

self.frame2 = ttk.Frame(self.parent, width=100, height=20, style='My2.TFrame')
self.frame2.grid(row=0, column=6, padx=20, pady=5)


#Menu Creation
self.menu1 = tk.Menu(self.parent, tearoff=0)
self.parent.config(menu=self.menu1)
self.fileMenu = tk.Menu(self.menu1, tearoff=0)
self.fileMenu.add_command(label="Open", command=self.donothing)
self.fileMenu.add_command(label="Save", command=self.donothing)

self.fileMenu.add_separator()

self.fileMenu.add_command(label="Exit", command=self.parent.quit)
self.fileMenu.add_cascade(label="File", menu=self.menu1)

self.editMenu = tk.Menu(self.menu1, tearoff=0)
self.editMenu.add_command(label="Cut", command=self.donothing)
self.editMenu.add_command(label="Copy", command=self.donothing)
self.editMenu.add_command(label="Paste", command=self.donothing)
self.editMenu.add_cascade(label="Edit", menu=self.menu1)

def donothing(self):
filewin = Toplevel(self.parent)
button = Button(filewin, text="Do nothing button")
button.pack()



def main():
root=tk.Tk()
ug=UserGui(root)
root.mainloop()

if __name__ == '__main__':
main()


Edit 1,2,3: I have corrected the add_cascade option for menu with menu=self.menu1 and I still do not have a file menu displaying.










share|improve this question
















I'm relatively new to Python and I'm sure this is an error with the structure of my code, but I cannot seem to get the filemenu to display in my GUI. Can someone tell me what errors I have made with the filemenu inclusion? Also, I am sorry, but the spacing after copying and pasting is a little off. The class indentation level is proper on my side. I am using Python 3.71



Any other comments on better or more Pythonic ways to accomplish what I have here are also welcome and thank you for your help in advance!



from tkinter import *
from tkinter import ttk
import tkinter.scrolledtext as tkst
import os
import tkinter as tk
from functools import partial
from PIL import Image, ImageTk

class UserGui(tk.Tk):

def __init__(self,parent):
self.parent=parent
self.widgets()

def widgets(self):
self.parent.configure(bg='white')
self.frame1_style = ttk.Style()
self.frame1_style.configure('My.TFrame', background='white')
self.frame2_style = ttk.Style()
self.frame2_style.configure('My2.TFrame',background='white')
self.parent.title("TGUI")


self.frame1 = ttk.Frame(self.parent, style='My.TFrame') #Creating Total Window Frame 1
self.frame1.grid(row=0, column=0, sticky=(N, S, E, W))

self.frame2 = ttk.Frame(self.parent, width=100, height=20, style='My2.TFrame')
self.frame2.grid(row=0, column=6, padx=20, pady=5)


#Menu Creation
self.menu1 = tk.Menu(self.parent, tearoff=0)
self.parent.config(menu=self.menu1)
self.fileMenu = tk.Menu(self.menu1, tearoff=0)
self.fileMenu.add_command(label="Open", command=self.donothing)
self.fileMenu.add_command(label="Save", command=self.donothing)

self.fileMenu.add_separator()

self.fileMenu.add_command(label="Exit", command=self.parent.quit)
self.fileMenu.add_cascade(label="File", menu=self.menu1)

self.editMenu = tk.Menu(self.menu1, tearoff=0)
self.editMenu.add_command(label="Cut", command=self.donothing)
self.editMenu.add_command(label="Copy", command=self.donothing)
self.editMenu.add_command(label="Paste", command=self.donothing)
self.editMenu.add_cascade(label="Edit", menu=self.menu1)

def donothing(self):
filewin = Toplevel(self.parent)
button = Button(filewin, text="Do nothing button")
button.pack()



def main():
root=tk.Tk()
ug=UserGui(root)
root.mainloop()

if __name__ == '__main__':
main()


Edit 1,2,3: I have corrected the add_cascade option for menu with menu=self.menu1 and I still do not have a file menu displaying.







python-3.x user-interface tkinter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 11 at 18:58







whisperquiet

















asked Jan 4 at 0:25









whisperquietwhisperquiet

1717




1717













  • You are adding your File and Edit menus to themselves, rather than the top-level menu.

    – jasonharper
    Jan 4 at 0:30











  • You need to fix the indentation problems in your example code.

    – Bryan Oakley
    Jan 4 at 1:20











  • @jasonharper Thank you for your comment. Even when I switched the menu option pointer to menu=self.menu1 in the add_cascade lines for the fileMenu and editMenu, I still did not get the menu bar with "File" and "Edit" to populate.

    – whisperquiet
    Jan 4 at 18:37











  • That made it worse, actually. Try self.menu1.add_cascade(label="File", menu=self.fileMenu)

    – jasonharper
    Jan 4 at 19:42











  • @JasonHarper , that solved it. Thank you very much for your comment. That call makes way more sense. I had my dependencies completely flipped in my understanding. If you want to copy & paste that to an answer I will mark it as such so others can reference this.

    – whisperquiet
    Jan 4 at 19:49



















  • You are adding your File and Edit menus to themselves, rather than the top-level menu.

    – jasonharper
    Jan 4 at 0:30











  • You need to fix the indentation problems in your example code.

    – Bryan Oakley
    Jan 4 at 1:20











  • @jasonharper Thank you for your comment. Even when I switched the menu option pointer to menu=self.menu1 in the add_cascade lines for the fileMenu and editMenu, I still did not get the menu bar with "File" and "Edit" to populate.

    – whisperquiet
    Jan 4 at 18:37











  • That made it worse, actually. Try self.menu1.add_cascade(label="File", menu=self.fileMenu)

    – jasonharper
    Jan 4 at 19:42











  • @JasonHarper , that solved it. Thank you very much for your comment. That call makes way more sense. I had my dependencies completely flipped in my understanding. If you want to copy & paste that to an answer I will mark it as such so others can reference this.

    – whisperquiet
    Jan 4 at 19:49

















You are adding your File and Edit menus to themselves, rather than the top-level menu.

– jasonharper
Jan 4 at 0:30





You are adding your File and Edit menus to themselves, rather than the top-level menu.

– jasonharper
Jan 4 at 0:30













You need to fix the indentation problems in your example code.

– Bryan Oakley
Jan 4 at 1:20





You need to fix the indentation problems in your example code.

– Bryan Oakley
Jan 4 at 1:20













@jasonharper Thank you for your comment. Even when I switched the menu option pointer to menu=self.menu1 in the add_cascade lines for the fileMenu and editMenu, I still did not get the menu bar with "File" and "Edit" to populate.

– whisperquiet
Jan 4 at 18:37





@jasonharper Thank you for your comment. Even when I switched the menu option pointer to menu=self.menu1 in the add_cascade lines for the fileMenu and editMenu, I still did not get the menu bar with "File" and "Edit" to populate.

– whisperquiet
Jan 4 at 18:37













That made it worse, actually. Try self.menu1.add_cascade(label="File", menu=self.fileMenu)

– jasonharper
Jan 4 at 19:42





That made it worse, actually. Try self.menu1.add_cascade(label="File", menu=self.fileMenu)

– jasonharper
Jan 4 at 19:42













@JasonHarper , that solved it. Thank you very much for your comment. That call makes way more sense. I had my dependencies completely flipped in my understanding. If you want to copy & paste that to an answer I will mark it as such so others can reference this.

– whisperquiet
Jan 4 at 19:49





@JasonHarper , that solved it. Thank you very much for your comment. That call makes way more sense. I had my dependencies completely flipped in my understanding. If you want to copy & paste that to an answer I will mark it as such so others can reference this.

– whisperquiet
Jan 4 at 19:49












2 Answers
2






active

oldest

votes


















0














EDIT: I'm sorry I didn't notice the Python-3 tag in time, it's all the same except when inherriting you would call super().__init__ instead of the Frame.__init__ directly. That would make it more Py3-like. Even so, this should still work.



Weirdly, pushing the menu.config down to the run function worked for me - even though it looks like it should work the way you did it.



def main():
root=tk.Tk()
ug=UserGui(root)
root.config(menu=ug.fileMenu)
root.mainloop()

if __name__ == '__main__':
main()


Oterwise there are some things you can work on to make it more OOP like and readable. THis is how I usually handle making GUIs. The idea is to split the GUI's into Frames that then do simmilar things. I.e. your app could have left and right Frame where the RightFrame would hold the textbox ad the left Frame would actually have 2 sub frames - one for the names and dropdowns and the other for the buttons. That way each individual functionality is handled by the Frames themselves and it's not all in one giant class, the elements in those Frames are placed relative to the Frame's grid itself, while all the Frames are placed in the MainFrame's grid. This lets you split a lot of code into modules as well and helps with maintainability.



The sub-frames emit "global" events (events bothering other frames) by propagating them through the MainFrame, that's why they all carry a self.parent - their parent frame, and a self.root - the MainFrame. The MainFrame is also the Frame in which I like to put something like self.data which itself is a class on its own (outside Tkinter) that handles all the data input/output and logic so that you don't clutter the GUI code logic with data calculations and logic. Ideally the Data class would handle data errors and GUI would only then have to handle any errors in logic (such as selecting two impossible-to-combine options from the dropdown menus.



from tkinter import *
from tkinter import ttk

class SubFrame(Frame):
def __init__(self, parent, text="Top Right"):
Frame.__init__(self)
self.pack()
self.parent = parent
self.root = parent.root
self.label=Label(self, text=text).pack()


class RightFrame(Frame):
def __init__(self, parent):
Frame.__init__(self, relief=RAISED, borderwidth=1)
self.pack(side=RIGHT, fill=BOTH, expand=1)
self.root = parent
self.label = Label(self, text="Right Frame").pack()


class LeftFrame(Frame):
def __init__(self, parent):
Frame.__init__(self, relief=RAISED, borderwidth=1)
self.pack(side=LEFT, fill=BOTH, expand=1)
self.root = parent
self.label = Label(self, text="Left Frame").pack()

#again Frames which would have a parent class RightFrame and root MainFrame
self.subFrame1 = SubFrame(self)
self.subFrame2 = SubFrame(self, text="Top Right SubFrame 2")

class MainFrame(Tk):
def __init__(self):
Tk.__init__(self)
self.geometry("1100x600")
self.title("Working Example")

self.leftFrame = LeftFrame(self)
self.rightFrame = RightFrame(self)
#self.data = MagicalDataHandlingClass()



def run():
app = MainFrame()
app.mainloop()


EDIT answer to comments that are too long to fit



The call to Frame.__init__(...) is made because the class definition looks like class LeftFrame(Frame). Usually to declare a class what you would write is just class LeftFrame. When you add the bit in the () what is happening is called inheritance. When you inherit from a class (called parent), your class (called child) inherits all of the methods and attributes of parent. But much like you have to initialize your class to get an object, i.e. lf = LeftFrame(...) the parent class has to be initialized too. In Python this initialization is done by calling the special dunder __init__(...) function. So that call to Frame.__init__(...) happens because you need to tell the parent class what are all the values it needs to work properly. In Python 3 however it is recommended that instead of instantiating the parent by name like that you use the super function like super().__init__(....). This happens for a lot of complicated reasons most of which you probably don't have to worry about for a while yet (such as what if you inherit from multiple classes at the same time, what if you inherit from a class that inherited from a different one, etc...). I wouldn't try to feel overwhelmed by understanding the complete power of super() if you're just starting because 99% of the time in Python 3 just doing super().__init__(...) will do exactly what you want even if you don't understand. If you feel like getting in over your head Raymond Hettinger has a good writeup of Super is Super and why exactly it's so much better than old way.






share|improve this answer


























  • I appreciate your answer and I will definitely make the appropriate edits for this structure as I was just running into the same line of thought myself. The answer to my original problem on the file menu was in the comments for the post, but this is highly appreciated. I tried to run your code "as-is" and I am new to Python so the super() is not familiar to me. I have tried reading it in link, but I do not fully understand.

    – whisperquiet
    Jan 4 at 20:50











  • @whisperquiet answered the question as an edit because it's too long for comments. Yes, you should definitely accept Jason's answer if/when he posts it, upvotes are appreciated though but karma-sellout in me hates saying it, so do what you think is right.

    – ljetibo
    Jan 4 at 21:03











  • Thank you for your explanation of super and the concept of inheritance, your help is extremely appreciated. Just to clarify, to get a Python 3+ running version of the code you've posted, I would change the following: Frame.__init__(self, relief=RAISED, borderwidth=1) to super().__init__(self, relief=RAISED, borderwidth=1) And then apply the change structure to the LeftFrame and MainFrame class definitions? I have tried implementing this because what you say makes sense, but it is still not functioning. In your run() definition do I have to include anything else?

    – whisperquiet
    Jan 4 at 21:14








  • 1





    I would most certainly upvote, but I just created this account and do not have enough reputation to upvote!

    – whisperquiet
    Jan 4 at 21:17











  • @whisperquiet THe code I posted originally was just a sketch of an idea. There's a bunch of stuff missing, it's more like "here's the ouline of a design". I've updated the code to something that works on my system. It should work by just calling run on yours too. You have to play around with the pack or grid now to get all the frames where you want them exactly and then fill them in with functionality you need.

    – ljetibo
    Jan 4 at 21:41



















0














I will post this answer for completeness considering @JasonHarper has not copied it to an answer format and I want others to be able to benefit from the post.



The key was the object that I was calling the add_cascade on the child Menu widget object instead of the main Menu widget object called self.menu1. The key was changing:



self.fileMenu.add_cascade(label="File", menu=self.menu1)



to :



self.menu1.add_cascade(label="File", menu=self.fileMenu)


This was the proper way of adding the fileMenu Menu object to the total Menu widget object of self.menu1.






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%2f54031641%2fpython-tkinter-gui-file-menu-not-displaying-though-gui-is-operational%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    EDIT: I'm sorry I didn't notice the Python-3 tag in time, it's all the same except when inherriting you would call super().__init__ instead of the Frame.__init__ directly. That would make it more Py3-like. Even so, this should still work.



    Weirdly, pushing the menu.config down to the run function worked for me - even though it looks like it should work the way you did it.



    def main():
    root=tk.Tk()
    ug=UserGui(root)
    root.config(menu=ug.fileMenu)
    root.mainloop()

    if __name__ == '__main__':
    main()


    Oterwise there are some things you can work on to make it more OOP like and readable. THis is how I usually handle making GUIs. The idea is to split the GUI's into Frames that then do simmilar things. I.e. your app could have left and right Frame where the RightFrame would hold the textbox ad the left Frame would actually have 2 sub frames - one for the names and dropdowns and the other for the buttons. That way each individual functionality is handled by the Frames themselves and it's not all in one giant class, the elements in those Frames are placed relative to the Frame's grid itself, while all the Frames are placed in the MainFrame's grid. This lets you split a lot of code into modules as well and helps with maintainability.



    The sub-frames emit "global" events (events bothering other frames) by propagating them through the MainFrame, that's why they all carry a self.parent - their parent frame, and a self.root - the MainFrame. The MainFrame is also the Frame in which I like to put something like self.data which itself is a class on its own (outside Tkinter) that handles all the data input/output and logic so that you don't clutter the GUI code logic with data calculations and logic. Ideally the Data class would handle data errors and GUI would only then have to handle any errors in logic (such as selecting two impossible-to-combine options from the dropdown menus.



    from tkinter import *
    from tkinter import ttk

    class SubFrame(Frame):
    def __init__(self, parent, text="Top Right"):
    Frame.__init__(self)
    self.pack()
    self.parent = parent
    self.root = parent.root
    self.label=Label(self, text=text).pack()


    class RightFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=RIGHT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Right Frame").pack()


    class LeftFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=LEFT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Left Frame").pack()

    #again Frames which would have a parent class RightFrame and root MainFrame
    self.subFrame1 = SubFrame(self)
    self.subFrame2 = SubFrame(self, text="Top Right SubFrame 2")

    class MainFrame(Tk):
    def __init__(self):
    Tk.__init__(self)
    self.geometry("1100x600")
    self.title("Working Example")

    self.leftFrame = LeftFrame(self)
    self.rightFrame = RightFrame(self)
    #self.data = MagicalDataHandlingClass()



    def run():
    app = MainFrame()
    app.mainloop()


    EDIT answer to comments that are too long to fit



    The call to Frame.__init__(...) is made because the class definition looks like class LeftFrame(Frame). Usually to declare a class what you would write is just class LeftFrame. When you add the bit in the () what is happening is called inheritance. When you inherit from a class (called parent), your class (called child) inherits all of the methods and attributes of parent. But much like you have to initialize your class to get an object, i.e. lf = LeftFrame(...) the parent class has to be initialized too. In Python this initialization is done by calling the special dunder __init__(...) function. So that call to Frame.__init__(...) happens because you need to tell the parent class what are all the values it needs to work properly. In Python 3 however it is recommended that instead of instantiating the parent by name like that you use the super function like super().__init__(....). This happens for a lot of complicated reasons most of which you probably don't have to worry about for a while yet (such as what if you inherit from multiple classes at the same time, what if you inherit from a class that inherited from a different one, etc...). I wouldn't try to feel overwhelmed by understanding the complete power of super() if you're just starting because 99% of the time in Python 3 just doing super().__init__(...) will do exactly what you want even if you don't understand. If you feel like getting in over your head Raymond Hettinger has a good writeup of Super is Super and why exactly it's so much better than old way.






    share|improve this answer


























    • I appreciate your answer and I will definitely make the appropriate edits for this structure as I was just running into the same line of thought myself. The answer to my original problem on the file menu was in the comments for the post, but this is highly appreciated. I tried to run your code "as-is" and I am new to Python so the super() is not familiar to me. I have tried reading it in link, but I do not fully understand.

      – whisperquiet
      Jan 4 at 20:50











    • @whisperquiet answered the question as an edit because it's too long for comments. Yes, you should definitely accept Jason's answer if/when he posts it, upvotes are appreciated though but karma-sellout in me hates saying it, so do what you think is right.

      – ljetibo
      Jan 4 at 21:03











    • Thank you for your explanation of super and the concept of inheritance, your help is extremely appreciated. Just to clarify, to get a Python 3+ running version of the code you've posted, I would change the following: Frame.__init__(self, relief=RAISED, borderwidth=1) to super().__init__(self, relief=RAISED, borderwidth=1) And then apply the change structure to the LeftFrame and MainFrame class definitions? I have tried implementing this because what you say makes sense, but it is still not functioning. In your run() definition do I have to include anything else?

      – whisperquiet
      Jan 4 at 21:14








    • 1





      I would most certainly upvote, but I just created this account and do not have enough reputation to upvote!

      – whisperquiet
      Jan 4 at 21:17











    • @whisperquiet THe code I posted originally was just a sketch of an idea. There's a bunch of stuff missing, it's more like "here's the ouline of a design". I've updated the code to something that works on my system. It should work by just calling run on yours too. You have to play around with the pack or grid now to get all the frames where you want them exactly and then fill them in with functionality you need.

      – ljetibo
      Jan 4 at 21:41
















    0














    EDIT: I'm sorry I didn't notice the Python-3 tag in time, it's all the same except when inherriting you would call super().__init__ instead of the Frame.__init__ directly. That would make it more Py3-like. Even so, this should still work.



    Weirdly, pushing the menu.config down to the run function worked for me - even though it looks like it should work the way you did it.



    def main():
    root=tk.Tk()
    ug=UserGui(root)
    root.config(menu=ug.fileMenu)
    root.mainloop()

    if __name__ == '__main__':
    main()


    Oterwise there are some things you can work on to make it more OOP like and readable. THis is how I usually handle making GUIs. The idea is to split the GUI's into Frames that then do simmilar things. I.e. your app could have left and right Frame where the RightFrame would hold the textbox ad the left Frame would actually have 2 sub frames - one for the names and dropdowns and the other for the buttons. That way each individual functionality is handled by the Frames themselves and it's not all in one giant class, the elements in those Frames are placed relative to the Frame's grid itself, while all the Frames are placed in the MainFrame's grid. This lets you split a lot of code into modules as well and helps with maintainability.



    The sub-frames emit "global" events (events bothering other frames) by propagating them through the MainFrame, that's why they all carry a self.parent - their parent frame, and a self.root - the MainFrame. The MainFrame is also the Frame in which I like to put something like self.data which itself is a class on its own (outside Tkinter) that handles all the data input/output and logic so that you don't clutter the GUI code logic with data calculations and logic. Ideally the Data class would handle data errors and GUI would only then have to handle any errors in logic (such as selecting two impossible-to-combine options from the dropdown menus.



    from tkinter import *
    from tkinter import ttk

    class SubFrame(Frame):
    def __init__(self, parent, text="Top Right"):
    Frame.__init__(self)
    self.pack()
    self.parent = parent
    self.root = parent.root
    self.label=Label(self, text=text).pack()


    class RightFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=RIGHT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Right Frame").pack()


    class LeftFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=LEFT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Left Frame").pack()

    #again Frames which would have a parent class RightFrame and root MainFrame
    self.subFrame1 = SubFrame(self)
    self.subFrame2 = SubFrame(self, text="Top Right SubFrame 2")

    class MainFrame(Tk):
    def __init__(self):
    Tk.__init__(self)
    self.geometry("1100x600")
    self.title("Working Example")

    self.leftFrame = LeftFrame(self)
    self.rightFrame = RightFrame(self)
    #self.data = MagicalDataHandlingClass()



    def run():
    app = MainFrame()
    app.mainloop()


    EDIT answer to comments that are too long to fit



    The call to Frame.__init__(...) is made because the class definition looks like class LeftFrame(Frame). Usually to declare a class what you would write is just class LeftFrame. When you add the bit in the () what is happening is called inheritance. When you inherit from a class (called parent), your class (called child) inherits all of the methods and attributes of parent. But much like you have to initialize your class to get an object, i.e. lf = LeftFrame(...) the parent class has to be initialized too. In Python this initialization is done by calling the special dunder __init__(...) function. So that call to Frame.__init__(...) happens because you need to tell the parent class what are all the values it needs to work properly. In Python 3 however it is recommended that instead of instantiating the parent by name like that you use the super function like super().__init__(....). This happens for a lot of complicated reasons most of which you probably don't have to worry about for a while yet (such as what if you inherit from multiple classes at the same time, what if you inherit from a class that inherited from a different one, etc...). I wouldn't try to feel overwhelmed by understanding the complete power of super() if you're just starting because 99% of the time in Python 3 just doing super().__init__(...) will do exactly what you want even if you don't understand. If you feel like getting in over your head Raymond Hettinger has a good writeup of Super is Super and why exactly it's so much better than old way.






    share|improve this answer


























    • I appreciate your answer and I will definitely make the appropriate edits for this structure as I was just running into the same line of thought myself. The answer to my original problem on the file menu was in the comments for the post, but this is highly appreciated. I tried to run your code "as-is" and I am new to Python so the super() is not familiar to me. I have tried reading it in link, but I do not fully understand.

      – whisperquiet
      Jan 4 at 20:50











    • @whisperquiet answered the question as an edit because it's too long for comments. Yes, you should definitely accept Jason's answer if/when he posts it, upvotes are appreciated though but karma-sellout in me hates saying it, so do what you think is right.

      – ljetibo
      Jan 4 at 21:03











    • Thank you for your explanation of super and the concept of inheritance, your help is extremely appreciated. Just to clarify, to get a Python 3+ running version of the code you've posted, I would change the following: Frame.__init__(self, relief=RAISED, borderwidth=1) to super().__init__(self, relief=RAISED, borderwidth=1) And then apply the change structure to the LeftFrame and MainFrame class definitions? I have tried implementing this because what you say makes sense, but it is still not functioning. In your run() definition do I have to include anything else?

      – whisperquiet
      Jan 4 at 21:14








    • 1





      I would most certainly upvote, but I just created this account and do not have enough reputation to upvote!

      – whisperquiet
      Jan 4 at 21:17











    • @whisperquiet THe code I posted originally was just a sketch of an idea. There's a bunch of stuff missing, it's more like "here's the ouline of a design". I've updated the code to something that works on my system. It should work by just calling run on yours too. You have to play around with the pack or grid now to get all the frames where you want them exactly and then fill them in with functionality you need.

      – ljetibo
      Jan 4 at 21:41














    0












    0








    0







    EDIT: I'm sorry I didn't notice the Python-3 tag in time, it's all the same except when inherriting you would call super().__init__ instead of the Frame.__init__ directly. That would make it more Py3-like. Even so, this should still work.



    Weirdly, pushing the menu.config down to the run function worked for me - even though it looks like it should work the way you did it.



    def main():
    root=tk.Tk()
    ug=UserGui(root)
    root.config(menu=ug.fileMenu)
    root.mainloop()

    if __name__ == '__main__':
    main()


    Oterwise there are some things you can work on to make it more OOP like and readable. THis is how I usually handle making GUIs. The idea is to split the GUI's into Frames that then do simmilar things. I.e. your app could have left and right Frame where the RightFrame would hold the textbox ad the left Frame would actually have 2 sub frames - one for the names and dropdowns and the other for the buttons. That way each individual functionality is handled by the Frames themselves and it's not all in one giant class, the elements in those Frames are placed relative to the Frame's grid itself, while all the Frames are placed in the MainFrame's grid. This lets you split a lot of code into modules as well and helps with maintainability.



    The sub-frames emit "global" events (events bothering other frames) by propagating them through the MainFrame, that's why they all carry a self.parent - their parent frame, and a self.root - the MainFrame. The MainFrame is also the Frame in which I like to put something like self.data which itself is a class on its own (outside Tkinter) that handles all the data input/output and logic so that you don't clutter the GUI code logic with data calculations and logic. Ideally the Data class would handle data errors and GUI would only then have to handle any errors in logic (such as selecting two impossible-to-combine options from the dropdown menus.



    from tkinter import *
    from tkinter import ttk

    class SubFrame(Frame):
    def __init__(self, parent, text="Top Right"):
    Frame.__init__(self)
    self.pack()
    self.parent = parent
    self.root = parent.root
    self.label=Label(self, text=text).pack()


    class RightFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=RIGHT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Right Frame").pack()


    class LeftFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=LEFT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Left Frame").pack()

    #again Frames which would have a parent class RightFrame and root MainFrame
    self.subFrame1 = SubFrame(self)
    self.subFrame2 = SubFrame(self, text="Top Right SubFrame 2")

    class MainFrame(Tk):
    def __init__(self):
    Tk.__init__(self)
    self.geometry("1100x600")
    self.title("Working Example")

    self.leftFrame = LeftFrame(self)
    self.rightFrame = RightFrame(self)
    #self.data = MagicalDataHandlingClass()



    def run():
    app = MainFrame()
    app.mainloop()


    EDIT answer to comments that are too long to fit



    The call to Frame.__init__(...) is made because the class definition looks like class LeftFrame(Frame). Usually to declare a class what you would write is just class LeftFrame. When you add the bit in the () what is happening is called inheritance. When you inherit from a class (called parent), your class (called child) inherits all of the methods and attributes of parent. But much like you have to initialize your class to get an object, i.e. lf = LeftFrame(...) the parent class has to be initialized too. In Python this initialization is done by calling the special dunder __init__(...) function. So that call to Frame.__init__(...) happens because you need to tell the parent class what are all the values it needs to work properly. In Python 3 however it is recommended that instead of instantiating the parent by name like that you use the super function like super().__init__(....). This happens for a lot of complicated reasons most of which you probably don't have to worry about for a while yet (such as what if you inherit from multiple classes at the same time, what if you inherit from a class that inherited from a different one, etc...). I wouldn't try to feel overwhelmed by understanding the complete power of super() if you're just starting because 99% of the time in Python 3 just doing super().__init__(...) will do exactly what you want even if you don't understand. If you feel like getting in over your head Raymond Hettinger has a good writeup of Super is Super and why exactly it's so much better than old way.






    share|improve this answer















    EDIT: I'm sorry I didn't notice the Python-3 tag in time, it's all the same except when inherriting you would call super().__init__ instead of the Frame.__init__ directly. That would make it more Py3-like. Even so, this should still work.



    Weirdly, pushing the menu.config down to the run function worked for me - even though it looks like it should work the way you did it.



    def main():
    root=tk.Tk()
    ug=UserGui(root)
    root.config(menu=ug.fileMenu)
    root.mainloop()

    if __name__ == '__main__':
    main()


    Oterwise there are some things you can work on to make it more OOP like and readable. THis is how I usually handle making GUIs. The idea is to split the GUI's into Frames that then do simmilar things. I.e. your app could have left and right Frame where the RightFrame would hold the textbox ad the left Frame would actually have 2 sub frames - one for the names and dropdowns and the other for the buttons. That way each individual functionality is handled by the Frames themselves and it's not all in one giant class, the elements in those Frames are placed relative to the Frame's grid itself, while all the Frames are placed in the MainFrame's grid. This lets you split a lot of code into modules as well and helps with maintainability.



    The sub-frames emit "global" events (events bothering other frames) by propagating them through the MainFrame, that's why they all carry a self.parent - their parent frame, and a self.root - the MainFrame. The MainFrame is also the Frame in which I like to put something like self.data which itself is a class on its own (outside Tkinter) that handles all the data input/output and logic so that you don't clutter the GUI code logic with data calculations and logic. Ideally the Data class would handle data errors and GUI would only then have to handle any errors in logic (such as selecting two impossible-to-combine options from the dropdown menus.



    from tkinter import *
    from tkinter import ttk

    class SubFrame(Frame):
    def __init__(self, parent, text="Top Right"):
    Frame.__init__(self)
    self.pack()
    self.parent = parent
    self.root = parent.root
    self.label=Label(self, text=text).pack()


    class RightFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=RIGHT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Right Frame").pack()


    class LeftFrame(Frame):
    def __init__(self, parent):
    Frame.__init__(self, relief=RAISED, borderwidth=1)
    self.pack(side=LEFT, fill=BOTH, expand=1)
    self.root = parent
    self.label = Label(self, text="Left Frame").pack()

    #again Frames which would have a parent class RightFrame and root MainFrame
    self.subFrame1 = SubFrame(self)
    self.subFrame2 = SubFrame(self, text="Top Right SubFrame 2")

    class MainFrame(Tk):
    def __init__(self):
    Tk.__init__(self)
    self.geometry("1100x600")
    self.title("Working Example")

    self.leftFrame = LeftFrame(self)
    self.rightFrame = RightFrame(self)
    #self.data = MagicalDataHandlingClass()



    def run():
    app = MainFrame()
    app.mainloop()


    EDIT answer to comments that are too long to fit



    The call to Frame.__init__(...) is made because the class definition looks like class LeftFrame(Frame). Usually to declare a class what you would write is just class LeftFrame. When you add the bit in the () what is happening is called inheritance. When you inherit from a class (called parent), your class (called child) inherits all of the methods and attributes of parent. But much like you have to initialize your class to get an object, i.e. lf = LeftFrame(...) the parent class has to be initialized too. In Python this initialization is done by calling the special dunder __init__(...) function. So that call to Frame.__init__(...) happens because you need to tell the parent class what are all the values it needs to work properly. In Python 3 however it is recommended that instead of instantiating the parent by name like that you use the super function like super().__init__(....). This happens for a lot of complicated reasons most of which you probably don't have to worry about for a while yet (such as what if you inherit from multiple classes at the same time, what if you inherit from a class that inherited from a different one, etc...). I wouldn't try to feel overwhelmed by understanding the complete power of super() if you're just starting because 99% of the time in Python 3 just doing super().__init__(...) will do exactly what you want even if you don't understand. If you feel like getting in over your head Raymond Hettinger has a good writeup of Super is Super and why exactly it's so much better than old way.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 4 at 21:39

























    answered Jan 4 at 20:03









    ljetiboljetibo

    2,3191221




    2,3191221













    • I appreciate your answer and I will definitely make the appropriate edits for this structure as I was just running into the same line of thought myself. The answer to my original problem on the file menu was in the comments for the post, but this is highly appreciated. I tried to run your code "as-is" and I am new to Python so the super() is not familiar to me. I have tried reading it in link, but I do not fully understand.

      – whisperquiet
      Jan 4 at 20:50











    • @whisperquiet answered the question as an edit because it's too long for comments. Yes, you should definitely accept Jason's answer if/when he posts it, upvotes are appreciated though but karma-sellout in me hates saying it, so do what you think is right.

      – ljetibo
      Jan 4 at 21:03











    • Thank you for your explanation of super and the concept of inheritance, your help is extremely appreciated. Just to clarify, to get a Python 3+ running version of the code you've posted, I would change the following: Frame.__init__(self, relief=RAISED, borderwidth=1) to super().__init__(self, relief=RAISED, borderwidth=1) And then apply the change structure to the LeftFrame and MainFrame class definitions? I have tried implementing this because what you say makes sense, but it is still not functioning. In your run() definition do I have to include anything else?

      – whisperquiet
      Jan 4 at 21:14








    • 1





      I would most certainly upvote, but I just created this account and do not have enough reputation to upvote!

      – whisperquiet
      Jan 4 at 21:17











    • @whisperquiet THe code I posted originally was just a sketch of an idea. There's a bunch of stuff missing, it's more like "here's the ouline of a design". I've updated the code to something that works on my system. It should work by just calling run on yours too. You have to play around with the pack or grid now to get all the frames where you want them exactly and then fill them in with functionality you need.

      – ljetibo
      Jan 4 at 21:41



















    • I appreciate your answer and I will definitely make the appropriate edits for this structure as I was just running into the same line of thought myself. The answer to my original problem on the file menu was in the comments for the post, but this is highly appreciated. I tried to run your code "as-is" and I am new to Python so the super() is not familiar to me. I have tried reading it in link, but I do not fully understand.

      – whisperquiet
      Jan 4 at 20:50











    • @whisperquiet answered the question as an edit because it's too long for comments. Yes, you should definitely accept Jason's answer if/when he posts it, upvotes are appreciated though but karma-sellout in me hates saying it, so do what you think is right.

      – ljetibo
      Jan 4 at 21:03











    • Thank you for your explanation of super and the concept of inheritance, your help is extremely appreciated. Just to clarify, to get a Python 3+ running version of the code you've posted, I would change the following: Frame.__init__(self, relief=RAISED, borderwidth=1) to super().__init__(self, relief=RAISED, borderwidth=1) And then apply the change structure to the LeftFrame and MainFrame class definitions? I have tried implementing this because what you say makes sense, but it is still not functioning. In your run() definition do I have to include anything else?

      – whisperquiet
      Jan 4 at 21:14








    • 1





      I would most certainly upvote, but I just created this account and do not have enough reputation to upvote!

      – whisperquiet
      Jan 4 at 21:17











    • @whisperquiet THe code I posted originally was just a sketch of an idea. There's a bunch of stuff missing, it's more like "here's the ouline of a design". I've updated the code to something that works on my system. It should work by just calling run on yours too. You have to play around with the pack or grid now to get all the frames where you want them exactly and then fill them in with functionality you need.

      – ljetibo
      Jan 4 at 21:41

















    I appreciate your answer and I will definitely make the appropriate edits for this structure as I was just running into the same line of thought myself. The answer to my original problem on the file menu was in the comments for the post, but this is highly appreciated. I tried to run your code "as-is" and I am new to Python so the super() is not familiar to me. I have tried reading it in link, but I do not fully understand.

    – whisperquiet
    Jan 4 at 20:50





    I appreciate your answer and I will definitely make the appropriate edits for this structure as I was just running into the same line of thought myself. The answer to my original problem on the file menu was in the comments for the post, but this is highly appreciated. I tried to run your code "as-is" and I am new to Python so the super() is not familiar to me. I have tried reading it in link, but I do not fully understand.

    – whisperquiet
    Jan 4 at 20:50













    @whisperquiet answered the question as an edit because it's too long for comments. Yes, you should definitely accept Jason's answer if/when he posts it, upvotes are appreciated though but karma-sellout in me hates saying it, so do what you think is right.

    – ljetibo
    Jan 4 at 21:03





    @whisperquiet answered the question as an edit because it's too long for comments. Yes, you should definitely accept Jason's answer if/when he posts it, upvotes are appreciated though but karma-sellout in me hates saying it, so do what you think is right.

    – ljetibo
    Jan 4 at 21:03













    Thank you for your explanation of super and the concept of inheritance, your help is extremely appreciated. Just to clarify, to get a Python 3+ running version of the code you've posted, I would change the following: Frame.__init__(self, relief=RAISED, borderwidth=1) to super().__init__(self, relief=RAISED, borderwidth=1) And then apply the change structure to the LeftFrame and MainFrame class definitions? I have tried implementing this because what you say makes sense, but it is still not functioning. In your run() definition do I have to include anything else?

    – whisperquiet
    Jan 4 at 21:14







    Thank you for your explanation of super and the concept of inheritance, your help is extremely appreciated. Just to clarify, to get a Python 3+ running version of the code you've posted, I would change the following: Frame.__init__(self, relief=RAISED, borderwidth=1) to super().__init__(self, relief=RAISED, borderwidth=1) And then apply the change structure to the LeftFrame and MainFrame class definitions? I have tried implementing this because what you say makes sense, but it is still not functioning. In your run() definition do I have to include anything else?

    – whisperquiet
    Jan 4 at 21:14






    1




    1





    I would most certainly upvote, but I just created this account and do not have enough reputation to upvote!

    – whisperquiet
    Jan 4 at 21:17





    I would most certainly upvote, but I just created this account and do not have enough reputation to upvote!

    – whisperquiet
    Jan 4 at 21:17













    @whisperquiet THe code I posted originally was just a sketch of an idea. There's a bunch of stuff missing, it's more like "here's the ouline of a design". I've updated the code to something that works on my system. It should work by just calling run on yours too. You have to play around with the pack or grid now to get all the frames where you want them exactly and then fill them in with functionality you need.

    – ljetibo
    Jan 4 at 21:41





    @whisperquiet THe code I posted originally was just a sketch of an idea. There's a bunch of stuff missing, it's more like "here's the ouline of a design". I've updated the code to something that works on my system. It should work by just calling run on yours too. You have to play around with the pack or grid now to get all the frames where you want them exactly and then fill them in with functionality you need.

    – ljetibo
    Jan 4 at 21:41













    0














    I will post this answer for completeness considering @JasonHarper has not copied it to an answer format and I want others to be able to benefit from the post.



    The key was the object that I was calling the add_cascade on the child Menu widget object instead of the main Menu widget object called self.menu1. The key was changing:



    self.fileMenu.add_cascade(label="File", menu=self.menu1)



    to :



    self.menu1.add_cascade(label="File", menu=self.fileMenu)


    This was the proper way of adding the fileMenu Menu object to the total Menu widget object of self.menu1.






    share|improve this answer




























      0














      I will post this answer for completeness considering @JasonHarper has not copied it to an answer format and I want others to be able to benefit from the post.



      The key was the object that I was calling the add_cascade on the child Menu widget object instead of the main Menu widget object called self.menu1. The key was changing:



      self.fileMenu.add_cascade(label="File", menu=self.menu1)



      to :



      self.menu1.add_cascade(label="File", menu=self.fileMenu)


      This was the proper way of adding the fileMenu Menu object to the total Menu widget object of self.menu1.






      share|improve this answer


























        0












        0








        0







        I will post this answer for completeness considering @JasonHarper has not copied it to an answer format and I want others to be able to benefit from the post.



        The key was the object that I was calling the add_cascade on the child Menu widget object instead of the main Menu widget object called self.menu1. The key was changing:



        self.fileMenu.add_cascade(label="File", menu=self.menu1)



        to :



        self.menu1.add_cascade(label="File", menu=self.fileMenu)


        This was the proper way of adding the fileMenu Menu object to the total Menu widget object of self.menu1.






        share|improve this answer













        I will post this answer for completeness considering @JasonHarper has not copied it to an answer format and I want others to be able to benefit from the post.



        The key was the object that I was calling the add_cascade on the child Menu widget object instead of the main Menu widget object called self.menu1. The key was changing:



        self.fileMenu.add_cascade(label="File", menu=self.menu1)



        to :



        self.menu1.add_cascade(label="File", menu=self.fileMenu)


        This was the proper way of adding the fileMenu Menu object to the total Menu widget object of self.menu1.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 11 at 19:02









        whisperquietwhisperquiet

        1717




        1717






























            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%2f54031641%2fpython-tkinter-gui-file-menu-not-displaying-though-gui-is-operational%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

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas