def initGUI(): global gui_screen, myguiapp, speedpot, speedlabel, modeswitch, opclo gui_screen = lamina.LaminaPartialScreenSurface(100, 500, 10, -10) myguiapp = gui.Container(width=640, height=480, surface=gui_screen.surf) #myguiapp.style["bgimage"] = "none" modeswitch = gui.Switch(0, ["Comp", 'World', 'Tool', 'Joint'], [0, 1, 2, 3], x=-10, y=30, width=65) modeswitch.label.style["color"] = (255, 255, 255) modeswitch.style["align"] = "right" modeswitch.label.style["font-size"] = 14 myguiapp.add(modeswitch)
be sure to see)! """ import sys sys.path.insert(0, "..") import random import pygame import gooeypy as gui from gooeypy.const import * pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode((640, 480)) myguiapp = gui.Container(width=640, height=100, surface=pygame.surface.Surface((640, 100), pygame.SRCALPHA)) # Lets create a very simple game where you move around an image. image = pygame.image.load("image.png").convert_alpha() x = 200 y = 250 tb = gui.TextBlock(value="This example is for demonstrating how you can easily use GooeyPy in your already made game.", align="center", y=20, width=350) def get_data(): # We are going to set this function to be the value of the TextBlock widget, # (i.e. link it). Because GooeyPy doesn't know when x or y changes, it will # call this function every tick. It will still only update it's widgets when
import sys sys.path.insert(0, "..") import gooeypy as gui import pygame from gooeypy.const import * pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode((640, 480), pygame.SRCALPHA) # Since version 0.2 any widget behaves as a top level element. But all top-level # widgets must be passed a pygame Surface (which screen is) that it will draw to. myguiapp = gui.Container(width=640, height=480, surface=screen) # Create some widgets (if any of this is confusing, just read the docs for the # widget). w1 = gui.Button("reset", x=20, y=30) w2 = gui.Input(x=100, y=30, width=240) w3 = gui.Switch(x=500, y=30) w4 = gui.HSlider(min_value=20, length=10, x=200, y=160) w9 = gui.VSlider(length=40, x=600, y=160, step=False) l1 = gui.Label(value="Pulsate:", x=395, y=30, font_size=25) data = """This example is to demonstrate GooeyPy's widgets and functionality. You can also have line breaks.""" tb = gui.TextBlock(value=data, x=200, y=350, width=300)
""" import sys sys.path.insert(0, "..") import pygame import gooeypy as gui from gooeypy.const import * pygame.init() # Ok, this is really really cool... a CLOCK!!! Ok, so maybe that's not so new... clock = pygame.time.Clock() screen = pygame.display.set_mode((640, 480), pygame.SRCALPHA) app = gui.Container(width=640, height=480, surface=screen) class Menus(gui.Container): """ We have this to hold all of our menus. Keeps things clean and tidy. """ def activate(self, index): """ Basically what we do here is deactivate all the widgets (menus) and then activate the menu at index. When a widget is not active, it simply disappears. """ for w in self.widgets: w.active = False self.widgets[index].active = True menus = Menus(width=640, height=480) # There is one **very important** thing I want to note here. If you ever get
def initGUI(): global gui_screen, myguiapp, speedpot, speedlabel, modeswitch, align, opclo, fpsindic, signalsVBox, msgblock leftPanel[1] = lamina.LaminaPartialScreenSurface(100, 32, 10, -10) rightPanel[1] = lamina.LaminaPartialScreenSurface(100, 32, -10, -10) bottomPanel[1] = lamina.LaminaPartialScreenSurface(510, 64, 0.0, 10) leftPanel[0] = gui.Container(width=100, height=32, surface=leftPanel[1].surf) rightPanel[0] = gui.Container(width=100, height=32, surface=rightPanel[1].surf) bottomPanel[0] = gui.Container(width=510, height=64, surface=bottomPanel[1].surf) leftPanel[0].value = "left panel" rightPanel[0].value = "right panel" bottomPanel[0].value = "bottom panel" leftPanel[0].style["bgimage"] = "none" rightPanel[0].style["bgimage"] = "none" bottomPanel[0].style["bgimage"] = "none" adjust_panels() labels = ["X", "Y", "Z", "RX", "RY", "RZ"] modeswitch = gui.Switch(0, ["COMP", 'WORLD', 'TOOL', 'JOINT'], [0, 1, 2, 3], x=0, y=0, width=65) modeswitch.label.style["color"] = (255, 255, 255) modeswitch.style["align"] = "center" modeswitch.label.style["font-size"] = 14 enableStealEvents([modeswitch]) modeswitch.connect(CHANGE, onModeSwitch) rightPanel[0].add(modeswitch) align = gui.Button("ALIGN", x=0, y=35 * 7, width=65) align.label.style["color"] = (255, 255, 255) align.style["align"] = "center" align.style["valign"] = "top" align.label.style["font-size"] = 14 enableStealEvents([align]) align.connect(CLICK, onAlign) rightPanel[0].add(align) opclo = gui.Switch(0, ["OPEN", "CLOSE"], [0, 1], x=0, y=35 * 8, width=65) opclo.label.style["color"] = (255, 255, 255) opclo.style["align"] = "center" opclo.style["valign"] = "top" opclo.label.style["font-size"] = 14 enableStealEvents([opclo]) opclo.connect(CHANGE, onOpenClose) rightPanel[0].add(opclo) speedpot = gui.HSlider(value=50, min_value=1, length=99, x=0, y=20, width=300) speedpot.style["align"] = "right" speedpot.style["valign"] = "center" enableStealEvents([speedpot]) bottomPanel[0].add(speedpot) speedlabel = gui.Button("MCP Speed: 50", x=0, y=20, width=130) speedlabel.style["align"] = "left" speedlabel.style["valign"] = "center" speedlabel.label.style["color"] = (255, 255, 255) speedlabel.label.style["font-size"] = 14 speedlabel.connect(CLICK, onSpeedToggle) enableStealEvents([speedlabel]) bottomPanel[0].add(speedlabel) speedpot.connect(CHANGE, onSpeedChange) msgblock = gui.TextBlock("spanac", x=0, y=-18) msgblock.style["align"] = "center" msgblock.style["valign"] = "center" msgblock.style["padding"] = (0, 0, 0, 0) msgblock.active = False bottomPanel[0].add(msgblock) #con = gui.TextBlock(value="spanac\ncastraveti", x=0, y=-50, width=300) #con.style["align"] = "center" #con.style["valign"] = "bottom" #enableStealEvents([con]) #myguiapp.add(con) for i, l in enumerate(labels): addPlusMinus(rightPanel[0], l, i + 1) onModeSwitch() #~ fpsindic = gui.Button("0 fps", x=0, y=0, width=70) #~ fpsindic.style["align"] = "left" #~ fpsindic.style["valign"] = "top" #~ fpsindic.label.style["color"] = (255,255,255) #~ fpsindic.label.style["font-size"] = 14 #~ leftPanel[0].add(fpsindic) signalsVBox = gui.VBox(x=0, y=0, width=90) signalsVBox.value = "signals" leftPanel[0].add(signalsVBox)
print 'Goal is already:', goal def change_colour(new_colour): global colour colour = new_colour ai.setColour(colour) print 'Changed colour to', colour # Setup the GUI components: pygame.init() clock = pygame.time.Clock() height = 21 * len(strategies) screen = pygame.display.set_mode((640, height), pygame.SRCALPHA) gui = gooeypy.Container(width=640, height=height, surface=screen) hbox = gooeypy.HBox(x=0, y=0) gui.add(hbox) strategy_select = gooeypy.SelectBox(width=200, scrollable=True) for strategy in strategies: strategy_select.add(strategy, strategy) hbox.add(strategy_select) left_goal_button = gooeypy.Button('Blue->Left') left_goal_button.click = lambda: change_goal('left') hbox.add(left_goal_button) right_goal_button = gooeypy.Button('Blue->Right') right_goal_button.click = lambda: change_goal('right')