def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1100, 600) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.frame = mf.MyFrame(self.centralwidget) #self.frame = QtWidgets.QFrame(self.centralwidget) self.frame.setMinimumSize(QtCore.QSize(800, 500)) self.frame.setMaximumSize(QtCore.QSize(800, 500)) self.frame.setAutoFillBackground(False) self.frame.setFrameShape(QtWidgets.QFrame.Box) self.frame.setFrameShadow(QtWidgets.QFrame.Raised) self.frame.setMidLineWidth(3) self.frame.setObjectName("frame") self.gridLayout.addWidget(self.frame, 0, 2, 1, 1) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setMaximumSize(QtCore.QSize(16777215, 25)) font = QtGui.QFont() font.setFamily("MS Shell Dlg 2") font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.textEdit = QtWidgets.QTextEdit(self.centralwidget) self.textEdit.setMinimumSize(QtCore.QSize(200, 0)) self.textEdit.setObjectName("textEdit") self.verticalLayout.addWidget(self.textEdit) self.createButton = QtWidgets.QPushButton(self.centralwidget) self.createButton.setObjectName("createButton") self.verticalLayout.addWidget(self.createButton) self.runButton = QtWidgets.QPushButton(self.centralwidget) self.runButton.setObjectName("runButton") self.verticalLayout.addWidget(self.runButton) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.sld = QtWidgets.QSlider(self.centralwidget) self.sld.setProperty("value", 10) self.sld.setOrientation(QtCore.Qt.Vertical) self.sld.setObjectName("sld") self.gridLayout.addWidget(self.sld, 0, 1, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 1100, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self): """ This starts the Tk framework up, instantiates the Model (a Counter object), instantiates the View (a MyFrame object), and starts the event loop that waits for the user to press a Button on the View. """ root = tkinter.Tk() self.model = counter.Counter() self.view = myFrame.MyFrame(self) self.view.mainloop() root.destroy()
def __init__(self): ''' starts TK framework instantiates model (converter) instantiates view (MyFrame) starts event loop ''' root = tkinter.Tk() self.model = converter.Converter() self.view = myFrame.MyFrame(self) self.view.mainloop() root.destroy()
""" This main program creates a MyFrame object that contains two Buttons and a Label. If anyone is writing an application that needs a Frame containing two Buttons and a Label, they can just create an instance of class MyFrame and Python will put a Frame onto the user's screen that contains two Buttons and a Label. Here is such a program: """ import myFrame # contains class MyFrame import tkinter if __name__ == "__main__": root = tkinter.Tk() view = myFrame.MyFrame() # puts the Frame onto the user's screen view.mainloop()