コード例 #1
0
 def __init__(self, shell, filename, **kwds):
     
     text = get_text(filename)
     text_pages = text.split("\nPAGE\n")
     pages = []
     page_size = (0, 0)
     for text_page in text_pages:
         lines = text_page.strip().split("\n")
         page = Page(self, lines[0], lines[1:])
         pages.append(page)
         page_size = maximum(page_size, page.size)
     self.pages = pages
     bf = self.button_font
     b1 = Button("Prev Page", font = bf, action = self.prev_page)
     b2 = Button("Menu", font = bf, action = self.go_back)
     b3 = Button("Next Page", font = bf, action = self.next_page)
     
     self.b = ((shell.rect.width-page_size[0])/2, (shell.rect.height-page_size[1])/2)
     
     page_rect = Rect(self.b, page_size)
     gap = (0, 18)
     b1.topleft = add(page_rect.bottomleft, gap)
     b2.midtop = add(page_rect.midbottom, gap)
     b3.topright = add(page_rect.bottomright, gap)
     Screen.__init__(self, shell, **kwds)
     self.size =  add(b3.bottomright, self.b)
     self.add(b1)
     self.add(b2)
     self.add(b3)
     self.prev_button = b1
     self.next_button = b3
     self.set_current_page(0)
コード例 #2
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		self.shell = shell
		f1 = get_font(24, "VeraBd.ttf")
		title = Label("Rdrive", font = f1)
		def screen_button(text, screen):
			return Button(text, action = lambda: shell.show_screen(screen))
		menu = Column([
			screen_button("Text Screen", shell.text_screen),
			screen_button("Text Fields", shell.fields_screen),
			screen_button("Controls", shell.controls_screen),
			screen_button("Timing", shell.anim_screen),
			screen_button("Grid View", shell.grid_screen),
			screen_button("Palette View", shell.palette_screen),
			screen_button("Image Array", shell.image_array_screen),
			screen_button("Modal Dialogs", shell.dialog_screen),
			screen_button("Tab Panel", shell.tab_panel_screen),
			screen_button("Table View", shell.table_screen),
			Button("Quit", shell.quit),
		], align = 'l')
		contents = Column([
			title,
			menu,
		], align = 'l', spacing = 20)
		self.add_centered(contents)
コード例 #3
0
 def __init__(self, shell):
     Screen.__init__(self, shell)
     self.model = DemoControlsModel()
     width_field = FloatField(ref=AttrRef(self.model, 'width'))
     height_field = FloatField(ref=AttrRef(self.model, 'height'))
     area_display = ValueDisplay(ref=AttrRef(self.model, 'area'),
                                 format="%.2f")
     shape = AttrRef(self.model, 'shape')
     shape_choices = Row([
         RadioButton(setting='rectangle', ref=shape),
         Label("Rectangle"),
         RadioButton(setting='triangle', ref=shape),
         Label("Triangle"),
         RadioButton(setting='ellipse', ref=shape),
         Label("Ellipse"),
         ProgressBar(100, 50, ref=AttrRef(self.model, 'area')),
     ])
     grid = Grid([
         [Label("Width"), width_field],
         [Label("Height"), height_field],
         [Label("Shape"), shape_choices],
         [Label("Area"), area_display],
     ])
     back = Button("Menu", action=shell.show_menu)
     contents = Column([grid, back])
     self.add_centered(contents)
     width_field.focus()
コード例 #4
0
ファイル: gui.py プロジェクト: AnnanFay/pyge-solitaire
 def __init__(self, shell):
     Screen.__init__(self, shell)
     self.shell = shell
     title = Label("Pyge", font = self.f1)
     def screen_button(text, screen):
         return Button(text, action = lambda: shell.show_screen(screen))
     
     menu = Column(
         [
             screen_button("Play", shell.board_screen),
             screen_button("Help", shell.help_screen),
             screen_button("Settings", shell.settings_screen),
             Button("Quit", shell.quit),
         ],
         align = 'l'
     )
     contents = Column(
         [
             title,
             menu,
         ],
         align = 'l',
         spacing = 20
     )
     self.add_centered(contents)
コード例 #5
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		f = get_font(15, "VeraBd.ttf")
		title = Label("Norwegian Butter Exports", font = f)
		table = DemoTableView()
		back = Button("Menu", action = shell.show_menu)
		contents = Column([title, table, back], spacing = 30)
		self.add_centered(contents)
コード例 #6
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		grid = DemoGridView()
		lbl = Label("Cl1ck a Squ4r3")
		grid.output = lbl
		btn = Button("Menu", action = self.go_back)
		contents = Column([grid, lbl, btn], align = 'l', spacing = 30)
		self.add_centered(contents)
コード例 #7
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		w, h = self.size
		grid = DemoPaletteView()
		grid.center = (w/2, h/2)
		self.add(grid)
		btn = Button("Menu", action = self.go_back)
		btn.center = (w/2, h - 50)
		self.add(btn)
コード例 #8
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		pages = TabPanel()
		pages.size = 300, 200
		self.pages = pages
		for i in xrange(1, 4):
			page = self.make_test_page(i)
			pages.add_page("Page %s" % i, page)
		back = Button("Menu", action = shell.show_menu)
		contents = Column([pages, back], spacing = 30)
		self.add_centered(contents)
コード例 #9
0
	def __init__(self, shell):
		Screen.__init__(self, shell)
		self.rect = shell.rect.inflate(-100, -100)
		w, h = self.size
		self.points = [[100, 50], [w - 50, 100], [50, h - 50]]
		from random import randint
		def randv():
			return randint(-5, 5)
		self.velocities = [[randv(), randv()] for i in range(len(self.points))]
		btn = Button("Menu", action = self.go_back)
		btn.rect.center = (w/2, h - 20)
		self.add(btn)
コード例 #10
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		self.images = get_image_array("fruit.png", shape = 3, border = 2)
		self.image = Image(self.images[0])
		self.index = 0
		contents = Column([
			Label("Image Array", font = get_font(18, "VeraBd.ttf")),
			self.image,
			Button("Next Fruit", action = self.next_image),
			Button("Menu", action = shell.show_menu),
		], spacing = 30)
		self.add_centered(contents)
コード例 #11
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		self.rect = shell.rect.inflate(-100, -100)
		w, h = self.size
		self.points = [[100, 50], [w - 50, 100], [50, h - 50]]
		from random import randint
		def randv():
			return randint(-5, 5)
		self.velocities = [[randv(), randv()] for i in range(len(self.points))]
		btn = Button("Menu", action = self.go_back)
		btn.rect.center = (w/2, h - 20)
		self.add(btn)
コード例 #12
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		menu = Column([
			Button("Ask a Question", self.test_ask),
			Button("Request Old Filename", self.test_old),
			Button("Request New Filename", self.test_new),
			Button("Look for File or Directory", self.test_lookfor),
		], align = 'l')
		contents = Column([
			Label("File Dialogs", font = get_font(18, "VeraBd.ttf")),
			menu,
			Button("Menu", action = shell.show_menu),
		], align = 'l', spacing = 30)
		self.add_centered(contents)
コード例 #13
0
	def __init__(self, shell):
		Screen.__init__(self, shell)
		menu = Column([
			Button("Ask a Question", self.test_ask),
			Button("Request Old Filename", self.test_old),
			Button("Request New Filename", self.test_new),
			Button("Look for File or Directory", self.test_lookfor),
		], align = 'l')
		contents = Column([
			Label("File Dialogs", font = get_font(18, "VeraBd.ttf")),
			menu,
			Button("Menu", action = shell.show_menu),
		], align = 'l', spacing = 30)
		self.add_centered(contents)
コード例 #14
0
ファイル: demo2.py プロジェクト: shaik9/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		self.fld1 = self.add_field("Name", 200)
		self.fld2 = self.add_field("Race", 250)
		btn = Button("OK", action = self.ok)
		btn.rect.midtop = (320, 300)
		self.add(btn)
		out = Label("")
		out.rect.width = 400
		out.rect.topleft = (200, 350)
		self.out = out
		self.add(out)
		btn = Button("Menu", action = self.go_back)
		btn.rect.midtop = (320, 400)
		self.add(btn)
		self.fld1.focus()
コード例 #15
0
ファイル: demo.py プロジェクト: arafat-al-mahmud/rdrive
	def __init__(self, shell):
		Screen.__init__(self, shell)
		self.shell = shell
		f1 = get_font(24, "VeraBd.ttf")
		title = Label("Rdrive", font = f1)
		def screen_button(text, screen):
			return Button(text, action = lambda: shell.show_screen(screen))
		menu = Column([
			screen_button("Controls", shell.controls_screen),
			Button("Quit", shell.quit),
		], align = 'l')
		contents = Column([
			title,
			menu,
		], align = 'l', spacing = 20)
		self.add_centered(contents)
コード例 #16
0
ファイル: test.py プロジェクト: mammoths/mammoths.github.io
    def __init__(self, shell):
        Screen.__init__(self, shell)
        self.shell = shell
        f1 = get_font(24, "VeraBd.ttf")
        title = Label("Test Demo", font=f1)

        def screen_button(text, screen):
            return Button(text, action=lambda: shell.show_screen(screen))

        start_button = screen_button("Start", shell.button1)
        start_button.enabled_bg_color = Color("green")
        quit_button = Button("Quit", shell.quit)
        quit_button.enabled_bg_color = Color("red")
        menu = Column([start_button, quit_button], align='l')
        contents = Column([
            title,
            menu,
        ], align='l', spacing=20)
        self.add_centered(contents)
コード例 #17
0
    def __init__(self, shell):

        Screen.__init__(self, shell)
        self.shell = shell  #so save can use

        def setting(name):
            return AttrRef(self.shell.settings, name)

        self.size_field = IntField(ref=setting('board_size'))
        self.size_field.enter_action = self.save

        board_styles = [(b.title, b.title) for b in shell.pyge.board_styles]
        style_name = setting('board_style')
        self.style_choices = SelectField(board_styles, style_name)
        self.style_choices.enter_action = self.save

        self.highlights = Grid([
            [
                CheckBox(ref=setting('highlight_selected')),
                Label("Selected Peg")
            ],
            [
                CheckBox(ref=setting('highlight_moves')),
                Label("Possible Moves")
            ],
        ])

        self.show_grid = CheckBox(ref=setting('show_grid'))

        grid = Grid([
            [Label("Board Size"), self.size_field],
            [Label("Board Style"), self.style_choices],
            [Label("Highlight"), self.highlights],
            [Label("Show Grid"), self.show_grid],
        ])

        back = Button("Menu", action=shell.show_menu)
        save = Button("Save", action=self.save)

        contents = Column([grid, save, back])
        self.add_centered(contents)

        self.size_field.focus()
コード例 #18
0
    def __init__(self, shell):
        Screen.__init__(self, shell)
        self.shell = shell
        f1 = get_font(24, "VeraBd.ttf")
        title = Label("Rdrive", font=f1)

        def screen_button(text, screen):
            return Button(text, action=lambda: shell.show_screen(screen))

        menu = Column([
            screen_button("Controls", shell.controls_screen),
            Button("Quit", shell.quit),
        ],
                      align='l')
        contents = Column([
            title,
            menu,
        ], align='l', spacing=20)
        self.add_centered(contents)
コード例 #19
0
    def __init__(self, shell):
        Screen.__init__(self, shell)
        self.shell = shell
        title = Label("Pyge", font=self.f1)

        def screen_button(text, screen):
            return Button(text, action=lambda: shell.show_screen(screen))

        menu = Column([
            screen_button("Play", shell.board_screen),
            screen_button("Help", shell.help_screen),
            screen_button("Settings", shell.settings_screen),
            Button("Quit", shell.quit),
        ],
                      align='l')
        contents = Column([
            title,
            menu,
        ], align='l', spacing=20)
        self.add_centered(contents)
コード例 #20
0
    def __init__(self, shell):

        Screen.__init__(self, shell)

        self.pyge = shell.pyge

        self.rect = shell.rect
        w, h = self.size

        bc = BoardContainer(self)
        self.add_centered(bc)

        #add buttons
        menu_button = Button("Menu", action=self.go_back)
        menu_button.rect.center = (w / 1.5, h - 20)
        self.add(menu_button)

        undo_button = Button("Undo", action=self.undo)
        undo_button.rect.center = (w / 3, h - 20)
        self.add(undo_button)
コード例 #21
0
ファイル: gui.py プロジェクト: AnnanFay/pyge-solitaire
 def __init__(self, shell):
     
     Screen.__init__(self, shell)
     
     self.pyge = shell.pyge
     
     self.rect = shell.rect
     w, h = self.size
     
     bc = BoardContainer(self)
     self.add_centered(bc)
     
     #add buttons
     menu_button = Button("Menu", action = self.go_back)
     menu_button.rect.center = (w/1.5, h - 20)
     self.add(menu_button)
     
     undo_button = Button("Undo", action = self.undo)
     undo_button.rect.center = (w/3, h - 20)
     self.add(undo_button)
コード例 #22
0
ファイル: demo.py プロジェクト: arafat-al-mahmud/rdrive
	def dispatch_key(self, name, event):
		Screen.dispatch_key(self,name,event)

		self.old_dir= self.dir
		
		if event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_UP:
			self.dir=1
		if event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_DOWN:
			self.dir= -1
		if event.type == pygame.KEYUP and event.dict['key'] == pygame.K_UP:
			self.dir= 0
		if event.type == pygame.KEYUP and event.dict['key'] == pygame.K_DOWN:
			self.dir= 0

		grid = Grid([
                [Label("Width")],
                [Label("Height")],
                [Label("Shape")],
                [Label("Area")],
        ])
		contents = Column([grid])
		self.add(contents)
コード例 #23
0
	def __init__(self, shell):
		Screen.__init__(self, shell)
		model = DemoControlsModel()
		width_field = FloatField(ref = AttrRef(model, 'width'))
		height_field = FloatField(ref = AttrRef(model, 'height'))
		area_display = ValueDisplay(ref = AttrRef(model, 'area'), format = "%.2f")
		shape = AttrRef(model, 'shape')
		shape_choices = Row([
			RadioButton(setting = 'rectangle', ref = shape), Label("Rectangle"),
			RadioButton(setting = 'triangle', ref = shape), Label("Triangle"),
			RadioButton(setting = 'ellipse', ref = shape), Label("Ellipse"),
		])
		grid = Grid([
			[Label("Width"), width_field],
			[Label("Height"), height_field],
			[Label("Shape"), shape_choices],
			[Label("Area"), area_display],
		])
		back = Button("Menu", action = shell.show_menu)
		contents = Column([grid, back])
		self.add_centered(contents)
		width_field.focus()
コード例 #24
0
    def dispatch_key(self, name, event):
        Screen.dispatch_key(self, name, event)

        self.old_dir = self.dir

        if event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_UP:
            self.dir = 1
        if event.type == pygame.KEYDOWN and event.dict['key'] == pygame.K_DOWN:
            self.dir = -1
        if event.type == pygame.KEYUP and event.dict['key'] == pygame.K_UP:
            self.dir = 0
        if event.type == pygame.KEYUP and event.dict['key'] == pygame.K_DOWN:
            self.dir = 0

        grid = Grid([
            [Label("Width")],
            [Label("Height")],
            [Label("Shape")],
            [Label("Area")],
        ])
        contents = Column([grid])
        self.add(contents)
コード例 #25
0
ファイル: gui.py プロジェクト: AnnanFay/pyge-solitaire
 def __init__(self, shell):
 
     Screen.__init__(self, shell)
     self.shell = shell #so save can use
     
     def setting(name):
         return AttrRef(self.shell.settings, name)
     
     self.size_field = IntField(ref = setting('board_size'))
     self.size_field.enter_action = self.save
     
     board_styles = [(b.title,b.title) for b in shell.pyge.board_styles]
     style_name = setting('board_style')
     self.style_choices = SelectField(board_styles, style_name)
     self.style_choices.enter_action = self.save
     
     self.highlights = Grid([
         [CheckBox(ref = setting('highlight_selected')), Label("Selected Peg")],
         [CheckBox(ref = setting('highlight_moves')), Label("Possible Moves")],
     ])
     
     self.show_grid = CheckBox(ref = setting('show_grid'))
     
     grid = Grid([
         [Label("Board Size"), self.size_field],
         [Label("Board Style"), self.style_choices],
         [Label("Highlight"), self.highlights],
         [Label("Show Grid"), self.show_grid],
     ])
     
     back = Button("Menu", action = shell.show_menu)
     save = Button("Save", action = self.save)
     
     contents = Column([grid, save, back])
     self.add_centered(contents)
     
     self.size_field.focus()