示例#1
0
    def __init__(self,
                 screen,
                 pos_x,
                 pos_y,
                 label_text,
                 width=200,
                 label_size=150,
                 min=0.0,
                 max=1.0,
                 initial=0.5,
                 margin=20):
        self.width = width
        self.label_size = label_size

        self.label = TextBox(screen, pos_x, pos_y, label_size, 30, fontSize=16)
        self.label.setText(label_text)
        self.slider = Slider(screen,
                             pos_x + self.label_size + margin,
                             pos_y,
                             self.width,
                             20,
                             min=min,
                             max=max,
                             step=0.01,
                             initial=initial)
        self.output = TextBox(screen,
                              pos_x + self.label_size + self.width +
                              margin * 2,
                              pos_y,
                              30,
                              20,
                              fontSize=10)
def setup():
	Boid_List = BoidGroup(POPSIZE, p1_cam)
	sliders, values = [], []
	for i in range(6):
		if i < 3:
			sliders.append(Slider(flockDisplay, p2_cam.x+30, (i+1)*70, 
				(width-div*width)//1-60, 16, min=0., max=100., step=1,
				colour = white, handleRadius = 8, initial = perRadius[i] ))
			values.append(TextBox(flockDisplay, p2_cam.x+190, (i+1)*70-25, 
				20, 20, fontSize=10, colour=black, textColour=white))
		else:
			sliders.append(Slider(flockDisplay, p2_cam.x+30, 40+(i+1)*70,
			 (width-div*width)//1-60, 16, min=0., max=1., step=0.01,
			 colour = white, handleRadius = 8, initial = weights[i%3] ))
			values.append(TextBox(flockDisplay, p2_cam.x+180, 40+(i+1)*70-25, 
				20, 20, fontSize=10, colour=black, textColour=white))
	return Boid_List, sliders, values
示例#3
0
class LabeledSlider:
    def __init__(self,
                 screen,
                 pos_x,
                 pos_y,
                 label_text,
                 width=200,
                 label_size=150,
                 min=0.0,
                 max=1.0,
                 initial=0.5,
                 margin=20):
        self.width = width
        self.label_size = label_size

        self.label = TextBox(screen, pos_x, pos_y, label_size, 30, fontSize=16)
        self.label.setText(label_text)
        self.slider = Slider(screen,
                             pos_x + self.label_size + margin,
                             pos_y,
                             self.width,
                             20,
                             min=min,
                             max=max,
                             step=0.01,
                             initial=initial)
        self.output = TextBox(screen,
                              pos_x + self.label_size + self.width +
                              margin * 2,
                              pos_y,
                              30,
                              20,
                              fontSize=10)

    def draw(self):
        self.label.draw()
        self.slider.draw()
        self.output.draw()

    def update(self, events):
        self.slider.listen(events)
        self.output.setText("%.2f" % self.slider.getValue())

    def get_value(self):
        return self.slider.getValue()

    def set_value(self, value):
        self.slider.setValue(value)
示例#4
0
                250,
                270,
                80,
                text='START',
                fontSize=50,
                margin=20,
                inactiveColour=(255, 0, 0),
                pressedColour=(0, 255, 0),
                radius=20,
                onClick=main,
                onClickParams=(WIN, WIDTH))
slider = Slider(WIN,
                250,
                180,
                180,
                40,
                min=5,
                max=40,
                step=1,
                handleColour=(255, 0, 0),
                handleRadius=22)
output = TextBox(WIN, 460, 180, 110, 40, fontSize=20)
buttonArray = ButtonArray(
    WIN,
    50,
    150,
    150,
    200,
    (1, 4),
    border=5,
    texts=('A*', 'BFS', 'Dijkstra', 'Github'),
)
示例#5
0
scalefactor = 220
#-----------------------------------------------------------------------
#                              Constants
#-----------------------------------------------------------------------
g = 9.81
l = 1
alpha = 0
omega = 0
theta = 0.9 * np.pi
dt = 1 / framerate
C = 0.999
slider = Slider(screen,
                100,
                100,
                800,
                20,
                min=0.0,
                max=2 * l,
                step=0.01,
                initial=l)
output = TextBox(screen,
                 475,
                 50,
                 50,
                 30,
                 borderColour=(0, 0, 0),
                 borderThickness=1,
                 radius=3,
                 textColour=(0, 0, 0),
                 fontSize=20)
#-----------------------------------------------------------------------
示例#6
0
    def main(self):

        # Buttons for cards in home screen
        blue = Button(black, 145, 295, 110, 160)
        gray = Button(black, 295, 295, 110, 160)
        green = Button(black, 445, 295, 110, 160)

        # Custom Bet Input
        slider = Slider(self.win, 250, 250, 200, 40, min=1, max=500, step=1, handleRadius=25)
        outputText = TextBox(self.win, 315, 325, 70, 50, fontSize=30)

        # Buttons for Bet Selection
        minButton = Button(white, 190, 400, 100, 50, 'MIN')
        maxButton = Button(white, 410, 400, 100, 50, 'MAX')
        customButton = Button(white, 300, 400, 100, 50, "CUSTOM")

        # Buttons for Game Selection
        hitButton = Button(white, 600, 150, 90, 50, 'HIT')
        standButton = Button(white, 600, 250, 90, 50, 'STAND')
        splitButton = Button(white, 600, 350, 90, 50, 'SPLIT')
        doubleButton = Button(white, 600, 450, 90, 50, 'DOUBLE')

        back = ''
        state = 0

        # Game Class
        blackjack = Blackjack()
        user = blackjack.user
        dealer = blackjack.dealer

        run = True
        while run:
            events = pygame.event.get()
            for event in events:
                pos = pygame.mouse.get_pos()
                if event.type == pygame.QUIT:
                    run = False

                self.checkHover(blue, gray, green, minButton, maxButton, customButton, hitButton, standButton, splitButton, doubleButton, pos)

                if event.type == pygame.MOUSEBUTTONDOWN:
                    if state == 0:
                        if blue.isOver(pos):
                            back = pygame.transform.scale(blueCard, (80, 110))
                        elif gray.isOver(pos):
                            back = pygame.transform.scale(grayCard, (80, 110))
                        elif green.isOver(pos):
                            back = pygame.transform.scale(greenCard, (80, 110))
                        else:
                            break
                        state = 1
                        self.fade()
                        blackjack.deckOfCards.shuffle()
                    elif state == 1:
                        bet = 0
                        if minButton.isOver(pos):
                            bet = 1
                        elif maxButton.isOver(pos):
                            bet = 500
                        elif customButton.isOver(pos):
                            bet = slider.getValue()
                        else:
                            break
                        state = 2
                        blackjack.place_bet(bet)
                        blackjack.deal_start_cards()
                        self.display_first_cards(user, dealer, back, blackjack)
                    elif state == 2:
                        if hitButton.isOver(pos):
                            blackjack.hit()
                        elif standButton.isOver(pos):
                            blackjack.stand()
                        elif doubleButton.isOver(pos):
                            blackjack.double()
                        elif splitButton.isOver(pos):
                            pass
                        else:
                            break

            if state == 0:
                self.display_homescreen(blue, gray, green)
            elif state == 1:
                slider.listen(events)
                blackjack.set_status('user')
                self.display_betting(user.balance, slider, outputText, minButton, maxButton, customButton, back)
            elif state == 2:
                self.display_game(blackjack, user, dealer, back, hitButton, standButton, splitButton, doubleButton)
                self.display_status(blackjack)

            stat = blackjack.get_status()
            if stat == 'user':
                blackjack.check_blackjack()
            elif stat == 'dealer':
                self.display_status(blackjack)
                self.dealer_turn(blackjack)
            elif stat == 'reset' or stat == 'over' or stat == 'dealerbust' or stat == 'won' or stat == 'lost':
                state = 1
                self.display_status(blackjack)
                pygame.display.update()
                blackjack.reset_game()
                pygame.time.delay(2500)

            pygame.display.update()
    win.blit(gen_text, (10, speed_text.get_height() * 2 + 30))

    slider.draw()

    bird_slider.draw()

    pygame.display.update()


win = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
slider = Slider(win,
                170,
                10,
                200,
                25,
                min=1,
                max=10,
                step=1,
                initial=1,
                handleRadius=12,
                curved=False,
                handleColour=(83, 83, 83))
bird_slider = Slider(win,
                     470,
                     45,
                     200,
                     25,
                     min=0,
                     max=100,
                     step=1,
                     initial=0,
                     handleRadius=12,
from pygame_widgets import Slider, TextBox, Button

WIDTH, HEIGHT = (600, 600)
WHITE = (255,255,255)
BLACK = (0,0,0)
GREEN = ("#39FF14")
RED = (255,7,58)
INIT_EPC = 20

pg.init()
fps = 60
clock = pg.time.Clock()
screen = pg.display.set_mode((WIDTH,HEIGHT))
pg.display.set_caption('Fourier Series')
pg.mouse.set_cursor(*pg.cursors.tri_left)
slider = Slider(screen,WIDTH-340,HEIGHT-50,170,16,min=1, max=50, step=1,color=WHITE,handleColor=BLACK,handleRadius=8,initial=INIT_EPC)
textBox = TextBox(screen, WIDTH-140,HEIGHT-70,40,40,fontSize=15,colour=BLACK,textColour=GREEN)
on_button = Button(screen, WIDTH-150, 20, 50, 30, text="ON",
					fontSize=15, margin=20,
		            inactiveColour=GREEN,
		            hoverColour=(128,128,128),
		            pressedColour=WHITE, radius=2,
		            onClick=lambda:True)
off_button = Button(screen, WIDTH-80, 20, 50, 30, text="OFF",
					fontSize=15, margin=20,
		            inactiveColour=RED,
		            hoverColour= (128,128,128),
		            pressedColour=WHITE, radius=2,
		            onClick=lambda:True)
font1 = pg.font.Font('freesansbold.ttf', 16)
text = font1.render('Epicycles : ', True, GREEN, BLACK)
示例#9
0
文件: main.py 项目: fangyman/PyJaC
    'x_move': 1,
    'y_move': 1,
    'x': randint(0,
                 screen_size.get_width() - image.get_width() - 100),
    'y': randint(0,
                 screen_size.get_height() - image.get_height())
}  # constants

black = (0, 0, 0)  # background color to fill in rgb values
timer = pygame.time.Clock()  # clock to update the frames
xslider = Slider(root,
                 screen_size.get_width() - 80,
                 100,
                 60,
                 40,
                 min=0,
                 max=20,
                 step=1,
                 colour=(220, 174, 150),
                 handleColour=(255, 255, 255),
                 handleRadius=15,
                 curved=True)
xtextbox = TextBox(root,
                   screen_size.get_width() - 100,
                   150,
                   100,
                   40,
                   fontSize=15,
                   borderColour=(91, 100, 103))
yslider = Slider(root,
                 screen_size.get_width() - 80,
                 0,
示例#10
0
win = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Pendulum-Simulation")
pendulum = Pendulum()
plt.style.use("seaborn")
fig, ax = plt.subplots()
MOVE = False
A = L = G = 0


def start():
    global MOVE
    MOVE = not MOVE


sliders = [
    Slider(win, 700, 50, 70, 20, min=1, max=L, step=0.1, initial=1),
    Slider(win, 700, 100, 70, 20, min=30, max=350, step=0.1, initial=30),
    Slider(win, 700, 150, 70, 20, min=1, max=5000, step=0.1, initial=9.81)
]
button_s = Button(win,
                  10,
                  10,
                  100,
                  50,
                  text='Start/Stop',
                  fontSize=30,
                  margin=20,
                  inactiveColour=green,
                  pressedColour=red,
                  radius=50,
                  onClick=start)