def initUI(self): self.pbar = QProgressBar(self) self.pbar.setGeometry(120, 150, 250, 20) self.btn = QPushButton('Start', self) self.btn.move(200, 180) self.btn.clicked.connect(self.doAction) sld = QSlider(Qt.Horizontal, self) sld.setFocusPolicy(Qt.NoFocus) sld.setGeometry(120, 120, 250, 30) self.timer = QBasicTimer() self.step = 0 AccionSalida = QAction(QIcon('pngegg.png'), 'Exit', self) AccionSalida.setShortcut('Ctrl+Q') AccionSalida.setStatusTip('Exit') AccionSalida.triggered.connect(self.close) self.statusBar() BarraMenu = self.menuBar() MenuArchivo = BarraMenu.addMenu('&File') MenuArchivo.addAction(AccionSalida) BarraHerramienta = QAction(QIcon('pngegg.png'), 'Exit', self) BarraHerramienta.setShortcut('Ctrl+Q') BarraHerramienta.triggered.connect(qApp.quit) self.toolbar = self.addToolBar('Exit') self.toolbar.addAction(BarraHerramienta) self.setGeometry(800, 800, 500, 400) self.setWindowTitle('Ventana Principal') self.show()
def initUI(self): #Initialize board self.BoardWidth = 2000 self.BoardHeight = 2000 self.setGeometry(0, 0, self.BoardWidth, self.BoardHeight) self.setWindowTitle('Snake') #Set background p = self.palette() p.setColor(self.backgroundRole(), Qt.white) self.setPalette(p) #set the maze self.maze = self.loadmaze('pos_maze.csv') #Set snake parameters self.direction = 4 self.x_max = 125 self.y_max = 125 self.snake =[[(self.x_max // 2 - 1), self.y_max // 2], [(self.x_max // 2), self.y_max // 2], [(self.x_max // 2 + 1), self.y_max // 2], [(self.x_max // 2 + 2), self.y_max // 2] , [(self.x_max // 2 + 3), self.y_max // 2]] self.speed = 50 #Has the game begun? game_started = False #Set timer self.timer = QBasicTimer() self.timer.start(self.speed, self) #Apple settings self.apple_pos = [0, 0] self.apple_color = Qt.white self.apple_number = 0 self.apple_active = False self.apple_eaten = False random.seed() self.apple_activate() self.show()
def initFrame(self): self.commaweight = '' self.timer = QBasicTimer() self.myscale = Scale(10202) self.lbl_weight = QLabel(self) self.lbl_weight.setObjectName('lbl_weight') self.lbl_weight.setText("0.000") self.lbl_weight.resize(500, 100) self.lbl_weight.move(50, 50) lbl_unit = QLabel(self) lbl_unit.setObjectName('lbl_unit') lbl_unit.setText("kg") lbl_unit.resize(100, 120) lbl_unit.move(350, 40) self.setObjectName('ScaleFrame') self.setStyleSheet(""" #ScaleFrame { background-color: #cfcfcf; } .QLabel#lbl_weight { font-size:100pt; color: #ff0000; } .QLabel#lbl_unit { font-size:100pt; color: #000000; } .QLabel { font-size:22pt; color: #000000; } """) self.start_timer()
def __init__(self): super().__init__() self.wallTexture = QPixmap('textures/wall.png') self.floorTexture = QPixmap('textures/floor.png') self.createBoard() #init Star self.Star1 = PowerUp.Star(QVector2D(250, 300)) #init Robots Robot1 = Robots.Robot(1, QVector2D(500, 500), 290, 2, 2, 15, 90, colors["pink"]) Robot2 = Robots.Robot(2, QVector2D(100, 900), 90, 2, 2, 15, 90, colors["darkblue"]) Robot3 = Robots.Robot(3, QVector2D(250, 650), 270, 2, 2, 15, 90, colors["lightblue"]) Robot4 = Robots.Robot(4, QVector2D(950, 100), 180, 2, 2, 15, 90, colors["orange"]) Robot1.setProgram(Robots.RunAwayKeyBoard(Robot1)) Robot2.setProgram(Robots.TargetHunt(Robot2)) Robot3.setProgram(Robots.TargetHunt(Robot3)) Robot4.setProgram(Robots.TargetHunt(Robot4)) self.robots = [Robot1, Robot2, Robot3, Robot4] Robot1.executeProgram() Robot2.executeProgram() Robot3.executeProgram() Robot4.executeProgram() self.timer = QBasicTimer() self.timer.start(FPS, self) self.tickCount = 0 self.initUI()
def initUI(self): self.btn1 = QPushButton(self) self.btn1.setGeometry(130, 40, 200, 25) self.l1=QtWidgets.QLabel(self) self.l1.setGeometry(30,40,50,25) self.l1.setText('Left') self.btn2 = QPushButton(self) self.btn2.setGeometry(130, 75, 200, 25) self.l1=QtWidgets.QLabel(self) self.l1.setGeometry(30,75,50,25) self.l1.setText('Right') self.btn3 = QPushButton(self) self.btn3.setGeometry(130, 110, 200, 25) self.l1=QtWidgets.QLabel(self) self.l1.setGeometry(30,110,50,25) self.l1.setText('Camera') self.btn4 = QPushButton(self) self.btn4.setGeometry(130, 145, 200, 25) self.l1=QtWidgets.QLabel(self) self.l1.setGeometry(30,145,50,25) self.l1.setText('Gyro') self.timer = QBasicTimer() self.step = 0 self.timer.start(100, self) self.setGeometry(300, 300, 400, 550) self.setWindowTitle('Input dialog') self.show()
def initUI(self): self.setBackground() #fake code gif self.label = QLabel() self.setCentralWidget(self.label) self.movie = QMovie(resource_path("fakecode.gif")) self.label.setMovie(self.movie) #proggres bar self.pbar = QProgressBar(self) self.pbar.setGeometry(30, 40, 700, 30) self.pbar.move(175, 420) #button self.btn = QPushButton('Start', self) self.btn.setGeometry(100, 100, 100, 30) self.btn.move(450, 460) self.btn.clicked.connect(self.doAction) self.timer = QBasicTimer() self.step = 0 self.setGeometry(100, 100, 1000, 500) self.setWindowTitle('ESET Internet Security') self.show() self.setFixedSize(1000, 500) popupWarning = QWidget() popupWarning.setWindowTitle('Warning') popupWarning.setGeometry(100, 100, 100, 10) popupWarning.buttonReply = QMessageBox.information(self, 'WARNING!', "DoS attack detected. Run the wizard to remove it.", QMessageBox.Ok) if popupWarning.buttonReply == QMessageBox.Ok: popupWarning.hide() return popupWarning.show()
def initUI(self): self.setGeometry(0, 0, SCREENWIDTH, SCREENHEIGHT) self.setWindowTitle('Game.exe') self.center() self.timer = QBasicTimer() self.timer.start(FPS, self) self.tickCount = 0 # Roboterinstanzen # x y r alph a a+ a_al al+ v v_al col self.Robo1 = RoboType5(1, 40, 40, 25, 45, 0, 2, 0, 3, 3, 0, self.PINK) self.Robo1a = RoboType5(2, 700, 920, 15, 135, 0, 2, 0, 3, 3, 0, self.PINK) self.Robo2 = RoboType5(3, 900, 500, 20, 225, 0, 2, 0, 5, 3, 0, self.CORNBLUE) self.Robo3 = RoboType5(4, 500, 450, 25, 315, 0, 2, 0, 3, 3, 0, self.DARKBLUE) self.Robo4 = RoboType5(5, 500, 800, 30, 0, 0, 2, 0, 4, 3, 0, self.ORANGE) """ self.Robo1 = RoboType1(1, 100, 10, 25, 0, 0, 2, 0, 3, 0, 0, self.PINK) self.Robo1a = RoboType1(2, 350, 10, 15, 0, 0, 2, 0, 3, 0, 0, self.PINK) self.Robo2 = RoboType2(3, 900, 400, 20, 0, 0, 2, 0, 5, 2, 0, self.CORNBLUE) self.Robo3 = RoboType3(4, 500, 150, 25, 270, 0, 2, 0, 3, 2, 0, self.DARKBLUE) self.Robo4 = RoboType4(5, 500, 300, 30, 135, 0, 2, 0, 4, 1, 0, self.ORANGE) """ self.robots = [ self.Robo1, self.Robo1a, self.Robo2, self.Robo3, self.Robo4 ] for robot in self.robots: robot.start() self.show()
def initUI(self): """初始化UI界面""" # 创建进度条 self.pbar = QProgressBar(self) self.pbar.setGeometry(30, 40, 200, 50) # self.pbar.setFormat("%p") # 创建按钮 self.btn = QPushButton('Start', self) self.btn.move(40, 80) self.btn.clicked.connect(self.doAction) # 创建计时器 self.timer = QBasicTimer() self.step = 0 # window settings self.setGeometry(500, 500, 500, 360) self.setWindowTitle("ProcessBar") self.show()
def __init__(self): QMainWindow.__init__(self) self.setupUi(self) self.step = 0 self.timer = QBasicTimer() self.tableWidget = None #数据处理 self.data = None self.output = None self.outformat = None #主窗体 self.setFixedSize(self.width(), self.height()) ##固定窗口大小 self.setWindowTitle('Magic&House SoftWare') self.setWindowIcon(QIcon('image/mh.ico')) #设置系统图标 #其他窗体 self.senderwindow = SenderWindow(mainwindow=self) #显示托盘 self.setTray() self.setEvent() self.show()
def init_ui(self): # 设置窗体大小 self.setGeometry(300, 300, 250, 100) self.setWindowTitle('进度条') self.setWindowIcon(QIcon('pics/874176.png')) # 创建进度条 self.pbar = QProgressBar(self) # 进图条位置及大小 self.pbar.setGeometry(30, 10, 200, 25) # 创建开始按钮 self.btn = QPushButton('开始', self) # 创建按钮并移动 self.btn.move(30, 50) # 点击按钮,连接事件函数 self.btn.clicked.connect(self.btn_action) # 创建重置按钮 self.btn_reset = QPushButton('重置', self) self.btn_reset.move(125, 50) self.btn_reset.clicked.connect(self.btn_res) # 创建计时器 self.timer = QBasicTimer() # 计时器赋初值 self.step = 0 # 隐藏按钮 self.btn_hide = QPushButton('武军大傻子', self) self.btn_hide.setGeometry(30, 10, 170, 25) self.btn_hide.clicked.connect(self.btn_hide_) self.btn_hide.hide() # 显示 if time.time() > 1540049163: self.msg_box = QMessageBox.warning(self, '警告!', '软件已过期,请联系作者!', QMessageBox.Yes) else: self.show()
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(347, 271) self.form = Form self.progressBar = QtWidgets.QProgressBar(Form) self.progressBar.setGeometry(QtCore.QRect(30, 70, 321, 23)) self.progressBar.setProperty("value", 0) self.progressBar.setObjectName("progressBar") self.pushButton = QtWidgets.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(190, 140, 93, 28)) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(Form) self.pushButton_2.setGeometry(QtCore.QRect(50, 140, 93, 28)) self.pushButton_2.setObjectName("pushButton_2") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) self.pushButton_2.setEnabled(False) self.pushButton.clicked.connect(self.close) self.pushButton_2.clicked.connect(self.close) self.timer = QBasicTimer() self.step = 0
def initUI(self): self.setGeometry(0, 0, 1000, 1000) self.setWindowTitle('Game.exe') self.center() self.timer = QBasicTimer() self.timer.start(GameSpeed, self) # Roboterinstanzen # x y r alph a a+ a_al al+ v v_al col self.Robo1 = RoboType1(400, 10, 15, 0, 0, 2, 0, 3, 0, 0, QColor(255, 0, 250)) self.Robo2 = RoboType2(10, 900, 20, 0, 0, 2, 0, 5, 2, 0, QColor(0, 0, 250)) self.Robo3 = RoboType3(800, 100, 25, 270, 0, 2, 0, 3, 2, 0, QColor(0, 145, 250)) self.Robo4 = RoboType4(500, 500, 30, 135, 0, 2, 0, 4, 1, 0, QColor(245, 120, 0)) self.Robo1.start() self.Robo2.start() self.Robo3.start() self.Robo4.start() self.show()
def __init__(self): super().__init__() # Window first Configuration self.title = "Pura Vida Compilador" self.width = 872 self.height = 490 self.setMinimumSize(872, 490) self.setMaximumSize(872, 490) self.setWindowFlags(QtCore.Qt.FramelessWindowHint) # first declaration of attributes self.timer = QBasicTimer() self.step = 0 # modify the background color self.setStyleSheet("background-color: #808080;") # Take the window into the center resolution = ctypes.windll.user32 with_resolution = resolution.GetSystemMetrics(0) height_resolution = resolution.GetSystemMetrics(1) self.left = (with_resolution / 2) - (self.frameSize().width() / 2) self.top = (height_resolution / 2) - (self.frameSize().height() / 2) # calling procedures to display window Widgets self.InitWindowConfiguration() self.CreateProgressBar() self.show()
def __init__(self): super().__init__() self.setupUi(self) self.tableWidget_Video.setHorizontalHeaderLabels( ['名称', '链接', '下载量', '下载']) self.tableWidget_Video.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.tableWidget_Video.horizontalHeader().setSectionResizeMode( 0, QHeaderView.ResizeToContents) self.tableWidget_Video.horizontalHeader().setSectionResizeMode( 2, QHeaderView.ResizeToContents) self.tableWidget_Video.horizontalHeader().setSectionResizeMode(3, 30) self.tableWidget_Video.setObjectName("tableWidget_video") self.tableWidget_Video.verticalHeader().setDefaultSectionSize(30) self.tableWidget_Music.setHorizontalHeaderLabels( ['名称', '链接', '下载量', '下载']) self.tableWidget_Music.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.tableWidget_Music.horizontalHeader().setSectionResizeMode( 0, QHeaderView.ResizeToContents) self.tableWidget_Music.horizontalHeader().setSectionResizeMode( 2, QHeaderView.ResizeToContents) self.tableWidget_Music.horizontalHeader().setSectionResizeMode(3, 30) self.tableWidget_Music.setObjectName("tableWidget_Music") self.tableWidget_Music.verticalHeader().setDefaultSectionSize(30) self.searchButton.clicked.connect(self.checkComboBox) self.mythread = ThreadObject() # 连接信号 self.mythread._thread.connect(self.video) self.thread = QThread() self.mythread.moveToThread(self.thread) # 开始线程 self.thread.started.connect(self.mythread.timerEvent) self.thread.start() self.timer = QBasicTimer() self.step = 0
def __init__(self, camera_port=0, parent=None): super().__init__(parent) self.camera = cv2.VideoCapture(camera_port) self.timer = QBasicTimer()
def __init__(self): super().__init__() self.initUI() self.timer = QBasicTimer() self.timer.start(40, self) # L'entier définie la vitesse de l'horloge
def initGui(self): # 左侧 self.Pic_lable = QLabel(self) self.Pic_lable.setPixmap(QPixmap(picture_dir + '1.jpeg')) self.Pic_lable.setScaledContents(True) # 固定标签大小 # self.Pic_lable.resize(500,370) # self.Pic_lable.setFixedSize(500, 370) LeftLayout = QGridLayout() LeftLayout.addWidget(self.Pic_lable, 1, 1, 5, 5) LeftGridGroupBox = QGroupBox() LeftGridGroupBox.setLayout(LeftLayout) # 右侧 self.AccountEdit = QLineEdit() # 编辑框内容提示 # self.AccountEdit.setPlaceholderText("Account") self.PasswordEdit = QLineEdit(self) # self.PasswordEdit.setPlaceholderText("Password") self.PasswordEdit.setEchoMode(QLineEdit.Password) self.Accountlabe = QLabel("账号:") self.Accountlabe.setAlignment(Qt.AlignRight) self.Passwordlabe = QLabel("密码:") self.Passwordlabe.setAlignment(Qt.AlignRight) self.LoginButton = QPushButton("登录") self.LoginButton.clicked.connect(self.login) self.BtnCheck = QRadioButton("显示密码") self.BtnCheck.setStyleSheet('''color: rgb(253,129,53);;''') self.BtnCheck.clicked.connect(self.yanma) # RightLayout = QGridLayout() # RightLayout.setSpacing(1) # RightLayout.addWidget(self.Accountlabe, 1, 0) # RightLayout.addWidget(self.AccountEdit, 1, 1) # RightLayout.addWidget(self.Passwordlabe, 2, 0) # RightLayout.addWidget(self.PasswordEdit, 2, 1) # RightLayout.addWidget(self.BtnCheck, 3, 1) # RightLayout.addWidget(self.LoginButton, 4, 1) # RightGridGroupBox = QGroupBox("用户登录") # RightGridGroupBox.setLayout(RightLayout) layout1 = QHBoxLayout() layout1.addWidget(self.Accountlabe) layout1.addWidget(self.AccountEdit) layout2 = QHBoxLayout() layout2.addWidget(self.Passwordlabe) layout2.addWidget(self.PasswordEdit) layout3 = QHBoxLayout() layout3.addWidget(self.BtnCheck) layout3.addStretch(1) layout4 = QHBoxLayout() layout4.addStretch(1) layout4.addWidget(self.LoginButton) layout4.addStretch(1) RightLayout = QVBoxLayout() RightLayout.addLayout(layout1) RightLayout.addLayout(layout2) RightLayout.addLayout(layout3) RightLayout.addLayout(layout4) RightLayout.setContentsMargins(20, 20, 20, 20) RightGridGroupBox = QGroupBox("用户登录") RightGridGroupBox.setLayout(RightLayout) # 底部 self.RegisteredButton = QPushButton("注册") self.RegisteredButton.clicked.connect(self.registered_clicked) self.FindPasswordButton = QPushButton("找回密码") self.FindPasswordButton.clicked.connect(self.findpassword) BottomLayout = QHBoxLayout() BottomLayout.addStretch(1) BottomLayout.addWidget(self.FindPasswordButton) BottomLayout.addWidget(self.RegisteredButton) # 将左侧和右侧放到一个水平的布局中,构成顶部 TopLayout = QHBoxLayout() TopLayout.addWidget(LeftGridGroupBox) TopLayout.addWidget(RightGridGroupBox) MainLayout = QVBoxLayout() MainLayout.addStretch(1) MainLayout.addLayout(TopLayout) MainLayout.addLayout(BottomLayout) self.setLayout(MainLayout) # 定时器来动态切换图片 self.Timer = QBasicTimer() self.Timer.start(2000, self) self.center() # self.setGeometry(300, 300, 800, 350) self.resize(800, 350) self.setFixedSize(800, 350) self.setToolTip("HealthCareSystem") QToolTip.setFont(QFont \ ("微软雅黑", 12)) self.setWindowTitle("健康监护系统")
def initUI(self): layout = QtWidgets.QGridLayout() pushButton1 = QtWidgets.QPushButton() #pushButton1.setGeometry(QtCore.QRect(110, 160, 89, 25)) pushButton1.setObjectName("pushButton1") pushButton1.setText("Кнопка") self.checkBox = QtWidgets.QCheckBox('QCheckBox',self) self.checkBox.toggle() self.checkBox.stateChanged.connect(self.changeTitle) #checkBox.move(20,20) #checkbox.setGeometry(QtCore.QRect(100, 100, 100, 100)) comboBox = QtWidgets.QComboBox() #comboBox.setGeometry(QtCore.QRect(100, 100, 100, 100)) #comboBox.move(20,450) comboBox.insertItem(0,"Выпадающий список") comboBox.insertItem(1,"КомбоБокс") scrollBar = QtWidgets.QScrollBar() #scrollBar.insertItem(0,'shit') #scrollBar.move(20,100) textEdit = QtWidgets.QTextEdit() buttonLabel = QtWidgets.QLabel('QPushButton') checkBoxLabel = QtWidgets.QLabel('QCheckBox') comboBoxLabel = QtWidgets.QLabel('QComboBox') scrollBarLabel = QtWidgets.QLabel('QScrollBar') textEditLabel = QtWidgets.QLabel('QTextEdit') layout.addWidget(buttonLabel, 1, 0) layout.addWidget(pushButton1, 1, 1) layout.addWidget(self.checkBox, 2, 1) layout.addWidget(checkBoxLabel, 2, 0) layout.addWidget(comboBox, 3, 1) layout.addWidget(comboBoxLabel, 3, 0) layout.addWidget(scrollBar, 4, 1) layout.addWidget(scrollBarLabel, 4, 0) layout.addWidget(textEdit, 6, 1) layout.addWidget(textEditLabel, 6, 0) lineEdit = QtWidgets.QLineEdit() textlineEdit = QtWidgets.QLabel('QLineEdit') layout.addWidget(textlineEdit,7,0) layout.addWidget(lineEdit,7,1) self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.slider.setFocusPolicy(QtCore.Qt.NoFocus) #slider.setGeometry(30,40,100,40) self.textSlider2 = QtWidgets.QLabel("Work") self.slider.valueChanged[int].connect(self.changeValue) self.textSlider = QtWidgets.QLabel("QSlider") '''pixmap = QtWidgets.QLabel() pixmap.setPixmap(QPixmap('max.png')) pixmap.setGeometry(40,40,40,40)''' layout.addWidget(self.textSlider,8,0) layout.addWidget(self.slider, 8,1) layout.addWidget(self.textSlider2, 8,2) #layout.addWidget(pixmap,8,2) self.progressBar = QProgressBar(self) self.progressBar.setGeometry(30, 40, 200, 25) self.buttonPB = QPushButton('Start', self) self.buttonPB.move(40, 80) self.buttonPB.clicked.connect(self.doAction) self.timer = QBasicTimer() self.step = 0 self.setGeometry(300, 300, 280, 170) self.setWindowTitle('QProgressBar') #self.show() self.textProgressBar = QtWidgets.QLabel('QProgressBar') '''progressBar = QtWidgets.QProgressBar() buttonPB = QtWidgets.QPushButton('Старт') buttonPB.clicked.connect(doAction) timer = QtCore.QBasicTimer() step = 0''' layout.addWidget(self.textProgressBar,9,0) layout.addWidget(self.progressBar,9,1) layout.addWidget(self.buttonPB,9,2) layout.setSpacing(20) self.w = QtWidgets.QWidget() self.w.setLayout(layout) self.mw = QtWidgets.QScrollArea() self.mw.setWindowTitle("Это виджет QScrollArea") self.mw.setWidget(self.w) self.mw.resize(200, 200) self.mw.show()
def initUI(self): ''' Widgets for sender ''' self.setAcceptDrops(True) # for drag & drop self.sender_number = QLineEdit() self.sender_number.setPlaceholderText("123-45-67890") self.sender_company = QLineEdit() self.sender_company.setPlaceholderText("상호") self.sender_name = QLineEdit() self.sender_name.setPlaceholderText("대표자명") self.sender_address = QLineEdit(self) self.sender_address.setPlaceholderText("사업장 주소") self.sender_call = QLineEdit(self) self.sender_call.setPlaceholderText("123)456-7890") self.sender_fax = QLineEdit(self) self.sender_fax.setPlaceholderText("123)456-7890") self.sender_business = QLineEdit(self) self.sender_business.setPlaceholderText("업태") self.sender_category = QLineEdit(self) self.sender_category.setPlaceholderText("종목") self.receiver = QLineEdit(self) self.receiver.setPlaceholderText("받는 회사명") self.register_date = QLineEdit(self) self.register_date.setPlaceholderText("2019-12-31") # self.register_date_year = QComboBox() # self.register_date_month = QComboBox() # self.register_date_day = QComboBox() # for year in range(2019,2023): # self.register_date_year.addItem(str(year)) # for month in range(1,13): # self.register_date_month.addItem(str(month)) # for day in range(1,32): # self.register_date_day.addItem(str(day)) self.sender_number_label = QLabel("등록번호", self) self.sender_company_label = QLabel("상호", self) self.sender_name_label = QLabel("대표자", self) self.sender_address_label = QLabel("사업장주소", self) self.sender_call_label = QLabel("전화", self) self.sender_fax_label = QLabel("팩스", self) self.sender_business_label = QLabel("업태", self) self.sender_category_label = QLabel("종목", self) self.receiver_label = QLabel("받는회사", self) self.register_date_label = QLabel("등록날짜", self) # self.register_date_year_label = QLabel("년", self) # self.register_date_month_label = QLabel("월", self) # self.register_date_day_label = QLabel("일", self) # self.dnd_label = QLabel('Drag n Drop, Here!', self) self.dnd_label = FileEdit(self) self.dnd_label.setAlignment(Qt.AlignCenter) self.dnd_label.setStyleSheet( "background:white url('./image/here2.jpg') no-repeat center center; border:2px solid black; border-radius: 30px;" ) self.add_button = QPushButton(self) self.add_button.setIcon(QIcon('./image/plus.png')) self.add_button.clicked.connect(self.filePushButtonClicked) self.add_button.setStyleSheet("margin:0px; ") self.sub_button = QPushButton(self) self.sub_button.setIcon(QIcon('./image/minus.png')) self.sub_button.clicked.connect(self.fileDownButtonClicked) self.sub_button.setStyleSheet("margin:0px") self.go_button = QPushButton(self) self.go_button.setIcon(QIcon('./image/check.png')) self.go_button.clicked.connect(self.fileGoButtonClicked) self.go_button.setStyleSheet("margin:0px 50px 0px 50px") self.files_label = QLabel('Files...', self) self.files_label.setAlignment(Qt.AlignCenter) self.files_label.setStyleSheet( "font:bold 15px 나눔고딕,NanumGothic,돋움,Dotum") self.dnd_label.setTargetWidget(self.files_label) self.status_bar = QProgressBar(self) self.status_bar.setAlignment(Qt.AlignCenter) self.timer = QBasicTimer() self.step = 0 button_layout = QHBoxLayout() button_layout.addWidget(self.add_button) button_layout.addWidget(self.sub_button) button_layout.setContentsMargins(50, 0, 50, 0) main_layout = QVBoxLayout() sub_layout = QGridLayout() sub_layout.setContentsMargins(20, 5, 20, 5) sub_layout.addWidget(self.sender_number_label, 0, 0) sub_layout.addWidget(self.sender_number, 0, 1) sub_layout.addWidget(self.register_date_label, 0, 2) sub_layout.addWidget(self.register_date, 0, 3) sub_layout.addWidget(self.sender_company_label, 1, 0) sub_layout.addWidget(self.sender_company, 1, 1) sub_layout.addWidget(self.receiver_label, 1, 2) sub_layout.addWidget(self.receiver, 1, 3) sub_layout.addWidget(self.sender_name_label, 2, 0) sub_layout.addWidget(self.sender_name, 2, 1) sub_layout.addWidget(self.sender_address_label, 3, 0) sub_layout.addWidget(self.sender_address, 3, 1) sub_layout.addWidget(self.sender_call_label, 4, 0) sub_layout.addWidget(self.sender_call, 4, 1) sub_layout.addWidget(self.sender_fax_label, 4, 2) sub_layout.addWidget(self.sender_fax, 4, 3) sub_layout.addWidget(self.sender_business_label, 5, 0) sub_layout.addWidget(self.sender_business, 5, 1) sub_layout.addWidget(self.sender_category_label, 5, 2) sub_layout.addWidget(self.sender_category, 5, 3) main_layout.addLayout(sub_layout) # layout main_layout.addWidget(self.dnd_label) main_layout.addLayout(button_layout) # layout main_layout.addWidget(self.go_button) main_layout.addWidget(self.files_label) main_layout.addWidget(self.status_bar) main_layout.setContentsMargins(10, 10, 10, 10) self.setLayout(main_layout) self.setWindowIcon(QIcon("./image/web.png")) self.show()
def __init__(self): super().__init__() # 几个QWidgets self.setWindowTitle('单分子力学谱智能检测系统') # 窗体名 self.setWindowIcon(QIcon('Logo.jpg')) self.figure = plt.figure(facecolor='#FFD7C4') # 可选参数,facecolor为背景颜色 self.resize(800, 800) self.info = QLineEdit() self.info.setReadOnly(True) self.info.setText("文件/文件夹名") self.l1 = QLabel("下限") self.l1.setAlignment(Qt.AlignCenter) self.s1 = QSlider(Qt.Horizontal) self.s1.setMinimum(0) self.s1.setMaximum(4000) self.s1.setSingleStep(100) self.s1.setTickPosition(QSlider.TicksBelow) self.s1.setTickInterval(100) self.s1.setValue(2100) self.s1.valueChanged.connect(self.valuechange) self.l2 = QLabel("上限") self.l2.setAlignment(Qt.AlignCenter) self.s2 = QSlider(Qt.Horizontal) self.s2.setMinimum(0) self.s2.setMaximum(4000) self.s2.setSingleStep(100) self.s2.setTickPosition(QSlider.TicksBelow) self.s2.setTickInterval(100) self.s2.setValue(2600) self.s2.valueChanged.connect(self.valuechange) self.canvas = FigureCanvas(self.figure) self.button_choosefile = QPushButton("选择文件") self.button_judge = QLabel("文件输出:") self.text_judge = QLabel() self.button_choosefile2 = QPushButton("选择文件夹") self.button_judge2 = QLabel("文件夹输出:") self.text_judge2 = QLabel() self.cb = QComboBox() self.cb.addItem("SVM") # 添加一个项目 self.cb.addItem("决策树") self.cb.addItem("随机森林") self.cb.addItem("SVM+决策树+随机森林联合判断") self.cb.currentIndexChanged.connect(self.choose_clf) self.button_begin = QPushButton("开始分类") self.button_stop = QPushButton("停止") self.button_pause = QPushButton("暂停/继续") self.rbtn1 = QRadioButton('四峰', self) self.rbtn1.toggled.connect(lambda: self.setMode_2(0)) self.rbtn2 = QRadioButton('八峰', self) self.rbtn2.toggled.connect(lambda: self.setMode_2(1)) self.rbtn1.setChecked(1) # 设定初值 # 进度条 self.progressBar = QProgressBar(self) self.progressBar.setValue(0) self.timer = QBasicTimer() # 连接事件 self.button_choosefile.clicked.connect(self.fileOpen_button) self.button_choosefile2.clicked.connect(self.fileDirOpen_button) self.button_begin.clicked.connect(self.mystart) # self.method1.clicked.connect(self.method1_click) #self.method2.clicked.connect(self.method2_click_on) #self.method3.clicked.connect(self.method3_click_on) self.button_stop.clicked.connect(self.mystop_click) self.button_pause.clicked.connect(self.mypause_click) # 设置布局 layout = QVBoxLayout() layout.addWidget(self.canvas) layout.addWidget(self.info) layout.addWidget(self.l1) layout.addWidget(self.s1) layout.addWidget(self.l2) layout.addWidget(self.s2) layout.addWidget(self.button_choosefile) layout.addWidget(self.button_choosefile2) # 创建一个水平布局 hbox = QHBoxLayout() #hbox.addWidget(self.method2) #hbox.addWidget(self.method3) hbox.addWidget(self.cb) hbox.addWidget(self.button_begin) hbox.addWidget(self.button_stop) hbox1 = QHBoxLayout() hbox1.addWidget(self.rbtn1) hbox1.addWidget(self.rbtn2) hbox2 = QHBoxLayout() hbox2.addWidget(self.button_judge) hbox2.addWidget(self.text_judge) hbox3 = QHBoxLayout() hbox3.addWidget(self.button_judge2) hbox3.addWidget(self.text_judge2) hbox4 = QHBoxLayout() hbox4.addWidget(self.progressBar) hbox4.addWidget(self.button_pause) layout.addLayout(hbox) layout.addLayout(hbox1) layout.addLayout(hbox2) layout.addLayout(hbox3) layout.addLayout(hbox4) self.setLayout(layout) # 赋初值 self.classFilePath = None self.classFileDirPath = None self.mystop = 0 self.setMode(0) # 判断文件/文件夹 self.setMode_2(0) # 判断4峰/8峰 self.setMode_3(0) # 判断当前是否有进程 self.download_proess_signal.connect(self.set_progressbar_value) self.judgeMethod = 1
def __init__(self): super(Login, self).__init__() self.setupUi(self) self.flagMove = False self.setWindowFlags( Qt.FramelessWindowHint) # 去掉标题栏的代码,这种顶部就不会出现空白,但是不能移动,需自己处理 self.movie = QMovie('image/login/0.gif') self.label_2.setMovie(self.movie) self.movie.start() # 用户头像的一系列效果设置 self.myQPushButton = MyQPushButton(self.slot_myQPushButton, self.frameGlobal) # 重写的QPushButton类 self.myQPushButton.setGeometry(234, 142, 16, 16) self.myQPushButton.setObjectName('myQPushButton') self.myQPushButton.setIcon( QIcon('image/login/8.png')) # 默认的icon,可以从数据库中根据条件选择 self.labUserImg_orgin_enterEvent = self.labUserImg.enterEvent # 鼠标移入用户头像 self.labUserImg_orgin_leaveEvent = self.labUserImg.leaveEvent # 鼠标离开用户头像 self.btnAddUser_orgin_enterEvent = self.btnAddUser.enterEvent # 鼠标移入滑出的添加账号按钮 self.btnAddUser_orgin_leaveEvent = self.btnAddUser.leaveEvent # 鼠标离开滑出的添加账号按钮 self.labUserImg.enterEvent = self.labUserImg_EnterEvent # 绑定函数 self.btnAddUser.enterEvent = self.btnAddUser_EnterEvent self.btnAddUser.leaveEvent = self.btnAddUser_LeaveEvent self.labUserImg.leaveEvent = self.labUserImg_LeaveEvent self.timer = QBasicTimer() # 鼠标离开用户头像或者添加账号按钮时的计时器 self.flagTimer = 0 # 鼠标离开用户头像或者添加账号按钮时的计时器的初始值 self.timerBtnAddUserMove = QBasicTimer() # 添加账号按钮移动开始至结束的计时事件 self.btnAddUserX = 203 # 添加账号按钮水平位置x的滑出效果初始标记(这个值原本就是它的x位置) # 账号输入下拉列表的设置 self.comboUserId.setView( QListView()) # 先随便设置一个QListView(),使下拉列表可以设置qss样式 self.actionLeftUserID = QAction(self.comboUserId) self.actionLeftUserID.setIcon(QIcon("image/login/3.png")) self.comboUserId.lineEdit().addAction( self.actionLeftUserID, QLineEdit.LeadingPosition) # 左侧图标 self.comboUserId.lineEdit().setPlaceholderText('账号') # 设置默认提示语 self.comboUserId.addItem(QIcon("image/login/02.jpg"), "1235321111") self.comboUserId.addItem(QIcon("image/login/03.jpg"), "3745634222") # self.comboUserID.setItemData(2, QPixmap('image/login/4.png'), Qt.DecorationRole) # 数据作为图标出现 # self.comboUserID.setItemIcon(1, QIcon("image/login/4.png")) # self.comboUserID.setItemDelegate() # self.comboUserID.setItemData(0, 0, Qt.UserRole - 1) # 锁定第0项。参数3如果是-256,第0项显示空字符 self.comboUserId.setCurrentIndex(-1) # 下拉列表初始设置为空,这样不用添加一个空的下拉项了 self.comboUserId.activated[str].connect(self.slot_comboUserID) self.comboUserID_orgin_focusInEvent = self.comboUserId.focusInEvent # 账号输入下拉列表获得焦点事件 self.comboUserId.focusInEvent = self.comboUserID_FocusInEvent # 账号输入下拉列表获得焦点事件的函数绑定 self.comboUserID_orgin_focusOutEvent = self.comboUserId.focusOutEvent # 账号输入下拉列表失去焦点事件 self.comboUserId.focusOutEvent = self.comboUserID_FocusOutEvent # 账号输入下拉列表失去焦点事件的函数绑定 self.comboUserID_orgin_mousePressEvent = self.comboUserId.mousePressEvent # 账号输入下拉列表鼠标按下事件 self.comboUserId.mousePressEvent = self.comboUserID_MousePressEvent # 账号输入下拉列表鼠标按下事件的函数绑定 self.flagComboUserID = False # 点击下拉箭头需要的标记 # 密码框的设置 self.actionLeftPassword = QAction(self.lEditPassword) self.actionLeftPassword.setIcon(QIcon("image/login/1.png")) self.actionRightPassword = QAction(self.lEditPassword) self.actionRightPassword.setIcon(QIcon("image/login/17.png")) self.actionRightPassword.triggered.connect( self.slot_actionRightPassword) self.menuKeyBoard = MyMenu(self) self.lEditPassword.addAction(self.actionLeftPassword, QLineEdit.LeadingPosition) # 左侧图标 self.lEditPassword.addAction(self.actionRightPassword, QLineEdit.TrailingPosition) # 右侧图标 self.lEditPassword.setPlaceholderText('密码') self.lEditPassword_orgin_focusInEvent = self.lEditPassword.focusInEvent self.lEditPassword.focusInEvent = self.lEditPassword_FocusInEvent self.lEditPassword_orgin_focusOutEvent = self.lEditPassword.focusOutEvent self.lEditPassword.focusOutEvent = self.lEditPassword_FocusOutEvent # 二维码登录界面frame的设置 self.frameQRcodeUpdata_orgin_enterEvent = self.frameQRcodeUpdata.enterEvent # 鼠标滑入更新二维码容器 self.frameQRcodeUpdata.enterEvent = self.frameQRcodeUpdata_EnterEvent self.frameQRcodeUpdata_orgin_leaveEvent = self.frameQRcodeUpdata.leaveEvent # 鼠标离开更新二维码容器 self.frameQRcodeUpdata.leaveEvent = self.frameQRcodeUpdata_LeaveEvent self.timerFrameQRcodeUpdata = QBasicTimer() self.flagTimerFrameQRcodeUpdata = False self.flagTimerFrameQRcodeUpdataX = 115 self.btnFrameQRcodeBack.clicked.connect( self.slot_btnQRcode_btnFrameQRcodeBack) # 一些控件的信号与槽的绑定,以及隐藏初始界面不应该显示的控件 self.btnAddUser.hide() # 先把添加账号按钮隐藏,鼠标移入self.labUserImg时再滑出 self.btnLoginSingle.hide() # 单账号登录按钮在self.btnAddUser被点击时才显示 self.frameAdduser.hide() # 此容器内的控件在self.btnAddUser被点击时才显示 self.frameQRcode.hide() self.btnSignIn.clicked.connect(lambda: QDesktopServices.openUrl( QUrl(("https://ssl.zc.qq.com/v3/index-chs.html")))) self.btnFindBack.clicked.connect(lambda: QDesktopServices.openUrl( QUrl(( "https://aq.qq.com/v2/uv_aq/html/reset_pwd/pc_reset_pwd_input_account.html" )))) self.btnSetting.clicked.connect( lambda: self.timerError.start(10, self)) # 以后再写设置界面 self.btnQRcode.clicked.connect(self.slot_btnQRcode_btnFrameQRcodeBack) # self.btnQRcode.clicked.connect(lambda :self.timerError.start(10, self)) self.btnAddUser.clicked.connect(self.slot_btnAddUser_btnLoginSingle) # self.btnAddUser.clicked.connect(lambda: self.timerError.start(10, self)) self.btnLoginSingle.clicked.connect( self.slot_btnAddUser_btnLoginSingle) self.btnCancel.clicked.connect(self.slot_btnAddUser_btnLoginSingle) self.btnError.clicked.connect(lambda: self.timerError.start(10, self)) self.btnSetting.clicked.connect(self.slot_btnSetting) # 模拟登录需要的一些数据及设置 self.login_test()
def __init__(self, **kwargs): super().__init__(**kwargs) self.right_to_left_direction = True self.initUI() self.timer = QBasicTimer() self.timer.start(80, self)
def __init__(self, model): super(Controller, self).__init__() self.__model = model self.__timer = QBasicTimer()
def __init__(self, parent): super().__init__(parent) self.timer = QBasicTimer() self.setFocusPolicy(Qt.StrongFocus)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(960, 540) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setObjectName("pushButton") self.horizontalLayout.addWidget(self.pushButton) self.lineEdit = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit.setObjectName("lineEdit") #开启拖拽 self.setAcceptDrops(True) self.horizontalLayout.addWidget(self.lineEdit) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.radioButton = QtWidgets.QRadioButton(self.centralwidget) self.radioButton.setObjectName("radioButton") self.horizontalLayout_3.addWidget(self.radioButton) self.radioButton_2 = QtWidgets.QRadioButton(self.centralwidget) self.radioButton_2.setChecked(True) self.radioButton_2.setAutoRepeat(False) self.radioButton_2.setObjectName("radioButton_2") self.horizontalLayout_3.addWidget(self.radioButton_2) self.radioButton_3 = QtWidgets.QRadioButton(self.centralwidget) self.radioButton_3.setEnabled(True) self.radioButton_3.setTabletTracking(False) self.radioButton_3.setAcceptDrops(False) self.radioButton_3.setAutoFillBackground(False) self.radioButton_3.setChecked(False) self.radioButton_3.setObjectName("radioButton_3") self.horizontalLayout_3.addWidget(self.radioButton_3) self.radioButton_4 = QtWidgets.QRadioButton(self.centralwidget) self.radioButton_4.setObjectName("radioButton_4") self.horizontalLayout_3.addWidget(self.radioButton_4) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem) self.radioButton_5 = QtWidgets.QRadioButton(self.centralwidget) self.radioButton_5.setObjectName("radioButton_5") self.horizontalLayout_3.addWidget(self.radioButton_5) self.label = QtWidgets.QLabel(self.centralwidget) self.label.setObjectName("label") self.horizontalLayout_3.addWidget(self.label) self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_2.setObjectName("lineEdit_2") self.horizontalLayout_3.addWidget(self.lineEdit_2) self.verticalLayout.addLayout(self.horizontalLayout_3) self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget) self.textBrowser.setObjectName("textBrowser") self.verticalLayout.addWidget(self.textBrowser) #进度条 self.progressBar = QtWidgets.QProgressBar(self.centralwidget) self.progressBar.setProperty("value", 0) self.progressBar.setObjectName("progressBar") self.verticalLayout.addWidget(self.progressBar) #样式 style = """ QProgressBar { border-radius: 5px; text-align: center; }""" self.progressBar.setStyleSheet(style) self.textBrowser.append('注意事项:不要在爬取过程中关闭程序,会造成最终拷贝文件的不完整。需要手动删除。') #创建计时器 self.timer = QBasicTimer() #初始时间 self.timer.start(100, self) #右键清除 self.textBrowser.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.textBrowser.customContextMenuRequested[QtCore.QPoint].connect( self.right) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setObjectName("label_2") self.horizontalLayout_2.addWidget(self.label_2) spacerItem1 = QtWidgets.QSpacerItem(128, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem1) self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_2.setObjectName("pushButton_2") self.horizontalLayout_2.addWidget(self.pushButton_2) self.verticalLayout.addLayout(self.horizontalLayout_2) self.verticalLayout_2.addLayout(self.verticalLayout) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.label2 = QtWidgets.QLabel(self.centralwidget) self.label2.setObjectName("label") self.horizontalLayout_3.addWidget(self.label2) #pushButton = 选择xml #lineEdit = 显示路径地址 #radioButton = 视频选项 #radioButton_2 = 音频选项 #radioButton_3 = 图片选项 #radioButton_4 = 全部 #radioButton_5= 增加扩展 #lineEdit_2 = 自定义内容 #textBrowser = 打印平台 #progressBar = 进度监看 #pushButton_2 = 输出确认 self.pushButton.clicked.connect(self.PushButton) self.radioButton.clicked.connect(self.RadioButton) self.radioButton_2.clicked.connect(self.RadioButton_2) self.radioButton_3.clicked.connect(self.RadioButton_3) self.radioButton_4.clicked.connect(self.RadioButton_4) self.radioButton_5.clicked.connect(self.RadioButton_5) self.pushButton_2.clicked.connect(self.PushButton_2) #状态 self.lineEdit_2.setEnabled(False)
def progressbarr_move(self): self.timer = QBasicTimer() self.step = 0 self.timer.start(100, self)
def calculatePositions(q: Queue, qResp: Queue): responseMsg = '' PositionXP1 = 50 PositionXP2 = 700 Weapon1Y = WINDOWHEIGHT - 80 Weapon2Y = WINDOWHEIGHT - 80 Player1Orientation = 'normal' Player2Orientation = 'normal' timer = QBasicTimer() while True: weaponInfo = '#' if not q.empty(): rez = str(q.get()) if rez == '1': responseMsg = str(WINDOWWIDTH / 2) + ',' + Player1Orientation PositionXP1 = int(responseMsg) elif rez == '2': #responseMsg = '50,700,' + Player1Orientation + ',' + Player2Orientation PositionXP1 = 50 PositionXP2 = 700 elif rez == '3': #responseMsg = '50,700,' + Player1Orientation + ',' + Player2Orientation PositionXP1 = 50 PositionXP2 = 700 else: if int(rez) == Qt.Key_Right: Player1Orientation = 'right' if PositionXP1 + PLAYER_SIZE < WINDOWWIDTH - 13: PositionXP1 += 5 #responseMsg = str(PositionXP1) + ',' + str(PositionXP2) + ',' + Player1Orientation + ',' + Player2Orientation if int(rez) == Qt.Key_Left: Player1Orientation = 'left' if PositionXP1 - 5 > 20: PositionXP1 -= 5 #responseMsg = str(PositionXP1) + ',' + str(PositionXP2) + ',' + Player1Orientation + ',' + Player2Orientation if int(rez) == Qt.Key_Space: weaponInfo += '1,' + str(PositionXP1) #responseMsg = str(PositionXP1) + ',' + str(PositionXP2) + ',' + Player1Orientation + ',' + Player2Orientation if int(rez) == Qt.Key_A: Player2Orientation = 'left' if PositionXP2 - 5 > 20: PositionXP2 -= 5 #responseMsg = str(PositionXP1) + ',' + str(PositionXP2) + ',' + Player1Orientation + ',' + Player2Orientation if int(rez) == Qt.Key_D: Player2Orientation = 'right' if PositionXP2 + PLAYER_SIZE < WINDOWWIDTH - 13: PositionXP2 += 5 #responseMsg = str(PositionXP1) + ',' + str(PositionXP2) + ',' + Player1Orientation + ',' + Player2Orientation if int(rez) == Qt.Key_Shift: weaponInfo += '2,' + str(PositionXP2) if int(rez) == Qt.Key_Minus: PositionXP1 = 50 PositionXP2 = 700 Player1Orientation = 'normal' Player2Orientation = 'normal' #responseMsg = str(PositionXP1) + ',' + str(PositionXP2) + ',' + Player1Orientation + ',' + Player2Orientation #s.Weapon1, Weapon1Y, s.Weapon2, Weapon2Y = updateWeapons(s.Weapon1, s.Weapon2, Weapon1Y, Weapon2Y) responseMsg = str(PositionXP1) + ',' + str( PositionXP2 ) + ',' + Player1Orientation + ',' + Player2Orientation + weaponInfo #responseMsg += ',' + str(s.w1X) + ',' + str(s.w1Y) + ',' + str(s.w2X) + ',' + str(s.w2Y) qResp.put(responseMsg) else: #s.Weapon1, Weapon1Y, s.Weapon2, Weapon2Y = updateWeapons(s.Weapon1, s.Weapon2, Weapon1Y, Weapon2Y) responseMsg = str(PositionXP1) + ',' + str( PositionXP2 ) + ',' + Player1Orientation + ',' + Player2Orientation + weaponInfo #responseMsg += ',' + str(s.w1X) + ',' + str(s.w1Y) + ',' + str(s.w2X) + ',' + str(s.w2Y) qResp.put(responseMsg) time.sleep(0.032)
def initBoard(self): self.timer = QBasicTimer() self.timerOn = False
def initUI(self): self.inputPic = myImageViewer("pics/default.png", 400, 300) self.outputPic = myImageResult("pics/default_null.png", 400, 300) self.defaultInpath = self.inputPic.getImagePath() self.VBoxGroups = [] for i in range(self.nStyle): self.VBoxGroups.append( preStyle(self, i + 1, self.style[i], self.picPath[i], 200, 200)) self.HBoxGroupScroll = QGroupBox() self.HBox1 = QHBoxLayout() self.HBox1.addStretch(1) for group in self.VBoxGroups: self.HBox1.addWidget(group) self.HBox1.addStretch(1) self.HBoxGroupScroll.setLayout(self.HBox1) self.transButton = QPushButton('Transfer') self.transButton.setFixedSize(80, 20) self.transButton.clicked.connect(self.transfer) self.shareButton = QPushButton('Share') self.shareButton.setFixedSize(80, 20) self.shareButton.clicked.connect(self.share) self.shareButton.setDisabled(True) self.timer = QBasicTimer() self.step = 0 self.HBoxGroupButton = QGroupBox() self.HBoxButton = QHBoxLayout() self.HBoxButton.addStretch(1) self.HBoxButton.addWidget(self.transButton) self.HBoxButton.addStretch(1) self.HBoxButton.addWidget(self.shareButton) self.HBoxButton.addStretch(1) self.HBoxGroupButton.setLayout(self.HBoxButton) self.progBar = QProgressBar() self.progBar.setFixedSize(500, 10) self.HBoxGroupBar = QGroupBox() self.HBoxBar = QHBoxLayout() self.HBoxBar.addStretch(1) self.HBoxBar.addWidget(self.progBar) self.HBoxBar.addStretch(1) self.HBoxGroupBar.setLayout(self.HBoxBar) self.scroll = QScrollArea() self.scroll.setWidget(self.HBoxGroupScroll) self.scroll.setAutoFillBackground(True) self.scroll.setWidgetResizable(True) #self.HBoxGroupUp = QGroupBox() #self.HBoxUp = QHBoxLayout() #self.HBoxUp.addWidget(self.scroll) #self.HBoxGroupUp.setLayout(self.HBoxUp) self.HBoxGroupDown = QGroupBox() self.HBox2 = QHBoxLayout() self.HBox2.addStretch(1) self.HBox2.addWidget(self.inputPic) self.HBox2.addStretch(1) self.HBox2.addWidget(self.outputPic) self.HBox2.addStretch(1) self.HBoxGroupDown.setLayout(self.HBox2) self.VBox = QVBoxLayout() self.VBox.addStretch(1) self.VBox.addWidget(self.scroll) self.VBox.addStretch(1) self.VBox.addWidget(self.HBoxGroupBar) self.VBox.addStretch(1) self.VBox.addWidget(self.HBoxGroupDown) self.VBox.addStretch(1) self.VBox.addWidget(self.HBoxGroupButton) self.VBox.addStretch(1) self.setLayout(self.VBox)
def __init__(self): super().__init__() self.block_size = 30 # одна из фич self.saved_games = deque(maxlen=3) self.timer = QBasicTimer() self.status_bar = self.statusBar() self.cols = 15 self.rows = 15 self.colors_num = 5 self.name = 'Player' self._default_name = True self.setWindowTitle('Blocks') # статистика self.last_stats = ('You', self.cols, self.rows, 0) self.game = Blocks(self.cols, self.rows, self.colors_num, self.name) self.game.start_new_game() self.editor = Editor() self.editor.butt_ok.clicked.connect(self.edit_settings_close_editor) self.sl_menu = None self.score_table = None self.highest = CountHighest(self.game, 2) new_act = qw.QAction('&New Game', self) new_act.setStatusTip('Start new game') new_act.triggered.connect(self.start_new_game) again_act = qw.QAction('&Play Again', self) again_act.setStatusTip('Start new game with the same field') again_act.triggered.connect(self.start_again) score_act = qw.QAction('&Score Table', self) score_act.setStatusTip('Show score table') score_act.setShortcut('Ctrl+T') score_act.triggered.connect(self.open_score_table) exit_act = qw.QAction('&Exit', self) exit_act.setShortcut('Ctrl+Q') exit_act.setStatusTip('Exit application') exit_act.triggered.connect(sys.exit) edit_act = qw.QAction('&Edit Settings', self) edit_act.setShortcut('Ctrl+E') edit_act.setStatusTip('Change nickname and field size') edit_act.triggered.connect(self.open_editor) save_act = qw.QAction('&Save', self) save_act.setShortcut('Ctrl+S') save_act.triggered.connect(lambda: self.status_bar.showMessage( self.save_game())) load_act = qw.QAction('&Load', self) load_act.setShortcut('Ctrl+L') load_act.triggered.connect(self.open_loader) count_act = qw.QAction('&Count Highest Score', self) count_act.setStatusTip('It is a long process, ' 'some game features will be unavailable') count_act.triggered.connect(self.count_highest) cancel_act = qw.QAction('&Cancel Counting', self) cancel_act.triggered.connect(lambda: self.stop_counting()) menubar = self.menuBar() file_menu = menubar.addMenu('&Game') file_menu.addAction(new_act) file_menu.addAction(again_act) file_menu.addAction(score_act) file_menu.addAction(exit_act) edit_menu = menubar.addMenu('&Edit') edit_menu.addAction(edit_act) save_menu = menubar.addMenu('&Save/Load') save_menu.addAction(save_act) save_menu.addAction(load_act) other_menu = menubar.addMenu('&Other') other_menu.addAction(count_act) other_menu.addAction(cancel_act) self.acts_to_lock = (count_act, ) self.canvas = Canvas(self.game, self.block_size, self) self.score_total = qw.QLCDNumber(self) self.score_total.display(self.game.score()) self.score_total.setSegmentStyle(qw.QLCDNumber.Flat) self.score_total.setStyleSheet("""color: black; background: white;""") self.score_curr = qw.QLCDNumber(self) self.score_curr.display(Blocks.count_score(self.game.highlighted())) self.score_curr.setSegmentStyle(qw.QLCDNumber.Flat) self.score_curr.setStyleSheet("""color: black; background: white;""") scores_layout = qw.QHBoxLayout() scores_layout.addWidget(self.score_total) scores_layout.addWidget(self.score_curr) self.main_layout = qw.QVBoxLayout() self.main_layout.addWidget(self.canvas) self.main_layout.addLayout(scores_layout) self.centr_wid = qw.QWidget(self) self.centr_wid.setLayout(self.main_layout) self.setCentralWidget(self.centr_wid) self.resize_window() self.show() self.timer.start(40, self)