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 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 buildFocusSelecter(self, focus=None): if self.focusDocument is not None: self.groups = [] self.focusDocument.clear() self.remove(self.focusDocument) if self.focusDocument in self.owningWidgets: self.owningWidgets.remove(self.focusDocument) self.killEditableDocument() actors = self.script.actors if focus is not None: focusGroup = gui.Group('actor-group-focus', focus) else: focusGroup = gui.Group('actor-group-focus', actors[0]) focusGroup.connect(gui.CHANGE, self.changeFocus) self.groups.append(focusGroup) focusDocument = gui.Document() length = 20 - len(actors) i = 0 for anActor in actors: focusToolTable = gui.Table() focusToolTable.tr() focusToolTable.td(gui.Image(anActor.thumb)) focusToolTable.tr() focusToolTable.td(gui.Label(anActor.shortName(length))) focusTool = gui.Tool(focusGroup, focusToolTable, anActor, name='actor-tool-focus-' + str(i)) focusDocument.add(focusTool) focusDocument.add(gui.Spacer(4, 1)) i += 1 if len(actors) < limits['actors']: plusLabel = gui.Label(_("Add actor")) plusTool = gui.Tool(focusGroup, plusLabel, _("Add actor"), style={ 'margin': 10, 'padding': 5 }, name='actor-focus-plusTool') focusDocument.add(plusTool) self.add(focusDocument, 20, 20) self.focusDocument = focusDocument self.buildEditablesDocument() self.owningWidgets.append(focusDocument)
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 _genEmergencyStopTable(self): # create a table with 'yes' or 'no' option in container # and also a gruop for selection self._group = gui.Group(name='YesNoGroup', value=None) table = gui.Table() table.tr() table.td(gui.Tool(self._group, gui.Label('Yes'), value=1)) table.td(gui.Spacer(width=50, height=20)) table.td(gui.Tool(self._group, gui.Label('No'), value=0)) self._group.send(gui.CHANGE) def onChange(self): self._click.play() self._group.connect(gui.CHANGE, onChange, self) return table
def _genCardTbl(self, stacks): '''convert all stacks into visual stacks(a table widget) and place them in a group which only be selected one at a time input: card stacks, a stack includes 2 cards return: the generate Table(a widget)''' # create a talbe(widget) to place all stack of cards self._stacksGroup = gui.Group(name='stacksGroup', value=None) stacksTable = gui.Table(name='stacksTable') # generate all cards included in the input argument stacks # and place them on the table 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][1] vcard[i] = createCardView(card) stacksTable.td(gui.Tool(self._stacksGroup, vcard[i], value=i)) stacksTable.td(gui.Label(" ")) # monitor the event whether the selection change self._stacksGroup.send(gui.CHANGE) def onChange(self): self._click.play() self._stacksGroup.connect(gui.CHANGE, onChange, self) return stacksTable
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 __init__(self, playerName): self._playerName = playerName self.EsUsed = 0 # load audios pygame.mixer.init() self._click = pygame.mixer.Sound(strings.Audio.click) self._confirm = pygame.mixer.Sound(strings.Audio.confirm) # 1. define the title of the dialog lableStr = 'Emergency Stop Window for ' + self._playerName title = gui.Label(lableStr) # 2. define the container of the dialog EScontainer = gui.Container(width=400, heigt=300) # 2.1 create a label in container lable = gui.Label('Do you want to use Emergency Stop Card?') lbw, lbh = lable.resize() EScontainer.add(lable, int((400 - lbw) / 2), 20) # 2.2 create a table with 'yes' or 'no' option in container and also a gruop for selection table = gui.Table() table.tr() g = gui.Group(value=0) table.td(gui.Tool(g, gui.Label('Yes'), value=1)) table.td(gui.Spacer(width=50, height=20)) table.td(gui.Tool(g, gui.Label('No'), value=0)) tblw, tblh = table.resize() EScontainer.add(table, int((400 - tblw) / 2), 20 + lbh + 20) g.send(gui.CHANGE) def gv(self): self._click.play() g.connect(gui.CHANGE, gv, self) # create a confirm button to confirm selection self.confirmButton = gui.Button("Confirm") def cEsD(self): self.EsUsed = g.value print('ES WINDOW SELECTION IS ', self.EsUsed) self._confirm.play() self.confirmButton.connect(gui.CLICK, cEsD, self) # add confirm button to container EScontainer.add(self.confirmButton, 160, 100) # initialie Emergency Sop dialog gui.Dialog.__init__(self, title, EScontainer)
def build_slots(self): slots_group = gui.Group(value=self.inputs[self.port]['slot']) slots = gui.Table() wslots = [self.inputs[self.port]['slot']] + self.slots for slot in [1, 2, 3]: slots.tr() if slot in wslots: slots.td( gui.Tool(slots_group, gui.Image(p('icons/slot%d.png' % (slot))), value=slot)) else: slots.td(gui.Image(p('icons/slot%d.png' % (slot)))) slots.tr() slots.td(gui.Tool(slots_group, gui.Label('None'), value='')) slots_group.connect(gui.CHANGE, self.slot_change, slots_group) return slots
def paintRevealedCard(revealCard): table = gui.Table() table.tr() # create the player name part as a button nameBlock = gui.Button(revealCard[0], width=70, height=25) table = tbl.td(nameBlock) table = tbl.tr() table = tbl.td(gui.Spacer(width=1, height=5)) table = tr() # create the card part as a table group = gui.Group(value=None) cardBlock = createCardView(revealCard[1]) table.td(gui.Tool(group, cardBlock, None)) return table
def __init__(self, script): gui.Table.__init__(self, width=geom['tab'].width, height=geom['tab'].height) self.script = script panels = [ filePanel.FilePanel, backdropPanel.BackdropPanel, actorPanel.ActorPanel, writePanel.WritePanel, theaterPanel.TheaterPanel ] curPanel = 0 self.activePanel = panels[curPanel](self.script) self.activePanel.build() self.panelHolder = gui.Container(width=geom['panel'].width, height=geom['panel'].height) self.panelHolder.add(self.activePanel, 0, 0) self.tabGroup = gui.Group('tab-group-panels', panels[curPanel]) self.tabGroup.connect(gui.CHANGE, self.changePanel) buttonHeight = geom['tab'].height / len(panels) * 3 / 5 buttonWidth = geom['tab'].width * 3 / 5 self.panelLabels = {} for aPanel in panels: self.tr() panelLabel = gui.Label(aPanel.name, name='tab-label-panels-' + aPanel.name) self.panelLabels[aPanel] = panelLabel aPanel.sourceTab = self panelTool = gui.Tool(self.tabGroup, panelLabel, aPanel, width=buttonWidth, height=buttonHeight, name='tab-tool-panels-' + aPanel.name) self.td(panelTool, style={'padding': 10})
def _genCardTbl(self, cards): '''generate card group''' # create a talbe(widget) to place all cards cardsTable = gui.Table(name='cardsTable') 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] = createCardView(cards[i]) cardsTable.td(gui.Tool(self._cardsGroup, vcard[i], value=i)) cardsTable.td(gui.Spacer(width=10, height=20)) # monitor the event whether the selection change self._cardsGroup.send(gui.CHANGE) def onChange(self): self._click.play() self._cardsGroup.connect(gui.CHANGE, onChange, self) return cardsTable
def buildFocusSelecter(self): if self.focusDocument in self.widgets: self.groups = [] self.focusDocument.clear() self.remove(self.focusDocument) if self.focusDocument in self.owningWidgets: self.owningWidgets.remove(self.focusDocument) self.killSelectablesDocument() self.remove(self.focusDocument) actors = self.script.actors focusGroup = gui.Group('write-group-focus', self.script.getFirstActor()) focusGroup.connect(gui.CHANGE, self.changeFocus) self.groups.append(focusGroup) focusDocument = gui.Document() focusDocument.add(gui.Label(_("Change speaker:"))) focusDocument.br(1) length = 15 - len(actors) for anActor in actors: focusToolTable = gui.Table() focusToolTable.tr() focusToolTable.td(gui.Image(anActor.thumb)) focusToolTable.tr() focusToolTable.td(gui.Label(anActor.shortName(length))) focusTool = gui.Tool(focusGroup, focusToolTable, anActor, name='write-tool-focus-' + anActor.name) focusDocument.add(focusTool) focusDocument.add(gui.Spacer(4, 1)) self.add(focusDocument, *geom['scriptPanel'].topleft) self.focusDocument = focusDocument self.buildSelectablesDocument()
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') c.td(gui.Tool(g, gui.Label('A'), value='a')) c.td(gui.Tool(g, gui.Label('B'), value='b')) c.td(gui.Tool(g, gui.Label('C'), value='c')) c.tr() c.td(gui.Label("Input")) def cb(): print("Input received") w = gui.Input(value='Cuzco', size=8) w.connect("activate", cb) c.td(w, colspan=3)
def build(self): panel.Panel.build(self) backdropDocument = gui.Document(width=geom['panel'].width, align=0) back = self.script.backdrop backdropGroup = gui.Group('backdrop-group-backdrops', back) backdropGroup.connect(gui.CHANGE, self.changeBackdrop) start = self.backdropIndex end = min(len(backdrops), self.backdropIndex + self.backdropsOnscreen) for aBackdrop in backdrops[start:end]: thumbPath = os.path.join('games/broadway/backdrops', aBackdrop + '_thumb.png') filePath = aBackdrop backdropToolTable = gui.Table() backdropToolTable.tr() backdropToolTable.td(gui.Image(thumbPath)) backdropToolTable.tr() backdropToolTable.td(gui.Label(_(string.capwords(aBackdrop)))) backdropTool = gui.Tool(backdropGroup, backdropToolTable, filePath, style={'margin': 4}, name='backdrop-tool-backdrops-' + aBackdrop) backdropDocument.add(backdropTool) backdropDocument.add(gui.Spacer(4, 6)) #Custom Backdrop from local source customBackdropButton = gui.Button( _("Your's"), name='backdrop-button-backdrops-custom', style={ 'width': 80, 'height': 32 }) customBackdropButton.connect(gui.CLICK, self.externalBackdrop) #Custom Backdrop from online source (teacher) teacherBackdropButton = gui.Button( _("Teacher's"), name='backdrop-button-backdrops-teacher', style={ 'width': 80, 'height': 32 }, disabled=not hacks['server']) teacherBackdropButton.connect(gui.CLICK, self.teacherBackdrop) backdropGroup.connect(gui.CHANGE, self.changeBackdrop) self.groups = backdropGroup navigationButtons = gui.Table(width=geom['panel'].width) navigationButtons.tr() maxSize = (len(backdrops) - self.backdropsOnscreen - 1) size = geom['panel'].width * 3 / 4 / ( 1 + (maxSize / float(self.backdropsOnscreen))) progressBar = gui.HSlider(value=self.backdropIndex, min=0, max=maxSize, size=size, step=1, disabled=True, width=geom['panel'].width * 3 / 4, style={ 'padding': 4, 'margin': 10 }) navigationButtons.td(progressBar, colspan=5) navigationButtons.tr() homeButton = gui.Button(gui.Image(images['go-first'])) homeButton.connect(gui.CLICK, self.gotoBackdropPage, 0) navigationButtons.td(homeButton) previousButton = gui.Button(gui.Image(images['go-back'])) previousButton.connect(gui.CLICK, self.gotoBackdropPage, self.backdropIndex - self.backdropsOnscreen) navigationButtons.td(previousButton) if start == end: label = _("No backdrops loaded") elif (end - start) == 1: label = _("Backdrop %(index)d") % {"index": (start + 1)} else: label = _("Backdrops %(start_index)d to %(end_index)d") % { "start_index": start + 1, "end_index": end } navigationButtons.td(gui.Label(label)) forwardButton = gui.Button(gui.Image(images['go-next'])) forwardButton.connect(gui.CLICK, self.gotoBackdropPage, self.backdropIndex + self.backdropsOnscreen) navigationButtons.td(forwardButton) endButton = gui.Button(gui.Image(images['go-last'])) endButton.connect(gui.CLICK, self.gotoBackdropPage, len(backdrops)) navigationButtons.td(endButton) self.add(backdropDocument, 0, 30) self.add(navigationButtons, 0, geom['panel'].height // 2 + 25) self.add(customBackdropButton, 10, 50) self.add(teacherBackdropButton, 10, 100) self.owningWidgets.append(customBackdropButton) self.owningWidgets.append(teacherBackdropButton) self.owningWidgets.append(backdropDocument) self.owningWidgets.append(navigationButtons)
def _initUi(self): """ init the different elements of the ui """ self._grp = gui.Group() self._grp.connect(gui.CHANGE, self._chgTab) # top widget self._widget = gui.Table() # tabs self._tabs = gui.Table(width=self._size['w']) self._widget.td(self._tabs) self._widget.tr() self._widget.td(gui.Spacer(10, 10)) # Config view self._cv = ConfigView(self._size, self, defaultCfg) b = gui.Tool(self._grp, gui.Label(_('Configuration')), self._cv.widget, height=self._size['m_h'], width=self._size['m_w']) self._tabs.td(b, align=-1) self._cfgBtn = b # Sensor view self._sv = SensorView(self._size, self) b = gui.Tool(self._grp, gui.Label(_('Sensor View Check')), self._sv.widget, height=self._size['m_h'], width=self._size['m_w']) self._tabs.td(b, align=1) # Connection table self._widget.tr() self._conTb = gui.Table(width=self._size['w'], height=self._size['c_h']) self._conTb.tr() self._infoLb = gui.Label(_('Pull Gun Trigger to start configuration')) self._conTb.td(self._infoLb) self._conTb.tr() self._conLb = (gui.Label('-- 0 ' + _('device(s) connected') + ' --')) self._conTb.td(self._conLb) box = gui.ScrollArea(self._conTb) self._widget.td(box, style={'border': 1}, colspan=4) self._tab = box # Status bar self._widget.tr() tt2 = gui.Table(width=self._size['w']) tt2.tr() self._devIdLb = gui.Label('') self._firmLb = gui.Label('') tt2.td(self._devIdLb) tt2.td(self._firmLb, align=1) tt2.tr() self._quitBn = gui.Button(_("Quit")) self._quitBn.connect(gui.CLICK, self.quit, None) tt2.td(self._quitBn, colspan=2) self._widget.td(tt2) # Calibration window self._calWn = CalibrationWnd(self._size, self)
d.add(w) d.space((8, 8)) ####################################### def tab(): box.widget = g.value g = gui.Group() g.connect(gui.CHANGE, tab) tt = gui.Table() tt.tr() b = gui.Tool(g, gui.Label("Container"), c) tt.td(b) b = gui.Tool(g, gui.Label("Table"), t) tt.td(b) b = gui.Tool(g, gui.Label("Document"), d) tt.td(b) tt.tr() spacer = gui.Spacer(240, 120) box = gui.ScrollArea(spacer, height=120) tt.td(box, style={'border': 1}, colspan=3) app.connect(gui.QUIT, app.quit, None) app.run(tt) pygame.quit()