Codigo Python v4
Codigo Python v4
import wx
# Windows, Mac, and Linux. This program widgets.py uses VPython to handle
# and the category "Controls" describes all the things you can do with
# When you see "wxButton" that actually means wx.Button, after importing
# wx. The wxPython library is based on wxWidgets, a library for C++ programs,
# inheriting class.
# zetcode.com/wxpython.
cube.dir = -1
cube.dir = 1
w.visible = False
sleep(3)
w.visible = True
w.fullscreen = True
sleep(3)
w.fullscreen = False
exit()
cube.color = color.red
cube.color = color.cyan
choice = t1.GetSelection()
cube.color = color.red
cube.color = color.cyan
def cuberate(value):
cube.dtheta = 2*value*pi/1e4
value = s1.GetValue()
L = 320
Hgraph = 400
# Create a window. Note that w.win is the wxPython "Frame" (the window).
# window.dwidth and window.dheight are the extra width and height of the window
# compared to the display region inside the window. If there is a menu bar,
w = window(width=2*(L+window.dwidth),
height=L+window.dheight+window.menuheight+Hgraph,
menus=True, title='Widgets',
d = 20
cube = box(color=color.red)
# in the right half of the window. Positions and sizes are given in
# terms of pixels, and pos(0,0) is the upper left corner of the window.
p = w.panel # Refers to the full region of the window in which to place widgets
style=wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE)
left.Bind(wx.EVT_BUTTON, setleft)
right.Bind(wx.EVT_BUTTON, setright)
hide.Bind(wx.EVT_BUTTON, sethide)
full.Bind(wx.EVT_BUTTON, setfull)
exit_program = wx.Button(p, label='Exit under program control', pos=(L+70,200))
exit_program.Bind(wx.EVT_BUTTON, leave)
t1.Bind(wx.EVT_RADIOBOX, togglecubecolor)
size=(150,90), style=wx.TE_MULTILINE)
s1.Bind(wx.EVT_SCROLL, setrate)
# Create a menu of options (Rotate right, Rotate right, Make red, Make cyan).
menu = wx.Menu()
# Add this menu to an Options menu next to the default File menu in the menubar
m.Append(menu, 'Options')
# Initializations
funct1 = gcurve(color=color.cyan)
funct3 = gdots(color=color.yellow)
# A VPython program that uses these wxPython capabilities should always end
while True:
rate(100)
cube.rotate(axis=(0,1,0), angle=cube.dir*cube.dtheta)