def build_background_select(self): background = gui.Table() background.td(gui.Label("Room background:"), style={'padding_right': 6}) self.background_input = gui.Input(size=16) inp = gui.Button('...') inp.connect(gui.CLICK, self.file_dialog_open, None) self.bckg_group = gui.Group(name='background', value='') t = gui.Table() t.tr() t.td(gui.Radio(self.bckg_group, value='')) t.td(gui.Label('None'), align=-1, style={'padding_left': 4}) t.tr() custom_bckg = gui.Radio(self.bckg_group, value='custom') t.td(custom_bckg) t.td(self.background_input, style={'padding_left': 4}) t.td(inp, style={'padding_left': 4}) if self.bckg is not None and self.bckg != "None"\ and os.path.exists(self.bckg): self.background_input.value = self.bckg custom_bckg.click() background.td(t) return background
def __init__(self,**params): fga = (255,25,0) title = gui.Label(u"游戏设置",font=psubfts) self.dfstr=[u'普 通',u'高 级',u'专 家',u'大 师'] self.value=gui.Form() tab=gui.Table() tab.tr() tab.td(gui.Spacer(width=8,height=16)) tab.tr() tab.td(gui.Label(u"难 度:",font=psubfts), align=1,valign=1) tt=gui.Table(width=200) sld=gui.HSlider(0,0,3,size=32,width=180,height=25,name='dif') dflb=gui.Label(self.dfstr[sld.value],width=180,font=psubfts,color=fga) sld.connect(gui.CHANGE, self.ajust,(sld,dflb)) tt.tr() tt.td(dflb) tt.tr() tt.td(sld,align=0,width=240) tab.td(tt) tab.tr() tab.td(gui.Spacer(width=8,height=16)) g = gui.Group(name='gstyle',value='style 1') tab.tr() tab.td(gui.Label(u"样 式:",font=psubfts),align=1) tt=gui.Table(width=200) tt.tr() tt.td(gui.Radio(g,value="style 1"),align=1) tt.td(gui.Image('data/s1.gif',width=36,height=36),align=-1) #tt.td(gui.Label(u"一",font=psubfts),align=-1) tt.td(gui.Radio(g,value="style 2"),align=1) tt.td(gui.Image('data/s2.gif',width=36,height=36),align=-1) tt.td(gui.Radio(g,value="style 3"),align=1) tt.td(gui.Image('data/s3.png',width=36,height=36),align=-1) tab.td(tt) tab.tr() tab.td(gui.Spacer(width=8,height=16)) tab.tr() bv=gui.Label(u"确定",font=psubfts,color=fga) bt=gui.Button(bv) bt.connect(gui.CLICK, self.send, gui.CHANGE) tab.td(bt,width=120,align=1) bv=gui.Label(u"取消",font=psubfts,color=fga) bt=gui.Button(bv) bt.connect(gui.CLICK, self.close,None) tab.td(bt) tab.tr() tab.td(gui.Spacer(width=8,height=16)) gui.Dialog.__init__(self, title, tab)
def __init__(self, ship = None): self.ship = ship self.container = pgui.Container(width=300, height=100) self.position = 15,945 #List of 3 null slots self.item_slot = {} self.button_group = pgui.Group() for i in range(4): button = pgui.Radio(self.button_group, i, width=100, height=100) button.style.width = 128 button.style.height= 128 button.focusable = False self.container.add(button, i * 143, 0) self.item_slot[i] = None self.__setattr__("button%s" % i, button) # def switch_weapon(value): # key = value.value # if self.ship is not None: # self.ship.weapon = self.weapon_slot[key] # # self.button_group.connect(pgui.CHANGE, switch_weapon, self.button_group) self.update()
def __init__(self, **params): gui.Table.__init__(self, **params) self.value = gui.Form() '''self.content = gui.Table() self.scrollArea = gui.ScrollArea(self.content, width=270, height=372, hscrollbar=False) self.tr() self.td(self.scrollArea) self.tr() g = gui.Group(name="grpTileType") self.content.td(gui.Label("Ground", color=UI_FONT_COLOR)) self.content.td(gui.Spacer(10, 0)) e = gui.Radio(g, value=1) e.click() self.content.td(e) self.content.tr() self.content.td(gui.Label("Fringe", color=UI_FONT_COLOR)) self.content.td(gui.Spacer(10, 0)) self.content.td(gui.Radio(g, value=2)) ''' self.tr() g = gui.Group(name="grpTileType") self.td(gui.Label("Ground", color=UI_FONT_COLOR)) self.td(gui.Spacer(10, 0)) e = gui.Radio(g, value=1) e.click() self.td(e) self.tr() self.td(gui.Label("Fringe", color=UI_FONT_COLOR)) self.td(gui.Spacer(10, 0)) self.td(gui.Radio(g, value=2)) e = gui.Select(name='selTileType') e.add('Layer 1', 0) e.add('Layer 2', 1) e.add('Layer 3', 2) e.add('Fringe', 3) e.value = 0 self.td(e)
def create_radio_button(container, windos_size, model): font = pygame.font.SysFont("default", 30) rbt = pgui.Table() radio = pgui.Group() r_button1 = pgui.Radio(radio, 1) r_button1_label = pgui.Label(" Manhattan", font=font, color=WHITE) rbt.add(r_button1) rbt.add(r_button1_label) rbt.tr() r_button2 = pgui.Radio(radio, 2) r_button2_label = pgui.Label("Euclidean", font=font, color=WHITE) rbt.add(r_button2) rbt.add(r_button2_label) rbt.tr() container.add(rbt, 20, windos_size[1] - 50) # coordinate (x, y) radio.value = 1 radio.connect(pgui.CHANGE, radio_button_action, (model, radio.value))
def __init__(self, **params): gui.Table.__init__(self, **params) self.value = gui.Form() self.tr() g = gui.Group(name="grpTileType") self.td(gui.Label("Ground", color=UI_FONT_COLOR)) self.td(gui.Spacer(10, 0)) e = gui.Radio(g, value=1) e.click() self.td(e) self.tr() self.td(gui.Label("Fringe", color=UI_FONT_COLOR)) self.td(gui.Spacer(10, 0)) self.td(gui.Radio(g, value=2))
def start_input(self, attrs): r = self.attrs_to_map(attrs) params = self.map_to_params(r) #why bother #params = {} type_, name, value = r.get('type', 'text'), r.get('name', None), r.get('value', None) f = self.form if type_ == 'text': e = gui.Input(**params) self.map_to_connects(e, r) self.item.add(e) elif type_ == 'radio': if name not in f.groups: f.groups[name] = gui.Group(name=name) g = f.groups[name] del params['name'] e = gui.Radio(group=g, **params) self.map_to_connects(e, r) self.item.add(e) if 'checked' in r: g.value = value elif type_ == 'checkbox': if name not in f.groups: f.groups[name] = gui.Group(name=name) g = f.groups[name] del params['name'] e = gui.Checkbox(group=g, **params) self.map_to_connects(e, r) self.item.add(e) if 'checked' in r: g.value = value elif type_ == 'button': e = gui.Button(**params) self.map_to_connects(e, r) self.item.add(e) elif type_ == 'submit': e = gui.Button(**params) self.map_to_connects(e, r) self.item.add(e) elif type_ == 'file': e = gui.Input(**params) self.map_to_connects(e, r) self.item.add(e) b = gui.Button(value='Browse...') self.item.add(b) def _browse(value): d = gui.FileDialog() d.connect(gui.CHANGE, gui.action_setvalue, (d, e)) d.open() b.connect(gui.CLICK, _browse, None) self._locals[r.get('id', None)] = e
def levelup(self): self.lvl += 1 self.xp -= 100 app = gui.Desktop() app.connect(gui.QUIT, app.quit, None) c = gui.Table() c.tr() c.td(gui.Label("Character levelup"), colspan=4) c.tr() c.td(gui.Label("Name :" + self.name)) c.tr() c.td(gui.Label("Level :" + str(self.lvl))) c.tr() c.td(gui.Label("Strength " + str(self.strength))) c.td(gui.Label("Spirit " + str(self.spirit))) c.td(gui.Label("Agility " + str(self.agility))) c.tr() g = gui.Group(value=1) c.td(gui.Radio(g, value=1)) c.td(gui.Radio(g, value=2)) c.td(gui.Radio(g, value=3)) def doneit(): if globalconst.DEBUG: print g.value if g.value == 1: self.strength += 1 self.healthmax = 5 * self.strength if g.value == 2: self.spirit += 1 self.energymax = 5 * (self.strength + self.spirit + self.agility) if g.value == 3: self.agility += 1 btn = gui.Button("Done") btn.connect(gui.CLICK, doneit) btn.connect(gui.CLICK, app.quit) c.tr() c.td(btn, colspan=4) app.run(c)
def build_background_select(self): background = gui.Table() background.td(gui.Label("Room background:"), style={'padding_right': 6}) self.background_input = gui.Input(size=16) inp = gui.Button('...') inp.connect(gui.CLICK, self.file_dialog_open, None) self.bckg_group = gui.Group(name='background', value='') t = gui.Table() t.tr() t.td(gui.Radio(self.bckg_group, value='')) t.td(gui.Label('None'), align=-1, style={'padding_left': 4}) t.tr() t.td(gui.Radio(self.bckg_group, value='custom')) t.td(self.background_input, style={'padding_left': 4}) t.td(inp, style={'padding_left': 4}) background.td(t) return background
def __init__(self, value, **params): gui.Container.__init__(self, **params) self.gui_form = gui.Form() t = gui.Table(align=-1, valign=-1) t.tr() g = gui.Group(value=value, name='difficulty') t.td(gui.Radio(g, value=config.EASY), width=30, height=22) t.td(gui.Label("Easy"), align=-1) t.tr() t.td(gui.Radio(g, value=config.MED_DIF), width=30, height=22) t.td(gui.Label("Medium"), align=-1) t.tr() t.td(gui.Radio(g, value=config.HARD), width=30, height=22) t.td(gui.Label("Hard"), align=-1) t.tr() t.td(gui.Radio(g, value=config.SUPER), width=30, height=22) t.td(gui.Label("Superstar"), align=-1) g.connect(gui.CHANGE, self.changed, None) self.add(t, 0, 0)
def __init__(self, value, **params): gui.Container.__init__(self, **params) self.ev_manager = params['ev_manager'] self.board = params['board'] self.gui_form = gui.Form() t = gui.Table(background=(255, 255, 255), align=-1) t.tr() t.td(gui.Label("Board Size:"), colspan=2) t.tr() g = gui.Group(value=value, name='board_size') t.td(gui.Radio(g, value=config.BOARD_SMALL)) t.td(gui.Label("Small"), align=-1) t.tr() t.td(gui.Radio(g, value=config.BOARD_MED)) t.td(gui.Label("Med"), align=-1) t.tr() t.td(gui.Radio(g, value=config.BOARD_LARGE)) t.td(gui.Label("Large"), align=-1) g.connect(gui.CHANGE, self.changed, None) self.add(t, 0, 0)
def __init__(self, game_screen, game_engine): self._screen = game_screen self._engine = game_engine self._images = [] self._app = gui.Desktop() self._app.connect(gui.QUIT, self._app.quit, None) self._table = gui.Table() #first row self._table.tr() if self._engine.time_of_day == game.TIME_DAY: self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_day_1_early_bird.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_day_2_rethink.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_day_3_mana_steal.png")) elif self._engine.time_of_day == game.TIME_NIGHT: self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_night_1_from_the_dusk.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_night_2_long_night.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_night_3_mana_search.png")) for img in self._images: self._table.td(img) #second row self._table.tr() self._radio = gui.Group() self._table.td(gui.Radio(self._radio,value=1)) self._table.td(gui.Radio(self._radio,value=2)) self._table.td(gui.Radio(self._radio,value=3)) #third row self._table.tr() if self._engine.time_of_day == game.TIME_DAY: self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_day_4_planning.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_day_5_great_start.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_day_6_the_right_moment.png")) elif self._engine.time_of_day == game.TIME_NIGHT: self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_night_4_midnight_meditation.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_night_5_preparation.png")) self._images.append(gui.Image("assets/images/cards/tactics/gui_tactics_night_6_sparing_power.png")) for i in range(3, 6): self._table.td(self._images[i]) #fourth row self._table.tr() self._table.td(gui.Radio(self._radio,value=4)) self._table.td(gui.Radio(self._radio,value=5)) self._table.td(gui.Radio(self._radio,value=6)) #fifth row self._table.tr() button = gui.Button("Select Tactics") self._table.td(button, colspan=3) button.connect(gui.CLICK, self._commit_values)
def __init__(self, mode, dif, **params): gui.Table.__init__(self, **params) self.ev_manager = params['ev_manager'] self.ev_manager.register_listener(self) self.h1 = pygame.font.Font(config.font_logo, 18) self.gui_form = gui.Form() self.tr() self.td(gui.Label("Mode:", font=self.h1, color=config.COLOR5), colspan=2, align=-1, height=50) g = gui.Group(value=mode, name='mode') self.tr() self.td(gui.Radio(g, value=config.TIME_CHALLENGE)) self.td(gui.Label("Time Challenge"), align=-1) self.tr() self.td(gui.Radio(g, value=config.PLAN_AHEAD)) self.td(gui.Label("Plan Ahead"), align=-1) self.tr() self.td(gui.Label("Difficulty:", font=self.h1, color=config.COLOR5), colspan=2, align=-1, height=50) g = gui.Group(value=dif, name='difficulty') self.tr() self.td(gui.Radio(g, value=config.EASY), width=30) self.td(gui.Label("Easy"), align=-1) self.tr() self.td(gui.Radio(g, value=config.MED_DIF)) self.td(gui.Label("Medium"), align=-1) self.tr() self.td(gui.Radio(g, value=config.HARD)) self.td(gui.Label("Hard"), align=-1) self.tr() self.td(gui.Radio(g, value=config.SUPER)) self.td(gui.Label("Superstar"), align=-1) self.tr() self.refresh_button = gui.Button("Refresh") self.td(self.refresh_button, colspan=2, align=-1, height=50) self.refresh_button.connect(gui.CLICK, self.refresh, None)
def main(): """this function is called when the program starts. it initializes everything it needs, then runs in a loop until the function returns.""" global lines #Initialize Everything pygame.init() pygame.font.init() font = pygame.font.SysFont("default", 18) fontBig = pygame.font.SysFont("default", 24) fontSub = pygame.font.SysFont("default", 20) screen = pygame.display.set_mode(screenSize) pygame.display.set_caption('GUI Test - PGU') # create GUI object gui = pgui.App() textArea = pygame.Rect(370, 20, 250, 320) # layout using document lo = pgui.Container(width=350) # create page label #lo.block(align=-1) #lo.br(8) #lo.tr() title = pgui.Label("Pygame GUI Test Page - PGU", font=fontBig) lo.add(title, 29, 13) # create progress bar label # progress bar pbl = pgui.Label("Progress Bar Not Supported") lo.add(pbl, 354, 371) # create checkbuttons and add to gui cbt = pgui.Table() cb1 = pgui.Switch() cb1.connect(pgui.CHANGE, logCheckAction, (cb1, "Check Box 1")) cb1l = pgui.Label("Check Box 1") cbt.add(cb1) cbt.add(cb1l) cbt.tr() cb2 = pgui.Switch() cb2.connect(pgui.CHANGE, logCheckAction, (cb2, "Check Box 2")) cb2l = pgui.Label("Check Box 2") cbt.add(cb2) cbt.add(cb2l) cbt.tr() cb3 = pgui.Switch() cb3.connect(pgui.CHANGE, logCheckAction, (cb3, "Check Box 3")) cb3l = pgui.Label("Check Box 3") cbt.add(cb3) cbt.add(cb3l) lo.add(cbt, 52, 52) # create radio buttons, put in table, and add to gui rbt = pgui.Table() radio = pgui.Group() rb1 = pgui.Radio(radio, 1) rb1l = pgui.Label("Radio Button 1") rbt.add(rb1) rbt.add(rb1l) rbt.tr() rb2 = pgui.Radio(radio, 2) rb2l = pgui.Label("Radio Button 2") rbt.add(rb2) rbt.add(rb2l) rbt.tr() rb3 = pgui.Radio(radio, 3) rb3l = pgui.Label("Radio Button 3") rbt.add(rb3) rbt.add(rb3l) rbt.tr() lo.add(rbt, 210, 52) radio.connect(pgui.CHANGE, logRadioAction, (radio, "Radio Button 3")) # create txt box label txtl = pgui.Label("Text Box", font=fontSub) lo.add(txtl, 30, 127) # create text box txt = pgui.Input("next line of input", size=45) txt.connect(pgui.BLUR, logInputAction, txt) lo.add(txt, 28, 149) # add buttons, both regular and toggle btn1 = pgui.Button("Button 1") btn1.connect(pgui.CLICK, logButtonAction, ("Button 1 clicked")) lo.add(btn1, 36, 250) btn2 = pgui.Button("Button 2") btn2.connect(pgui.CLICK, logButtonAction, ("Button 2 clicked")) lo.add(btn2, 133, 250) btn3 = pgui.Button("Button 3") btn3.connect(pgui.CLICK, logButtonAction, ("Button 3 clicked")) lo.add(btn3, 230, 250) # create toggle button not avail label tbl = pgui.Label("Toggle Buttons Not Supported") lo.add(tbl, 36, 290) iml = pgui.Label("Image Map Not Supported") lo.add(iml, 36, 340) # create slider label sll = pgui.Label("Slider", font=fontSub) lo.add(sll, 36, 195) # create slider sl = pgui.HSlider(value=1, min=0, max=100, size=32, width=200, height=16) sl.connect(pgui.CHANGE, logSliderAction, sl) lo.add(sl, 53, 210) #, colspan=3) # make some insensitive btn2.style.disabled = True cb3.style.disabled = True # clear setup noise, and put initial content in lines = [] lines.append('top line of input') lines.append('second line of input') gui.init(lo) #Main Loop while 1: #Handle Input Events for event in pygame.event.get(): if event.type == QUIT: return elif event.type == KEYDOWN and event.key == K_ESCAPE: return # pass event to gui gui.event(event) # clear background, and draw clock-spinner screen.fill((250, 250, 250)) radius = 30 spinPos = 240, 362 sp2 = spinPos[0] + 1, spinPos[1] progressAngle = int(time.time() % 15 * 24 - 90) #60 pygame.draw.circle(screen, (180, 180, 180), spinPos, radius, 0) for angle in range(-90, progressAngle): a = angle * math.pi / 180 tgt = radius*math.cos(a)+spinPos[0], \ radius*math.sin(a)+spinPos[1] pygame.draw.line(screen, (254, 254, 254), spinPos, tgt, 2) pygame.draw.circle(screen, (0, 0, 0), spinPos, radius, 2) pygame.draw.circle(screen, (0, 0, 0), spinPos, radius + 1, 3) pygame.draw.circle(screen, (0, 0, 0), sp2, radius, 2) pygame.draw.circle(screen, (0, 0, 0), sp2, radius + 1, 3) pygame.draw.line(screen, (0, 0, 0), spinPos, tgt, 2) tgt = spinPos[0], spinPos[1] - radius pygame.draw.line(screen, (0, 0, 0), spinPos, tgt, 2) # Draw GUI gui.paint(screen) edText = "\n".join(lines) text.writepre(screen, font, textArea, (0, 0, 0), edText) pygame.display.flip()
def GuiSetup(): global app global MotorMin, MotorMax global LSlider, RSlider, FSlider, ASlider global speedLbl, depLbl, preLbl, depInput global pSwitch, Pbox, Ibox, Dbox app = gui.Desktop() app.connect(gui.QUIT, app.quit, None) Main = gui.Table(width=900) Main.tr() # c.tr() makes a row # c.td(component) creates a cell # Top panel for displaying network status and emergancy options n = gui.Table() n.tr() n.td(gui.Label("Network: Status"), height=40) n.td(gui.Label(" ")) emergeButton = gui.Button("In Case of Emergency") emergeButton.connect(gui.CLICK, emergeClick) n.td(emergeButton) #Make sub tabels to be put into c that hold seperate elements. #tabel on the "west" side of the frame. w = gui.Table() w.tr() #Radio button group w.tr() w1 = gui.Table() w1.tr() w1.td(gui.Label("PID Controls"), colspan=5, height=50) w1.tr() pidSwitch = gui.Switch(value=False) pidSwitch.connect(gui.CLICK, arm_disarm_Component, 0) w1.td(pidSwitch) w1.td(gui.Label("Arm ")) w1.td(gui.Label(""), width=95, height=30) pidButton1 = gui.Button("Hover") pidButton1.connect(gui.CLICK, pidHover) w1.td(pidButton1, align=1) w.td(w1, align=-1) w.tr() w2 = gui.Table() w2.tr() depInput = gui.Input(size=6) w2.td(depInput, align=-1) w2.td(gui.Label("m "), align=-1, width=30, height=30) pidButton2 = gui.Button("Go to depth") pidButton2.connect(gui.CLICK, pidGoDepth) w2.td(pidButton2, align=1) w.td(w2, align=-1) #Sliders to control coeficients w.tr() w3 = gui.Table() #P w3.tr() #w3.td(gui.Label("Stable ")) Pbox = gui.Input(value="0", height=16, width=120) w3.td(Pbox) w3.td(gui.Label(" Quick"), align=-1) #I w3.tr() #w3.td(gui.Label("Stable ")) Ibox = gui.Input(value="0", height=16, width=120) w3.td(Ibox) w3.td(gui.Label(" Accurate"), align=-1) #D w3.tr() #w3.td(gui.Label("Cautious ")) Dbox = gui.Input(value="0", height=16, width=120) w3.td(Dbox) w3.td(gui.Label(" Responsive"), align=-1) w.td(w3, align=-1) #Restore PID defaults button w.tr() w4 = gui.Table() w4.tr() pidButton3 = gui.Button("Restore PID Defaults") pidButton3.connect(gui.CLICK, pidDefault) w4.td(pidButton3, valign=1) w4.td(gui.Label(""), height=30) ## w4.tr() ## pidButton4 = gui.Button("Auto-Calibrate") ## pidButton4.connect(gui.CLICK, pidCalibrate) ## w4.td(pidButton4) ## w4.td(gui.Label(""), height = 30) w.td(w4, align=-1) #Second panel under top panel for depth, pressure, and subsytems label w.tr() w5 = gui.Table() w5.tr() w5.td(gui.Label("Depth "), height=30, align=-1) depLbl = gui.Input("0", size=6) w5.td(depLbl, align=1) w5.td(gui.Label(" m")) w5.tr() w5.td(gui.Label("Pressure "), align=-1) preLbl = gui.Input("0", size=6) w5.td(preLbl, align=1) w5.td(gui.Label(" kPa")) w.td(w5, align=-1) #Soleniod controls w.tr() w.td(gui.Label("Solenoid Controls "), height=30, align=-1) w.tr() w6 = gui.Table() w6.tr() sol0 = gui.Switch(false) sol0.connect(gui.CLICK, fireSol, 0) w6.td(sol0) sol1 = gui.Switch(false) sol1.connect(gui.CLICK, fireSol, 1) w6.td(sol1) sol2 = gui.Switch(false) sol2.connect(gui.CLICK, fireSol, 2) w6.td(sol2) sol3 = gui.Switch(false) sol3.connect(gui.CLICK, fireSol, 3) w6.td(sol3) sol4 = gui.Switch(false) sol4.connect(gui.CLICK, fireSol, 4) w6.td(sol4) sol5 = gui.Switch(false) sol5.connect(gui.CLICK, fireSol, 5) w6.td(sol5) sol6 = gui.Switch(false) sol6.connect(gui.CLICK, fireSol, 6) w6.td(sol6) sol7 = gui.Switch(false) sol7.connect(gui.CLICK, fireSol, 7) w6.td(sol7) sol8 = gui.Switch(false) sol8.connect(gui.CLICK, fireSol, 8) w6.td(sol8) sol9 = gui.Switch(false) sol9.connect(gui.CLICK, fireSol, 9) w6.td(sol9) w.td(w6, align=0) w.tr() w.td(gui.Label("0 1 2 3 4 5 6 7 8 9"), height=30, align=0) # Center tabel that holds all the navigation data. c = gui.Table() #verticle sliders for motor bars and space for surface. c.tr() c1 = gui.Table() c1.tr() LSlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) RSlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) FSlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) ASlider = gui.VSlider(value=0, min=Motormin, max=Motormax, size=20, height=120, width=16) c1.td(LSlider, width=20, valign=1) c1.td(RSlider, width=20, valign=1) c1.td(gui.Label(" Surface "), height=180, width=240) c1.td(FSlider, width=20, valign=1) c1.td(ASlider, width=20, valign=1) c1.tr() c1.td(gui.Label("L")) c1.td(gui.Label("R")) c1.td(gui.Label("")) c1.td(gui.Label("F")) c1.td(gui.Label("A")) c.td(c1) # Motor duty cycle bar. c.tr() c2 = gui.Table() c2.tr() c2.td(gui.Label(" Motor Duty Cycle "), height=50, colspan=3, valign=1) c2.tr() c2.td(gui.Label("0 "), height=30) MotormaxS = gui.HSlider(value=25, min=0, max=127, size=20, height=16, width=120) MotormaxS.connect(gui.CHANGE, setMotorMax, MotormaxS) c2.td(MotormaxS) c2.td(gui.Label(" 100")) c.td(c2) #motor configuration graphic c.tr() c3 = gui.Table() c3.tr() c3.td(gui.Label(""), height=30) c3.tr() c3.td(gui.Label(" Motor Configuration ")) c3.tr() c3.td(gui.Label(" Surface "), height=150, width=150) c3.tr() c3.td(gui.Label(""), height=30) c.td(c3) #Radio Buttons for controling pitch and button for speed cycle. c.tr() c4 = gui.Table() c4.tr() pSwitch = gui.Switch(value=False) pSwitch.connect(gui.CLICK, arm_disarm_Component, 4) c4.td(pSwitch) c4.td(gui.Label("Pitch on")) c4.td(gui.Label(" ")) spdCycButton = gui.Button("Speed Cycle") spdCycButton.connect(gui.CLICK, speedCycle) c4.td(spdCycButton) c4.tr() speedLbl = gui.Input("1/1", size=4, align=1) c4.td(speedLbl, colspan=4, align=1) c.td(c4) # East tabel for hold all the subsystems functions. e = gui.Table(width=200) e.tr() e.td(gui.Label(" Subsystems "), height=50) e.tr() sysSelectGroup = gui.Group(value=0) disarmRadio = gui.Radio(sysSelectGroup, value=0) disarmRadio.connect(gui.CLICK, arm_disarm_Component, 5) e0 = gui.Table() e0.tr() e0.td(disarmRadio, width=20) e0.td(gui.Label("Disarm All")) e.td(e0) # Critter Getter functions. e.tr() e1 = gui.Table() e1.tr() e1a = gui.Table() e1a.tr() e1a.td(gui.Label("Critter Getter"), height=29, align=-1) e1a.td(gui.Label(), width=30) cgRadio = gui.Radio(sysSelectGroup, value=1) cgRadio.connect(gui.CLICK, arm_disarm_Component, 1) e1a.td(cgRadio) e1a.td(gui.Label("Arm ")) e1a.td(gui.Label(""), height=29, width=20) e1.td(e1a, align=-1) e1.tr() e1b = gui.Table() e1b.tr() e1b.td(gui.Label("Status: "), height=29, align=-1) critLbl = gui.Input(size=15) e1b.td(critLbl) e1.td(e1b, align=-1) e1.tr() e1b = gui.Table() e1b.tr() cgButton1 = gui.Button("Flush") cgButton2 = gui.Button("Extend") cgButton1.connect(gui.CLICK, operateWC, 1) cgButton2.connect(gui.CLICK, operateWC, 2) e1b.td(cgButton1) e1b.td(gui.Label(""), height=29) e1b.td(cgButton2) e1.td(e1b, align=-1) e.td(e1, height=120, align=-1) #Water Collecter functions. e.tr() e2 = gui.Table() e2.tr() e2a = gui.Table() e2a.tr() e2a.td(gui.Label("Water Collecter"), height=29, align=-1) e2a.td(gui.Label(), width=30) wcRadio = gui.Radio(sysSelectGroup, value=2) wcRadio.connect(gui.CLICK, arm_disarm_Component, 2) e2a.td(wcRadio) e2a.td(gui.Label("Arm ")) e2a.td(gui.Label(""), height=29, width=20) e2.td(e2a, align=-1) e2.tr() e2b = gui.Table() e2b.tr() e2b.td(gui.Label("Status: "), height=29, align=-1) wcLbl = gui.Input(size=15) e2b.td(wcLbl) e2.td(e2b, align=-1) e2.tr() e2c = gui.Table() e2c.tr() wcButton = gui.Button("Operate") e2c.td(wcButton, height=29) e2.td(e2c, align=-1) e.td(e2, height=120, align=-1) #Cap and trade functions. e.tr() e3 = gui.Table() e3.tr() #CandTarm_disarm = gui.Group(value = 2) e3a = gui.Table() e3a.tr() e3a.td(gui.Label("Cap and Trade"), height=29, align=-1) e3a.td(gui.Label(), width=30) ctRadio = gui.Radio(sysSelectGroup, value=3) ctRadio.connect(gui.CLICK, arm_disarm_Component, 3) e3a.td(ctRadio) e3a.td(gui.Label("Arm ")) e3a.td(gui.Label(""), height=29, width=20) e3.td(e3a, align=-1) e3.tr() e3b = gui.Table() e3b.tr() e3b.td(gui.Label("Status: "), height=29, align=-1) ctLbl = gui.Input(size=15) e3b.td(ctLbl) e3.td(e3b, align=-1) e3.tr() ctButton1 = gui.Button("Operate") e3.td(ctButton1, height=29, align=-1) e.td(e3, height=120, align=-1) #put it together. Main.tr() Main.td(n, colspan=3) Main.tr() Main.td(gui.Label(""), height=30) Main.tr() Main.td(w, valign=-1) Main.td(c, valign=-1) Main.td(e, valign=-1) Main.tr() Main.td(gui.Label(""), height=30) app.init(Main) #Main is main tabel.
def __init__(self, noise_model, noise_value, rand_under): title = gui.Label("Simulation Preferences") ##Once a form is created, all the widgets that are added with a name ##are added to that form. ##:: self.value = gui.Form() self.noise = [0, 0, 5, 5] self.noise[noise_model] = noise_value self.prev_noise_model = noise_model t = gui.Table() t.tr() t.td(gui.Spacer(width=8, height=8)) t.tr() t.td(gui.Label("IR Sensor Noise", align=0)) t.tr() g = gui.Group(name="irnoise", value=noise_model) tt = gui.Table() g.connect(gui.CHANGE, self.switch_noise, (tt, g)) tt.tr() radio0 = gui.Radio(g, value=NO_NOISE) tt.td(radio0) tt.td(gui.Label(" None"), align=-1, width=300, colspan=3) tt.tr() radio2 = gui.Radio(g, value=SAMPLED_NOISE) tt.td(radio2) tt.td(gui.Label(" Sampled"), align=-1, width=300, colspan=3) tt.tr() radio3 = gui.Radio(g, value=GAUSSIAN_NOISE) tt.td(radio3) tt.td(gui.Label(" Gaussian"), align=-1) self.noise_slider1 = gui.HSlider(name="noise1", value=self.noise[GAUSSIAN_NOISE], min=1, max=9, size=20, width=80, height=16) self.noise_label1 = gui.Label("Noise Level " + str(self.noise_slider1.value)) self.noise_slider1.connect( gui.CHANGE, self.adjust_noise, (self.noise_slider1, self.noise_label1, GAUSSIAN_NOISE)) if noise_model == GAUSSIAN_NOISE: tt.add(self.noise_slider1, 2, 2) tt.add(self.noise_label1, 3, 2) tt.tr() radio4 = gui.Radio(g, value=ANGULAR_NOISE) tt.td(radio4) tt.td(gui.Label(" Angular"), align=-1) self.noise_slider2 = gui.HSlider(name="noise2", value=self.noise[ANGULAR_NOISE], min=1, max=9, size=20, width=80, height=16) self.noise_label2 = gui.Label("Noise Level " + str(self.noise_slider2.value)) self.noise_slider2.connect( gui.CHANGE, self.adjust_noise, (self.noise_slider2, self.noise_label2, ANGULAR_NOISE)) if noise_model == ANGULAR_NOISE: tt.add(self.noise_slider2, 2, 3) tt.add(self.noise_label2, 3, 3) t.td(tt, colspan=1) tt = gui.Table() tt.tr() tt.td(gui.Label("Extra Sensor Options"), colspan=2) tt.tr() tt.td(gui.Spacer(width=8, height=8)) tt.tr() tt.td(gui.Switch(name="randunder", value=rand_under)) tt.td(gui.Label(" Random under-reads")) tt.tr() tt.td(gui.Spacer(width=8, height=40)) t.td(tt, colspan=1) t.tr() t.td(gui.Spacer(width=8, height=8)) ##The okay button CLICK event is connected to the Dialog's ##send event method. It will send a gui.CHANGE event. ##:: t.tr() e = gui.Button("Okay") e.connect(gui.CLICK, self.send, gui.CHANGE) t.td(e) ## e = gui.Button("Cancel") e.connect(gui.CLICK, self.close, None) t.td(e) gui.Dialog.__init__(self, title, t)
def draw_gui_kinect(title, index, lo, x, y): title = gui.Label(title, font=fontBig) lo.add(title, x, y) w = widgets[index] radio_device_table = gui.Table() w['radio_device_group'] = gui.Group() w['radio_device_eras1'] = gui.Radio(w['radio_device_group'], 1) w['radio_device_eras2'] = gui.Radio(w['radio_device_group'], 2) w['radio_device_eras3'] = gui.Radio(w['radio_device_group'], 3) w['radio_device_eras4'] = gui.Radio(w['radio_device_group'], 4) w['radio_device_group'].connect(gui.CHANGE, activate_button_start_tango, index) w['radio_device_eras1_lbl'] = gui.Label(" eras-1 ", font=fontSub) w['radio_device_eras2_lbl'] = gui.Label(" eras-2 ", font=fontSub) w['radio_device_eras3_lbl'] = gui.Label(" eras-3 ", font=fontSub) w['radio_device_eras4_lbl'] = gui.Label(" eras-4 ", font=fontSub) radio_device_table.tr() radio_device_table.td(w['radio_device_eras1']) radio_device_table.td(w['radio_device_eras1_lbl']) radio_device_table.tr() radio_device_table.td(w['radio_device_eras2']) radio_device_table.td(w['radio_device_eras2_lbl']) radio_device_table.tr() radio_device_table.td(w['radio_device_eras3']) radio_device_table.td(w['radio_device_eras3_lbl']) radio_device_table.tr() radio_device_table.td(w['radio_device_eras4']) radio_device_table.td(w['radio_device_eras4_lbl']) lo.add(radio_device_table, x, y + 22) w['button_start_tango'] = gui.Button("Start", font=fontSub) w['button_start_tango'].connect(gui.CLICK, start_tango, index) lo.add(w['button_start_tango'], x, y + 95) table_display_depth_skeleton = gui.Table() w['cb_display_depth'] = gui.Switch(display_depth[index]) w['cb_display_depth'].connect(gui.CHANGE, toggle_display_depth, index) w['label_display_depth'] = gui.Label("depth", align=-1, font=fontSub) table_display_depth_skeleton.tr() table_display_depth_skeleton.td(w['cb_display_depth']) table_display_depth_skeleton.td(w['label_display_depth']) w['cb_display_skeleton'] = gui.Switch(display_skeleton[index]) w['cb_display_skeleton'].connect(gui.CHANGE, toggle_display_skeleton, index) w['label_display_skeleton'] = gui.Label("skeleton", align=-1, font=fontSub) table_display_depth_skeleton.tr() table_display_depth_skeleton.td(w['cb_display_skeleton']) table_display_depth_skeleton.td(w['label_display_skeleton']) lo.add(table_display_depth_skeleton, x, y + 120) w['device_slider'] = gui.VSlider(value=0, min=-27, max=27, size=32, width=16, height=220) w['device_slider'].connect(pygame.locals.MOUSEBUTTONUP, change_tilt, index) lo.add(w['device_slider'], x + 75, y + 20) lo.add(img_device[index], x + 95, y) lo.add(img_device_skeleton[index], x + 95, y) toggle_kinect_manager_gui(index)
def make_gui(): global pb, font, textArea, lines font = pygame.font.SysFont("default", 18) fontBig = pygame.font.SysFont("default", 24) fontSub = pygame.font.SysFont("default", 20) theme = pgui.Theme('test_theme') # create GUI object gui = pgui.App(theme=theme) textArea = pygame.Rect(390, 20, 250, 320) # layout using document lo = pgui.Container(width=screenSize[0]) # create page label # lo.block(align=-1) #lo.br(8) #lo.tr() title = pgui.Label("Pygame GUI Test Page - PGU", font=fontBig) lo.add(title, 29, 13) # create progress bar label # progress bar pbl = pgui.Label('Progress Bar') lo.add(pbl, 354, 351) pb = pgui.ProgressBar(10, 0, 100, width=200) lo.add(pb, 354, 371) # create checkbuttons and add to gui cbt = pgui.Table() cb1 = pgui.Switch() cb1.connect(pgui.CHANGE, logCheckAction, (cb1, "Check Box 1")) cb1l = pgui.Label("Check Box 1") cbt.add(cb1) cbt.add(cb1l) cbt.tr() cb2 = pgui.Switch() cb2.connect(pgui.CHANGE, logCheckAction, (cb2, "Check Box 2")) cb2l = pgui.Label("Check Box 2") cbt.add(cb2) cbt.add(cb2l) cbt.tr() cb3 = pgui.Switch() cb3.connect(pgui.CHANGE, logCheckAction, (cb3, "Check Box 3")) cb3l = pgui.Label("Check Box 3") cbt.add(cb3) cbt.add(cb3l) lo.add(cbt, 52, 52) # create radio buttons, put in table, and add to gui rbt = pgui.Table() radio = pgui.Group() rb1 = pgui.Radio(radio, 1) rb1l = pgui.Label("Radio Button 1") rbt.add(rb1) rbt.add(rb1l) rbt.tr() rb2 = pgui.Radio(radio, 2) rb2l = pgui.Label("Radio Button 2") rbt.add(rb2) rbt.add(rb2l) rbt.tr() rb3 = pgui.Radio(radio, 3) rb3l = pgui.Label("Radio Button 3") rbt.add(rb3) rbt.add(rb3l) rbt.tr() lo.add(rbt, 210, 52) radio.connect(pgui.CHANGE, logRadioAction, (radio, "Radio Button 3")) # create txt box label txtl = pgui.Label("Text Box", font=fontSub) lo.add(txtl, 30, 127) # create text box txt = pgui.Input("next line of input", size=40) txt.connect(pgui.BLUR, logInputAction, txt) lo.add(txt, 28, 149) # add buttons, both regular and toggle btn1 = pgui.Button("Button 1") btn1.connect(pgui.CLICK, logButtonAction, ("Button 1 clicked")) lo.add(btn1, 36, 250) btn2 = pgui.Button("Button 2") btn2.connect(pgui.CLICK, logButtonAction, ("Button 2 clicked")) lo.add(btn2, 133, 250) btn3 = pgui.Button("Button 3") btn3.connect(pgui.CLICK, logButtonAction, ("Button 3 clicked")) lo.add(btn3, 230, 250) # create toggle button not avail label tbl = pgui.Label("Toggle Buttons Not Supported") lo.add(tbl, 36, 290) img = pgui.Image("clear.png") img.connect(pgui.CLICK, logImg) # iml = pgui.Label("Image Map Not Supported") lo.add(img, 36, 340) # create slider label sll = pgui.Label("Slider", font=fontSub) lo.add(sll, 36, 195) # create slider sl = pgui.HSlider(value=1, min=0, max=100, size=32, width=200, height=16) sl.connect(pgui.CHANGE, logSliderAction, sl) lo.add(sl, 53, 210) # , colspan=3) # make some insensitive btn2.disabled = True cb3.disabled = True # clear setup noise, and put initial content in lines = [] lines.append('top line of input') lines.append('second line of input') progBar(pb, lines) # update progress bar for above two items gui.init(lo) return gui
c.td(gui.Switch(False), colspan=3) c.tr() c.td(gui.Label("Checkbox")) ##Note how Groups are used for Radio buttons, Checkboxes, and Tools. ##:: g = gui.Group(value=[1, 3]) c.td(gui.Checkbox(g, value=1)) c.td(gui.Checkbox(g, value=2)) c.td(gui.Checkbox(g, value=3)) ## c.tr() c.td(gui.Label("Radio")) g = gui.Group() c.td(gui.Radio(g, value=1)) c.td(gui.Radio(g, value=2)) c.td(gui.Radio(g, value=3)) c.tr() c.td(gui.Label("Select")) e = gui.Select() e.add("Goat", 'goat') e.add("Horse", 'horse') e.add("Dog", 'dog') e.add("Pig", 'pig') c.td(e, colspan=3) c.tr() c.td(gui.Label("Tool")) g = gui.Group(value='b')
def __init__(self, pSize, pApp, pDefCfg): tbl = gui.Table(width=pSize['w'], height=pSize['c_h']) ## tilt g = gui.Group() tbl2 = gui.Table() tbl2.tr() tbl2.td(gui.Label(_('Tilt / Z Correction')), colspan=2) tbl2.tr() tbl2.td(gui.Radio(g, value='off')) tbl2.td(gui.Label(_('Off'))) tbl2.tr() tbl2.td(gui.Radio(g, value='intelligent')) tbl2.td(gui.Label(_('Intelligent'))) tbl2.tr() tbl2.td(gui.Radio(g, value='continuous')) tbl2.td(gui.Label(_('Continuous'))) self.tiltGrp = g tiltTbl = gui.Table(width=pSize['w']/5) tiltTbl.tr() tiltTbl.td(tbl2, style={'border':1}) ## recoil recoilTbl = gui.Table(width=pSize['w']/3) recoilTbl.tr() recoilTbl.td(gui.Label(_('Recoil'))) self.recoilSl = gui.HSlider(value=0, min=0, max=250, size=25, step=10, width=pSize['s_w'], height=pSize['s_h']) recoilTbl.td(self.recoilSl) button = gui.Button(_('Test')) button.connect(gui.CLICK, pApp.recoil, None) self._testBtn = button recoilTbl.td(button) ## IR gain irTbl = gui.Table(width=pSize['w']/3) irTbl.tr() irTbl.td(gui.Label(_('IR Gain'))) self.irGainSl = gui.HSlider(value=1, min=1, max=5, size=10, width=pSize['s_w'], height=pSize['s_h']) irTbl.td(self.irGainSl) txt = gui.Input(size=5) self.irGainSl.connect(gui.CHANGE, _slChange, (self.irGainSl, txt)) txt.focusable = False self.irGainSl.send(gui.CHANGE) irTbl.td(txt) ### disable auto gain irTbl.tr() irTbl.td(gui.Spacer(10,5)) irTbl.tr() chkbox = gui.Switch() chkbox.connect(gui.CLICK, _ckbClicked, (chkbox, self.irGainSl)) irTbl.td(chkbox) irTbl.td(gui.Label(_('Disable Auto Gain')), colspan=2, align=-1) self.autoGainSw = chkbox ## device ID devTbl = gui.Table(width=pSize['w']/4) devTbl.tr() devTbl.td(gui.Label(_('Device ID:'))) self.devIdSlt = gui.Select() for x in xrange(0x1601,0x1609): self.devIdSlt.add('0x%x' % x, x) devTbl.td(self.devIdSlt) ## button assignments btnTbl = gui.Table() btnTbl.tr() btnTbl.td(gui.Label(_('Button Assignments')), colspan=5) btnTbl.tr() btnTbl.td(gui.Spacer(20,20)) btnTbl.tr() btnTbl.td(gui.Label("")) btnTbl.td(gui.Label(_('On Screen')+" ")) btnTbl.td(gui.Label(_('Enable Cal')+" ")) btnTbl.td(gui.Label(_('Off Screen')+" ")) btnTbl.td(gui.Label(_('Enable Cal')+" ")) btnTbl.tr() btnTbl.td(gui.Spacer(10,5)) ### TRIG btnTbl.tr() btnTbl.td(gui.Label(_('TRIG')+" ")) self.onActTrigSlt, self.onCalTrigCb = _buildSltCb(btnTbl) self.offActTrigSlt, self.offCalTrigCb = _buildSltCb(btnTbl) ### LEFT btnTbl.tr() btnTbl.td(gui.Label(_('LEFT')+" ")) self.onActLeftSlt, self.onCalLeftCb = _buildSltCb(btnTbl) self.offActLeftSlt, self.offCalLeftCb = _buildSltCb(btnTbl) ### RIGHT btnTbl.tr() btnTbl.td(gui.Label(_('RIGHT')+" ")) self.onActRightSlt, self.onCalRightCb = _buildSltCb(btnTbl) self.offActRightSlt, self.offCalRightCb = _buildSltCb(btnTbl) ## Cal Delay calTbl = gui.Table(width=pSize['w']/4) calTbl.tr() calTbl.td(gui.Label(_('Cal Delay (Secs)'))) self.calDlSl = gui.HSlider(value="3", min=3, max=10, size=10, width=pSize['s_w'], height=pSize['s_h']) calTbl.td(gui.Spacer(10,5)) calTbl.td(self.calDlSl) txt = gui.Input(size=5) self.calDlSl.connect(gui.CHANGE, _slChange, (self.calDlSl, txt)) txt.focusable = False self.calDlSl.send(gui.CHANGE) calTbl.td(gui.Spacer(10,5)) calTbl.td(txt) ## joystick / mouse self.mjGrp = gui.Group() jtkTbl = gui.Table(width=pSize['w']/3) jtkTbl.tr() rad = gui.Radio(self.mjGrp, value='joystick') rad.connect(gui.CLICK, self._changeDevType, True) jtkTbl.td(rad) jtkTbl.td(gui.Label(_('Emulate Joystick'))) rad = gui.Radio(self.mjGrp, value='mouse') rad.connect(gui.CLICK, self._changeDevType, False) jtkTbl.td(rad) jtkTbl.td(gui.Label(_('Emulate Mouse'))) self._curSel = None ## button save saveBtn = gui.Button(_('Save Configuration')) saveBtn.connect(gui.CLICK, pApp.save, None) self._saveBtn = saveBtn dcntBtn = gui.Button(_('Disconnect')) dcntBtn.connect(gui.CLICK, pApp.disconnect, None) ## button set defaults defBtn = gui.Button(_('Set Defaults')) defBtn.connect(gui.CLICK, self.setConfig, pDefCfg) # assemble window tbl.tr() tbl.td(tiltTbl) tbl.td(btnTbl) tbl.tr() tbl.td(recoilTbl) tbl.td(calTbl) tbl.tr() tbl.td(irTbl) tbl.td(jtkTbl) tbl.tr() tbl.td(devTbl) tbl.tr() tbl.td(defBtn) tbl.td(saveBtn) tbl.tr() tbl.td(dcntBtn, colspan=2) # Configuration self.widget = tbl
def __init__(self, **params): gui.Table.__init__(self, **params) fg = (0, 255, 255) #self.value = 'pp' #self.tr() #self.tt = gui.Label(value = self.value,color=fg, name='gg') #self.td(self.tt,colspan=2) self.tr() self.td(gui.Label("alpha: ", color=fg), align=-1) slider = gui.HSlider(1, 0, 100, size=20, width=100, height=16, name='alphaSlider') label = gui.Input(value=slider.value / 100.0, size=5, name='alphaLabel') slider.connect(gui.CHANGE, self.slideChange, label.name, slider, 100.0) self.td(label, align=1) self.td(slider, colspan=2) self.tr() self.td(gui.Label("gamma: ", color=fg), align=-1) slider = gui.HSlider(90, 0, 100, size=20, width=100, height=16, name='gammaSlider') label = gui.Input(value=slider.value / 100.0, size=5, name='gammaLabel') slider.connect(gui.CHANGE, self.slideChange, label.name, slider, 100.0) self.td(label, align=1) self.td(slider, colspan=2) self.tr() self.td(gui.Label("epsilon: ", color=fg), align=-1) slider = gui.HSlider(10, 0, 100, size=20, width=100, height=16, name='epsilonSlider') label = gui.Input(value=slider.value / 100.0, size=5, name='epsilonLabel') slider.connect(gui.CHANGE, self.slideChange, label.name, slider, 100.0) self.td(label, align=1) self.td(slider, colspan=2) self.tr() self.td(gui.Label("fps: ", color=fg), align=-1) slider = gui.HSlider(5, 1, 500, size=20, width=100, height=16, name='fpsSlider') label = gui.Input(value=slider.value, size=5, name='fpsLabel') slider.connect(gui.CHANGE, self.slideChange, label.name, slider, 1) self.td(label, align=1) self.td(slider, colspan=2) self.tr() self.td(gui.Label("# step: ", color=fg), align=-1) label = gui.Input(value=0, size=10, name='stepLabel') self.td(label, align=1) self.tr() self.td(gui.Label("# episode: ", color=fg), align=-1) label = gui.Input(value=0, size=10, name='episodeLabel') self.td(label, align=1) self.tr() self.td(gui.Label("# rewards: ", color=fg), align=-1) label = gui.Input(value=0, size=10, name='rewardLabel') self.td(label, align=1) self.tr() start = gui.Button("Start") start.connect(gui.CLICK, self.start) self.td(start) stop = gui.Button("Stop") stop.connect(gui.CLICK, self.stop) self.td(stop) self.tr() button = gui.Button("Load") button.connect(gui.CLICK, self.load) self.td(button) button = gui.Button("Save") button.connect(gui.CLICK, self.save) self.td(button) self.tr() self.td(gui.Label("Player: ", color=fg), align=-1) self.tr() g = gui.Group(name='player_type', value='SARSA') self.td(gui.Label(" SARSA: ", color=fg), align=-1) r = gui.Radio(g, value='SARSA') r.connect(gui.CLICK, self.changePlayer, r.value) self.td(r) #self.tr() #self.td(gui.Label(" Q_Learning: ",color=fg),align=-1) #r = gui.Radio(g,value='Q_Learning') #r.connect(gui.CLICK, self.changePlayer, r.value) #self.td(r) self.tr() self.td(gui.Label(" Human: ", color=fg), align=-1) r = gui.Radio(g, value='Human') r.connect(gui.CLICK, self.changePlayer, r.value) self.td(r)
def run(self): """Run the item""" # Initialize the item self.set_item_onset() self.sri = self.time() self.experiment.set("response", None) self.experiment.set("response_time", None) # Create the app self.app = gui.Desktop(item=self) self.app.connect(gui.QUIT, self.app.quit, None) # Create a list of choices choices = [] for choice in self.get("choices").split(";"): choices.append(self.experiment.unsanitize(choice)) pad = 0 # The maximum line length, used to pad the options # Create an HTML document for the content doc = html.HTML("") for l in self.experiment.unsanitize(self.get("question")).split("\n"): doc.add(gui.Label(l)) pad = max(pad, len(l)) doc.br(0) # Determine the colspan if self.get("orientation") == "vertical": span = 2 else: span = len(choices) # Create a 2-column table, start with the HTML on the first row c = gui.Table() c.tr() c.td(doc, colspan=span, align=-1) # A group for the responses group = gui.Group() if self.get("orientation") == "vertical": # In the vertical orientation each choice is in a row for option in choices: l = gui.Label(option.ljust(pad)) if self.get("allow_multiple") == "no": r = gui.Radio(group, value=option) else: r = gui.Checkbox(group, value=option) r.connect(gui.CLICK, self.set_response, option) c.tr() c.td(r, align=-1, width=32, height=32) c.td(l, align=-1, height=32) else: # In the horizontal orientation each choise is in a column # First a row with labels c.tr() for option in choices: l = gui.Label(option) c.td(l, align=-1, height=32) # Next a row with response buttons c.tr() for option in choices: if self.get("allow_multiple") == "no": r = gui.Radio(group, value=option) else: r = gui.Checkbox(group, value=option) r.connect(gui.CLICK, self.set_response, option) c.td(r, align=-1, width=32, height=32) # Add the accept button, if necessary if self.get("accept_on_click") == "no": c.tr() e = gui.Button(self.get("accept_text")) e.connect(gui.CLICK, self.app.quit, None) c.td(e, colspan=span, align=-1, height=32, valign=1) # Keep running the app until a response has been received while True: self.app.run(c) if self.get("response") != "None" or self.get("allow_empty") == "yes": break # Return success return True
def __init__(self,**params): title = gui.Label("New Picture...") ##Once a form is created, all the widgets that are added with a name ##are added to that form. ##:: self.value = gui.Form() t = gui.Table() t.tr() t.td(gui.Label("Size"),align=0,colspan=2) tt = gui.Table() tt.tr() tt.td(gui.Label("Width: "),align=1) tt.td(gui.Input(name="width",value=256,size=4)) tt.tr() tt.td(gui.Label("Height: "),align=1) tt.td(gui.Input(name="height",value=256,size=4)) t.tr() t.td(tt,colspan=2) ## t.tr() t.td(gui.Spacer(width=8,height=8)) t.tr() t.td(gui.Label("Format",align=0)) t.td(gui.Label("Background",align=0)) t.tr() g = gui.Group(name="format",value="rgb") tt = gui.Table() tt.tr() tt.td(gui.Radio(g,value="rgb")) tt.td(gui.Label(" RGB"),align=-1) tt.tr() tt.td(gui.Radio(g,value="bw")) tt.td(gui.Label(" Grayscale"),align=-1) t.td(tt,colspan=1) g = gui.Group(name="color",value="#ffffff") tt = gui.Table() tt.tr() tt.td(gui.Radio(g,value="#000000")) tt.td(gui.Label(" Black"),align=-1) tt.tr() tt.td(gui.Radio(g,value="#ffffff")) tt.td(gui.Label(" White"),align=-1) tt.tr() default = "#ffffff" radio = gui.Radio(g,value="custom") color = gui.Color(default,width=40,height=16,name="custom") picker = ColorDialog(default) color.connect(gui.CLICK,gui.action_open,{'container':t,'window':picker}) picker.connect(gui.CHANGE,gui.action_setvalue,(picker,color)) tt.td(radio) tt.td(color) t.td(tt,colspan=1) t.tr() t.td(gui.Spacer(width=8,height=8)) ##The okay button CLICK event is connected to the Dailog's ##send event method. It will send a gui.CHANGE event. ##:: t.tr() e = gui.Button("Okay") e.connect(gui.CLICK,self.send,gui.CHANGE) t.td(e) ## e = gui.Button("Cancel") e.connect(gui.CLICK,self.close,None) t.td(e) gui.Dialog.__init__(self,title,t)
import my_gui gui = pgui.App() lo = pgui.Container(width=1920, height=1080) img = my_gui.InfoBlock() img.add_to_gui(lo) import my_gui p = my_gui.Box(system.system) p.position = 100, 100 p.add_to_gui(lo) p.update() container = pgui.Container(width=300, height=100) container.focusable = False gah = pgui.Group() radio_button = pgui.Radio(gah, 'Blue') radio_button_2 = pgui.Radio(gah, 'Red') radio_button_3 = pgui.Radio(gah, 'Yellow Mofof') radio_button.focusable = False radio_button_2.focusable = False radio_button_3.focusable = False container.add(radio_button, 100, 100) container.add(radio_button_2, 200, 100) container.add(radio_button_3, 300, 100) container.focus(radio_button_3) lo.add(container, 0, 0) def change_visiblity(value): print(value.value) print("yolo")