示例#1
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))
示例#2
0
    def __init__(self, **params):
        title = gui.Label("Settings")
        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.Image(p('icons/choose_port.png'))
        self.box = gui.ScrollArea(spacer)
        table.tr()
        table.td(self.box, style={'border': 1})

        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)

        self.init_ports()
        gui.Dialog.__init__(self, title, self.container)
示例#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
文件: dialog.py 项目: tcjinaz/nxtIDE
    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)
示例#5
0
    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)
示例#6
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))
示例#7
0
    def __init__(self, **params):
        gui.Table.__init__(self, **params)
        self.value = gui.Form()
        self.engine = None

        self._data = ''

        self._count = 1
        self.focused = False

        def clickChatMsg(value):
            # disable movement when chat msg is mouse clicked
            if self.focused:
                self.focused = False
            else:
                self.focused = True

            g.canMoveNow = False

        self.tr()
        self.chatMsg = gui.Input(maxlength=128, width=468, focusable=False)
        self.chatMsg.connect(gui.CLICK, clickChatMsg, None)
        self.chatMsg.connect(gui.KEYDOWN, self.lkey)
        self.td(self.chatMsg)

        self.tr()
        self.chatList = gui.Table()
        self.box = gui.ScrollArea(self.chatList,
                                  width=480,
                                  height=172,
                                  hscrollbar=False)
        self.td(self.box)

        self.tr()

        class Hack(gui.Spacer):
            def __init__(self, box):
                super(gui.Spacer, self).__init__()
                self.box = box

            def resize(self, width=None, height=None):
                self.box.set_vertical_scroll(65535)
                return 1, 1

        dirtyHack = Hack(self.box)
        self.td(dirtyHack)
示例#8
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))
示例#9
0
    def _build_ui(self):
        self._solver_label, self._solver_field = self._create_solver_select()
        self._show_grid_label, self._show_grid_field = self._create_show_grid_checkbox(
        )
        self._show_grid_lines_label, self._show_grid_lines_field = self._create_show_grid_lines_checkbox(
        )
        self._num_ants_label, self._num_ants_field = self._create_num_ants_field(
        )

        self._solver_ui = self._build_solver_ui(self._get_default_solver())
        self._solver_container = gui.ScrollArea(self._solver_ui)
        self._on_solver_change(self._solver_field)

        self._build_buttons()

        self._main_container.tr()
        self._main_container.td(self._solver_label, valign=-1, align=-1)
        self._main_container.td(self._solver_field, valign=-1, align=-1)

        self._main_container.tr()
        self._main_container.td(self._num_ants_label, valign=-1, align=-1)
        self._main_container.td(self._num_ants_field, valign=-1, align=-1)

        self._main_container.tr()
        self._main_container.td(self._show_grid_label, valign=-1, align=-1)
        self._main_container.td(self._show_grid_field, valign=-1, align=-1)

        self._main_container.tr()
        self._main_container.td(self._show_grid_lines_label,
                                valign=-1,
                                align=-1)
        self._main_container.td(self._show_grid_lines_field,
                                valign=-1,
                                align=-1)

        self._main_container.tr()
        self._main_container.td(self._solver_container,
                                colspan=2,
                                valign=-1,
                                align=-1)

        self._main_container.tr()
        self._main_container.td(self._button_panel, colspan=2)
示例#10
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)
示例#11
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))
示例#12
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))
    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)
示例#14
0
            eval(code, globals(), _locals)
        except:
            e_type, e_value, e_traceback = sys.exc_info()
            print('Traceback (most recent call last):')
            traceback.print_tb(e_traceback, None, s)
            print(e_type, e_value)

        sys.stdout = _stdout


app = gui.Desktop()
t = gui.Table(width=500, height=400)

t.tr()
lines = gui.Table()
box = gui.ScrollArea(lines, 500, 380)
t.td(box)

t.tr()
line = gui.Input(size=49)
line.connect(gui.KEYDOWN, lkey)
t.td(line)

t.tr()


class Hack(gui.Spacer):
    def resize(self, width=None, height=None):
        box.set_vertical_scroll(65535)
        return 1, 1
示例#15
0
文件: replay.py 项目: smallka/replay
def main(filename):
	pygame.init()
	pygame.display.set_caption("Replay")

	clock = pygame.time.Clock()

	screen = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT), SWSURFACE)
	main_board = board.Board(screen, BOARD_LEFT, BOARD_TOP, BOARD_WIDTH, BOARD_HEIGHT)

	app = gui.App()
	container = gui.Container(align=-1, valign=-1)
	table = gui.Table()
	box = gui.ScrollArea(table, BOARD_WIDTH, BOARD_TOP)
	container.add(box, BOARD_LEFT, 0)
	app.init(container)

	proc = processor.Processor(filename)

	while True:
		need_scroll_down = False
		entities_count = len(entity.GetAllEntities())

		for event in pygame.event.get():
			if event.type == QUIT:
				pygame.quit()
				sys.exit()

			elif event.type == KEYUP:
				if event.key == K_ESCAPE:
					pygame.quit()
					sys.exit()

				elif event.key == K_j:
					# next cmd
					line = proc.Next()
					if line is not None:
						table.tr()
						table.td(gui.Label(line), align=-1)
						need_scroll_down = True

				elif event.key == K_k:
					# undo prev cmd
					if proc.Prev():
						table.remove_row(table.getRows() - 1)

				elif event.key == K_m:
					# next cmds until me move
					me = entity.GetMe()
					if me is not None:
						old_pos = me.pos
						while True:
							line = proc.Next()
							if line is None:
								break

							table.tr()
							table.td(gui.Label(line), align=-1)
							need_scroll_down = True

							if me.pos != old_pos:
								break

				elif event.key == K_a:
					main_board.AdjustScaleAndOffset(entity.GetAllEntities())

			elif event.type == MOUSEBUTTONDOWN:
				pos = pygame.mouse.get_pos()
				pos = main_board.TransformReverse(pos)
				ent = entity.GetEntityAtPos(pos)
				if ent is not None:
					entity.SetMe(ent)

				app.event(event)

			else:
				app.event(event)

		screen.fill(COLOR_BG)

		entities = entity.GetAllEntities()

		if len(entities) != entities_count:
			main_board.AdjustScaleAndOffset(entities)

		main_board.DrawCoordSystem()

		for ent in reversed(entities):
			ent.Draw(main_board)

		app.paint()
		pygame.display.flip()

		# bug: only work in next frame
		if need_scroll_down:
			box.set_vertical_scroll(65536)

		clock.tick(FPS)
示例#16
0
c.add(gui.Label("Click on Cuzco's Face!"), 0, 0)

img = gui.Image("cuzco.png")


def myfnc(_event, _widget, _code, a, b, c):
    print(_event, _widget, _code, a, b, c)
    pos = _event.pos
    img.value.fill((255, 0, 0), (pos[0], pos[1], 2, 2))
    img.repaint()
    t.tr()
    t.td(gui.Label(str(("point at ", pos))))
    prog.value += 1
    #box.resize()
    #box.set_vertical_scroll()


img.connect(gui.CLICK, myfnc, 1, 2, 3)

c.add(img, 20, 20)

t = gui.Table()
box = gui.ScrollArea(t, 300, 240)
c.add(box, 10, 120)

prog = gui.ProgressBar(10, 0, 40, width=200)
c.add(prog, 50, 400)

app.connect(gui.QUIT, app.quit, None)
app.run(c)
示例#17
0
import sys
sys.path.insert(0, "..")

from pgu import gui
from pgu import html

app = gui.Desktop()

##check if the documentation has been built
##::
fname = "../docs/index.html"
if not os.path.isfile(fname):
    print 'to run this demo, the documentation must be built'
    print '$ cd docs'
    print '$ python build.py'
##
else:

    ##open the file, hand it to a HTML object and display it
    ##::
    f = open(fname)
    text = "".join(f.readlines())
    f.close()

    doc = html.HTML(text, align=-1, valign=-1, width=800)

    view = gui.ScrollArea(doc, 820, 400)
    app.connect(gui.QUIT, app.quit, None)
    app.run(view)
    ##
示例#18
0
            eval(code, globals(), _locals)
        except:
            e_type, e_value, e_traceback = sys.exc_info()
            print('Traceback (most recent call last):')
            traceback.print_tb(e_traceback, None, s)
            print(e_type, e_value)

        sys.stdout = _stdout


app = gui.Desktop()
t = gui.Table(width=300, height=200)

t.tr()
lines = gui.Table()
box = gui.ScrollArea(lines, 300, 180)
t.td(box)

t.tr()
line = gui.Input(size=49)
line.connect(gui.KEYDOWN, lkey)
t.td(line)

t.tr()


class Hack(gui.Spacer):
    def resize(self, width=None, height=None):
        box.set_vertical_scroll(65535)
        return 1, 1
示例#19
0
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()
示例#20
0
    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)