Esempio n. 1
0
 def __init__(self):
   win = vs.window(width=1024, height=720, menus=False, title='SIMULATE VPYTHON GUI')# make a main window. Also sets w.panel to addr of wx window object.
   scene = vs.display( window=win, width=800, height=720, forward=-vs.vector(1,1,2))# make a 3D panel
   vss = scene
   p = win.panel
   sphere_button = wx.Button(p, label='Sphere', pos=(810,10), size=(190,100))
   #sphere_button.Bind(wx.EVT_BUTTON, self.options())
   cube_button = wx.Button(p, label='Cube', pos=(810,120), size=(190,100))
    def __init__(self, obj):
        self.object = obj
        L = 400.
        w = window(width=2 * window.dwidth + L,
                   height=L + window.dheight + window.menuheight,
                   menus=True,
                   title='Control')  # create the window
        p = w.panel
        self.s1 = wx.Slider(p, pos=(0.25 * L, 0.25 * L), size=(200, 60))
        # create the slider that control the nutation angle
        self.s1.SetMin(1)
        self.s1.SetMax(50 * pi)
        self.s1.SetValue(30 * pi)
        wx.StaticText(p,
                      pos=(0.25 * L, 0.15 * L),
                      label='set nutation angle',
                      size=(200, 25),
                      style=wx.ALIGN_CENTER)
        self.s1.Bind(wx.EVT_SCROLL, self.SetNutation)

        self.s2 = wx.Slider(p, pos=(0.25 * L, 0.55 * L), size=(200, 60))
        # create the slider that contro the velocity of rotation
        self.s2.SetMin(0)
        self.s2.SetMax(100)
        self.s2.SetValue(30)
        wx.StaticText(p,
                      pos=(0.25 * L, 0.45 * L),
                      label='set rotation velocity',
                      size=(200, 25),
                      style=wx.ALIGN_CENTER)
        self.s2.Bind(wx.EVT_SCROLL, self.SetRotationVel)

        text1 = wx.StaticText(p,
                              pos=(0.25 * L, 0.75 * L),
                              label='the total energy is:',
                              size=(200, 25),
                              style=wx.ALIGN_CENTER)
        self.text2 = wx.TextCtrl(p, pos=(0.25 * L, 0.8 * L), size=(200, 25))
        self.text2.SetValue('0')  # create the text to show the total energy
Esempio n. 3
0
    def __init__(self):
        size, toolsHeight, heightMargin = self.getFrameSize()
        grayDarkness = 0.9  # 1 is black
        self.w = window(width=size,
                        height=size + toolsHeight,
                        title="Origami Simulator")
        self.scene = display(window=self.w,
                             x=0,
                             y=0,
                             width=size,
                             height=size,
                             ambient=color.gray(grayDarkness),
                             background=BACKGROUND_COLOR)

        self.initToolbar()
        # from http://www.wxpython.org/doriginalCoords/api/
        # wx.Window-class.html#SetSizeHints
        self.w.win.SetSizeHints(minW=size,
                                minH=size + toolsHeight + heightMargin,
                                maxW=size,
                                maxH=size + toolsHeight + heightMargin)

        # == THE THUMBNAIL PANEL ==
        panelHeight = 100
        self.panel = wx.Panel(parent=self.w.win,
                              pos=(0, size),
                              size=(size, panelHeight))
        self.panel.Bind(wx.EVT_PAINT, lambda event: self.OnPaint(event))

        self.origami = Origami()
        self.mode = 1
        self.tb.EnableTool(self.editID, False)  # disable edit
        self.tb.EnableTool(self.prevID, False)  # disable prev
        self.tb.EnableTool(self.nextID, False)  # disable next

        self.scene.bind('mousedown', self.mouseDown)
        self.scene.bind('keydown', self.keyPressed)
        self.init()
        self.loop()
Esempio n. 4
0
        paused = True
        next.Enable()
        seed_set.Enable()
        previous.Enable()
        env_set.Enable()
        play.SetLabel("Start")


#########################

######## GUI Code #######

win = window(
    menus=True,
    title=_title,
    x=wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X) / 2 - WIN_WIDTH / 2,
    y=wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) / 2 - WIN_HEIGHT / 2,
    width=WIN_WIDTH,
    height=WIN_HEIGHT)
win.win.SetMinSize(
    (WIN_WIDTH, WIN_HEIGHT
     ))  # The VPython window object doesn't inherit from the wx.Frame,
win.win.SetMaxSize(
    (WIN_WIDTH,
     WIN_HEIGHT))  # but rather *has* a frame, which happens to be called 'win'
disp = display(window=win, x=d, y=d, height=DISP_HEIGHT, width=DISP_WIDTH)

p = win.panel  # Panel to hold controls

# Rule
rule_txt = wx.StaticText(
Esempio n. 5
0
#coding:utf-8
"""
Simulation of the VPython camera geometry.
Version using wx widgets.  Geoff Tovey, England, 11 March 2014.

================================================================================
"""

from __future__ import division, print_function
import visual as vs   # for 3D panel
import wx   # for widgets

# Draw window & 3D pane =================================================

# make a main window. Also sets w.panel to addr of wx window object.
WIN = vs.window(width=1024, height=720, menus=False,
                title='SIMULATE VPYTHON GUI')
# make a 3D panel
SCENE = vs.display(window=WIN, width=830, height=690,
                   forward=-vs.vector(1, 1, 2))
CLR = vs.color
VSS = SCENE

# Draw 3D model ======================

def axes(frame, colour, size, posn):
    """Make axes visible (of world or frame)."""
    # Use None for world.
    directions = [
        vs.vector(size, 0, 0), vs.vector(0, size, 0), vs.vector(0, 0, size)]
    texts = ["X", "Y", "Z"]
    posn = vs.vector(posn)
Esempio n. 6
0
from __future__ import division, print_function
import pygame
import serial
import time
import serial
from visual import *
import visual as vs   # for 3D panel
import wx
from numpy import array
import math
#import scipy

#TODO create separate threads for the visualizer and control
#interface
win = vs.window(width=1920, height=1080, menus=False,
                title='Learner display')
                
scene = vs.display(window = win,
     x=0, y=0, width=1700, height=1000,
     center=(0,0,0), background=(0,0,0),forward=-vs.vector(0,0,1))

userzoom = False
right = 10
left = 20
up = 15
down = 13
centerOfG = vector(0,0,0)

#TODO account for ultrasonic offset
#TODO add wheels to 3D model
robot = frame(make_trail=True)
Esempio n. 7
0
 def __init__(self, wide, high, title='Elviz'):
     self.window = window(menus=False, title=title)
     self.scene = display(width=wide, height=high)
from random import randint

L = 12
scene.range = L
T = 0.1

colors = [
    color.red, color.green, color.blue, color.yellow, color.cyan, color.magenta
]

walls = []
balls = []

run = True
win = vs.window(width=1024,
                height=720,
                menus=False,
                title='ELASTIC COLLISIONS BBY')
scene = vs.display(window=win,
                   width=830,
                   height=690,
                   forward=-vs.vector(1, 1, 2))

total_balls = 0

x1 = scene.width + 5
pan = win.panel
pan.SetSize((1024, 720))

#temp_ball = sphere(pos=vector(0,0,0), radius=0.5, color=color.green)

wx.StaticText(
Esempio n. 9
0
		previous.Disable()
		env_set.Disable()
		play.SetLabel("Pause")
	else:
		paused = True
		next.Enable()
		seed_set.Enable()
		previous.Enable()
		env_set.Enable()
		play.SetLabel("Start")

#########################

######## GUI Code #######

win = window(menus=True, title=_title, x=wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)/2-WIN_WIDTH/2, 
	y=wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)/2-WIN_HEIGHT/2, width=WIN_WIDTH, height=WIN_HEIGHT)
win.win.SetMinSize((WIN_WIDTH, WIN_HEIGHT)) # The VPython window object doesn't inherit from the wx.Frame,
win.win.SetMaxSize((WIN_WIDTH, WIN_HEIGHT)) # but rather *has* a frame, which happens to be called 'win'
disp = display(window=win, x=d, y=d, height=DISP_HEIGHT, width=DISP_WIDTH)

p = win.panel # Panel to hold controls

# Rule
rule_txt = wx.StaticText(p, pos=(DISP_WIDTH+d*2, d), label="Rule: ", )
rule_txt.SetFont(font)
rule_txtctrl = wx.TextCtrl(p, pos=(rule_txt.Position.Get()[0]+rule_txt.Size.Get()[0], rule_txt.Position.Get()[1]),
	size=(200,22), style=wx.ALIGN_RIGHT)
rule_txtctrl.SetFont(font)
rule_set = wx.Button(p, label="Set Rule", pos=(rule_txtctrl.Position.Get()[0]+rule_txtctrl.Size.Get()[0]+d, rule_txtctrl.Position.Get()[1]-2))
rule_set.Bind(wx.EVT_BUTTON, set_rule)
Esempio n. 10
0
#coding=utf-8
from __future__ import unicode_literals, print_function, division
from visual import window, cylinder, ring, random, sphere, mag, sleep, rate, mag2, dot, norm, cross, exit, box
from visual.graph import display, vector, color, gdisplay, gcurve, ghistogram, arange
from math import sqrt, pi, cos, sin, exp, asin
import wx
import os

import config

config.w = window(title='Модель динамики газа в поршне',
                  style=wx.CAPTION | wx.CLOSE_BOX)
config.w.win.ShowFullScreen(True)

width, height = config.w.win.GetSize()
config.w.width = width
config.w.height = height


def MenuInterface():
    """Create main menu interface"""
    def ModelButton(evt):
        """Go to simulation window"""
        config.menu_switch = 1

    def AuthorsButton(evt):
        """Go to authors window"""
        config.menu_switch = 2

    def TheoryButton(evt):
        """Go to theory window"""
Esempio n. 11
0
File: ui.py Progetto: Octaplex/elviz
 def __init__(self, wide, high, title='Elviz'):
     self.window = window(menus=False, title=title)
     self.scene = display(width=wide, height=high)
Esempio n. 12
0
import visual as vs
import wx

L = 320
w = vs.window( width  = 2 * ( L + vs.window.dwidth ),
               height = L + vs.window.dheight + vs.window.menuheight,
               menus  = True, title = 'Widgets' )
w.autoscale = False

# Place a 3D display widget in the left half of the window.
d = 20
vs.display( window  = w, x = d, y = d,
            width   = L - 2 * d, height = L - 2 * d,
            range  = 200.,
            forward = - vs.vector( 0, 0, 1 ) )

balloon = vs.sphere( radius = 1., color = vs.color.red )

def SetBalloonRadius(evt):
    balloon.radius = slider.GetValue()

def PumpBalloon(evt):
    balloon.radius *= 1.1

def PunctureBalloon(evt):
    balloon.radius = 1.

# Place buttons, radio buttons, a scrolling text object, and a slider
# 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.
panel = w.panel # Refers to the full region of the window in which to place widgets