import re
string = '''onclick="MapWork('gm_1', '53.964127393', '27.6241564751')">'''
pattern = r", ?\'([\d\.]+)"
result = re.findall(pattern,string)
print(result[0],result[1])
import re
string = '''onclick="MapWork('gm_1', '53.964127393', '27.6241564751')">'''
result = re.findall(r'onclick="MapWork(.+?)"',string)
res = re.findall("'(.+?)'",str(result))
print(res[1],res[2])
print(user[5])
UPDATE INTO finance(url, rep, obem, nick) VALUES (?, ?, ?, ?)''', (url, rep, obem, nick)
def insert_data(self, url, rep, obem, nick):
self.c.execute('''INSERT INTO finance(url, rep, obem, nick) VALUES (?, ?, ?, ?)''',
(url, rep, obem, nick))
self.conn.commit()
class TwoWindow(QtWidgets.QMainWindow, double_window.Ui_MainWindow): def __inir__(self):
from PyQt5 import (QtWidgets, QtCore, QtGui)
from PyQt5.QtGui import QIcon
import sys, time
class myWindow(QtWidgets.QWidget):
def __init__(self, parent = None):
QtWidgets.QWidget.__init__(self, parent)
self.grid = QtWidgets.QGridLayout()
# 1
self.grid.setVerticalSpacing(0)
self.grid.setContentsMargins(0, 0, 0, 0)
self.button_1 = QtWidgets.QPushButton("1")
self.button_2 = QtWidgets.QPushButton("2")
# 2
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHeightForWidth(self.button_1.sizePolicy().hasHeightForWidth())
self.button_1.setSizePolicy(sizePolicy)
sizePolicy.setHeightForWidth(self.button_2.sizePolicy().hasHeightForWidth())
self.button_2.setSizePolicy(sizePolicy)
self.label = QtWidgets.QLabel("1")
self.label1 = QtWidgets.QLabel("2")
self.grid.setSpacing(0)
self.grid.addWidget(self.button_1, 0, 0)
self.grid.addWidget(self.label, 0, 1)
self.grid.addWidget(self.button_2, 1, 0)
self.grid.addWidget(self.label1, 1, 1)
self.setLayout(self.grid)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = myWindow()
window.setWindowTitle("test")
window.resize(300, 300)
window.show()
sys.exit(app.exec_())
self.grid.setGeometry(QtCore.QRect(80, 50, 110, 60))
в # 1, а сам грид запихивать в виджет, который уже и будет нужным размером окна (300, 300 в данном случае) from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Ui_Main(QtWidgets.QWidget):
def setupUi(self, Main):
Main.setObjectName("Main")
Main.resize(800, 480)
self.QtStack = QtWidgets.QStackedLayout()
self.stack1 = QtWidgets.QWidget()
self.stack2 = QtWidgets.QWidget()
self.stack3 = QtWidgets.QWidget()
self.Window1UI()
self.Window2UI()
self.Window3UI()
self.QtStack.addWidget(self.stack1)
self.QtStack.addWidget(self.stack2)
self.QtStack.addWidget(self.stack3)
def Window1UI(self):
self.stack1.resize(800, 480)
#PushButton1#
self.PushButton1 = QtWidgets.QPushButton(self.stack1)
self.PushButton1.setText("BUTTON 1")
self.PushButton1.setGeometry(QtCore.QRect(10, 10, 100, 100))
#PushButton2#
self.PushButton2 = QtWidgets.QPushButton(self.stack1)
self.PushButton2.setText("BUTTON 2")
self.PushButton2.setGeometry(QtCore.QRect(150, 150, 100, 100))
def Window2UI(self):
self.stack2.resize(800, 480)
self.stack2.setStyleSheet("background: red")
def Window3UI(self):
self.stack3.resize(800, 480)
self.stack3.setStyleSheet("background: blue")
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
from ui_Main import Ui_Main
class Main(QMainWindow, Ui_Main):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.setupUi(self)
self.PushButton1.clicked.connect(self.OpenWindow1)
self.PushButton2.clicked.connect(self.OpenWindow2)
def OpenWindow1(self):
self.QtStack.setCurrentIndex(1)
def OpenWindow2(self):
self.QtStack.setCurrentIndex(2)
if __name__ == '__main__':
app = QApplication(sys.argv)
showMain = Main()
sys.exit(app.exec_())