Hello! I was wondering if anybody could help me with something. I'm writing off-line banking application. I already have a code in Python and now I need to write window aplication for it.
How should I begin? I wrote some simple code for main window in PyQt. But I dont know how to make some new window.
But now I'm thinking. If I'll write code for PyQt (with buttons and simple information) how should I connect my code of banking application and code for PyQt. Or maybe I should write all together? I'm new in python so I need to understand how I should start.
For beginning I'll show my code for main window in PyQt, but it doesn't work. I tried to make main window and new window, where I can check password.

This is Main window

# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui, Qt
import Ac1Action

class myQMainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

#new class. it inherits class myQMainWindow
class MyWindow (myQMainWindow):
    def setupUi(self, MainWindow):
        self.mainwindow = MainWindow
        MainWindow.setObjectName("Internet Banking")
        MainWindow.resize(226, 146)

        #creating some buttons and labels
        self.labelOwner = QtGui.QLabel ('Iryna Zelenetska')

        self.label1 = QtGui.QLabel ('Accounts')
        self.btnQuit1 = QtGui.QPushButton ('&Account 1')
        self.btnQuit2 = QtGui.QPushButton ('&Account 2')
        self.label2 = QtGui.QLabel ('Privacy')
        self.btnQuit3 = QtGui.QPushButton ('&Change Password')

        #positioning of buttons and labels
        self.vbox = QtGui.QVBoxLayout ()
        self.vbox.addWidget(self.labelOwner, alignment = QtCore.Qt.AlignCenter)
        self.vbox.addWidget(self.label1, alignment = QtCore.Qt.AlignTop)
        self.vbox.addWidget(self.btnQuit1, alignment = QtCore.Qt.AlignCenter)
        self.vbox.addWidget(self.btnQuit2, alignment = QtCore.Qt.AlignCenter)
        self.vbox.addWidget(self.label2, alignment = QtCore.Qt.AlignCenter)
        self.vbox.addWidget(self.btnQuit3, alignment = QtCore.Qt.AlignCenter)

        #making signals for buttons
        MainWindow.connect(self.btnQuit1, QtCore.SIGNAL('clicked()'), self.showAc1Action, QtCore.SIGNAL('clicked()'))
        self.connect(self.btnQuit2, QtCore.SIGNAL('clicked()'),QtGui.qApp.quit)
        self.connect(self.btnQuit3, QtCore.SIGNAL('clicked()'),QtGui.qApp.quit)

    #making signals for new window
    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Password check", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "PushButton", None, QtGui.QApplication.UnicodeUTF8))

    #instruction to show new window
    def showChildWindow(self):
        self.childForm, self.childWindow = Ac1Action.init(self.mainwindow)

#instructions to show main window
if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)
    MainWindow = MyWindow()
    sys.exit (app.exec_())

And this is just a form for a new window:

# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui

class childWindow(object):
    def setupUi(self, SmallWindow):
        SmallWindow.setFixedSize(330, 200)

    def retranslateUi(self, Form):

def init(parentwindow):
    SmallWindow = QtGui.QWidget(parentwindow)
    form = childWindow()
    return form, SmallWindow

I suggest using Tkinter. It is very simple and it is pre installed in python. Here is an example of a window with a single button.

from Tkinter import *

class App:
    def helloworldButtonClick(self):
        print("Hello World!")

    def __init__(self):
        self.root = Tk()
        self.root.title("Window With Button")

        self.helloworldButton = Button(self.root, text="Hello World", command=self.helloworldButtonClick)

if __name__ "__main__":
    app = App()

Only 13 lines of actual code!
You can also do listboxs, textboxs, labels, entrys and more!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.