示例#1
0
class Cronometro(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.main_window = Ui_MainWindow()
        self.main_window.setupUi(self)

        self.cron_window = PyGameWindow()
        self.cron_window.setWindowName("Marvin")

        self.timer = QtCore.QTimer(self)
        self.timer.setInterval(1000/60)

        self.file_name = ""

        # procedo a conectar los SIGNALS
        QtCore.QObject.connect(self.main_window.actionOpen_Race,QtCore.SIGNAL(_fromUtf8("activated()")),self.openFile)
        QtCore.QObject.connect(self.main_window.actionSave_As,QtCore.SIGNAL(_fromUtf8("activated()")),self.saveFileAs)
        QtCore.QObject.connect(self.main_window.actionSave_Race,QtCore.SIGNAL(_fromUtf8("activated()")),self.saveFile)


        QtCore.QObject.connect(self.timer,QtCore.SIGNAL(_fromUtf8("timeout()")),self.cron_window.update)

        self.timer.start()


    def hola(self):
        print "hola estoy corriendo =)"



    def openFile(self):
        self.file_name = QtGui.QFileDialog.getOpenFileName(self,
                                    _fromUtf8("Open Race..."),
                                    _fromUtf8("~"),
                                    _fromUtf8("Race Files (*.race);;All Files (*.*)"))


    def saveFileAs(self):
        self.file_name = QtGui.QFileDialog.getSaveFileName(self,
                                    _fromUtf8("Save Race As..."),
                                    _fromUtf8("sin_titulo.race"),
                                    _fromUtf8("Race Files (*.race);;All Files (*.*)"))


    def saveFile(self):
        if self.file_name == "":
            self.saveFileAs()
示例#2
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.main_window = Ui_MainWindow()
        self.main_window.setupUi(self)

        self.cron_window = PyGameWindow()
        self.cron_window.setWindowName("Marvin")

        self.timer = QtCore.QTimer(self)
        self.timer.setInterval(1000/60)

        self.file_name = ""

        # procedo a conectar los SIGNALS
        QtCore.QObject.connect(self.main_window.actionOpen_Race,QtCore.SIGNAL(_fromUtf8("activated()")),self.openFile)
        QtCore.QObject.connect(self.main_window.actionSave_As,QtCore.SIGNAL(_fromUtf8("activated()")),self.saveFileAs)
        QtCore.QObject.connect(self.main_window.actionSave_Race,QtCore.SIGNAL(_fromUtf8("activated()")),self.saveFile)


        QtCore.QObject.connect(self.timer,QtCore.SIGNAL(_fromUtf8("timeout()")),self.cron_window.update)

        self.timer.start()
示例#3
0
'''
Main file of the game: Implementation of the Interface with pygame
'''

import pygame
from game import Game2048
from pygame_window import PyGameWindow

if __name__ == '__main__':
    pygame.init()
    game2048 = Game2048()
    pygameWindow = PyGameWindow(game2048)
    pygameWindow.launch()
    pygame.quit()

    
    
示例#4
0
from research_queue import ResearchQueue
from operator import sub

###
# User defined fancy stuff
WINDOW_SIZE = (360, 160)  # Width and height (or vice versa)
BACKGROUND_COLOUR = (244, 214, 172)  # RGB
FONT_SIZE = 12
FONT_COLOUR = (0x00, 0x00, 0x00)  # RGB

MAX_FPS = 40

###

# Creates the window
window = PyGameWindow(WINDOW_SIZE, MAX_FPS)

# Set our fancy stuff
window.background = BACKGROUND_COLOUR
window.font_size = FONT_SIZE
window.font_colour = FONT_COLOUR

# Init the stuff here.
window.on_top()
screen = ScreenShooter()

# Filter functions for gathered resources (10, -50, 10)
positive_sum = lambda x: sum(filter(lambda x: x > 0, x)
                             )  # Sum of positive values
negative_sum = lambda x: -sum(filter(lambda x: x < 0, x))  # Sum of negative