Jump to content
Fórum Script Brasil
  • 0

CRAIR MENU EM PHYTON


aggp

Question

Queria saber como faço p criar um menu em phyton. Por exemplo. Quero criar tres opçoes para o usuario: Adição, subtração, Multiplicaçao e Divisao. Teclando o numero 1 realiza a adiçao, o numero 2 a subtração e assim, por diante. como fazer isso? Grato!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

exemplo

#!/usr/bin/python
# -*- coding: iso-8859-15 -*-

# Criado em:Sex 27/Mai/2008 hs 22:39
# Autor: MRSantos mrsantos@viaconnect.com.br

from sys import exit
from Tkinter import *

def file():
    print "file".upper()

def new():
    print "new".upper()

def open():
    print "open".upper()

def about():
    print "By MRSANTOS"

def tchau():
    print "Tchau...".upper()
    exit(0)

root = Tk()

# create a menu
menu = Menu(root)
root.config(menu=menu)

filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=new)
filemenu.add_command(label="Open...", command=open)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=tchau)

helpmenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=about)

mainloop()

mais exemplos em

http://mrsantos76.wordpress.com/category/python/page/3/

abraço

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.6k
×
×
  • Create New...