Beispiel #1
0
    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
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    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
Beispiel #5
0
    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
Beispiel #6
0
    def __init__(self, player):
        super().__init__(
            'Playing Window for %s' % player.name,
            Size(400, 130),
        )
        self._EsUsed = 0
        self._EmergencyStopTable = gui.Table()
        # create a label in container
        lable = gui.Label('Do you want to use Emergency Stop Card?')
        lableWidth, lableHeight = lable.resize()
        self.getContainer().add(lable, int((400 - lableWidth) / 2), 20)
        self._group = gui.Group(name='YesNoGroup', value=None)

        # create a confirm button to confirm selection
        confirmButton = gui.Button("Confirm")

        def onConfirm(self):
            if self._group.value is not None:
                self._EsUsed = self._group.value
                self._confirm.play()
                self.getContainer().remove(self._EmergencyStopTable)

        confirmButton.connect(gui.CLICK, onConfirm, self)
        # add confirm button to container
        self.getContainer().add(confirmButton, 160, 100)
Beispiel #7
0
    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("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)
Beispiel #9
0
    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
Beispiel #10
0
    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()
Beispiel #11
0
    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
Beispiel #12
0
    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
Beispiel #13
0
    def __init__(self, player):
        super().__init__(
            'Drafing Window for %s' % player.name,
            Size(800, 120),
        )
        # create a group of stacks for selection
        self._stacksGroup = gui.Group(name='stacksGroup', value=None)
        # a container to show all available stacks of cards and confirm button
        self._stacksTable = gui.Table()
        # create a confirm button for the human player to confirm his/her selection
        confirmButton = gui.Button("Confirm")
        self._selectedItem = None

        # define the the things need to do before close the drafting window
        def onConfirm(self):
            if self._stacksGroup.value is not None:
                # get the final selected item
                self._selectedItem = self._stacksGroup.value
                # remove all stacks from container
                self.getContainer().remove(self._stacksTable)
                # play the confirm audio
                self._confirm.play()

        confirmButton.connect(gui.CLICK, onConfirm, self)
        # add confirm button to container
        self.getContainer().add(confirmButton, 300, 120)
Beispiel #14
0
 def __init__(self, value, **params):
     gui.Table.__init__(self, **params)
     self.ev_manager = params['ev_manager']
     self.gui_form = gui.Form()
     g = gui.Group(value=[config.use_darkness], name='use_darkness')
     self.td(gui.Checkbox(g, value=1))
     self.td(gui.Label("Darkness"))
     g.connect(gui.CHANGE, self.changed, None)
Beispiel #15
0
 def __init__(self, value, **params):
     gui.Table.__init__(self, **params)
     self.ev_manager = params['ev_manager']
     self.gui_form = gui.Form()
     g = gui.Group(value=[config.fill_board], name='fill_board')
     self.td(gui.Checkbox(g, value=1))
     self.td(gui.Label("Fill board"))
     g.connect(gui.CHANGE, self.changed, None)
Beispiel #16
0
    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)
Beispiel #17
0
    def __init__(self,**params):
        self.task = gui.Form() # widget values get added to this dict
        self.state = None
        title = gui.Label("Task Dialog")
        table = gui.Table(width=400)
        
        # Name input
        table.tr()
        table.td(gui.Label("Name:"), colspan=1)
        table.td(gui.Input(name="name"), colspan=3)
        table.tr()
        table.td(gui.Spacer(width=1,height=5))
        
        # Notes input
        table.tr()
        table.td(gui.Label("Notes:"), colspan=1)
        table.td(gui.Input(name="notes"), colspan=3)
        table.tr()
        table.td(gui.Spacer(width=1,height=5))
        
        # Due date input
        table.tr()
        table.td(gui.Label("Due Date:"), colspan=1)
        table.td(gui.Input(name="dueDate"), colspan=3)
        table.tr()
        table.td(gui.Spacer(width=1,height=5))
        
        # tags checkbox
        table.tr()
        table.td(gui.Label("Tags:"), colspan=4, align=0)
        
        tagGroup = gui.Group(name="tags")
        table.tr()
        table.td(gui.Label("School"), colspan=2, align=1)
        table.td(gui.Checkbox(tagGroup,value="school"))
        
        table.tr()
        table.td(gui.Label("Work"), colspan=2, align=1)
        table.td(gui.Checkbox(tagGroup,value="work"))
        
        table.tr()
        table.td(gui.Label("Health"), colspan=2, align=1)
        table.td(gui.Checkbox(tagGroup,value="health"))
        
        
        table.tr()
        table.td(gui.Spacer(width=1,height=10))
        table.tr()
        self.saveBtn = gui.Button("Add Task")
        self.saveBtn.connect(gui.CLICK,self.send,gui.CHANGE)
        table.td(self.saveBtn, colspan=4)

        gui.Dialog.__init__(self,title,table)
Beispiel #18
0
 def __init__(self, gameboard, **params):
     gui.Table.__init__(self, **params)
     self.group = gui.Group(name='base_toolbar', value=None)
     self._next_tool_value = 0
     self.gameboard = gameboard
     self.cash_counter = mklabel(align=0)
     self.wood_counter = mklabel(align=0)
     self.chicken_counter = mklabel(align=0)
     self.egg_counter = mklabel(align=0)
     self.day_counter = mklabel(align=0)
     self.killed_foxes = mklabel(align=0)
     self.add_labels()
Beispiel #19
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)
Beispiel #20
0
 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
Beispiel #21
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)
Beispiel #22
0
    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
Beispiel #23
0
    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)
Beispiel #24
0
    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)
Beispiel #25
0
    def __init__(self, cards, EsUsed, playerName):
        # 1. initialize
        self.cards = cards
        self.EsUsed = EsUsed
        self._playerName = playerName
        self.selectedItem = None
        # crate a group of cards for selection
        self.cardsGroup = gui.Group(value=None)
        # 2. load audios
        pygame.mixer.init()
        self._click = pygame.mixer.Sound(strings.Audio.click)
        self._confirm = pygame.mixer.Sound(strings.Audio.confirm)

        # create the title of dialog
        lableStr = 'Playing Window for ' + self._playerName
        title = gui.Label(lableStr)
        # create a container to show all unused cards ,confirm button and the Emergency stop card
        self.cardsContainer = gui.Container(width=700, height=150)
        self.cardsTbl = 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
        self.confirmButton = gui.Button("Confirm")

        def clsDialog(self):
            self.selectedItem = self.cardsGroup.value
            if len(self.cards) > 0 and self.selected:
                print('finally select ',
                      self.cards[self.selectedItem].getName())
            elif len(self.cards) == 0:
                print('There is no card to play')
            elif not self.selected:
                print('you should select one card')
            self.selected = False
            self._confirm.play()

        self.confirmButton.connect(gui.CLICK, clsDialog, self)
        # add confirm button to container
        self.cardsContainer.add(self.confirmButton, 380, 120)

        # initialie Drafting dialog
        gui.Dialog.__init__(self,
                            title,
                            self.cardsContainer,
                            name='playingDialog')
Beispiel #26
0
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))
Beispiel #27
0
    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 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)
Beispiel #29
0
    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
Beispiel #30
0
    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)