Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

Commit

Permalink
Add pull-down menu (not in title bar) to widgets.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceSherwood committed Apr 4, 2015
1 parent f23fc56 commit 74e4210
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion site-packages/visual/examples/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def setfull(evt): # called on "Full screen for 3 s" button event
def leave(evt): # called on "Exit under program control" button event
exit()

def choose(evt):
selected = evt.GetSelection()
if selected == 0: cube.dir = -1
elif selected == 1: cube.dir = 1
elif selected == 2: cube.color = color.red
else: cube.color = color.cyan

def setred(evt): # called by "Make red" menu item
cube.color = color.red
t1.SetSelection(0) # set the top radio box button (red)
Expand Down Expand Up @@ -114,9 +121,18 @@ def setrate(evt): # called on slider events
full = wx.Button(p, label='Full screen for 3 s', pos=(1.5*L+10,50))
full.Bind(wx.EVT_BUTTON, setfull)

exit_program = wx.Button(p, label='Exit under program control', pos=(L+70,200))
exit_program = wx.Button(p, label='Exit under program control', pos=(L+10,200))
exit_program.Bind(wx.EVT_BUTTON, leave)

items = []
items.append('Rotate left')
items.append('Rotate right')
items.append('Make red')
items.append('Make cyan')
pulldown_menu = wx.Choice(p, choices=items, pos=(L+200,202))
pulldown_menu.Bind(wx.EVT_CHOICE, choose)
pulldown_menu.SetSelection(0)

t1 = wx.RadioBox(p, pos=(1.0*L,0.3*L), size=(0.25*L, 0.25*L),
choices = ['Red', 'Cyan'], style=wx.RA_SPECIFY_ROWS)
t1.Bind(wx.EVT_RADIOBOX, togglecubecolor)
Expand Down

0 comments on commit 74e4210

Please sign in to comment.