def __init__(self, bckg = "None"): self.bckg = bckg title = gui.Label("Set background") self.value = gui.Form() self.container = gui.Container() table = gui.Table() table.tr() table.td(self.build_background_select(), style={'padding_top': 10, 'padding_bottom': 10}) save = gui.Button('Save') save.connect(gui.CLICK, self.send, gui.CHANGE) table.tr() table.td(save, align=1) save_config = gui.Button('Save current configuration') save_config.connect(gui.CLICK, self.file_dialog_open, SAVE_CONFIG_EVENT) load_config = gui.Button('Load robot\'s configuration') load_config.connect(gui.CLICK, self.file_dialog_open, LOAD_CONFIG_EVENT) table.tr() table.td(save_config) table.tr() table.td(load_config) self.container.add(table, 0, 0) gui.Dialog.__init__(self, title, self.container)
def draw(self): if self.icon: self.iconButton = gui.Button(icons.icon(self.icon, 20, color="rgb(68, 115, 158)"), cls=self.btn_cls, height=20, width=36) else: self.iconButton = gui.Button(" ", cls=self.btn_cls, height=20, width=36) self.state = sensorValue(self.api, self.entity, cls=self.sw_cls, height=20) stateWidth = self.state._value.style.width + self.state.style.padding_left + self.state.style.padding_right self.sensorName = Light(self.api, self.entity, cls=self.btn_cls, width=(self.sensorName_width - stateWidth), height=20) self.widget.add(self.iconButton, 0, 0) self.widget.add(self.sensorName, 36, 0) print(("Width state = {}".format(str(self.state._value.style.width)))) self.widget.add(self.state, self.width - stateWidth, 0) return self.widget
def __init__(self, **params): gui.Table.__init__(self, **params) self.value = gui.Form() self.engine = None def btnLogin(btn): self.engine.doLogin() def btnRegister(btn): g.gameState = MENU_REGISTER if g.tcpConn is None: g.gameEngine.initConnection() self.tr() self.td(gui.Input(name="username", value="Username")) self.tr() self.td(gui.Password(name="password", value="password")) self.tr() self.td(gui.Spacer(0, 30)) self.tr() btn = gui.Button("Login", width=120) btn.connect(gui.CLICK, btnLogin, None) self.td(btn) self.tr() self.td(gui.Spacer(0, 5)) self.tr() btn = gui.Button("Register", width=120) btn.connect(gui.CLICK, btnRegister, None) self.td(btn)
def __init__(self,**params): gui.Table.__init__(self,**params) fg = (255,0,255) fga = (255,25,0) self.diflevel=0 self.styleset=0 self.selectedm=gameState.gameBegin fonts=pygame.font.Font('data/shaonv.ttf', 30) fonts.set_bold(True) self.tr() self.td(gui.Label(u"主 菜 单",color=fg,font=fonts),align=0) self.tr() bv=gui.Label(u"开始游戏",color=fga,font=psubfts) bt1=gui.Button(bv,width=150,height=30) bt1.connect(gui.CLICK,self.EnterMenu,0) self.td(bt1,align=0,height=50) self.optiond=OptionDialog() self.optiond.connect(gui.CHANGE,self.onchange,self.optiond.value) self.tr() bv=gui.Label(u"游戏设置",color=fga,font=psubfts) bt2=gui.Button(bv,width=150,height=30) bt2.connect(gui.CLICK,self.EnterMenu,1) self.td(bt2, align=0,height=50) self.tr() bv=gui.Label(u"退出游戏",color=fga,font=psubfts) bt3=gui.Button(bv,width=150,height=30) bt3.connect(gui.CLICK,self.EnterMenu,2) self.td(bt3, align=0,height=50)
def __init__(self, inputfield, **params): self.inpField = inputfield self._count = 1 title = gui.Label("Map Selector") t = gui.Table() t.tr() t.td(gui.Label('Select a map:'), colspan=2) t.tr() t.td(gui.Spacer(10, 20)) t.tr() self.mapList = gui.List(width=200, height=140) t.td(self.mapList, colspan=2) t.tr() t.td(gui.Spacer(10, 20)) t.tr() e = gui.Button('Choose map') e.connect(gui.CLICK, self.setInput, None) t.td(e) e = gui.Button('Cancel') e.connect(gui.CLICK, self.close, None) t.td(e) t.tr() t.td(gui.Spacer(10, 10)) gui.Dialog.__init__(self, title, t)
def __init__(self, engine, **params): gui.Container.__init__(self, **params) self.engine = engine # menu title self.tTitle = gui.Table(width=272, height=32) # navigation self.tBottom = gui.Table(width=272, height=200) self.tBottom.tr() e = gui.Button(_("Stats"), width=100, height=40) e.connect(gui.CLICK, self.toggleStats, None) self.tBottom.td(e) e = gui.Button(_("Inventory"), width=100, height=40) e.connect(gui.CLICK, self.toggleInventory, None) self.tBottom.td(e) self.tBottom.tr() e = gui.Button(_('Spellbook'), width=100, height=40) e.connect(gui.CLICK, self.toggleSpellbook, None) self.tBottom.td(e, colspan=2) self.tBottom.tr() e = gui.Button(_('Settings'), width=100, height=40) e.connect(gui.CLICK, self.toggleSettings, None) self.tBottom.td(e, colspan=2) self.add(self.tTitle, 0, 0) self.add(self.tBottom, 0, 368)
def draw(self): if self.icon: self.iconButton = gui.Button(icons.icon(self.icon, 20, color="rgb(68, 115, 158)"), cls=self.btn_cls, height=20, width=36) else: self.iconButton = gui.Button(" ", cls=self.btn_cls, height=20, width=36) self.light = Light(self.api, self.entity, cls=self.btn_cls, width=238, height=20) if self.entity.state != "unknown": self.switch = LightSwitch(self.api, self.entity, cls=self.sw_cls) else: self.switch = gui.Button("", cls=self.btn_cls, width=20, height=20) self.widget.add(self.iconButton, 0, 0) self.widget.add(self.light, 36, 0) self.widget.add(self.switch, self.width - 36, 0) return self.widget
def __init__(self, **params): title = gui.Label(_("Exit Game")) t = gui.Table() t.tr() t.td(gui.Label(_("Are you sure you want to quit?")), colspan=2) t.tr() t.td(gui.Spacer(10, 20)) def btnQuit(value): g.gameEngine.quitGame() t.tr() e = gui.Button(_("Quit")) e.connect(gui.CLICK, btnQuit, None) t.td(e) e = gui.Button(_("Cancel")) e.connect(gui.CLICK, self.close, None) t.td(e) t.tr() t.td(gui.Spacer(10, 10)) gui.Dialog.__init__(self, title, t)
def genEsCard(face_sta): if face_sta == params.FACE_UP: vcard = gui.Button("ES Card", width=75, height=95, name='EsButton') else: vcard = gui.Button(" ", width=75, height=95, name='EsButton') return vcard
def __init__(self, engine, **params): gui.Container.__init__(self, **params) self.engine = engine self.value = gui.Form() # item editor state self.itemNum = None # dialogs # menu title self.tTitle = gui.Table(width=272, height=32) self.tTitle.tr() self.tTitle.td(gui.Label("NPC Editor", name='npcTitle', color=UI_FONT_COLOR)) # content self.tContent = gui.Table(width=272, height=123) self.tContent.tr() self.tContent.tr() self.tContent.td(gui.Label('Name:', color=UI_FONT_COLOR), colspan=2) self.tContent.tr() self.tContent.td(gui.Input('', size=26, name='inpNpcName'), colspan=2, valign=-1) self.tContent.tr() self.tContent.td(gui.Label('Behaviour:', color=UI_FONT_COLOR), colspan=2) self.tContent.tr() e = gui.Select(name='selBehaviour') e.add('Attack on sight', 0) e.add('Attack when attacked', 1) e.add('Friendly', 2) e.add('Shopkeeper', 3) e.add('Guard', 4) e.value = 0 e.connect(gui.CHANGE, self.updateType, None) self.tContent.td(e, colspan=2) # data input self.tData = gui.Table(width=272, height=75) # bottom buttons self.tBottom = gui.Table(width=272, height=200) self.tBottom.tr() self.saveButton = gui.Button("Add NPC", width=100, height=40) self.saveButton .connect(gui.CLICK, self.saveNPC, None) self.tBottom.td(self.saveButton) e = gui.Button("Cancel", width=100, height=40) e.connect(gui.CLICK, self.cancel, None) self.tBottom.td(e) self.add(self.tTitle, 0, 0) self.add(self.tContent, 0, 100) self.add(self.tData, 0, 255) self.add(self.tBottom, 0, 368)
def __init__(self, level, **params): gui.Document.__init__(self, **params) self.cur_page = 0 self.level = level def done_pressed(): pygame.event.post(constants.GO_MAIN_MENU) def next_page(): self.cur_page += 1 if self.cur_page >= len(HELP): self.cur_page = 0 self.redraw() def prev_page(): self.cur_page -= 1 if self.cur_page < 0: self.cur_page = len(HELP) - 1 self.redraw() self.done_button = gui.Button("Return to Main Menu") self.done_button.connect(gui.CLICK, done_pressed) self.prev_button = gui.Button("Prev Page") self.prev_button.connect(gui.CLICK, prev_page) self.next_button = gui.Button("Next Page") self.next_button.connect(gui.CLICK, next_page) self.redraw()
def __init__(self, player): super().__init__( 'Playing Window for %s' % player.name, Size(700, 120), ) self._cards = [] self._EsUsed = [] self._selectedItem = None # crate a group of cards for selection self._cardsGroup = gui.Group(name='cardsGroup', value=None) self._cardsTable = gui.Table() self._esCardButton = gui.Button( ) # it's an Emergency Stop card, just show it as a button # create a confirm button for the human player to confirm his/her selection confirmButton = gui.Button("Confirm") def onConfirm(self): if self._cardsGroup.value is not None: self._selectedItem = self._cardsGroup.value self._confirm.play() self.getContainer().remove(self._cardsTable) self.getContainer().remove(self._esCardButton) confirmButton.connect(gui.CLICK, onConfirm, self) # add confirm button to container self.getContainer().add(confirmButton, 380, 120)
def __init__(self, engine, **params): self.engine = engine self._count = 0 title = gui.Label("Open Item") t = gui.Table() t.tr() t.td(gui.Label('Select an item:'), colspan=2) t.tr() t.td(gui.Spacer(10, 20)) t.tr() self.itemList = gui.List(width=200, height=140) t.td(self.itemList, colspan=2) t.tr() t.td(gui.Spacer(10, 20)) t.tr() e = gui.Button('Open item') e.connect(gui.CLICK, self.openItem, None) t.td(e) e = gui.Button('Cancel') e.connect(gui.CLICK, self.close, None) t.td(e) t.tr() t.td(gui.Spacer(10, 10)) gui.Dialog.__init__(self, title, t)
def file_treat(): global Window, Frame #TODO Agregar imagen a botones y estilo a fondo third_app = gui.Desktop(screen=Window, area=Frame) third_app.connect(gui.QUIT, third_app.quit, None) third_app.connect(gui.QUIT, app.quit, None) my_container3 = gui.Container(width=670, height=500) #Open button open_btn = gui.Button("Abrir") open_btn.connect(gui.CLICK, open_file_browser, True) #Save button save_btn = gui.Button("Guardar") save_btn.connect(gui.CLICK, open_file_browser, False) #Continue button / close file treatment ok_btn = gui.Button("Listo!") ok_btn.connect(gui.CLICK, third_app.quit, None) ok_btn.connect(gui.CLICK, app.quit, None) #Cancel button cancel_btn = gui.Button("Cancelar") cancel_btn.connect(gui.CLICK, third_app.quit, None) cancel_btn.connect(gui.CLICK, app.quit, None) #Add elements to container my_container3.add( gui.Image(const.imagespath + "Archivo_Background.png"), 0, 0) my_container3.add(open_btn, 155, 330) my_container3.add(save_btn, 455, 330) my_container3.add(ok_btn, 310, 375) my_container3.add(cancel_btn, 580, 10) third_app.run(my_container3) pygame.display.flip()
def __init__(self, **params): gui.Table.__init__(self, **params) self.value = gui.Form() self.engine = None def btnNextChar(btn): self.engine.charIndex += 1 self.engine.updateCharSelection() def btnPrevChar(btn): self.engine.charIndex -= 1 self.engine.updateCharSelection() def btnUseChar(btn): if self.lblPlayerName.value != 'Create a new character': g.tcpConn.sendUseChar(self.engine.charIndex - 1) g.gameState = MENU_INGAME else: # new char g.tcpConn.sendGetClasses() g.gameState = MENU_NEWCHAR def btnDelChar(btn): print "lawl" self.tr() self.lblPlayerName = gui.Label('PLAYER NAME', color=(255, 0, 0)) self.td(self.lblPlayerName, colspan=3, valign=1) self.tr() self.lblPlayerExtra = gui.Label('PLAYER LEVEL/CLASS', color=(255, 0, 0)) self.td(self.lblPlayerExtra, colspan=3) self.tr() btn = gui.Button("Previous", width=160, height=40) btn.connect(gui.CLICK, btnPrevChar, None) self.td(btn) self.td(gui.Spacer(300, 160)) btn = gui.Button("Next", width=160, height=40) btn.connect(gui.CLICK, btnNextChar, None) self.td(btn) self.tr() self.td(gui.Spacer(0, 0)) self.btnSelChar = gui.Button("Use Character", width=160, height=30) self.btnSelChar.connect(gui.CLICK, btnUseChar, None) self.td(self.btnSelChar) self.td(gui.Spacer(0, 0)) self.tr() self.td(gui.Spacer(0, 20)) self.tr() self.td(gui.Spacer(0, 0)) btn = gui.Button("Delete Character", width=160, height=30) btn.connect(gui.CLICK, btnDelChar, None) self.td(btn) self.td(gui.Spacer(0, 0))
def __init__(self, **params): title = gui.Label("Weibo Dict Analysis") container = gui.Container(width=500, height=400) td_style = {"padding_right": 10} ############################ table = gui.Table(width=400, height=300) table.tr() table.td(gui.Label("Dlut", style=td_style, cls="h2")) dut_button = gui.Button("School") dut_button.connect(gui.CLICK, self.show_dict_result, 'dlut') table.td(dut_button, style=td_style) dut_person_button = gui.Button("Person") dut_person_button.connect(gui.CLICK, self.show_dict_person_result, 'dlut') table.td(dut_person_button, style=td_style) table.tr() table.td(gui.Label("Tsinghua", style=td_style, cls="h2")) Tsinghua_button = gui.Button("School") Tsinghua_button.connect(gui.CLICK, self.show_dict_result, 'tsinghua') table.td(Tsinghua_button, style=td_style) Tsinghua_person_button = gui.Button("Person") Tsinghua_person_button.connect(gui.CLICK, self.show_dict_person_result, 'tsinghua') table.td(Tsinghua_person_button, style=td_style) table.tr() table.td(gui.Label("Peking", style=td_style, cls="h2")) peking_button = gui.Button("School") peking_button.connect(gui.CLICK, self.show_dict_result, 'peking') table.td(peking_button, style=td_style) peking_person_button = gui.Button("Person") peking_person_button.connect(gui.CLICK, self.show_dict_person_result, 'peking') table.td(peking_person_button, style=td_style) table.tr() table.td(gui.Label("Nanking", style=td_style, cls="h2")) naking_button = gui.Button("School") naking_button.connect(gui.CLICK, self.show_dict_result, 'nanking') table.td(naking_button, style=td_style) naking_person_button = gui.Button("Person") naking_person_button.connect(gui.CLICK, self.show_dict_person_result, 'nanking') table.td(naking_person_button, style=td_style) table.tr() table.td(gui.Label("Ecupsl", style=td_style, cls="h2")) ecupsl_button = gui.Button("School") ecupsl_button.connect(gui.CLICK, self.show_dict_result, 'ecupsl') table.td(ecupsl_button, style=td_style) ecupsl_person_button = gui.Button("Person") ecupsl_person_button.connect(gui.CLICK, self.show_dict_person_result, 'ecupsl') table.td(ecupsl_person_button, style=td_style) ############################ container.add(table, 20, 30) gui.Dialog.__init__(self, title, container)
def __init__(self, **params): gui.Table.__init__(self, **params) self.value = gui.Form() self.engine = None def btnNextClass(btn): self.engine.classIndex += 1 self.engine.updateClassSelection() def btnPrevClass(btn): self.engine.classIndex -= 1 self.engine.updateClassSelection() def btnCreateChar(btn): self.engine.createCharacter() def btnCancel(btn): g.gameState = MENU_CHAR self.tr() self.lblCharName = gui.Label(_('Character Name'), color=(255, 255, 255)) self.td(self.lblCharName, colspan=3, valign=1) self.tr() self.inpCharName = gui.Input(name='inpCharName', value='') self.td(self.inpCharName, colspan=3) self.tr() self.lblClassName = gui.Label(_('CLASS NAME'), color=(255, 255, 255)) self.td(self.lblClassName, colspan=3, valign=1) self.tr() btn = gui.Button(_("Previous"), width=160, height=40) btn.connect(gui.CLICK, btnPrevClass, None) self.td(btn) self.td(gui.Spacer(300, 160)) btn = gui.Button(_("Next"), width=160, height=40) btn.connect(gui.CLICK, btnNextClass, None) self.td(btn) self.tr() self.td(gui.Spacer(0, 0)) self.btnSelChar = gui.Button(_("Create Character"), width=160, height=30) self.btnSelChar.connect(gui.CLICK, btnCreateChar, None) self.td(self.btnSelChar) self.td(gui.Spacer(0, 0)) self.tr() self.td(gui.Spacer(0, 20)) self.tr() self.td(gui.Spacer(0, 0)) btn = gui.Button("Cancel", width=160, height=30) btn.connect(gui.CLICK, btnCancel, None) self.td(btn) self.td(gui.Spacer(0, 0))
def __init__(self, engine, **params): gui.Container.__init__(self, **params) self.engine = engine # item editor state self.npcNum = None # menus self.npcGeneralCtrl = NPCGeneralControl(parent=self, name='generalCtrl') self.npcCombatCtrl = NPCCombatControl(name='combatCtrl') self.npcStatsCtrl = NPCStatsControl(name='statsCtrl') # menu title self.tTitle = gui.Table(width=272, height=32) self.tTitle.tr() self.tTitle.td( gui.Label("NPC Editor", name='npcTitle', color=UI_FONT_COLOR)) # buttons self.t = gui.Table(width=272, height=50) e = gui.Button("General", width=70) e.connect(gui.CLICK, self.toggleGeneral, None) self.t.td(e) e = gui.Button("Combat", width=70) e.connect(gui.CLICK, self.toggleCombat, None) self.t.td(e) e = gui.Button("Stats", width=70) e.connect(gui.CLICK, self.toggleStats, None) self.t.td(e) # content self.tContent = gui.Table(width=272, height=123) self.tContent.tr() self.tContent.td(self.npcGeneralCtrl, valign=-1) # bottom buttons self.tBottom = gui.Table(width=272, height=200) self.tBottom.tr() self.saveButton = gui.Button("Add NPC", width=100, height=40) self.saveButton.connect(gui.CLICK, self.saveNPC, None) self.tBottom.td(self.saveButton) e = gui.Button("Cancel", width=100, height=40) e.connect(gui.CLICK, self.cancel, None) self.tBottom.td(e) self.add(self.tTitle, 0, 0) self.add(self.t, 0, 48) self.add(self.tContent, 0, 100) self.add(self.tBottom, 0, 368)
def __init__(self, **params): gui.Table.__init__(self, **params) self.value = gui.Form() self.engine = None def btnNextChar(btn): self.engine.charIndex += 1 self.engine.updateCharSelection() def btnPrevChar(btn): self.engine.charIndex -= 1 self.engine.updateCharSelection() def btnUseChar(btn=None): if self.lblPlayerName.value != 'Empty': g.tcpConn.sendUseChar(self.engine.charIndex-1) g.gameEngine.setState(MENU_INGAME) else: # new char g.tcpConn.sendGetClasses() g.gameEngine.setState(MENU_NEWCHAR) def btnDelChar(btn): print ("not yet implemented") self.tr() self.lblPlayerName = gui.Label('#PLAYER_NAME', antialias=1, color=UI_NAME_FONT_COLOR, font=g.charSelFont) self.td(self.lblPlayerName, colspan=3, valign=1, align=0) self.tr() self.lblPlayerExtra = gui.Label('#PLAYER_LEVEL_CLASS', antialias=1, color=UI_NAME_FONT_COLOR, font=g.charSelFont, name='lblExtra') self.td(self.lblPlayerExtra, colspan=3, align=0) self.tr() btn = gui.Button(_("Previous"), width=160, height=40) btn.connect(gui.CLICK, btnPrevChar, None) self.td(btn) self.td(gui.Spacer(300, 160)) btn = gui.Button(_("Next"), width=160, height=40) btn.connect(gui.CLICK, btnNextChar, None) self.td(btn) self.tr() self.td(gui.Spacer(0, 0)) self.btnSelChar = gui.Button(_("Use Character"), width=160, height=30) self.btnSelChar.connect(gui.CLICK, btnUseChar, None) self.td(self.btnSelChar) self.td(gui.Spacer(0, 0)) self.tr() self.td(gui.Spacer(0, 20)) self.tr() self.td(gui.Spacer(0, 0)) btn = gui.Button(_("Delete Character"), width=160, height=30) btn.connect(gui.CLICK, btnDelChar, None) self.td(btn) self.td(gui.Spacer(0, 0))
def __init__(self, designer): gui.Table.__init__(self) config = designer.config def fullscreen(btn): pygame.display.toggle_fullscreen() def analyse(btn): designer.analyseform = True # TODO: this could/should be custom events def connect(btn): designer.connectform = True def execute(btn): designer.executeform = True def clear(btn): designer.clearform = True fg = config['uicolor'] self.tr() self.td(gui.Label(" DESIGNER ")) td_left = {'padding_left': 25} td_right = {'padding_right': 25} btn = gui.Switch(value=False, name='fullscreen') btn.connect(gui.CHANGE, fullscreen, btn) self.td(gui.Label("full ", color=fg), align=1, style=td_left) self.td(btn, align=-1, style=td_right) td_styleb = { 'padding_left': 5, 'padding_right': 5, 'padding_top': 5, 'padding_bottom': 5 } btn = gui.Button("clear") btn.connect(gui.CLICK, clear, btn) self.td(btn, style=td_styleb) """ btn = gui.Button("analyse") btn.connect(gui.CLICK, analyse, btn) self.td(btn, style=td_styleb) """ btn = gui.Button("connect") btn.connect(gui.CLICK, connect, btn) self.td(btn, style=td_styleb) btn = gui.Button("execute") btn.connect(gui.CLICK, execute, btn) self.td(btn, style=td_styleb)
def __init__(self, surface): self.music = True self.sfx = True self.surface = surface self.bg = pygame.image.load("png/bg.png") self.surface.blit(self.bg, (0, 0)) self.app = gui.App(theme=gui.Theme("data/themes/clean")) self.app.connect(gui.QUIT, self.app.quit, None) self.table = gui.Table(width=self.surface.get_width(), height=self.surface.get_height()) self.table.tr() self.font = pygame.font.Font("font.ttf", 50) self.sfont = pygame.font.Font("font.ttf", 16) self.table.td(gui.Label("Zombie Hordes", font=self.font)) self.table.tr() self.button = gui.Button("Play", width=200, font=self.sfont) self.button.connect(gui.CLICK, self.playgame) self.table.td(self.button) self.quit = gui.Button("Quit", width=200, font=self.sfont) self.quit.connect(gui.CLICK, self.app.quit, None) self.dlg = None def dlo(): self.dlg = TestDialog(self) self.dlg.open() threading.Thread(target=dlc).start() def dlc(): while self.dlg.is_open(): pass self.surface.blit(self.bg, (0, 0)) self.app.repaint() self.options = gui.Button("Options", width=200, font=self.sfont) self.options.connect(gui.CLICK, dlo) self.table.tr() self.table.td(self.options) self.table.tr() self.table.td(self.quit) self.game = None
def __init__(self, tStart, tEnd, tElapsed, **params): gui.Table.__init__(self, **params) self.speed = 1.0 self.t = 0.0 self.paused = False def cb_slider_changed(slider): self.t = slider.value def cb_faster(): self.speed *= 2.0 def cb_slower(): self.speed /= 2.0 def cb_pause(): self.paused = True def cb_play(): self.paused = False fg = (255, 255, 255) self.tr() # first row of buttons: # - pause || # - resume > # - slow down << # - speedup >> # - time slider btn = gui.Button("||") btn.connect(gui.CLICK, cb_pause) self.td(btn) btn = gui.Button(">") btn.connect(gui.CLICK, cb_play) self.td(btn) btn = gui.Button("<<") btn.connect(gui.CLICK, cb_slower) self.td(btn) btn = gui.Button(">>") btn.connect(gui.CLICK, cb_faster) self.td(btn) self.td(gui.Label("")) self.td(gui.Label("")) self.td(gui.Label("")) self.timeslider = gui.HSlider(0.0, 0.0, tElapsed, size=20, width=400, height=16, name='time', colspan=15) self.timeslider.connect(gui.CHANGE, cb_slider_changed, self.timeslider) self.td(self.timeslider) self.app = gui.App() self.app.init(self)
def __init__(self, sim): gui.Table.__init__(self) config = sim.config def fullscreen(btn): pygame.display.toggle_fullscreen() def designer(btn): sim.designerform = True def restart(btn): sim.restartform = True def fps_update(slider): sim.fps = slider.value fg = config['uicolor'] self.tr() self.td(gui.Label(" SIMULATION ")) td_left = {'padding_left': 25} td_right = {'padding_right': 25} btn = gui.Switch(value=False, name='fullscreen') btn.connect(gui.CHANGE, fullscreen, btn) self.td(gui.Label("full ", color=fg), align=1, style=td_left) self.td(btn, align=-1, style=td_right) td_styleb = { 'padding_left': 5, 'padding_right': 5, 'padding_top': 5, 'padding_bottom': 5 } btn = gui.Button("designer") btn.connect(gui.CLICK, designer, btn) self.td(btn, style=td_styleb) btn = gui.Button("restart") btn.connect(gui.CLICK, restart, btn) self.td(btn, style=td_styleb) self.td(gui.Label("FPS:")) slider = gui.HSlider(value=sim.fps, min=25, max=config['fpsmax'], size=20, width=120, name='fps') self.td(slider) slider.connect(gui.CHANGE, fps_update, slider)
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 __init__(self, title_txt, button_txt, allow_new, cls="dialog"): self.value = None self.save_folder = config.config.save_folder self.save_games = {} self._populate_save_games() if allow_new: self.name_input = gui.Input() else: self.name_input = None td_style = { 'padding_left': 4, 'padding_right': 4, 'padding_top': 2, 'padding_bottom': 2, } self.save_list = gui.List(width=350, height=250) games = self.save_games.keys() games.sort() for name in games: self.save_list.add(name, value=name) self.save_list.set_vertical_scroll(0) self.save_list.connect(gui.CHANGE, self._save_list_change) self.image_container = gui.Container() button_ok = gui.Button(button_txt) button_ok.connect(gui.CLICK, self._click_ok) button_cancel = gui.Button("Cancel") button_cancel.connect(gui.CLICK, self._click_cancel) body = gui.Table() body.tr() body.td(self.save_list, style=td_style, colspan=2) body.td(self.image_container, style=td_style, colspan=2) body.tr() if self.name_input: body.td(gui.Label("Save as:"), style=td_style, align=1) body.td(self.name_input, style=td_style) else: body.td(gui.Spacer(0, 0), style=td_style, colspan=2) body.td(button_ok, style=td_style, align=1) body.td(button_cancel, style=td_style, align=1) title = gui.Label(title_txt, cls=cls + ".title.label") gui.Dialog.__init__(self, title, body) if games: self.save_list.group.value = games[0]
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): self.app = app = gui.App() button_send = gui.Button('Send') button_OK = gui.Button('OK') # button_send.connect(gui.CLICK, on_btn_click, 'send') self.rect = pygame.Rect((120, 50, 200, 50)) table = gui.Table() table.tr() table.td(gui.Label("Button: ")) table.td(button_send) table.tr() table.td(gui.Label("Button: ")) table.td(button_OK) app.init(widget=table, screen=screen, area=self.rect)
def setup_menu(self): tbl = gui.Table(vpadding=5, hpadding=2) tbl.tr() dlg = TestDialog() def dialog_cb(): dlg.open() btn = gui.Button("Modal dialog", height=50) btn.connect(gui.CLICK, dialog_cb) tbl.td(btn) # Add a button for pausing / resuming the game clock def pause_cb(): if (self.engine.clock.paused): self.engine.resume() else: self.engine.pause() btn = gui.Button("Pause/resume clock", height=50) btn.connect(gui.CLICK, pause_cb) tbl.td(btn) # Add a slider for adjusting the game clock speed tbl2 = gui.Table() timeLabel = gui.Label("Clock speed") tbl2.tr() tbl2.td(timeLabel) slider = gui.HSlider(value=23, min=0, max=100, size=20, height=16, width=120) def update_speed(): self.engine.clock.set_speed(slider.value / 10.0) slider.connect(gui.CHANGE, update_speed) tbl2.tr() tbl2.td(slider) tbl.td(tbl2) self.menuArea.add(tbl, 0, 0)
def create_button(container, window_size, model, obstacle_ratio=0.2): font = pygame.font.SysFont("default", 30) start_button = pgui.Button("Start A* Search", width=50, height=30, font=font) start_button.connect(pgui.CLICK, start_button_action, model) random_button = pgui.Button("Random walls", width=50, height=30, font=font) random_button.connect(pgui.CLICK, random_button_action, (model, obstacle_ratio)) reset_button = pgui.Button("Reset", width=50, height=30, font=font) reset_button.connect(pgui.CLICK, reset_button_action, model) container.add(start_button, 200, window_size[1] - 45) container.add(random_button, 400, window_size[1] - 45) container.add(reset_button, 600, window_size[1] - 45)
def __init__(self, **params): gui.Table.__init__(self, **params) self.speed = 1.0 self.t = 0.0 self.paused = False self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = 7060 self.ip = "127.0.0.1" def cb_rewind(): self.sock.sendto("REWIND", (self.ip, self.port)) def cb_step_back(): self.sock.sendto("STEP_BACK", (self.ip, self.port)) def cb_pause(): self.sock.sendto("PAUSE", (self.ip, self.port)) def cb_step_forward(): self.sock.sendto("STEP_FORWARD", (self.ip, self.port)) def cb_play(): self.sock.sendto("PLAY", (self.ip, self.port)) self.tr() btn = gui.Button("<<") btn.connect(gui.CLICK, cb_rewind) self.td(btn) btn = gui.Button("<") btn.connect(gui.CLICK, cb_step_back) self.td(btn) btn = gui.Button("||") btn.connect(gui.CLICK, cb_pause) self.td(btn) btn = gui.Button(">") btn.connect(gui.CLICK, cb_step_forward) self.td(btn) btn = gui.Button(">>") btn.connect(gui.CLICK, cb_play) self.td(btn) self.app = gui.App() self.app.init(self)