コード例 #1
0
ファイル: main.py プロジェクト: frsilent/random
class StartQt4(QtGui.QMainWindow):

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.view = BoardView(self.ui.graphicsView)
        self.opponent = Ai()

        #event bindings
        QtCore.QObject.connect(self.ui.newGameButton,QtCore.SIGNAL("clicked()"),self.newGame)

    def newGame(self):
        self.view.clearBoard()
        self.board = None
        self.ui.winnerLabel.setText("Player goes first")

    def mousePressEvent(self, event):
        """
        Event executed after every mouse press; All internal game loop logic contained here
        """
        if self.view.winCheck():
            self.playerWin()

        #AI move
        self.opponent.updateBoard(self.view.boardMatrix)
        self.opponent.move()

        #check win

    def playerWin(self):
        self.ui.winnerLabel.setText("Congratulations! You won!")
コード例 #2
0
ファイル: run.py プロジェクト: releasefeng/rick
    def __init__(self):
        super(MyWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.createActions()
        self.createMenus()
        self.createToolBar()
コード例 #3
0
ファイル: run00.py プロジェクト: releasefeng/rick
    def __init__(self):
        super(MyWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.createActions()
        self.createMenus()
        self.connect(self.ui.commandLinkButton, QtCore.SIGNAL("clicked()"),self.SendMessage)
コード例 #4
0
ファイル: run.py プロジェクト: releasefeng/rick
class MyWindow(QtGui.QMainWindow):
    def __init__(self):
        super(MyWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.createActions()
        self.createMenus()
        self.createToolBar()
        #self.connect(self.ui.commandLinkButton, QtCore.SIGNAL("clicked()"),self.SendMessage)
        #self.ui.fileMenu.addAction(self.zoominAction)

    def createActions(self):
        self.zoominAction = QtGui.QAction(QtGui.QIcon("tes.png"),
                                          self.trUtf8("放大"), self)
        #self.zoominAction=QtGui.QAction(self.trUtf8('放大'),self)
        self.zoominAction.setShortcut("Ctrl+P")
        self.zoominAction.setToolTip(self.trUtf8("放大"))
        #self.connect(self.zoominAction,QtCore.SIGNAL("triggered()"),self.anotherWindow)

        self.zoomoutAction = QtGui.QAction(QtGui.QIcon("tes.png"),
                                           self.trUtf8("缩小"), self)
        #self.zoominAction=QtGui.QAction(self.trUtf8('放大'),self)
        self.zoomoutAction.setShortcut("Ctrl+P")
        self.zoomoutAction.setToolTip(self.trUtf8("缩小"))

    def SendMessage(self):
        self.ui.textBrowser.setPlainText(u'你按了按钮!')

    def createToolBar(self):
        self.toolbar = self.addToolBar('Exit')
        self.toolbar.addAction(self.zoominAction)
        #self.toolbar = self.addToolBar('out')
        self.toolbar.addAction(self.zoomoutAction)

    def createMenus(self):
        self.ui.menu.addAction(self.zoominAction)

    def Set(self):
        self.ui.textBrowser.setPlainText(u'你想设置设备参数!')
        #self.ui.add

    def anotherWindow(self):
        self.WChild = Ui_Dialog()
        self.Dialog = QtGui.QDialog(
            self)  # 不加self 不在父窗体中, 有两个任务栏 。 加self 表示在父子在窗体中在一个任务栏
        self.WChild.setupUi(self.Dialog)
        self.WChild.pushButton.clicked.connect(self.GetLine)
        #self.WChild.pushButtonCancel.clicked.connect(self.APPclose)
        self.Dialog.exec_()

    def GetLine(self):
        lineData = self.WChild.lineEdit.text()
        self.setWindowTitle(lineData)
        self.Dialog.close()
コード例 #5
0
ファイル: main.py プロジェクト: rafuru/MonPy-Qt
	def setupUI(self):
		"""
		Carga los objetos de la interfaz en variables locales
		Carga la configuracion guardada y realiza la conversion inicial
		"""
		self.app=QtGui.QApplication(sys.argv)
		QtGui.QMainWindow.__init__(self)
		self.mainWindow=Ui_MainWindow()
		self.mainWindow.setupUi(self)
		icon = QtGui.QIcon()
		icon.addPixmap(QtGui.QPixmap(":Images/images/icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
		self.setWindowIcon(icon)
		self.inputFrom=self.mainWindow.inputFrom
		self.inputTo=self.mainWindow.inputTo
		self.comboFrom=self.mainWindow.comboFrom
		self.comboTo=self.mainWindow.comboTo
		self.lblStatus=self.mainWindow.lblStatus

		self.inputFrom.setValidator(QtGui.QDoubleValidator())
		self.inputTo.setValidator(QtGui.QDoubleValidator())
		self.inputFrom.setText("1")
		self.fillCombos()
		self.loadPrefs()	
		self.update()	
		self.convert()

		pass
コード例 #6
0
ファイル: main.py プロジェクト: frsilent/random
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.view = BoardView(self.ui.graphicsView)
        self.opponent = Ai()

        #event bindings
        QtCore.QObject.connect(self.ui.newGameButton,QtCore.SIGNAL("clicked()"),self.newGame)
コード例 #7
0
ファイル: main.py プロジェクト: frsilent/chem_nomenclature
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.view = CarbonView(self.ui.graphicsView)

        self.molecule = None

        #function bindings
        QtCore.QObject.connect(self.ui.guessButton,QtCore.SIGNAL("clicked()"),self.guessButton)
        QtCore.QObject.connect(self.ui.clearButton,QtCore.SIGNAL("clicked()"),self.clearMolecule)
        QtCore.QObject.connect(self.ui.getNameButton,QtCore.SIGNAL("clicked()"),self.getName)
        QtCore.QObject.connect(self.ui.animateButton,QtCore.SIGNAL("clicked()"),self.animate)
        QtCore.QObject.connect(self.ui.randomButton,QtCore.SIGNAL("clicked()"),self.makeRandom)
        QtCore.QObject.connect(self.ui.additionalButton,QtCore.SIGNAL("clicked()"),self.getWebInfo)
        
        self.animation = Animation()
コード例 #8
0
ファイル: main.py プロジェクト: frsilent/chem_nomenclature
class StartQT4(QtGui.QMainWindow):

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.view = CarbonView(self.ui.graphicsView)

        self.molecule = None

        #function bindings
        QtCore.QObject.connect(self.ui.guessButton,QtCore.SIGNAL("clicked()"),self.guessButton)
        QtCore.QObject.connect(self.ui.clearButton,QtCore.SIGNAL("clicked()"),self.clearMolecule)
        QtCore.QObject.connect(self.ui.getNameButton,QtCore.SIGNAL("clicked()"),self.getName)
        QtCore.QObject.connect(self.ui.animateButton,QtCore.SIGNAL("clicked()"),self.animate)
        QtCore.QObject.connect(self.ui.randomButton,QtCore.SIGNAL("clicked()"),self.makeRandom)
        QtCore.QObject.connect(self.ui.additionalButton,QtCore.SIGNAL("clicked()"),self.getWebInfo)
        
        self.animation = Animation()

    def guessButton(self):
        if self.moleculeIsValid():
            self.checkGuess()

    def clearMolecule(self):
        self.view.clearImages()
        self.molecule = None
        self.ui.informationText.setPlainText("")
        self.ui.nomenclatureBox.setPlainText("")
        self.ui.guessResultLabel.setVisible(False)

    def moleculeIsValid(self):
        carbonMatrix = self.view.getCarbonMatrix()
        alertUser = self.ui.nomenclatureBox.setPlainText
        try:
            self.molecule = Alkane(carbonMatrix)
            return True
        #Raised when no carbons were added in the draw view
        except EmptyAlkaneError:
            alertUser("Please click in the grid to add carbons")
            return False
        #Raised when there are loops and blocks in the molecule
        except CyclicAlkaneError:
            alertUser("The molecule contains a loop or a block.")
            return False
        #Raised when not all of the carbons are adjacent
        except AlkaneNotConnectedError:
            alertUser("Not all of the carbons are connected.")
            return False
        #Raised on malformed substituents
        except BranchingCarbonChainError:
            alertUser("Only straight-chain substituents are supported.")
            return False
        #Raised on molecules with chains that are too long
        except LongestChainTooLongError:
            alertUser("This molecule is too large for me to name.")
            return False
        #Raised on molecules with substituents that are too long
        except SubstituentTooLargeError:
            alertUser("This molecule has a substituent that is too long.")
            return False
        #Raised on molecules with too many of one type of substituent
        except TooManyOfOneSubstituentGroupError:
            alertUser("This molecule has too many of one kind of substituent.")
            return False
    

    def getName(self):
        if self.moleculeIsValid():
            self.ui.nomenclatureBox.setPlainText(self.molecule.name)

    def checkGuess(self):
        self.ui.guessResultLabel.setVisible(True)
        if self.molecule.verify(self.ui.nomenclatureBox.toPlainText()):
            self.ui.guessResultLabel.setText("Correct!")
        else:
            self.ui.guessResultLabel.setText("Incorrect")

    def renderAlkane(self):
        self.view.setScreenToAlkane(self.molecule)
        
    def makeRandom(self):
        self.clearMolecule()
        self.molecule = Alkane.createRandomAlkane()
        self.view.setScreenToAlkane(self.molecule)

    def animate(self):
        self.view.clearImages()
        self.view.passAlkane(self.molecule)

    def getWebInfo(self):
        if self.moleculeIsValid():
            self.ui.nomenclatureBox.setPlainText(self.molecule.name)
            try:
                webMolecule = chemspipy.find_one(self.molecule.name)
                if webMolecule:
                    webMolecule.loadextendedcompoundinfo()
                    infoString = "Common Name: " + str(webMolecule.commonname)
                    infoString += "\nAverage Mass: " + str(webMolecule.averagemass)
                    infoString += "\nMolecular Weight: " + str(webMolecule.molecularweight)
                    infoString += "\nMono Isotopic Mass: " + str(webMolecule.monoisotopicmass)
                    infoString += "\nNominal Mass: " + str(webMolecule.nominalmass)
                else:
                    infoString = "Molecule not found"
            except:
                infoString = "Could not connect to remote service."
            
            self.ui.informationText.setPlainText(infoString)
コード例 #9
0
ファイル: main.py プロジェクト: cloveses/easy_match
import sys
import pony.orm.dbproviders.sqlite
from models.mydb import *
from ui.ui import Ui_MainWindow, QApplication

app = QApplication(sys.argv)
ex = Ui_MainWindow()
ex.show()
sys.exit(app.exec_())
コード例 #10
0
ファイル: main.py プロジェクト: rafuru/MonPy-Qt
class monPy (QtGui.QMainWindow):
	"""Este programa permite realizar conversiones entre
	Monedas soportadas por Google Calculator, el valor de
	cada moneda esta sujeto los datos que google tenga
	actualizados"""
	#Lista de Monedas
	monEx=sorted(["USD", "MXN", "EUR", "GBP", "INR", "AUD", "CAD", "JPY", "RMB", "THB", "SGD"])

	#Constructor de la clase de conversiones
	query=mon.negApi()

	#Constructor de la clase de guardado de datos
	save=sav.saving() 

	#Elementos de la Interfaz de Usuario
	mainWindow=None
	inputTo=None
	inputFrom=None
	comboFrom=None
	comboTo=None
	lblStatus=None

	#Variables
	prefs=None #Preferencias
	
	#Valor de la moneda actual
	valorActual=0.0
	#Moneda local 
	monFrom="" 
	#Moneda Extranjera
	monTo=""


	def __init__(self):
		self.setupUI()
		self.connectUi()
		self.centrarVentana()
		#Desplegar interfaz
		self.show()
		sys.exit(self.app.exec_())
		pass


	def setupUI(self):
		"""
		Carga los objetos de la interfaz en variables locales
		Carga la configuracion guardada y realiza la conversion inicial
		"""
		self.app=QtGui.QApplication(sys.argv)
		QtGui.QMainWindow.__init__(self)
		self.mainWindow=Ui_MainWindow()
		self.mainWindow.setupUi(self)
		icon = QtGui.QIcon()
		icon.addPixmap(QtGui.QPixmap(":Images/images/icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
		self.setWindowIcon(icon)
		self.inputFrom=self.mainWindow.inputFrom
		self.inputTo=self.mainWindow.inputTo
		self.comboFrom=self.mainWindow.comboFrom
		self.comboTo=self.mainWindow.comboTo
		self.lblStatus=self.mainWindow.lblStatus

		self.inputFrom.setValidator(QtGui.QDoubleValidator())
		self.inputTo.setValidator(QtGui.QDoubleValidator())
		self.inputFrom.setText("1")
		self.fillCombos()
		self.loadPrefs()	
		self.update()	
		self.convert()

		pass

	#Ok
	def fillCombos(self):
		for country in self.monEx:
			self.comboFrom.addItem(QtGui.QIcon(":Flags/images/flags/"+country+".png"),country)
			self.comboTo.addItem(QtGui.QIcon(":Flags/images/flags/"+country+".png"),country)
		pass

	#Checar Convert
	def connectUi(self):
		self.comboFrom.currentIndexChanged.connect(self.comboChanged)
		self.comboTo.currentIndexChanged.connect(self.comboChanged)
		self.inputFrom.textChanged.connect(self.convert)
		self.mainWindow.btnAbout.clicked.connect(self.showAbout)
		self.mainWindow.btnConf.clicked.connect(self.configure)
		self.mainWindow.btnUpdate.clicked.connect(self.update)
		return

	#Ok
	def configure(self):
		data=[self.monFrom,self.monTo,self.valorActual]
		if self.save.save(data):
			self.lblStatus.setText("Configuracion Guardada")
		else:
			self.lblStatus.setText("Error al Configurar")
		return

	#Ok
	def comboChanged(self):
		self.monFrom=self.monEx[self.comboFrom.currentIndex()]
		self.monTo=self.monEx[self.comboTo.currentIndex()]
		if self.update():
			self.convert()
			return
		self.convert()
		return

	#Ok
	def loadPrefs(self):
		try:
			self.prefs=self.save.read()
			if not (self.prefs==None):
				self.monFrom=self.prefs[0]
				self.monTo=self.prefs[1]
				self.valorActual=self.prefs[2]
			else:
				self.monFrom="USD"
				self.monTo="MXN"
		except ValueError as badConf:
			print ("Error al Cargar Configuracion")
			self.monFrom="USD"
			self.monTo="MXN"
			self.valorActual=0
		finally:
			self.comboFrom.setCurrentIndex(self.monEx.index(self.monFrom))
			self.comboTo.setCurrentIndex(self.monEx.index(self.monTo))

		return

	def convert(self):

		self.lblStatus.setText("")
		txt=self.inputFrom.text()
		conv=0
		r=0.0
		if not(txt=="" or txt=="e"):
			r=float(txt)*self.valorActual

		self.inputTo.setText(str("%.2f"%r))
		return

	#Ok
	def update(self):
		self.lblStatus.setText("Actualizando....")
		r=self.query.convert(1,self.monFrom,self.monTo)
		if r==None:
			print("Error de Conexion")
			self.lblStatus.setText("Sin Conexion")
			return False

		self.valorActual=r
		self.convert()
		self.lblStatus.setText("Actualizado")
		return True


	#---------- Tareas de la Interfaz -------- #
	#OK
	def showAbout(self):
		dlgAbout=QtGui.QDialog()
		dlgUI=Ui_About()
		dlgUI.setupUi(dlgAbout)
		pic=QtGui.QPixmap(":Images/images/logo.jpg")
		dlgUI.label.setPixmap(pic)
		dlgAbout.exec_()
		pass

	#Ok
	def centrarVentana(self):
		g=self.frameGeometry()
		c=QtGui.QDesktopWidget().availableGeometry().center()
		g.moveCenter(c)
		self.move(g.topLeft())
		pass
コード例 #11
0
 def __init__(self):
     super().__init__()
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
コード例 #12
0
ファイル: main.py プロジェクト: aoviedo92/easyip
 def options_dialog(self):
     options_dialog = Options()
     options_dialog.setStyleSheet(Ui_MainWindow.set_style_qss())
     options_dialog.exec_()
     self.refresh_data()