def __init__(self, window): QWebView.__init__(self) self.window = window with open(get_resource_path("leftpane.js"), "r") as f: self.js = f.read() self.setFixedWidth(0) self.setVisible(False) self.setUrl(QUrl.fromLocalFile(get_resource_path("leftpane.html"))) self.page().currentFrame().addToJavaScriptWindowObject("leftPane", self) self.page().currentFrame().evaluateJavaScript(self.js)
def intro(screen): #path list begins here music_path=resources.get_resource_path("BiancoHills.ogg", "music/Areas") mario_path=resources.get_resource_path("Mario.png", "images") grass_path=resources.get_resource_path("Grass.png", "images") bg_path=resources.get_resource_path("Grass_BG.png", "bg") jump_path=resources.get_resource_path("Mario_run_sprite.png", "images") mario=pygame.image.load(mario_path) grass=pygame.image.load(grass_path) bg=pygame.image.load(bg_path) mario_jump=pygame.image.load(jump_path) blit=screen.blit flip=pygame.display.flip fill=screen.fill music=pygame.mixer.music music.stop() music.load(music_path) music.set_volume(1) music.play(-1) mariox=0 marioy=0 jump=False up=True traveled=0 while mariox < 640: fill([0,0,0]) blit(bg, [0,0]) for i in [0, 72, 144, 216, 360, 432, 576]: blit(grass, [i, 200]) marioh=mario.get_rect().height if mariox==288:jump=True elif mariox==504:jump=True if traveled >=72:jump=False; traveled=0 if not jump: blit(mario, [mariox, 200-marioh+marioy]) up=True else: traveled+=1 if marioy<=-36:up=False if up:marioy-=1 else:marioy+=1 blit(mario_jump, [mariox, 200-marioh+marioy]) flip() mariox+=1 for event in pygame.event.get(): if event.type==pygame.KEYDOWN: if event.key==pygame.K_UP: jump=True #TODO:replace with code to run game pygame.quit() raise SystemExit
def __init__(self, parent = None, settings_path = "~/.config/scudcloud"): super(ScudCloud, self).__init__(parent) self.setWindowTitle('ScudCloud') self.settings_path = settings_path self.notifier = Notifier(self.APP_NAME, get_resource_path('scudcloud.png')) self.settings = QSettings(self.settings_path + '/scudcloud.cfg', QSettings.IniFormat) self.identifier = self.settings.value("Domain") if Unity is not None: self.launcher = Unity.LauncherEntry.get_for_desktop_id("scudcloud.desktop") else: self.launcher = DummyLauncher(self) self.leftPane = LeftPane(self) self.cookiesjar = PersistentCookieJar(self) self.zoom = self.readZoom() webView = Wrapper(self) webView.page().networkAccessManager().setCookieJar(self.cookiesjar) self.stackedWidget = QtGui.QStackedWidget() self.stackedWidget.addWidget(webView) centralWidget = QtGui.QWidget(self) layout = QtGui.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.leftPane) layout.addWidget(self.stackedWidget) centralWidget.setLayout(layout) self.setCentralWidget(centralWidget) self.addMenu() self.tray = Systray(self) self.systray(ScudCloud.minimized) self.installEventFilter(self) if self.identifier is None: webView.load(QtCore.QUrl(self.SIGNIN_URL)) else: webView.load(QtCore.QUrl(self.domain())) webView.show()
def __init__(self, img_name, img_domain="images", pos=[0,0], hp=1): img=resources.get_resource_path(img_name, img_domain) self.image=pygame.image.load(img) self.rect=self.image.get_rect() self.rect.left, self.rect.top = pos self.hp=hp super(GObject, self).__init__()
def loadroom(room): pygame.init() mixer=pygame.mixer mixer.init() music=mixer.music heroes, villains, solid, rendered, music_name, bg=room() print villains.sprites() path=resources.get_resource_path(music_name, "music") music.load(path) music.set_volume(0.5) music.play(-1) others=pygame.sprite.Group() pygame.key.set_repeat(10, 10) screen=pygame.display.set_mode([640,480]) fill=screen.fill blit=screen.blit flip=pygame.display.flip load=pygame.image.load clock=pygame.time.Clock() groups=[heroes, villains, others] while True: screen.fill(bg) rendered.draw(screen) clock.tick(30) kw={"heroes":heroes, "villains":villains, "others":others, "rendered":rendered, "solid":solid, "events":pygame.event.get()} for i in groups: i.update(kw) rendered.draw(screen) flip()
def urlChanged(self, qUrl): self.settings().setUserStyleSheetUrl( QUrl.fromLocalFile(get_resource_path("login.css"))) self.page().currentFrame().addToJavaScriptWindowObject("desktop", self) boot_data = self.page().currentFrame().evaluateJavaScript(self.js) self.window.quicklist(boot_data['channels']) self.window.teams(boot_data['teams']) self.window.enableMenus(self.isConnected()) url = qUrl.toString() if self.window.SIGNIN_URL != url and url.endswith(".slack.com/"): self.window.settings.setValue("Domain", 'https://'+qUrl.host())
def __init__(self, window): QWebView.__init__(self) self.window = window with open(get_resource_path("scudcloud.js"), "r") as f: self.js = f.read() QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True) QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.window.debug) self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged) self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) self.addActions()
def __init__(self, window): QWebView.__init__(self) self.window = window with open(get_resource_path("scudcloud.js"), "r") as f: self.js = f.read() # Required by Youtube videos (HTML5 video support only on Qt5) QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True) # We don't want Java QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled, False); # We don't need History QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True); # Required for copy and paste clipboard integration QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True) # Enabling Inspeclet only when --debug=True (requires more CPU usage) QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.window.debug) self.setZoomFactor(self.window.zoom) self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged) self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) self.addActions()
import pygame, resources, optparse, intro p=optparse.OptionParser() p.add_option('--test', '-t', action='store_true') options, arguments=p.parse_args() pygame.init() mixer=pygame.mixer mixer.init() music=mixer.music screen=pygame.display.set_mode([640,480]) flip=pygame.display.flip blit=screen.blit load=pygame.image.load fill=screen.fill #path list begins here title_path=resources.get_resource_path("FinalBowserCastleSMG2.ogg", "music/Areas") titlebg_path=resources.get_resource_path("SuperMarioGalaxyTitle.png", "images") #path list ends here music.load(title_path) music.set_volume(1) music.play(-1) titlebg=load(titlebg_path) fill([0,0,0]) blit(titlebg, [0,0]) flip() run=1 q=0 clear=0 if options.test:clear=1 while run: for event in pygame.event.get(): if event.type==pygame.QUIT:
def notify(self, title, message, retry=True): notice = notify2.Notification(title, message, get_resource_path('scudcloud.png')) # Allow appending new message to existing notification. notice.set_hint_string('x-canonical-append', '') notice.show() self.alert()