def surfaceLoad(self): self.leftBrick = self.Brick(30) self.rightBrick = self.Brick(self.screensize[0]-50) self.brickRects = [self.rightBrick, self.leftBrick] self.pauseMenu = widgets.PauseMenu() self.statusText = widgets.Text(550, 600, str(self.statusMessage), 30) self.pointsTextP1 = widgets.Text(500, 50, str(self.player1), 50) self.pointsTextP2 = widgets.Text(700, 50, str(self.player2), 50) self.ball = self.Ball(self)
def showGamePause(self): if game.isPaused: #Hiding menu game.isPaused = False for n in self.pausedWidgets: self.widgets.remove(n) self.pausedWidgets = None else: self.pausedWidgets = [] pos = ((game.SCREEN_SIZE[0] - 320) / 2, (game.SCREEN_SIZE[1] - 600) / 2) self.pausedWidgets.append( widgets.Icon(pygame.Rect(pos[0], pos[1], 320, 600), game.assets['img/gameover.png'])) pos = (pos[0] + 10, pos[1] + 10) rect = pygame.Rect(pos[0], pos[1], 300, 40) self.pausedWidgets.append( widgets.Text(rect, 'Paused.', font='gameover1')) pollution = len([ i for i in range(game.corruption.size[0] * game.corruption.size[1]) if game.corruption.surface[i] > 1 ]) def quitCb(*_): game.gameIsRunning = False def resumeCb(*_): self.showGamePause() def mainCb(*_): self.nextScene = self.parent rect.top += 300 self.pausedWidgets.append( widgets.TextButton(rect, 'Resume.', font='gameover3', callback=resumeCb)) rect.top += 50 self.pausedWidgets.append( widgets.TextButton(rect, 'Exit to menu.', font='gameover3', callback=mainCb)) rect.top += 50 self.pausedWidgets.append( widgets.TextButton(rect, 'Exit game.', font='gameover3', callback=quitCb)) for n in self.pausedWidgets: self.widgets.append(n) game.isPaused = True
def widget(self, date): widget = wd.Widget() now = date.time() hour = wd.Text( text=str(now.hour) + "h", font=wd.Font("AmericanTypewriter-Bold", 50), color=FOREGROUND, ) minutes = wd.DynamicDate(date=time(now.hour, 0, 0), style=wd.DATE_STYLE_RELATIVE, font=wd.Font("AmericanTypewriter", 17), color=FOREGROUND, padding=wd.PADDING_ALL) layouts = [widget.small_layout, widget.medium_layout] for layout in layouts: layout.add_vertical_spacer() layout.add_row([hour]) layout.add_row([minutes]) layout.set_background_color(BACKGROUND) return widget
def complication(self, date): min = date.time().minute text = wd.Text(str(min), font=wd.Font.bold_system_font_of_size(20)) complication = wt.Complication() complication.circular.add_row([text]) return complication
def add_post(post, layout, link=False): # If 'line' is 'True', the UI elements will be tappable if link: url = post.url else: url = None # Add the title of the post layout.add_row([ wd.Text( post.title, color=FOREGROUND_COLOR, font=wd.Font.bold_system_font_of_size(17), padding=wd.Padding(5, 0, 10, 10) ) ], link=url) layout.add_vertical_spacer() # Add the content of the post # post.content can contain HTML code # HTML code is automatically converted into plain text (no markup) layout.add_row([ wd.Text(post.content, color=FOREGROUND_COLOR, link=url, padding=wd.PADDING_HORIZONTAL ), ]) layout.add_vertical_spacer() # Add the publication date layout.add_row([ wd.Spacer(), wd.DynamicDate( post.date, color=FOREGROUND_COLOR, padding=wd.Padding(0, 10, 10, 10) ) ], link=url) # Set the background color of the widget layout.set_background_gradient(BACKGROUND_GRADIENT)
def __init__(self, screen, parent=False, username=False): self.screen = screen self.parent = parent self.username = username self.load() if self.parent: self.backButton = widgets.Button(25, screensize[1]-75, 100, 50, (255, 255, 255), text="Back") if self.username: self.loggedinText = widgets.Text(800, 650, "Logged in as "+self.username, 30) self.update()
def showGameover(self): pos = ((game.SCREEN_SIZE[0] - 320) / 2, (game.SCREEN_SIZE[1] - 600) / 2) self.widgets.append( widgets.Icon(pygame.Rect(pos[0], pos[1], 320, 600), game.assets['img/gameover.png'])) pos = (pos[0] + 10, pos[1] + 10) rect = pygame.Rect(pos[0], pos[1], 300, 40) self.widgets.append(widgets.Text(rect, 'Game over!', font='gameover1')) pollution = len([ i for i in range(game.corruption.size[0] * game.corruption.size[1]) if game.corruption.surface[i] > 1 ]) rect.top += 50 self.widgets.append( widgets.Text(rect, 'You survived %d nights.' % int(game.clock / game.dayTicks), font='gameover2')) rect.top += 50 self.widgets.append( widgets.Text(rect, 'You killed %d defenseless people.' % game.spawnedTotal, font='gameover2')) rect.top += 50 self.widgets.append( widgets.Text(rect, 'You destroyed %d acres of land.' % pollution, font='gameover2')) rect.top += 50 self.widgets.append(widgets.Text(rect, 'And why?', font='gameover3')) rect.top += 50 self.widgets.append( widgets.Text(rect, 'They were only defending themselves.', font='gameover2')) rect.top += 100 def quitCb(*_): game.gameIsRunning = False self.widgets.append( widgets.TextButton(rect, 'Exit.', font='gameover3', callback=quitCb)) rect.top += 50 def mainCb(*_): self.nextScene = self.parent self.widgets.append( widgets.TextButton(rect, 'Main menu.', font='gameover3', callback=mainCb))
def widget(self, date): widget = wd.Widget() layout = widget.medium_layout day = wd.Text(text=weekday(date), font=wd.Font("AmericanTypewriter-Bold", 50), color=FOREGROUND) date_text = wd.DynamicDate(date=date, font=wd.Font("AmericanTypewriter", 18), color=FOREGROUND, padding=wd.PADDING_ALL) layout.add_vertical_spacer() layout.add_row([day]) layout.add_row([date_text]) layout.set_background_color(BACKGROUND) layout.set_link(date.ctime()) return widget
from mainthread import mainthread BACKGROUND = wd.Color.rgb(255 / 255, 250 / 255, 227 / 255) FOREGROUND = wd.Color.rgb(75 / 255, 72 / 255, 55 / 255) @mainthread def suspend(): UIApplication.sharedApplication.suspend() note = input("Note: ") widget = wd.Widget() text = wd.Text(note, font=wd.Font("AmericanTypewriter", 18), color=FOREGROUND, padding=wd.PADDING_HORIZONTAL) symbol = wd.SystemSymbol(sf.PENCIL, padding=wd.Padding(10, 0, 10, 0), font_size=20) layouts = [widget.small_layout, widget.medium_layout, widget.large_layout] for layout in layouts: layout.add_row([symbol, wd.Spacer()]) layout.add_vertical_spacer() layout.add_row([text]) layout.add_vertical_spacer() layout.set_background_color(BACKGROUND)
cur = conn.cursor() cur.execute('SELECT dates FROM date_test WHERE date_test_id = 1') stored_date = cur.fetchone()[0] entrylabel.config(text=stored_date) label3 = wdg.Label(root, text='Combobox:', takefocus=1) label3.grid(column=0, row=4) combobox = wdg.ClickAnywhereCombo(root) combobox.grid(column=1, row=4) combobox.insert(0, '1499') label4 = wdg.Label(root, text='Text:', takefocus=1) label4.grid(column=0, row=5) text = wdg.Text(root, width=40, height=1) text.grid(column=1, row=5, columnspan=2) text.insert(1.0, '1601') show = wdg.Label(root) show.grid(column=0, row=6, columnspan=2) widgets = [simple, mostring, clarif3, clarif2, ranje, span, span1, span2] u = 0 for widg in widgets: button = wdg.Button( root, text='Validate', command=lambda widg=widg: validate.run_validator(widg)) button.grid(column=u, row=2)
if wd.link is None: wd.wait_for_internet_connection() posts = get_posts() widget = wd.Widget() # # # # # # Small # # # # # # # Add the post's title widget.small_layout.add_row([ wd.Text( posts[0].title, color=FOREGROUND_COLOR, font=wd.Font.bold_system_font_of_size(17), padding=wd.Padding(10, 0, 10, 10) ) ]) # Add the publication date at the bottom widget.small_layout.add_vertical_spacer() widget.small_layout.add_row([ wd.DynamicDate( posts[0].date, color=FOREGROUND_COLOR, padding=wd.Padding(0, 5, 0, 0) ) ]) # If the widget is pressed, the post's URL will be passed to the script