Skip to content

Commit

Permalink
Updated demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytra committed Oct 15, 2016
1 parent 01823e7 commit 85aedd5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import pymenu

# Initialise Colorama
pymenu.init()



# Now we will define some functions that our menu buttons will be linked to.
def hello():
print("Hello, world!")

# This next function will create a new menu within the main menu (Allows you to have buttons that bring up different menu screens)
def new_menu():

# Here we create a new menu object with different attributes.
newMenu = pymenu.Menu("Second Menu", "This is a separate menu", "This is some different footer text")

newMenu.set_program_title("PyMenu Demonstration") # Again we should set the program title
# Again we should set the program title.
newMenu.set_program_title("PyMenu Demonstration")

newMenu.add("First Button", hello)
newMenu.add("Back", newMenu.quit) # We should be able to return to the previous menu

# We should be able to return to the previous menu
newMenu.add("Back", newMenu.quit)

# And now to display the new menu.
newMenu.start()

# Finally, we should redraw the previous menu after the new menu has closed.
Expand All @@ -27,14 +29,18 @@ def new_menu():
# Create a new menu object. Menu(Title, Description, Footer)
myMenu = pymenu.Menu("Main Menu", "This is a short description of the menu.", "This is some footer text.")

myMenu.set_program_title("PyMenu Demonstration") # We should display the name of our program in the bottom right.
# We should display the name of our program in the bottom right. If not specified, PyMenu VX will be displayed.
myMenu.set_program_title("PyMenu Demonstration")

# Add a new button to the menu. add(Text, Function Pointer)
myMenu.add("First Button", hello)
# NOTE: It is important that you do not include parentheses when typing the function name.
# It is important that you do not include parentheses when typing the function name.

# We can create a new menu from within another one
# We can create a button which links to another menu
myMenu.add("Next Menu", new_menu)

myMenu.add("Exit", myMenu.quit) # We should be able to close the menu (This will end the program in this case)
myMenu.start()
# We should be able to close the menu (This will end the program in this case)
myMenu.add("Exit", myMenu.quit)

# Finally, in order to display the menu, we call the start() method.
myMenu.start()
Binary file modified images/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 85aedd5

Please sign in to comment.