<reponame>PrinceChou/Play-Python-with-Alisa
# Listing_20-2.py
# Copyright Warren & <NAME>, 2013
# Released under MIT license   http://www.opensource.org/licenses/mit-license.php
# Version $version  ----------------------------

# Adding an event handler for the button

import sys
from PyQt4 import QtCore, QtGui, uic

form_class = uic.loadUiType("MyFirstGui.ui")[0]

# Class definition for the main window
class MyWindowClass(QtGui.QMainWindow, form_class):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.pushButton.clicked.connect(self.button_clicked)  # connect the event handler

    # the event handler for the button click
    def button_clicked(self):
        x = self.pushButton.x()
        y = self.pushButton.y()
        x += 50
        y += 50
        self.pushButton.move(x, y)     # Move the button when we click it

app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass()
myWindow.show()
app.exec_()

# Listing_20-2.py
# Copyright Warren & <NAME>, 2013
# Released under MIT license   http://www.opensource.org/licenses/mit-license.php
# Version $version  ----------------------------

# Adding an event handler for the button

import sys
from PyQt4 import QtCore, QtGui, uic

form_class = uic.loadUiType("MyFirstGui.ui")[0]

# Class definition for the main window
class MyWindowClass(QtGui.QMainWindow, form_class):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.pushButton.clicked.connect(self.button_clicked)  # connect the event handler

    # the event handler for the button click
    def button_clicked(self):
        x = self.pushButton.x()
        y = self.pushButton.y()
        x += 50
        y += 50
        self.pushButton.move(x, y)     # Move the button when we click it

app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass()
myWindow.show()
app.exec_()
# Listing_20-2.py # Copyright Warren & <NAME>, 2013 # Released under MIT license   http://www.opensource.org/licenses/mit-license.php # Version $version  ---------------------------- # Adding an event handler for the button # Class definition for the main window # connect the event handler # the event handler for the button click # Move the button when we click it