示例#1
0
    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()
示例#2
0
    def __init__(self,**params):
        title = gui.Label("About Cuzco's Paint")

        width = 900
        height = 500
        doc = gui.Document(width=width)

        space = title.style.font.size(" ")

        doc.block(align=0)
        for word in """Cuzco's Paint v1.0 by Phil Hassey""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        doc.block(align=-1)
        doc.add(gui.Image("../../../img/gravitas_logo.png"),align=1)
        for word in """Cuzco's Paint is a revolutionary new paint program it has all the awesome features that you need to paint really great pictures.""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        doc.block(align=-1)
        for word in """Cuzco's Paint will drive you wild!  Cuzco's Paint was made as a demo of Phil's Pygame Gui.  We hope you enjoy it!""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)

        for i in range(0,10):
            doc.block(align=-1)
            for word in """This text has been added so we can show off our ScrollArea widget.  It is a very nice widget built by Gal Koren!""".split(" "):
                doc.add(gui.Label(word))
                doc.space(space)
            doc.br(space[1])

        gui.Dialog.__init__(self,title,gui.ScrollArea(doc,width,height))
示例#3
0
    def __init__(self, init_cb, save, load, set_ai_cb, font):
        self.app = gui.App()
        self.app.connect(gui.QUIT, self.app.quit, None)
        container = gui.Container(align=-1, valign=-1)
        self.font = font

        self.save_dlg = SaveDialog(save)
        self.load_dlg = LoadDialog(load)
        self.about_dlg = AboutDialog()
        self.dialogs = (self.save_dlg, self.load_dlg, self.about_dlg)

        menus = gui.Menus([
            ('Game/New', init_cb, True),
            ('Game/Save', self.save_dlg.open, None),
            ('Game/Load', self.load_dlg.open, None),
            ('Game/Quit', self.quit, None),
            ('AI Level/Dumb', set_ai_cb, AI_Level.dumb),
            ('AI Level/Smart', set_ai_cb, AI_Level.smart),
            ('Help/About', self.about_dlg.open, None),
        ])
        menus.rect.w, menus.rect.h = menus.resize()
        self.doc = gui.Document(width=0, height=0)  # TODO: vertical?
        self.log_box = gui.ScrollArea(self.doc,
                                      SCREEN_WIDTH,
                                      100,
                                      hscrollbar=False)
        self.log("Welcome to Battleships!")

        container.add(menus, 0, 0)
        container.add(self.log_box, 0, SCREEN_HEIGHT - 100)
        self.menus = menus
        self.elements = (menus, self.log_box)
        self.app.init(container)
示例#4
0
    def __init__(self, title, text, **params):
        title_label = gui.Label(title)

        doc = gui.Document()

        space = doc.style.font.size(" ")

        for paragraph in text.split('\n\n'):
            doc.block(align=-1)
            for word in paragraph.split():
                doc.add(gui.Label(word))
                doc.space(space)
            doc.br(space[1])
        doc.br(space[1])

        done_button = gui.Button("Close")
        done_button.connect(gui.CLICK, self.close)

        tbl = gui.Table()
        tbl.tr()
        tbl.td(doc)
        tbl.tr()
        tbl.td(done_button, align=1)

        gui.Dialog.__init__(self, title_label, tbl, **params)
示例#5
0
 def buildEditablesDocument(self):
     newActor = self.script.controls['actor-group-focus'].value
     self.editablesDocumentLeft = gui.Document()
     self.editablesDocumentRight = gui.Document()
     self.add(self.editablesDocumentLeft, 10, 95)
     self.add(self.editablesDocumentRight, 510, 95)
     if newActor != self.script.actors[0]:
         self.buildNameInput()
         self.buildSkinSelecter()
     self.buildVoiceSelecter()
     if newActor != self.script.actors[0]:
         self.buildLookSelecter()
         self.buildPoseSelecter()
         self.buildDirectionSelecter()
         self.buildMovers()
     self.owningWidgets.append(self.editablesDocumentLeft)
     self.owningWidgets.append(self.editablesDocumentRight)
示例#6
0
 def start_option(self,attrs):
     r = self.attrs_to_map(attrs)
     params = {} #style = self.map_to_style(r)
     
     self.myback('select')
     e = gui.Document(**params)
     self.item.add(e,value=r.get('value',None))
     self.myopen('option',e)
示例#7
0
文件: html.py 项目: illume/zanthor
    def _start_td(self, t, attrs):
        r = self.attrs_to_map(attrs)
        params = self.map_to_params(r)
        if 'cls' in params: params['cls'] = t + "." + params['cls']
        else: params['cls'] = t
        b = gui.Document(cls=t)

        self.myback('table')
        self.item.td(b, **params)
        self.myopen(t, b)
示例#8
0
 def start_block(self, t, attrs, align=-1):
     r = self.attrs_to_map(attrs)
     params = self.map_to_params(r)
     if 'cls' in params: params['cls'] = t + "." + params['cls']
     else: params['cls'] = t
     b = gui.Document(**params)
     if 'align' in params:
         align = params['align']
     self.item.block(align)
     self.item.add(b)
     self.myopen(t, b)
示例#9
0
    def __init__(self,**params):
        title = gui.Label("Welcome")

        doc = gui.Document(width=400)

        space = title.style.font.size(" ")

        doc.block(align=-1)
        doc.add(gui.Image("../../../img/gravyboat_logo_text_alt.png"),align=1)
        for word in """Welcome to Cuzco's Paint.  Cuzco's Paint is a demo of the features of Phil's Pygame GUI.  Cuzco's Paint only supports saving in the .TGA format.""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)

        gui.Dialog.__init__(self,title,doc)
示例#10
0
 def __init__(self):
     title = gui.Label('About')
     space = title.style.font.size(' ')
     doc = gui.Document(width=400, height=300)
     doc.block(align=0)
     doc.add(gui.Label('BATTLESHIPS'))
     doc.br(space[1])
     doc.block(align=0)
     doc.add(gui.Label('Made by Jan Wilamowski'))
     doc.block(align=0)
     doc.br(space[1])
     doc.add(gui.Label('Graphics by Fabian Freiesleben'))
     doc.block(align=0)
     doc.add(gui.Label('License: GPLv3'))
     super().__init__(title, doc)
示例#11
0
    def __init__(self, **params):
        title = gui.Label("massagebox")

        width = 400
        height = 50
        doc = gui.Document(width=width)

        space = title.style.font.size(" ")

        doc.block(align=0)
        for word in """TimeIsUp_RecordingFinished""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])
        gui.Dialog.__init__(self, title, gui.ScrollArea(doc, width, height))
示例#12
0
 def buildSelectablesDocument(self):
     #self.script.disableControls();
     newActor = self.script.controls['write-group-focus'].value
     self.selectablesDocumentTable = gui.Table(
         width=geom['scriptPanel'].width,
         height=geom['scriptPanel'].height / 2)
     self.selectablesDocumentTable.tr()
     self.selectablesDocumentLeft = gui.Document(
         width=geom['scriptPanel'].width / 2)
     self.selectablesDocumentTable.td(self.selectablesDocumentLeft)
     self.selectablesDocumentRight = gui.Document(
         width=geom['scriptPanel'].width / 2)
     self.selectablesDocumentTable.td(self.selectablesDocumentRight)
     self.add(self.selectablesDocumentTable, geom['scriptPanel'].left,
              geom['scriptPanel'].top + 75)
     if newActor == self.script.actors[0]:
         self.buildIdeaGenerator()
     else:
         self.buildLookSelecter()
         self.buildPoseSelecter()
         self.buildDirectionSelecter()
         self.buildMovers()
     #self.script.enableControls();
     self.scriptArea.focus()
示例#13
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)
示例#14
0
文件: utils.py 项目: trimlab/microMVP
    def __init__(self, **params):
        title = gui.Label("Help")

        doc = gui.Document(width=400)

        space = title.style.font.size(" ")

        doc.br(space[1])

        doc.block(align=-1)
        for word in """Please refer to http://arc.cs.rutgers.edu/mvp/""".split(
                " "):
            doc.add(gui.Label(word))
            doc.space(space)

        gui.Dialog.__init__(self, title, doc)
示例#15
0
    def __init__(self, title='', text_stream=''):
        title = gui.Label(title)

        width = 400
        height = 200
        doc = gui.Document(width=width)

        space = title.style.font.size(" ")

        doc.block(align=-1)
        lines = text_stream.split('\n')
        for line in lines:
            for word in line.split(" "):
                doc.add(gui.Label(word))
                doc.space(space)
            doc.br(space[1])
        super().__init__(title, gui.ScrollArea(doc, width, height))
示例#16
0
	def __init__(self,level):
		self.level = level

		title = gui.Label("Jump to level")

		doc = gui.Document()

		table = gui.Table()

		#table.td(gui.Label("select level"),colspan=1)

		table.tr()

		# dont set the current as default since it could be the testlevel
		#levname = level.__class__.__module__.split(".")[1]
		levname = ""

		sel = gui.Select(levname,width=150)

		self.sel = sel

		#sel.add("test level","testlevel")
		## use the import to see what level scripts are available 
		## and add the script filenames to list

		i = j = 1

		while True:
			levelName = "gamelevel" + str(i) + "_" + str(j)

			# this is bit rough way to find out the level scripts
			try:
				exec("from levels import " + levelName)	

				sel.add(levelName,levelName)
				j += 1
			except ImportError, err:
				# filter the other import errors
				if str(err) != ("cannot import name "+levelName):
					raise "excepted import error from level script "+levelName+": "+str(err)
				j = 1
				i += 1

				if i > 72: break
示例#17
0
文件: pyllk.py 项目: ibetsun/pyllk
 def __init__(self,mess,ft,**params):
     gui.Table.__init__(self,**params)
     width=500
     fg=(25,255,200)
     #self.tr()
     #self.td(gui.Label(" Message ",font=ft,color=(255,255,0)),width=width,align=0)
     
     self.tr()
     self.td(gui.Label(mess,font=ft,color=fg),width=width,align=0)
     self.tr()
     self.td(gui.Spacer(width=8,height=36))
     space=ft.size(" ")
     doc=gui.Document(width=width)
     doc.block(align=-1)
     for word in u"""按 ESC 取消或 空格 确定!""".split(" "):
        doc.add(gui.Label(word,font=psubfts,color=(255,255,0)))
        doc.space(space)
     self.tr()
     self.td(doc,align=0)   
示例#18
0
    def show_prices(self):
        """Popup dialog of prices"""

        tbl = gui.Table()
        tbl.tr()
        doc = gui.Document(width=540)
        space = doc.style.font.size(" ")
        for header in ['Item', 'Buy Price', 'Sell Price', 'Repair Price']:
            doc.add(misc.make_box("<b>%s</b>" % header, markup=True))
        doc.br(space[1])
        for building in buildings.BUILDINGS:
            doc.add(misc.make_box(building.NAME))
            doc.add(misc.make_box('%d planks' % building.BUY_PRICE))
            doc.add(misc.make_box('%d planks' % building.SELL_PRICE))
            if building.BREAKABLE:
                doc.add(misc.make_box('%d planks' % building.REPAIR_PRICE))
            else:
                doc.add(misc.make_box('N/A'))
            doc.br(space[1])
        for equip in equipment.EQUIPMENT:
            doc.add(misc.make_box(equip.NAME))
            doc.add(misc.make_box('%d groats' % equip.BUY_PRICE))
            doc.add(misc.make_box('%d groats' % equip.SELL_PRICE))
            doc.add(misc.make_box('N/A'))
            doc.br(space[1])
        doc.add(misc.make_box("5 planks"))
        doc.add(misc.make_box('%d groats' % self.gameboard.wood_buy_price))
        doc.add(misc.make_box('%d groats' % self.gameboard.wood_sell_price))
        doc.add(misc.make_box('N/A'))
        doc.br(space[1])

        misc.fix_widths(doc)
        for word in "Damaged equipment or buildings will be sold for" \
                " less than the sell price.".split():
            doc.add(gui.Label(word))
            doc.space(space)
        close_button = gui.Button("Close")
        tbl.td(doc)
        tbl.tr()
        tbl.td(close_button, align=1)
        dialog = gui.Dialog(gui.Label('Price Reference'), tbl)
        close_button.connect(gui.CLICK, dialog.close)
        dialog.open()
示例#19
0
    def _build_buttons(self):
        self._start_button = gui.Button('Start')
        self._stop_button = gui.Button('Stop')
        self._reset_button = gui.Button('Reset')
        self._restart_button = gui.Button('Restart')

        self._start_button.connect(gui.CLICK, self._call_listeners, 'start')
        self._stop_button.connect(gui.CLICK, self._call_listeners, 'stop')
        self._reset_button.connect(gui.CLICK, self._call_listeners, 'reset')
        self._restart_button.connect(gui.CLICK, self._call_listeners,
                                     'restart')

        self._button_panel = gui.Document()
        self._button_panel.add(self._start_button)
        self._button_panel.add(gui.Label('  '))
        self._button_panel.add(self._restart_button)
        self._button_panel.add(gui.Label('  '))
        self._button_panel.add(self._stop_button)
        self._button_panel.add(gui.Label('  '))
        self._button_panel.add(self._reset_button)
示例#20
0
    def __init__(self,**params):
        title = gui.Label("Help")

        doc = gui.Document(width=400)

        space = title.style.font.size(" ")

        doc.block(align=-1)
        doc.add(gui.Image("../../../img/gravitas_logo.png"),align=1)
        for word in """Cuzco's Paint is a revolutionary new paint program it has all the awesome features that you need to paint really great pictures.""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        doc.block(align=-1)
        for word in """This help isn't really here for any other reason than to have a help dialog.""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)

        gui.Dialog.__init__(self,title,doc)
示例#21
0
文件: pyllk.py 项目: ibetsun/pyllk
 def __init__(self,**params):
    gui.Table.__init__(self,**params)
    width=500
    fg=(25,255,200)
    #pft=pygame.font.Font('data/shaonv.ttf', 30)
    #psubft=pygame.font.Font('data/shaonv.ttf', 25)
    title=gui.Label(u"暂停游戏",font=psubft,color=(255,255,0))
    
    space=title.style.font.size(" ")
    self.tr()
    self.td(title,width=width,align=0)
    self.tr()
    self.td(gui.Spacer(width=8,height=36))
    doc=gui.Document(width=width)
    doc.block(align=-1)
    for word in u"""按 F8 返回游戏!""".split(" "):
        doc.add(gui.Label(word,font=psubfts,color=fg))
        doc.space(space)
    #doc.br(space[1])
    self.tr()
    self.td(doc,align=0)
示例#22
0
    def __init__(self, errorMessages):
        font = pygame.font.SysFont("", 22)
        title = gui.Label("Error")
        title.set_font(font)

        container = gui.Container(width=400, height=180)

        doc = gui.Document(width=380)
        space = title.style.font.size(" ")

        doc.block(align=-1)

        for message in errorMessages:
            messageLabel = gui.Label(message)
            messageLabel.set_font(font)
            doc.add(messageLabel)
            doc.br(space[1])

        container.add(gui.ScrollArea(doc, 390, 160), 5, 10)

        gui.Dialog.__init__(self, title, container)
示例#23
0
    def __init__(self, mainMenu, songName, score, message):
        self._mainMenu = mainMenu
        self._songName = songName
        self._score = score

        # Create the title
        titleLabel = gui.Label("Add your score")
        space = titleLabel.style.font.size(" ")

        # Create the document to put stuff in to
        width = 400
        height = 130
        document = gui.Document(width=width)

        # Create the description
        self._addText(message, space, document)

        # Create the user input label
        document.block(align=-1)
        userLabel = gui.Label('Name: ')
        document.add(userLabel)

        # Create the user input field
        self._userInput = gui.Input("Anonymous")
        document.add(self._userInput)

        # Add the Cancel button
        document.br(space[1])
        document.block(align=-1)
        cancelButton = gui.Button('Cancel')
        cancelButton.connect(gui.CLICK, self.close)
        document.add(cancelButton)

        # Add the Submit button
        submitButton = gui.Button('Submit')
        submitButton.connect(gui.CLICK, self._saveHighScore)
        document.add(submitButton)

        gui.Dialog.__init__(self, titleLabel,
                            gui.ScrollArea(document, width, height))
    def __init__(self, **params):
        title = gui.Label("Doc content")
        container = gui.Container(width=500, height=400)
        td_style = {"padding_right": 10}
        doc = gui.Document(width=400)
        space = title.style.font.size(" ")
        contents = params['contents']
        doc.block(align=0)
        #for content in contents:
        '''for word in """Cuzco's Paint v1.0 by Phil Hassey""".split(" "):
			doc.add(gui.Label(word))
			doc.space(space)
		doc.br(space[1])'''
        doc.block(align=-1)

        for w in contents:
            doc.add(gui.Label(w[0]))
            doc.br(space[1])
            print '', w[0], w[1], w[2], w[3], w[4]

        container.add(gui.ScrollArea(doc, 470, 370), 20, 20)
        gui.Dialog.__init__(self, title, container)
示例#25
0
文件: utils.py 项目: trimlab/microMVP
    def __init__(self, **params):
        title = gui.Label("About microMVP")

        width = 400
        height = 200
        doc = gui.Document(width=width)

        space = title.style.font.size(" ")

        doc.block(align=0)
        for word in """microMVP v2.0""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        doc.block(align=-1)
        for word in """microMVP v2.0""".split(" "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        gui.Dialog.__init__(self, title, gui.ScrollArea(doc, width, height))
示例#26
0
    def __init__(self, **params):
        title = gui.Label("Help")

        doc = gui.Document(width=400)

        space = title.style.font.size(" ")

        doc.block(align=-1)
        for word in """Made By Dara Sami\nemail: [email protected]\nstudentnumber:4313992""".split(
                "\n"):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        doc.block(align=-1)
        for word in """For any questions you can contact me.\n """.split("\n"):
            doc.add(gui.Label(word))
            doc.space(space)

        doc.block(align=-1)
        for word in """\nThis script visualizes a 2D steady flow around an airfoil in Pygame.\n The Flow.py script computes the flow using the vortex panel method. \n
The airfoil, angle of attack and flow accuracy are parameters that can be adjusted if desired\n(increasing doubles the grid).\n After changing the parameters click the Recompute flow button to recompute. \n This might take up to 20 seconds depending on the desired accuracy and your computer.\n\nYou can browse through some of the airfoils I have added to the program,but you can always \nadd more .dat files. \nPlease note that each .dat file must only contain coordinates in Selig format \n(see available .dat files as an example)and must be seperated by tabs.""".split(
                "\n"):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        doc.block(align=-1)
        for word in """I built the Flow.by code with the help of a course provided by Prof. Lorena.A.Barba.\nSource: http://lorenabarba.com/blog/announcing-aeropython/\nhere step-by-step instructions are found for vortex panel modeling.\nI slightly modified the code to make it suitable for pygame.
\nThe GUI.py script creates the menu.I made it using example code(gui18) contained in the PGU library.\nSource:http://pygame.org/project-PGU+-+Phil's+pyGame+Utilities-108-.html        
        
        
        """.split("\n"):
            doc.add(gui.Label(word))
            doc.space(space)

        gui.Dialog.__init__(self, title, doc)
示例#27
0
    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()
示例#28
0
    def __init__(self, **params):
        title = gui.Label("About PiCore")

        width = 400
        height = 200
        doc = gui.Document(width=width)

        space = title.style.font.size(" ")

        doc.block(align=0)
        for word in """PiCore v0.8 by Callum Lawson and Lawrence Esswood""".split(
                " "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        doc.block(align=0)
        for word in """A reincarnation of Corewars for the Raspberry Pi and other platforms.""".split(
                " "):
            doc.add(gui.Label(word))
            doc.space(space)
        doc.br(space[1])

        gui.Dialog.__init__(self, title, doc)
示例#29
0
    if len(tw):
        w = tw.pop()
        t.remove(w)


t.tr()
w = gui.Button('Add')
w.connect(gui.CLICK, t_add, None)
t.td(w, colspan=3)

w = gui.Button('Remove')
w.connect(gui.CLICK, t_remove, None)
t.td(w, colspan=3)

#####################################
d = gui.Document(width=240, height=120)

dn = 0
dw = []


def d_add(value):
    global dn
    w = gui.Label("%d " % dn)
    dw.append(w)
    d.add(w)
    dn += 1


def d_remove(value):
    if len(dw):
    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)