how can I create a menuBar using tkinter in pythonHow can I represent an 'Enum' in Python?Problem with Button Command Tkinter PythonWay to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”Using a button counter in Python tkinterTkinter Menu makes no Tab [Windows only]Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?TkInter Menubar causes program to not runTkinter Calculator Python 3.4.2Python TKinter Menu with Options

Turing patterns

What's up with this leaf?

What is the advantage of carrying a tripod and ND-filters when you could use image stacking instead?

How to retract an idea already pitched to an employer?

Trim MP4 video downloaded from YouTube in Keynote

What are the peak hours for public transportation in Paris?

What risks are there when you clear your cookies instead of logging off?

How to officially communicate to a non-responsive colleague?

How to project 3d image in the planes xy, xz, yz?

Comparing and find out which feature has highest shape area in QGIS?

Orange material in grout lines - need help to identify

How does a transformer increase voltage while decreasing the current?

What can plausibly explain many of my very long and low-tech bridges?

Can acid breath destroy things?

Can a user sell my software (MIT license) without modification?

Frame failure sudden death?

What is the giant octopus in the torture chamber for?

Give a short name / nick name to a printer in iOS?

Is using haveibeenpwned to validate password strength rational?

Movie about a boy who was born old and grew young

Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?

Confusion about off peak timings of London trains

Why doesn’t a normal window produce an apparent rainbow?

What makes Ada the language of choice for the ISS's safety-critical systems?



how can I create a menuBar using tkinter in python


How can I represent an 'Enum' in Python?Problem with Button Command Tkinter PythonWay to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”Using a button counter in Python tkinterTkinter Menu makes no Tab [Windows only]Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?TkInter Menubar causes program to not runTkinter Calculator Python 3.4.2Python TKinter Menu with Options






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








-1















I really hope that you understand the following question, because I wasn't sure how to ask this question so I hope you can help me, if not let me now



I want to make a program to practise my python programming skill. I want to make a store program where an employee could input items with the price, and where he could sell the items. I want to make it that one “page” is the items input an another “page” is the sell page. To so that I want to make a menu bar where the employee could press on the let's say input button and go to input items page, but when he wants to sell items he presses on the sell button and then he goes to the sell page but only the screen changes, not that there comes another tab/window.



I really hope I explained my problem good enough



Thanks in advance!!










share|improve this question
























  • Everything you want to do, you can learn to do with existing tutorials and documentation. What do you need our help? What specifically do you need help with?

    – Bryan Oakley
    Mar 24 at 17:25











  • I googled for a long time on how to make a python application that has multiple “pages”, so if I press a button in the menu bar(what I don’t now how to make) I get a different page but without multiple windows but I didn’t find anything

    – userBSM
    Mar 24 at 19:17











  • Where can I look how to do such a thing?

    – userBSM
    Mar 24 at 22:06

















-1















I really hope that you understand the following question, because I wasn't sure how to ask this question so I hope you can help me, if not let me now



I want to make a program to practise my python programming skill. I want to make a store program where an employee could input items with the price, and where he could sell the items. I want to make it that one “page” is the items input an another “page” is the sell page. To so that I want to make a menu bar where the employee could press on the let's say input button and go to input items page, but when he wants to sell items he presses on the sell button and then he goes to the sell page but only the screen changes, not that there comes another tab/window.



I really hope I explained my problem good enough



Thanks in advance!!










share|improve this question
























  • Everything you want to do, you can learn to do with existing tutorials and documentation. What do you need our help? What specifically do you need help with?

    – Bryan Oakley
    Mar 24 at 17:25











  • I googled for a long time on how to make a python application that has multiple “pages”, so if I press a button in the menu bar(what I don’t now how to make) I get a different page but without multiple windows but I didn’t find anything

    – userBSM
    Mar 24 at 19:17











  • Where can I look how to do such a thing?

    – userBSM
    Mar 24 at 22:06













-1












-1








-1








I really hope that you understand the following question, because I wasn't sure how to ask this question so I hope you can help me, if not let me now



I want to make a program to practise my python programming skill. I want to make a store program where an employee could input items with the price, and where he could sell the items. I want to make it that one “page” is the items input an another “page” is the sell page. To so that I want to make a menu bar where the employee could press on the let's say input button and go to input items page, but when he wants to sell items he presses on the sell button and then he goes to the sell page but only the screen changes, not that there comes another tab/window.



I really hope I explained my problem good enough



Thanks in advance!!










share|improve this question
















I really hope that you understand the following question, because I wasn't sure how to ask this question so I hope you can help me, if not let me now



I want to make a program to practise my python programming skill. I want to make a store program where an employee could input items with the price, and where he could sell the items. I want to make it that one “page” is the items input an another “page” is the sell page. To so that I want to make a menu bar where the employee could press on the let's say input button and go to input items page, but when he wants to sell items he presses on the sell button and then he goes to the sell page but only the screen changes, not that there comes another tab/window.



I really hope I explained my problem good enough



Thanks in advance!!







python-3.x tkinter tkinter-menu






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 29 at 20:01







userBSM

















asked Mar 24 at 15:40









userBSMuserBSM

165




165












  • Everything you want to do, you can learn to do with existing tutorials and documentation. What do you need our help? What specifically do you need help with?

    – Bryan Oakley
    Mar 24 at 17:25











  • I googled for a long time on how to make a python application that has multiple “pages”, so if I press a button in the menu bar(what I don’t now how to make) I get a different page but without multiple windows but I didn’t find anything

    – userBSM
    Mar 24 at 19:17











  • Where can I look how to do such a thing?

    – userBSM
    Mar 24 at 22:06

















  • Everything you want to do, you can learn to do with existing tutorials and documentation. What do you need our help? What specifically do you need help with?

    – Bryan Oakley
    Mar 24 at 17:25











  • I googled for a long time on how to make a python application that has multiple “pages”, so if I press a button in the menu bar(what I don’t now how to make) I get a different page but without multiple windows but I didn’t find anything

    – userBSM
    Mar 24 at 19:17











  • Where can I look how to do such a thing?

    – userBSM
    Mar 24 at 22:06
















Everything you want to do, you can learn to do with existing tutorials and documentation. What do you need our help? What specifically do you need help with?

– Bryan Oakley
Mar 24 at 17:25





Everything you want to do, you can learn to do with existing tutorials and documentation. What do you need our help? What specifically do you need help with?

– Bryan Oakley
Mar 24 at 17:25













I googled for a long time on how to make a python application that has multiple “pages”, so if I press a button in the menu bar(what I don’t now how to make) I get a different page but without multiple windows but I didn’t find anything

– userBSM
Mar 24 at 19:17





I googled for a long time on how to make a python application that has multiple “pages”, so if I press a button in the menu bar(what I don’t now how to make) I get a different page but without multiple windows but I didn’t find anything

– userBSM
Mar 24 at 19:17













Where can I look how to do such a thing?

– userBSM
Mar 24 at 22:06





Where can I look how to do such a thing?

– userBSM
Mar 24 at 22:06












1 Answer
1






active

oldest

votes


















0














Based on your comments to the question, it appears your main problem is that you don't know how to make a menubar, so I will address that part of the question.



Every top level window (instances of Tk and Toplevel) have a menu attribute that can be set to an instance of a Menu object. This menu can itself have dropdown menus, and that combination is what makes a menubar.



In order to make this work you must first create the menu, and then associate that menu with the window.



import tkinter as tk

root = tk.Tk()
self.menubar = tk.Menu()
root.configure(menu=self.menubar)


To create the sub-menus you must do something very similar. First, create a new Menu instance, then associate it with the menubar using add_cascade. Typically, the menu will be a child of the menubar. You use the add_command method to add items to the sub-menu.



In your case, you might want to create a "View" menu with items for switching between "Input" and "Sell". It would look something like this:



viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)


Example



Here is a complete working example. To keep it simple and on topic it doesn't actually switch pages. Instead, it just displays the "page" in a label.



import tkinter as tk

class MenuExample:

def __init__(self):
self.root = tk.Tk()

self.label = tk.Label(self.root, width=25)
self.label.pack(side="top", fill="both", expand=True, padx=20, pady=20)

self._create_menubar()

def _create_menubar(self):
# create the menubar
self.menubar = tk.Menu(self.root)
self.root.configure(menu=self.menubar)

# File menu
fileMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Exit", command=self.root.destroy)

# View menu
viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)

def switch_to_input(self):
# put the code to switch to the input page here...
self.label.configure(text="you clicked on View->Input")

def switch_to_sell(self):
# put the code to switch to the sell page here...
self.label.configure(text="you clicked on View->Sell")

app = MenuExample()
tk.mainloop()





share|improve this answer























  • Thanks Bryan Oakley, sorry for asking because I am not sure this is the place to ask it, but what is the code that switches pages, I also googled for a example for that but I didn’t find anything

    – userBSM
    Mar 25 at 6:13











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%2f55325508%2fhow-can-i-create-a-menubar-using-tkinter-in-python%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














Based on your comments to the question, it appears your main problem is that you don't know how to make a menubar, so I will address that part of the question.



Every top level window (instances of Tk and Toplevel) have a menu attribute that can be set to an instance of a Menu object. This menu can itself have dropdown menus, and that combination is what makes a menubar.



In order to make this work you must first create the menu, and then associate that menu with the window.



import tkinter as tk

root = tk.Tk()
self.menubar = tk.Menu()
root.configure(menu=self.menubar)


To create the sub-menus you must do something very similar. First, create a new Menu instance, then associate it with the menubar using add_cascade. Typically, the menu will be a child of the menubar. You use the add_command method to add items to the sub-menu.



In your case, you might want to create a "View" menu with items for switching between "Input" and "Sell". It would look something like this:



viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)


Example



Here is a complete working example. To keep it simple and on topic it doesn't actually switch pages. Instead, it just displays the "page" in a label.



import tkinter as tk

class MenuExample:

def __init__(self):
self.root = tk.Tk()

self.label = tk.Label(self.root, width=25)
self.label.pack(side="top", fill="both", expand=True, padx=20, pady=20)

self._create_menubar()

def _create_menubar(self):
# create the menubar
self.menubar = tk.Menu(self.root)
self.root.configure(menu=self.menubar)

# File menu
fileMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Exit", command=self.root.destroy)

# View menu
viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)

def switch_to_input(self):
# put the code to switch to the input page here...
self.label.configure(text="you clicked on View->Input")

def switch_to_sell(self):
# put the code to switch to the sell page here...
self.label.configure(text="you clicked on View->Sell")

app = MenuExample()
tk.mainloop()





share|improve this answer























  • Thanks Bryan Oakley, sorry for asking because I am not sure this is the place to ask it, but what is the code that switches pages, I also googled for a example for that but I didn’t find anything

    – userBSM
    Mar 25 at 6:13















0














Based on your comments to the question, it appears your main problem is that you don't know how to make a menubar, so I will address that part of the question.



Every top level window (instances of Tk and Toplevel) have a menu attribute that can be set to an instance of a Menu object. This menu can itself have dropdown menus, and that combination is what makes a menubar.



In order to make this work you must first create the menu, and then associate that menu with the window.



import tkinter as tk

root = tk.Tk()
self.menubar = tk.Menu()
root.configure(menu=self.menubar)


To create the sub-menus you must do something very similar. First, create a new Menu instance, then associate it with the menubar using add_cascade. Typically, the menu will be a child of the menubar. You use the add_command method to add items to the sub-menu.



In your case, you might want to create a "View" menu with items for switching between "Input" and "Sell". It would look something like this:



viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)


Example



Here is a complete working example. To keep it simple and on topic it doesn't actually switch pages. Instead, it just displays the "page" in a label.



import tkinter as tk

class MenuExample:

def __init__(self):
self.root = tk.Tk()

self.label = tk.Label(self.root, width=25)
self.label.pack(side="top", fill="both", expand=True, padx=20, pady=20)

self._create_menubar()

def _create_menubar(self):
# create the menubar
self.menubar = tk.Menu(self.root)
self.root.configure(menu=self.menubar)

# File menu
fileMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Exit", command=self.root.destroy)

# View menu
viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)

def switch_to_input(self):
# put the code to switch to the input page here...
self.label.configure(text="you clicked on View->Input")

def switch_to_sell(self):
# put the code to switch to the sell page here...
self.label.configure(text="you clicked on View->Sell")

app = MenuExample()
tk.mainloop()





share|improve this answer























  • Thanks Bryan Oakley, sorry for asking because I am not sure this is the place to ask it, but what is the code that switches pages, I also googled for a example for that but I didn’t find anything

    – userBSM
    Mar 25 at 6:13













0












0








0







Based on your comments to the question, it appears your main problem is that you don't know how to make a menubar, so I will address that part of the question.



Every top level window (instances of Tk and Toplevel) have a menu attribute that can be set to an instance of a Menu object. This menu can itself have dropdown menus, and that combination is what makes a menubar.



In order to make this work you must first create the menu, and then associate that menu with the window.



import tkinter as tk

root = tk.Tk()
self.menubar = tk.Menu()
root.configure(menu=self.menubar)


To create the sub-menus you must do something very similar. First, create a new Menu instance, then associate it with the menubar using add_cascade. Typically, the menu will be a child of the menubar. You use the add_command method to add items to the sub-menu.



In your case, you might want to create a "View" menu with items for switching between "Input" and "Sell". It would look something like this:



viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)


Example



Here is a complete working example. To keep it simple and on topic it doesn't actually switch pages. Instead, it just displays the "page" in a label.



import tkinter as tk

class MenuExample:

def __init__(self):
self.root = tk.Tk()

self.label = tk.Label(self.root, width=25)
self.label.pack(side="top", fill="both", expand=True, padx=20, pady=20)

self._create_menubar()

def _create_menubar(self):
# create the menubar
self.menubar = tk.Menu(self.root)
self.root.configure(menu=self.menubar)

# File menu
fileMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Exit", command=self.root.destroy)

# View menu
viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)

def switch_to_input(self):
# put the code to switch to the input page here...
self.label.configure(text="you clicked on View->Input")

def switch_to_sell(self):
# put the code to switch to the sell page here...
self.label.configure(text="you clicked on View->Sell")

app = MenuExample()
tk.mainloop()





share|improve this answer













Based on your comments to the question, it appears your main problem is that you don't know how to make a menubar, so I will address that part of the question.



Every top level window (instances of Tk and Toplevel) have a menu attribute that can be set to an instance of a Menu object. This menu can itself have dropdown menus, and that combination is what makes a menubar.



In order to make this work you must first create the menu, and then associate that menu with the window.



import tkinter as tk

root = tk.Tk()
self.menubar = tk.Menu()
root.configure(menu=self.menubar)


To create the sub-menus you must do something very similar. First, create a new Menu instance, then associate it with the menubar using add_cascade. Typically, the menu will be a child of the menubar. You use the add_command method to add items to the sub-menu.



In your case, you might want to create a "View" menu with items for switching between "Input" and "Sell". It would look something like this:



viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)


Example



Here is a complete working example. To keep it simple and on topic it doesn't actually switch pages. Instead, it just displays the "page" in a label.



import tkinter as tk

class MenuExample:

def __init__(self):
self.root = tk.Tk()

self.label = tk.Label(self.root, width=25)
self.label.pack(side="top", fill="both", expand=True, padx=20, pady=20)

self._create_menubar()

def _create_menubar(self):
# create the menubar
self.menubar = tk.Menu(self.root)
self.root.configure(menu=self.menubar)

# File menu
fileMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Exit", command=self.root.destroy)

# View menu
viewMenu = tk.Menu(self.menubar)
self.menubar.add_cascade(label="View", menu=viewMenu)
viewMenu.add_command(label="Input", command=self.switch_to_input)
viewMenu.add_command(label="Sell", command=self.switch_to_sell)

def switch_to_input(self):
# put the code to switch to the input page here...
self.label.configure(text="you clicked on View->Input")

def switch_to_sell(self):
# put the code to switch to the sell page here...
self.label.configure(text="you clicked on View->Sell")

app = MenuExample()
tk.mainloop()






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 22:49









Bryan OakleyBryan Oakley

227k22291447




227k22291447












  • Thanks Bryan Oakley, sorry for asking because I am not sure this is the place to ask it, but what is the code that switches pages, I also googled for a example for that but I didn’t find anything

    – userBSM
    Mar 25 at 6:13

















  • Thanks Bryan Oakley, sorry for asking because I am not sure this is the place to ask it, but what is the code that switches pages, I also googled for a example for that but I didn’t find anything

    – userBSM
    Mar 25 at 6:13
















Thanks Bryan Oakley, sorry for asking because I am not sure this is the place to ask it, but what is the code that switches pages, I also googled for a example for that but I didn’t find anything

– userBSM
Mar 25 at 6:13





Thanks Bryan Oakley, sorry for asking because I am not sure this is the place to ask it, but what is the code that switches pages, I also googled for a example for that but I didn’t find anything

– userBSM
Mar 25 at 6:13



















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%2f55325508%2fhow-can-i-create-a-menubar-using-tkinter-in-python%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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해