#!/usr/bin/python
# coding:utf-8
"""
@author: css
@software: PyCharm
@file: Window.py
@time: 2021/3/3 22:02:25
"""
from PyQt5 import QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import QIcon, QFont, QTextCursor
from PyQt5.QtWidgets import (QWidget, QPushButton,
QSystemTrayIcon, QScrollArea, QTextBrowser, QMenu, QLabel, QAction)
import time
import win32gui, win32con
from util.screen import screen
import cv2 as cv
class Window(QWidget):
isTopWin = True
selfWnd = None
height = 80
pokerLogStr = ''
def __init__(self, hWnd):
super().__init__()
left, top, right, bot = win32gui.GetWindowRect(hWnd)
self.setGeometry(0, 0, right - left, self.height)
# Qt.WindowStaysOnTopHint |
self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
# 任务栏托盘
# 在系统托盘处显示图标
self.tp = QSystemTrayIcon(self)
self.tp.setIcon(QIcon('icon.png'))
# 设置系统托盘图标的菜单
a1 = QAction('&欢乐斗地主记牌器', self, triggered=self.showTray)
a2 = QAction('&退出(Exit)', self, triggered=self.quitApp) # 直接退出可以用qApp.quit
tpMenu = QMenu()
tpMenu.addAction(a1)
tpMenu.addAction(a2)
self.tp.setObjectName("记牌器")
self.tp.setContextMenu(tpMenu)
# 不调用show不会显示系统托盘
self.tp.show()
self.tp.activated.connect(self.act)
# 信息提示
# 参数1:标题
# 参数2:内容
# 参数3:图标(0没有图标 1信息图标 2警告图标 3错误图标),0还是有一个小图标
self.tp.showMessage('tp', 'tpContent', icon=0)
self.hWnd = hWnd
self.setWindowTitle("CV记牌器")
pokerLabel = QLabel(self)
pokerLabel.setText("牌型: 王 2 A K Q J 10 9 8 7 6 5 4 3 ")
# 设置标签的左边距,上边距,宽,高
pokerLabel.setGeometry(QRect(0, 0, 800, 30))
# 设置文本标签的字体和大小,粗细等
pokerLabel.setFont(QtGui.QFont("Roman times", 15, QtGui.QFont.Bold))
self.pokerNumLabel = QLabel(self)
# 设置标签的左边距,上边距,宽,高
self.pokerNumLabel.setGeometry(QRect(0, 25, 800, 30))
# 设置文本标签的字体和大小,粗细等
self.pokerNumLabel.setFont(QtGui.QFont("Roman times", 15, QtGui.QFont.Bold))
self.handlePokerLabel = QLabel(self)
# 设置标签的左边距,上边距,宽,高
self.handlePokerLabel.setGeometry(QRect(0, 50, 800, 30))
# 设置文本标签的字体和大小,粗细等
self.handlePokerLabel.setFont(QtGui.QFont("Roman times", 15, QtGui.QFont.Bold))
self.screen = QPushButton(self)
self.screen.setText("截图")
self.screen.setGeometry(QRect(950, 3, 50, 20))
self.screen.clicked.connect(self.screenshot)
self.status = QLabel(self)
self.status.setGeometry(QRect(230, 58, 80, 20))
self.status.setText("未开始")
self.status.setFont(QtGui.QFont("Roman times", 15, QtGui.QFont.Bold))
self.status.setStyleSheet('color: orange')
self.setPokerSizeLabel = QPushButton(self)
self.setPokerSizeLabel.setGeometry(QRect(950, 29, 80, 20))
self.setPokerSizeLabel.setText("调整大小")
# self.setPokerSizeLabel.setFont(QtGui.QFont("Roman times", 15, QtGui.QFont.Bold))
self.setPokerSizeLabel.clicked.connect(self.setPokerSize)
self.clearLogButton = QPushButton(self)
self.clearLogButton.setGeometry(QRect(950, 55, 80, 20))
self.clearLogButton.setText("清空日志")
# self.setPokerSizeLabel.setFont(QtGui.QFont("Roman times", 15, QtGui.QFont.Bold))
self.clearLogButton.clicked.connect(self.clearLog)
line = QLabel(self)
# 设置标签的左边距,上边距,宽,高
line.setGeometry(QRect(0, 27, 690, 1))
line.setAutoFillBackground(True)
line.setStyleSheet('background-color: rgb(0, 0, 0)')
line = QLabel(self)
# 设置标签的左边距,上边距,宽,高
line.setGeometry(QRect(0, 52, 690, 1))
line.setAutoFillBackground(True)
line.setStyleSheet('background-color: rgb(0, 0, 0)')
line = QLabel(self)
# 设置标签的左边距,上边距,宽,高
line.setGeometry(QRect(700, 0, 80, 30))
line.setAutoFillBackground(True)
# line.setStyleSheet('background-color: rgb(0, 0, 0)')
line.setText("出牌\n日志:")
line = QLabel(self)
# 设置标签的左边距,上边距,宽,高
line.setGeometry(QRect(690, 0, 1, self.height))
line.setAutoFillBackground(True)
line.setStyleSheet('background-color: rgb(0, 0, 0)')
for index in range(13):
line = QLabel(self)
# 设置标签的左边距,上边距,宽,高
line.setGeometry(QRect(index * 45 + 113, 0, 1, self.height if index < 3 else 53))
line.setAutoFillBackground(True)
line.setStyleSheet('background-color: rgb(0, 0, 0)')
self.log_text = QTextBrowser(self)
self.log_text.move(740, 0)
self.log_text.resize(200, 80)
self.log_text.setText(self.pokerLogStr)
def setStatus(self, status):
if (status == 0):
self.status.setText("未开始")
sss = self.getFontLabelText("对局结束", 'red')
print(sss)
self.log_text.append(self.getFontLabelText("对局结束", 'red'))
elif status == 1:
self.status.setText("开局")
self.log_text.append(self.getFontLabelText("对局开始", 'green'))
elif status == 2:
self.status.setText("进行中")
def setPokerSize(self):
left, top, right, bot = win32gui.GetWindowRect(self.hWnd)
win32gui.SetWindowPos(self.hWnd, None, left, top, 1040, 629, win32con.SWP_SHOWWINDOW)
self.resize(1040, 80)
def clearLog(self):
self.log_text.clear()
def screenshot(self):
img = screen(self.hWnd)
cv.imwrite('screen/screen' + str(time.time()).split('.')[0] + '.png', img)
def color(self, num):
if num == 0:
return 'black'
if num == 1:
return 'green'
if num == 2:
return '#66b1ff'
if num == 3:
return 'orange'
if num == 4:
return 'red'
def getFontLabelText(self, text, color, font=18):
return "<font style = 'font-size:" + str(
font) + "px; font-weight: bold; color:" + color + ";'>" + text + "</font>"
def setNum(self, num, handNum, outList):
text = '数量:'
if len(num) > 0:
text += ' '
for index, value in enumerate(num):
text = text + self.gText(str(value), self.color(value))
if (index == 6):
text += ' '
self.pokerNumLabel.setText(text)
self.setHandPokerNum(handNum)
self.appendPokerLog(outList)
def appendPokerLog(self, logList):
list = []
pokerLogStr = ''
# print(logList)
if 'upotherList' in logList:
pokerLogStr += '上家:'
list = logList['upotherList']
if 'downotherList' in logList:
pokerLogStr += '下家:'
list = logList['downotherList']
if 'selfOutList' in logList:
pokerLogStr += '自家:'
list = logList['selfOutList']
if (len(list) > 0):
list.sort(key=lambda poker: poker['x'])
for item in list:
for num in range(0, item['num']):
pokerLogStr += item['name']
self.log_text.append(pokerLogStr)
self.log_text.moveCursor(self.log_text.textCursor().End)
def gText(self, text, colo
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。 基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+opencv实现的欢乐斗地主记牌器系统源码.zip 代码完整下载可用。基于python+ope
资源推荐
资源详情
资源评论
收起资源包目录
基于python+opencv实现的欢乐斗地主记牌器系统源码.zip (54个子文件)
基于python+opencv实现的欢乐斗地主记牌器系统源码
image
20210305175729360_f5XMHUJ5y1.png 258KB
20210305175500448_lkHCunENJY.png 712KB
20210305174532514_YV_hvvQlBy.png 342KB
20210305170936284_V2KFH56IZu.png 832KB
20210305174437819_rz8NIWpgUE.png 112KB
20210305171315796_D6ykiSzkED.png 783KB
20210305175840884_-r1BLIXC9c.png 101KB
20210305180702619_Bgybxlm1EY.png 257KB
main.py 10KB
pip 0B
.idea
HappyFightOpencv.iml 644B
libraries
R_User_Library.xml 123B
vcs.xml 180B
misc.xml 288B
modules.xml 284B
view
Window.py 10KB
LogWindow.py 2KB
templete
dawang.png 4KB
fangkuai_q.png 3KB
fangkuai_9_b.png 2KB
fangkuai_8_b.png 2KB
fangkuai_k_1.png 16KB
continue_game.png 20KB
fangkuai_j.png 2KB
fangkuai_7.png 2KB
fangkuai_2.png 2KB
fangkuai_2_b.png 2KB
fangkuai_7_b.png 1KB
fangkuai_4.png 2KB
fangkuai_a_b.png 2KB
fangkuai_5.png 2KB
fangkuai_k_b.png 2KB
fangkuai_q_b.png 2KB
fangkuai_j_b.png 1KB
fangkuai_8.png 3KB
victory.png 41KB
fangkuai_3_b.png 2KB
fangkuai_4_b.png 2KB
fangkuai_a.png 2KB
fangkuai_10.png 3KB
fangkuai_5_b.png 2KB
fangkuai_3.png 3KB
fangkuai_6.png 3KB
fangkuai_10_b.png 17KB
fangkuai_9.png 3KB
fangkuai_6_b.png 2KB
fangkuai_k.png 2KB
.gitignore 1KB
yanshi.py 3KB
util
screen.py 2KB
screen_old.py 2KB
PokerUtil.py 120B
vo
Poker.py 1KB
PokerBase.py 394B
共 54 条
- 1
资源评论
不安分的小女孩
- 粉丝: 9192
- 资源: 1976
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功