当前位置: 首页 > news >正文

用phython做网站网址缩短在线生成器

用phython做网站,网址缩短在线生成器,广安网站开发,做高清视频的网站星三角降压启动用可以用类进行封装,就像博图FB块那样。把逻辑都在类里完成,和外界需要交互的暴露出接口。测试过程中,发现类中直接用定时器QTimer会出现问题。然后就把定时器放到外面了。然后测试功能正常。 from PySide6.QtWidgets import …

星三角降压启动用可以用类进行封装,就像博图FB块那样。把逻辑都在类里完成,和外界需要交互的暴露出接口。测试过程中,发现类中直接用定时器QTimer会出现问题。然后就把定时器放到外面了。然后测试功能正常。

from PySide6.QtWidgets import *
from PySide6.QtCore import *
from PySide6.QtGui import *class Motor:def __init__(self,isrun:bool=None,is_star_run:bool=None,is_tran_run:bool=None,fault:bool=None):self.is_main_run = isrunself.is_star_run = is_star_runself.is_tran_run = is_tran_run,self.fault = fault@staticmethoddef get_bool(bytes:bytearray,address:int):byte_index = address//8bit_index = address % 8return bool(bytes[byte_index]>>bit_index & 1)@staticmethoddef set_bool(bytes:bytearray,address:int,value:bool):if value not in {1,0,False,True}:raise TypeError(f"Value value:{value} is not a boolean expression.")byte_index = address // 8bit_index = address % 8index_value = 1<< bit_indexcurrent_value = Motor.get_bool(bytes,address)if current_value == value:returnif value:bytes[byte_index] += index_valueelse:bytes[byte_index] -= index_valuedef __str__(self):return f'{self.is_main_run} {self.is_star_run} {self.is_tran_run} {self.fault}'class StarMotor(QObject):def __init__(self,motor:Motor=None,tim:QTimer=None):self.interval = 3000self.timer = timself.timer.setInterval(self.interval)self.motor = motorself.startTimer()def set_interval(self,val:int):self.interval = valdef on_timer(self):print("timer is starting")self.motor.set_bool()def start(self,state,bytes,out1,out2,out3):def on_timer():self.motor.set_bool(bytes,out3,1)self.motor.set_bool(bytes,out2,0)print("三角启动")if state:if not all([self.motor.is_main_run,self.motor.is_star_run,self.motor.is_tran_run]):self.motor.set_bool(bytes,out1,1)self.motor.set_bool(bytes,out2,1)print("星启动")if self.motor.is_main_run and self.motor.is_star_run:if not self.timer.isActive():self.timer.timeout.connect(on_timer)self.timer.setSingleShot(True)self.timer.start()if self.motor.fault:self.motor.set_bool(bytes,out1,0)self.motor.set_bool(bytes,out2,0)self.motor.set_bool(bytes,out3,0)print("fault")if not state:self.motor.set_bool(bytes, out1, 0)self.motor.set_bool(bytes, out2, 0)self.motor.set_bool(bytes, out3, 0)print("stop")class Ui(QWidget):def __init__(self):super().__init__()self.resize(600,600)self.init_ui()self.state = Noneself.motor = Motor()self.timer = QTimer(self)self.timer.timeout.connect(self.on_timer_loop)self.timer.start(100)self.bytes = bytearray(1)time2 = QTimer(self)self.d = StarMotor(self.motor,time2)def on_timer_loop(self):self.d.start(self.state,self.bytes,0,1,2)print(self.bytes)def init_ui(self):self.btn = QPushButton('start',self)self.btn2 = QPushButton('stop',self)self.btn3 = QPushButton('主运行',self)self.btn4 = QPushButton('星运行',self)self.btn5 = QPushButton('三角运行',self)self.btn6 = QPushButton('故障',self)self.btn.setCheckable(True)self.btn2.setCheckable(True)self.btn3.setCheckable(True)self.btn4.setCheckable(True)self.btn5.setCheckable(True)self.btn6.setCheckable(True)self.btn.move(100,30)self.btn2.move(100,80)self.btn3.move(100,130)self.btn4.move(100,230)self.btn5.move(100,330)self.btn6.move(100,430)self.btn.clicked.connect(self.btn_click)self.btn2.clicked.connect(self.btn_click2)self.btn3.clicked.connect(self.btn_click3)self.btn4.clicked.connect(self.btn_click4)self.btn5.clicked.connect(self.btn_click5)self.btn6.clicked.connect(self.btn_click6)def btn_click(self,checked):self.state = checkeddef btn_click2(self,checked):passdef btn_click3(self,checked):self.motor.is_main_run = checkeddef btn_click4(self,checked):self.motor.is_star_run=checkeddef btn_click5(self,checked):self.motor.is_tran_run = checkeddef btn_click6(self,checked):self.motor.fault=checkedif __name__ == '__main__':import sysapp = QApplication(sys.argv)win = Ui()win.show()sys.exit(app.exec())

http://www.ds6.com.cn/news/41987.html

相关文章:

  • iis网站建设中上海网站排名优化公司
  • 郑州高端品牌网站建设网站排名工具
  • 建网站的优势湖南企业seo优化推荐
  • wordpress 在浏览站点时显示工具栏新媒体运营培训班
  • 网站维护中是不是关闭网站了百度关键字优化价格
  • 企业网站建设方案模板制作网站需要什么软件
  • 做网站seo优化软件开发公司有哪些
  • 哪些网站可以免费做代码关键词歌词含义
  • 旅游预定型网站建设成都seo培训班
  • 网站开发定制公司西安的网络优化公司
  • 做外贸必须知道的网站网站访问量查询工具
  • 做电影小视频在线观看网站免费建站的网站哪个好
  • 郑州百度seo网站优中国职业培训在线平台
  • 做科研有什么好的网站做免费推广的平台
  • 淘宝客做网站怎样推广比百度好用的搜索软件
  • 杭州做网站哪家公司好seo教程论坛
  • 自定义优定软件网站建设长沙seo运营
  • 买了个网站源码后要怎么用武汉十大技能培训机构
  • 房屋设计软件app哪个好宁波seo网络推广渠道介绍
  • 合肥html5网站建设百度竞价推广出价技巧
  • 网站无备案无法登入百度产品大全入口
  • 营销网站建设网络公司郑州seo网站有优化
  • 企业网站规划小程序制作一个需要多少钱
  • 做网站的带宽多少钱seo自媒体培训
  • 网站 云建站东莞网站建设快速排名
  • 移动应用开发是什么意思盐城seo推广
  • 网站设计宽屏尺寸做网络营销推广
  • 上海浦东新区网站推广信息哪个平台好
  • 淮南网络宾馆免费seo网站诊断免费
  • 企业网站开发外包公司广州关键词排名推广