def initBody(self): ###-- CENTRAL PART self.body = QGroupBox() self.body.setTitle("My Masternodes") # masternode list self.myList = QListWidget() self.myList.setUpdatesEnabled(True) self.myList.setDragDropMode(QAbstractItemView.InternalMove) self.myList.setDefaultDropAction(Qt.MoveAction) self.current_mn = {} self.mnLed = {} self.mnLabel = {} self.mnBalance = {} self.btn_details = {} self.mnStatusLabel = {} self.mnStatusProgress = {} self.btn_remove = {} self.btn_edit = {} self.btn_start = {} self.btn_rewards = {} for masternode in self.caller.masternode_list: name = masternode['name'] self.insert_mn_list(name, masternode['ip'], masternode['port'], isHardware=masternode['isHardware']) vBox = QVBoxLayout() vBox.addWidget(self.myList) self.button_addMasternode = QPushButton("New Masternode") vBox.addWidget(self.button_addMasternode) vBox.stretch(1) self.body.setLayout(vBox)
def initUI(self): #set the main widget's tooltip # QToolTip.setFont(QFont('Sansserif',9)) # self.setToolTip('this is a <b>QWidget</b> widget') #set the button # btn = QPushButton('Button',self) # btn.move(150,250) # btn.resize(btn.sizeHint()) # btn.clicked.connect(QCoreApplication.instance().quit) # btn.setToolTip('this is a <b>QPushButton</b> button') #set the label # label1 = QLabel('label1',self) # label1.move(15,100) # label2 = QLabel('label2',self) # label2.move(35,200) #set the textEdit # texteEdit = QTextEdit() # self.setCentralWidget(texteEdit) #set the window center self.resize(550,350) self.setWindowTitle('Hello,PyQt5') self.setWindowIcon(QIcon('./resources/Icon.png')) #set the status bar # self.statusBar().showMessage('Ready') #set the menubar exitAction = QAction(QIcon('./resources/exit.jpg'),'&Exit',self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit the application') exitAction.triggered.connect(qApp.quit) # menuBar = self.menuBar() # fileBar = menuBar.addMenu('&File') # fileBar.addAction(exitAction) #set the toolbar # self.addToolBar('Exit').addAction(exitAction) #set the Layout okButton = QPushButton('OK') cancelButton = QPushButton('Cancel') hbox = QHBoxLayout() hbox.stretch(1) hbox.addWidget(okButton) hbox.addWidget(cancelButton) vbox = QVBoxLayout() vbox.stretch(1) vbox.addLayout(hbox) self.setLayout(vbox) self.center() self.show()
def initUI(self): self.nameText = QLabel(f"<b>{self.org.name}</b>") self.foodText = QLabel(f"Food: {round(self.org.food, 2)}") layout = QVBoxLayout() layout.stretch(1) layout.addWidget(self.nameText) layout.addWidget(self.foodText) self.setLayout(layout) self.setFixedWidth(150)
class OrgsList(QWidget): def __init__(self, parent): super().__init__() self.parent = parent self.pond = self.parent.pond self.initUI() def initUI(self): self.layout = QVBoxLayout() self.layout.stretch(1) self.orgsDisplays = [] for org in self.pond.orgs: self.orgsDisplays.append(OrgsDisplay(self, org)) self.layout.addWidget(self.orgsDisplays[-1]) self.setLayout(self.layout) def updateText(self): self.checkAlive() #self.checkNewOrgs() for i in self.orgsDisplays: i.updateText() def checkAlive(self): for i in self.orgsDisplays: if i.org.food <= 0: #self.layout.removeWidget(i) i.setParent(None) #i.deleteLater() i = None self.orgsDisplays = [i for i in self.orgsDisplays if i != None] def checkNewOrgs(self): for org in self.pond.orgs: if not any(i.org == org for i in self.orgsDisplays): self.orgsDisplays.append(OrgsDisplay(self, org)) self.layout.addWidget(self.orgsDisplays[-1])
def initUI(self): self.setGeometry(50, 50, 0, 0) self.mainWidget = QWidget(self) self.setCentralWidget(self.mainWidget) self.setWindowTitle('PondSim') self.pondThread = PondThread(self) self.world = WorldWidget(self) #self.orgsList = OrgsList(self) mainLayout = QHBoxLayout() subWidget = QWidget(self.mainWidget) subLayout1 = QVBoxLayout() subLayout1.stretch(1) self.timeText = QLabel(f"Time:\n{self.pond.t}", self.mainWidget) self.numOrgsText = QLabel( f"Population:\n{len(self.pond.orgs)} (+{len(self.pond.eggs)})", self.mainWidget) self.foodFreeText = QLabel( f"Food:\n{sum([i.food for i in self.pond.food])}", self.mainWidget) self.totalFreeFoodText = QLabel( f"Total food:\n{round(self.pond.countNetFood(), 2)}", self.mainWidget) subLayout1.addWidget(self.timeText) subLayout1.addWidget(self.numOrgsText) subLayout1.addWidget(self.foodFreeText) subLayout1.addWidget(self.totalFreeFoodText) subWidget.setLayout(subLayout1) subWidget.setFixedWidth(100) mainLayout.addWidget(subWidget) mainLayout.addWidget(self.world) #mainLayout.addWidget(self.orgsList) self.mainWidget.setLayout(mainLayout) self.show()
def newbeta(self): #self.setStyleSheet("QPushButton { margin: 450pxself.setLayout(self.box) try: self.labe = QLabel(self) self.labe.setText("Welcome") self.labe.setAlignment(Qt.AlignCenter) self.labe.setFont(lf) self.labe.resize(160, 100) self.label = QLabel(self) self.label.setText("**Enter your credentials to login to Register") self.l1 = QLabel(self) self.l1.setText(' Registration Form') self.l1.resize(150, 100) self.l2 = QLabel(self) self.l2.setText(' Full Name') self.l2.resize(150, 100) self.l2.move(0.32 * sw, 0.22 * sh) self.fnme = QLineEdit(self) self.fnme.setText("Full Name") self.l3 = QLabel(self) self.l3.setText(' Username') self.us = QLineEdit(self) self.us.setText("Username") self.l4 = QLabel(self) self.l4.setText(' Password') self.us1 = QLineEdit(self) self.us1.setText("Password") self.us1.setEchoMode(QLineEdit.PasswordEchoOnEdit) self.l5 = QLabel(self) self.l5.setText(' Confirm Password') self.l5.resize(150, 100) self.l5.move(0.32 * sw, 0.40 * sh) self.us2 = QLineEdit(self) self.us2.setText("Confirm ") self.us2.setEchoMode(QLineEdit.Password) self.l6 = QLabel(self) self.l6.setText(' Roll No') self.us3 = QLineEdit(self) self.us3.setText("Roll No") self.l7 = QLabel(self) self.l7.setText(' Gender') self.gen = QComboBox(self) self.gen.addItem(" Male", ) self.gen.addItem(" Female", ) self.gen.addItem(" Others", ) self.current = 'None' self.gen.activated.connect(self.handleActivated) self.l8 = QLabel(self) self.l8.setText(' Date of Birth') self.dt = QPushButton('Calendar', self) self.dt.setToolTip('Click Here to see the Calendar ') #self.dt.clicked.connect(dante) self.l9 = QLabel(self) self.l9.setText(' email ID') self.us6 = QLineEdit(self) self.us6.setText(" email ID") self.ag = QCheckBox("I Agree To Terms And Condition", self) self.but1 = QPushButton('Reset', self) self.but1.setToolTip('Click Here To Go Back To Sign-In Form') self.but1.resize(170, 20) self.but1.clicked.connect(lambda: self.on_reset1('regclear')) self.butt2 = QPushButton('Back', self) self.butt2.setToolTip('Click Here to Reset The Form') self.butt2.clicked.connect(lambda: self.on_back) self.butt3 = QPushButton('Register', self) self.butt3.setToolTip('Click here to Register And use the App') self.butt3.clicked.connect(self.on_yes) box = QBoxLayout(QBoxLayout.LeftToRight) box.stretch(1) box.setSpacing(1) box.addWidget(self.but1) box.addWidget(self.butt2) box.addWidget(self.butt3) ay1 = QBoxLayout(QBoxLayout.LeftToRight) aya = QBoxLayout(QBoxLayout.LeftToRight) ay2 = QBoxLayout(QBoxLayout.LeftToRight) ay3 = QBoxLayout(QBoxLayout.LeftToRight) ay4 = QBoxLayout(QBoxLayout.LeftToRight) ay5 = QBoxLayout(QBoxLayout.LeftToRight) ay6 = QBoxLayout(QBoxLayout.LeftToRight) ay7 = QBoxLayout(QBoxLayout.LeftToRight) ay8 = QBoxLayout(QBoxLayout.LeftToRight) ay9 = QBoxLayout(QBoxLayout.LeftToRight) ay10 = QBoxLayout(QBoxLayout.LeftToRight) ay1.addWidget(self.labe) aya.addWidget(self.label) aya.addWidget(self.l1) ay2.addWidget(self.l2) ay2.addWidget(self.fnme) ay3.addWidget(self.l3) ay3.addWidget(self.us) ay4.addWidget(self.l4) ay4.addWidget(self.us1) ay5.addWidget(self.l5) ay5.addWidget(self.us2) ay6.addWidget(self.l6) ay6.addWidget(self.us3) ay7.addWidget(self.l7) ay7.addWidget(self.gen) ay8.addWidget(self.l8) ay8.addWidget(self.dt) #ay8.addWidget(self.us5) ay9.addWidget(self.l9) ay9.addWidget(self.us6) ay10.addWidget(self.ag) #self.la.setContentsMargins(0.44*sw, 0.2*sh, 0.44*sw,0 box1 = QVBoxLayout() box1.stretch(1) box1.setSpacing(8) #box1.setContentsMargins(0.44*sw, 0.1*sh, 0.44*sw,0.1*sh) box1.addLayout(ay1) box1.addLayout(aya) box1.addLayout(ay2) box1.addLayout(ay3) box1.addLayout(ay4) box1.addLayout(ay5) box1.addLayout(ay6) box1.addLayout(ay7) box1.addLayout(ay8) box1.addLayout(ay9) box1.addLayout(ay10) box1.addLayout(box) self.reGGG.setLayout(box1) except Exception as dumm1: print(dumm1)
def now(self): self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) videoWidget = QVideoWidget() #self.videoWidget.setFullscreen(False) self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) self.positionSlider = QSlider(Qt.Horizontal) self.positionSlider.setRange(0, 0) self.positionSlider.sliderMoved.connect(self.setPosition) self.errorLabel = QLabel() self.errorLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) # Create new action openAction = QPushButton(QIcon('open.png'), '&Open', self) openAction.setShortcut('Ctrl+O') openAction.setStatusTip('Open movie') openAction.clicked.connect(self.openFile) self.setStyleSheet("QPushButton { margin: 150px; }") # Create a widget for window contents wid = QWidget(self) #self.setCentralWidget(wid) # Create layouts to place inside widget frm = QFormLayout() #frm.setContentsMargins(50, 300,100,10) frm.addRow(openAction, self.playButton) #50, 100,100,10 mylay = QBoxLayout(QBoxLayout.TopToBottom) mylay.stretch(1) #videoWidget.setFullscreen(False) mylay.addWidget(videoWidget) mylay.addLayout(frm) mylay.addWidget(self.positionSlider) controlLayout = QHBoxLayout() controlLayout.stretch(1) controlLayout.setContentsMargins(0, 0, 0, 0) controlLayout.addLayout(mylay) layout = QVBoxLayout() layout.stretch(1) layout.addWidget(videoWidget) layout.addWidget(self.errorLabel) layout.addLayout(controlLayout) # Set widget to contain window contents wid.setLayout(layout) self.mediaPlayer.setVideoOutput(videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError) self.tabk.setLayout(layout)
class LogWindow(QMainWindow): def __init__(self, mainWindow, pRows, pColumns): QWidget.__init__(self) self.parentWindow = mainWindow self.numItems = pRows # if pRows > 20: self.rows = pRows # else: # self.rows = 20 # Looks good :P self.columns = pColumns # Set the window properties self.set_window_properties() # Create the central widget self.cw = QWidget() self.setCentralWidget(self.cw) # Create the widgets self.create_widgets() # Create the layouts self.create_layout() # Fill the data in the QTableWidget self.fill_data() # So that user can close this window by pressing the Escape key self.escape = QShortcut(QKeySequence(Qt.Key_Escape), self) self.escape.activated.connect(self.close) def set_window_properties(self): self.setWindowTitle("Logs") self.setWindowIcon(QIcon('resources/logo.png')) self.setMinimumWidth(300) def create_layout(self): self.mainLayout = QVBoxLayout(self.cw) self.menuLayout = QHBoxLayout(self.cw) self.menuLayout.addWidget(QLabel("Menu")) self.dataLayout = QVBoxLayout(self.cw) self.dataLayout.addWidget(self.tableWidget) self.dataLayout.stretch(1) self.mainLayout.addLayout(self.menuLayout) self.mainLayout.addLayout(self.dataLayout) def create_widgets(self): self.tableWidget = QTableWidget(self.rows, self.columns) # So that there are no unwanted empty areas in the Log Window. self.tableWidget.horizontalHeader().setStretchLastSection(True) self.tableWidget.verticalHeader().setStretchLastSection(True) # Set the headers. Col1 Header = Date. Col2 Header = Instance Name self.tableWidget.setHorizontalHeaderLabels(["Date", self.parentWindow.currentInstanceName]) self.tableWidget.setColumnWidth(0, 150) # Get the required size fot the table based on the volume of data tableSize = self.get_table_size() # Set the size of the QTableWidget and the Log Window accordingly. self.tableWidget.setMaximumSize(tableSize) self.setMaximumSize(tableSize) def get_table_size(self): # Find Row height tableHeight = self.tableWidget.horizontalHeader().height() tableWidth = self.tableWidget.verticalHeader().width() + 4 for i in range(0, self.rows): tableHeight += self.tableWidget.rowHeight(i) for i in range(0, self.columns): tableWidth += self.tableWidget.columnWidth(i) tableSize = QSize(tableWidth, tableHeight) return tableSize def fill_data(self): date = 0 value = 1 for currentRow in range(0, self.numItems): for currentColumn in range(0, self.columns): temp = QTableWidgetItem() temp.setFlags(temp.flags() & ~Qt.ItemIsEditable) if currentColumn == 0: # Current column is the date column temp.setText(self.parentWindow.convert_int_to_date(self.parentWindow.data[currentRow][date])) else: # Current column is the value column temp.setText(str(self.parentWindow.data[currentRow][value]) + " " + self.parentWindow.unitName) self.tableWidget.setItem(currentRow, currentColumn, temp)