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 open_dialog(self, widget, x=None, y=None, close_callback=None): """Open a dialog for the given widget. Add close button.""" tbl = gui.Table() def close_dialog(): self.disp.close(tbl) if close_callback is not None: close_callback() close_button = gui.Button("Close") close_button.connect(gui.CLICK, close_dialog) tbl = gui.Table() tbl.tr() tbl.td(widget, colspan=2) tbl.tr() tbl.td(gui.Spacer(100, 0)) tbl.td(close_button, align=1) if x: offset = (self.disp.rect.center[0] + x, self.disp.rect.center[1] + y) else: offset = None self.disp.open(tbl, pos=offset) return tbl
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 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 setup_sliders(self): table = gui.Table() table.tr() table.td(gui.Label('Двигатели:', font=self.font), align=-1) self.left_engine_slider = gui.VSlider(value=0, min=-100, max=100, size=10, width=16, height=200) self.right_engine_slider = gui.VSlider(value=0, min=-100, max=100, size=10, width=16, height=200) table.tr() container = gui.Container() table.td(container) left_input = gui.Input('0', font=self.font, size=4) right_input = gui.Input('0', font=self.font, size=4) def sliders_changed(): left_input.value = str(-self.left_engine_slider.value) right_input.value = str(-self.right_engine_slider.value) self.change_engine_power(-self.left_engine_slider.value, -self.right_engine_slider.value) def inputs_changed(): try: left = int(left_input.value) right = int(right_input.value) if abs(left) <= 100 and abs(right) <= 100: self.left_engine_slider.value = -left self.right_engine_slider.value = -right self.change_engine_power(left, right) except: pass self.left_engine_slider.connect(gui.CHANGE, sliders_changed) self.right_engine_slider.connect(gui.CHANGE, sliders_changed) left_input.connect(gui.KEYDOWN, inputs_changed) right_input.connect(gui.KEYDOWN, inputs_changed) lt = gui.Table(width=35) lt.tr() lt.td(left_input, align=1) gt = gui.Table() gt.tr() gt.td(right_input, align=-1) container.add(left_input, 20, 90) container.add(self.left_engine_slider, 70, 0) container.add(self.right_engine_slider, 120, 0) container.add(right_input, 140, 90) table.tr() table.td(gui.Spacer(height=20, width=0)) return table
def __init__(self, pSize, pApp): tbl = gui.Table(width=pSize['w'], height=pSize['c_h']) # text on the left tbl2 = gui.Table() tbl2.tr() txt = _("To ckeck operation\n" "Aim gun sight at monitor\n" "Move gun within monitor boundary.\n" "Ensure IR point is visible\n" "to the gun when aimed\n" "at all areas of the screen.") lines = txt.split("\n") for line in lines: tbl2.tr() tbl2.td(gui.Label(str(line))) txtTbl = gui.Table(height=pSize['ir_h']) txtTbl.tr() txtTbl.td(tbl2, style={'border':1}) # legend tbl2 = gui.Table() tbl2.tr() tbl2.td(gui.Color(width=30,height=30, value=(255,0,0))) tbl2.td(gui.Label(" "+_('IR Good')), align=-1) tbl2.tr() tbl2.td(gui.Spacer(10,10)) tbl2.tr() tbl2.td(gui.Color(width=30,height=30, value=(255,165,0))) tbl2.td(gui.Label(" "+_('IR Good but faint')), align=-1) tbl2.tr() tbl2.td(gui.Spacer(10,10)) tbl2.tr() tbl2.td(gui.Color(width=30,height=30, value=(0,0,0))) tbl2.td(gui.Label(" "+_('IR Not visible')), align=-1) txtTbl.tr() txtTbl.td(gui.Spacer(10,10)) txtTbl.tr() txtTbl.td(tbl2, style={'border':1}) # test area self.tstArea = IrTest(width=pSize['ir_w'], height=pSize['ir_h']) # calibrate button btn = gui.Button(_('Calibrate')) btn.connect(gui.CLICK, pApp.startCal, None) tbl.tr() tbl.td(txtTbl) tbl.td(self.tstArea) tbl.tr() tbl.td(btn, colspan=2) self.widget = tbl
def __init__(self, init_code=None, init_text=None, ps1='>>>', **params): self._locals = {} self.commands = [] self.lastcmd = 0 title = gui.Label("Interactive console") self.container = gui.Container(background= (255, 255, 255)) t = gui.Table(width=env.w + env.WALL_HEIGHT*2 + 300 , height=85) t.tr() self.lines = gui.Table(background=(255, 255, 255)) self.box = gui.ScrollArea(self.lines, env.w + env.WALL_HEIGHT*2 + 300, 135, hscrollbar=False, vscrollbar=True, background=(255, 255, 255)) self.box.set_vertical_scroll(100) t.td(self.box) font = pygame.font.Font("theme/Inconsolata.ttf", 14) t.tr() it = gui.Table() it.td(gui.Label(' ' + ps1 + ' ', font=font)) dx = 1 if sys.platform.startswith('linux') else 0 self.line = gui.Input(size=(8*22 - len(ps1)*8 - dx), font=font) self.line.connect(gui.KEYDOWN, self.lkey) #self.line.connect(gui.MOUSEBUTTONDOWN, self.lkey) it.td(self.line) t.td(it) t.tr() t.td(Hack(1, 1, self.box)) self.container.add(t, 0, 0) if init_code is not None : code = compile(init_code, '<string>', 'single') eval(code,globals(),self._locals) if init_text is not None: _stdout = sys.stdout s = sys.stdout = StringStream(self.lines) val = self.line.value print(init_text) sys.stdout = _stdout self.ps1 = ps1 gui.Dialog.__init__(self, title, self.container)
def __init__(self, engine, **params): gui.Container.__init__(self, **params) self.engine = engine # menus self.propertiesCtrl = propertiesControl(name="propertiesCtrl") self.tileCtrl = placeTileControl(name="tileCtrl") self.blockCtrl = placeBlockControl(name="blockCtrl") self.warpCtrl = placeWarpControl(name="warpCtrl") # menu title self.tTitle = gui.Table(width=272, height=32) self.tTitle.tr() self.tTitle.td( gui.Label("Map Editor", name='mapTitle', color=UI_FONT_COLOR)) # buttons self.t = gui.Table(width=272, height=50) self.t.tr() e = gui.Button("Map Properties", width=200) e.connect(gui.CLICK, self.toggleProperties, None) self.t.td(e, colspan=3) self.t.tr() e = gui.Button("Tile", width=65) e.connect(gui.CLICK, self.toggleTile, None) self.t.td(e) e = gui.Button("Block", width=65) e.connect(gui.CLICK, self.toggleBlock, None) self.t.td(e) e = gui.Button("Warp", width=65) e.connect(gui.CLICK, self.toggleWarp, None) self.t.td(e) self.tContent = gui.Table(width=272, height=318) self.tBottom = gui.Table(width=272, height=200) self.tBottom.tr() e = gui.Button("Save", width=100, height=40) e.connect(gui.CLICK, self.saveMap, None) self.tBottom.td(e) e = gui.Button("Cancel", width=100, height=40) e.connect(gui.CLICK, self.cancelMap, None) self.tBottom.td(e) #self.t.td() self.add(self.tTitle, 0, 0) self.add(self.t, 0, 48) self.add(self.tContent, 0, 110) self.add(self.tBottom, 0, 368)
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 setup_menu(this): 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) port = Portrait("wizard.png") port.add_meter("magic", (100,150,220)) port.add_meter("stamina", (190,150,50)) tbl.td(port) inv = Inventory() tbl.td(inv) this.menuArea.add(tbl, 0, 0) return # Add a button for pausing / resuming the game clock def pause_cb(): return if (this.engine.clock.paused): this.engine.resume() else: this.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(): return this.engine.clock.set_speed(slider.value/10.0) slider.connect(gui.CHANGE, update_speed) tbl2.tr() tbl2.td(slider) tbl.td(tbl2) this.menuArea.add(tbl, 0, 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 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 __init__(self, bckg="None", port=None, **params): self.bckg = bckg self.port = port title = gui.Label("Setting sensor for port %d" % int(self.port)) self.value = gui.Form() self.container = gui.Container() table = gui.Table() table.tr() self.sensors_img = gui.Image(p('icons/sensors.jpg')) table.td(self.sensors_img, cellspan=3) spacer = gui.Spacer(200, 100) self.box = gui.ScrollArea(spacer) table.tr() table.td(self.box, style={'border': 1}) save = gui.Button('Save') save.connect(gui.CLICK, self.send, gui.CHANGE) table.tr() table.td(save, align=1) self.container.add(table, 0, 0) self.init_ports() self.change() gui.Dialog.__init__(self, title, self.container)
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 __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) self.container.add(table, 0, 0) gui.Dialog.__init__(self, title, self.container)
def build_sensors(self): sensors_group = gui.Group(value='') sensors = gui.Table() sensors.tr() sensors.td( gui.Tool(sensors_group, gui.Image(p('icons/light.png')), value='light')) sensors.tr() sensors.td( gui.Tool(sensors_group, gui.Image(p('icons/sonic.png')), value='sonic')) sensors.tr() sensors.td( gui.Tool(sensors_group, gui.Image(p('icons/touch.png')), value='touch')) sensors.tr() sensors.td( gui.Tool(sensors_group, gui.Image(p('icons/compass.png')), value='compass')) sensors.tr() sensors.td(gui.Tool(sensors_group, gui.Label('None'), value='')) sensors_group.connect(gui.CHANGE, self.sensor_change, sensors_group) return sensors
def __init__(self, **params): title = gui.Label("Weibo Word Contrast") container = gui.Container(width=500, height=400) td_style = {'padding_right': 10} ################################# table = gui.Table(width=490, height=300) g = gui.Group() table.tr() table.td(gui.Label("Dlut", style=td_style, cls="h2")) check_box_1 = gui.Checkbox(g, value=1) check_box_1.connect(gui.CLICK, self.get_checked, 1) table.td(check_box_1) table.td(gui.Label("Tsinghua", style=td_style, cls="h2")) check_box_2 = gui.Checkbox(g, value=2) check_box_2.connect(gui.CLICK, self.get_checked, 2) table.td(check_box_2) table.td(gui.Label("Peking", style=td_style, cls="h2")) check_box_3 = gui.Checkbox(g, value=3) check_box_3.connect(gui.CLICK, self.get_checked, 3) table.td(check_box_3) table.tr() table.td(gui.Label("Naking", style=td_style, cls="h2")) check_box_4 = gui.Checkbox(g, value=4) check_box_4.connect(gui.CLICK, self.get_checked, 4) table.td(check_box_4) table.td(gui.Label("Ecupsl", style=td_style, cls="h2")) check_box_5 = gui.Checkbox(g, value=5) check_box_5.connect(gui.CLICK, self.get_checked, 5) table.td(check_box_5) ''' table.tr() table.td(gui.Label("With IDF", style=td_style, cls="h2")) check_box_6 = gui.Checkbox(g, value=6) check_box_6.connect(gui.CLICK, self.get_checked,6) table.td(check_box_6) table.td(gui.Label("Without IDF", style=td_style, cls="h2")) check_box_7 = gui.Checkbox(g, value=7) check_box_7.connect(gui.CLICK, self.get_checked,7) table.td(check_box_7) ''' table.tr() table.td(gui.Label("Show difference", style=td_style, cls="h2")) word_contrast_button = gui.Button("Click") word_contrast_button.connect(gui.CLICK, self.show_word_contrast, -1) table.td(word_contrast_button) table.td(gui.Label("clear", style=td_style, cls="h2")) check_box_7 = gui.Checkbox(g, value=0) check_box_7.connect(gui.CLICK, self.clear_value, 0) table.td(check_box_7) ################################# container.add(table, 1, 10) gui.Dialog.__init__(self, title, container)
def genCardTbl(self, cards): # create a talbe(widget) to place all cards tbl = gui.Table(name='table') self.cardsGroup = gui.Group(value=None) # generate all cards included in the input argument stacks # and place them on the table amountCards = len(cards) if amountCards > 0: card = [None] * amountCards vcard = [None] * amountCards for i in range(amountCards): vcard[i] = general.genVcard(cards[i]) tbl.td(gui.Tool(self.cardsGroup, vcard[i], value=i)) tbl.td(gui.Spacer(width=10, height=20)) # monitor the event whether the selection change self.selected = False self.cardsGroup.send(gui.CHANGE) def getGv(self): print(cards[self.cardsGroup.value].getName(), ' is selected') self.selected = True self._click.play() self.cardsGroup.connect(gui.CHANGE, getGv, self) return tbl
def genVcard(card): # get the card information cardName = card.getName() cardValue = str(card.getValue()) cardType = card.getType() if cardType == 0: cardTypeStr = ' Normal ' elif cardType == 1: cardTypeStr = 'Repulsor' else: cardTypeStr = ' Tractor ' # create the card image as a table vcard = gui.Table(width=30) vcard.add(gui.Label(' ')) vcard.tr() vcard.add(gui.Label(' ')) vcard.add(gui.Label(cardValue)) vcard.tr() vcard.add(gui.Label(' ')) vcard.add(gui.Label(cardName)) vcard.tr() vcard.add(gui.Label(' ')) vcard.add(gui.Label(cardTypeStr)) vcard.tr() vcard.add(gui.Label(' ')) return vcard
def _create_image_widget(self, fullpath): """Create an image showing the contents of a save game file.""" try: data, screenshot, level_name, timestamp = read_savegame(fullpath) except Exception: return gui.Label("Bad Save Game") tbl = gui.Table() tbl.tr() if screenshot is None: tbl.td(gui.Label("No screenshot")) else: tbl.td(gui.Image(screenshot)) tbl.tr() if level_name is None: tbl.td(gui.Label("Level: ???")) else: tbl.td(gui.Label("Level: %s" % (level_name, ))) if timestamp is not None: tbl.tr() tbl.td(gui.Label(timestamp.strftime(self.TIMESTAMP_DISPLAY))) return tbl
def __init__(self, value="", **params): self.ev_manager = params['ev_manager'] self.ev_manager.register_listener(self) self.highs_table = config.current_highs self.score = params['score'] self.data = params['data'] title = gui.Label("New High Score!") main = gui.Table() self.gui_form = gui.Form() main.tr() main.td(gui.Label("Please enter your name:")) main.tr() self.name_field = gui.Input(value=value, name='player_name') main.td(self.name_field) main.tr() submit_button = gui.Button("Submit") main.td(submit_button) submit_button.connect(gui.CLICK, self.submit, None) submit_button.connect(gui.CLOSE, self.close, None) gui.Dialog.__init__(self, title, main) self.ev_manager.post(FreezeCards())
def __init__(self, ctx, screen_width, screen_height, x, y, width, height): self._ctx = ctx self._solvers = ctx.solvers self._solver_label, self._solver_field = None, None self._solver_ui = None self._width = width self._height = height self._event_listeners = collections.defaultdict(list) self._outer_container = gui.Container(width=screen_width, height=screen_height, align=-1, valign=-1) # outer container where stuff goes self._main_container = gui.Table(width=width, height=height, hpadding=5, vpadding=5, align=-1, valign=-1) self._outer_container.add(self._main_container, x, y) self._build_ui() application = gui.App() application.init(self._outer_container) self._application = application
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 genCardTbl(self, stacks): # create a talbe(widget) to place all stack of cards tbl = gui.Table() self.group = gui.Group(value=None) # generate all cards included in the input argument stacks # and place them on the table print('The latest length of the stacks is ', len(stacks)) card = [None] * len(stacks) vcard = [None] * len(stacks) for i in range(len(stacks)): # get the card information # create the image of each card as a table(widgit) card = stacks[i][0] vcard[i] = general.genVcard(card) # 4 cards in one row if (i % 4 == 0): tbl.tr() tbl.td(gui.Label(' ')) tbl.tr() tbl.td(gui.Tool(self.group, vcard[i], value=i)) tbl.td(gui.Label(" ")) # monitor the event whether the selection change self.group.send(gui.CHANGE) def getGv(self): print(stacks[self.group.value][0].getName(), ' is selected') self._click.play() self.group.connect(gui.CHANGE, getGv, self) return tbl
def build_slots(self): slots_group = gui.Group(value=self.inp['slot']) slots = gui.Table() for slot in [1, 2, 3]: slots.tr() if slot in self.slots: slots.td(gui.Tool(slots_group, gui.Image(p('icons/slot%d.png' % (slot))), value=slot)) # if this slot is already selected make it visible elif slot == self.inp['slot']: slots.td(gui.Tool(slots_group, gui.Image(p('icons/slot%d.png' % (slot))), value=slot, pcls='down')) else: slots.td(gui.Image(p('icons/slot%d.png' % (slot)))) slots.tr() slots.td(gui.Tool(slots_group, gui.Label('None'), value=0)) slots_group.connect(gui.CHANGE, self.slot_change, slots_group) return slots
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 run(self): """Run the item""" # Initialize the item self.set_item_onset() # Create the app self.app = gui.Desktop(item=self) self.app.connect(gui.QUIT, self.app.quit, None) 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) # Create a 2-column table, start with the HTML on the first row c = gui.Table() c.tr() c.td(doc, align=-1) c.tr() e = gui.Button(self.get("accept_text")) e.connect(gui.CLICK, self.app.quit, None) c.td(e, align=-1, height=32, valign=1) self.app.run(c) # Return success return True
def show_controls(self): """Popup dialog of controls""" COMBOS = [ ('Select multiple chickens', 'Shift & Left Click'), ('Move selected chickens', 'Ctrl & Left Click'), (' or', 'Right Click'), ('Unselect chickens and tool', 'Middle Click'), ('Save selection', 'Ctrl & 0 .. 9'), (' or', 'Alt & 0 .. 9'), ('Recall saved selection', '0 .. 9'), ('Exit game', 'Esc'), ] tbl = gui.Table() tbl.tr() doc = gui.Document(width=610) space = doc.style.font.size(" ") for header in ['Action', 'Combination']: doc.add(misc.make_box("<b>%s</b>" % header, markup=True)) doc.br(space[1]) for command, combo in COMBOS: doc.add(misc.make_box(command)) doc.add(misc.make_box(combo)) doc.br(space[1]) doc.br(space[1]) misc.fix_widths(doc) close_button = gui.Button("Close") tbl.td(doc) tbl.tr() tbl.td(close_button, align=1) dialog = gui.Dialog(gui.Label('Command Reference'), tbl) close_button.connect(gui.CLICK, dialog.close) dialog.open()
def __init__(self,value,**params): self.value = list(gui.parse_color(value)) title = gui.Label("Color Picker") main = gui.Table() main.tr() self.color = gui.Color(self.value,width=64,height=64) main.td(self.color,rowspan=3,colspan=1) ##The sliders CHANGE events are connected to the adjust method. The ##adjust method updates the proper color component based on the value ##passed to the method. ##:: main.td(gui.Label(' Red: '),1,0) e = gui.HSlider(value=self.value[0],min=0,max=255,size=32,width=128,height=16) e.connect(gui.CHANGE,self.adjust,(0,e)) main.td(e,2,0) ## main.td(gui.Label(' Green: '),1,1) e = gui.HSlider(value=self.value[1],min=0,max=255,size=32,width=128,height=16) e.connect(gui.CHANGE,self.adjust,(1,e)) main.td(e,2,1) main.td(gui.Label(' Blue: '),1,2) e = gui.HSlider(value=self.value[2],min=0,max=255,size=32,width=128,height=16) e.connect(gui.CHANGE,self.adjust,(2,e)) main.td(e,2,2) gui.Dialog.__init__(self,title,main)
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)