Example #1
0
 def __init__(self, conf, defeat):
     self.config = conf
     super().__init__()
     self.setWindowTitle(conf.get_text('victory'))
     self.setFixedSize(QSize(640, 480))
     self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.WindowTitleHint
                         | Qt.FramelessWindowHint)
     button = QPushButton(conf.get_text('close'), self)
     button.setCheckable(True)
     button.setFixedSize(QSize(640, 30))
     button.move(0, 450)
     # noinspection PyUnresolvedReferences
     button.clicked.connect(self.close)
     result_output = QTextEdit(self)
     result_output.setReadOnly(True)
     result_output.setFixedSize(QSize(640, 200))
     result_output.move(0, 250)
     result_output.setLineWrapMode(QTextEdit.NoWrap)
     result_output.insertHtml(self.generate_result_text())
     gview = QGraphicsView(self)
     scene = QGraphicsScene()
     if defeat:
         img = conf.theme_selected.get_defeat_pixmap()
         text = conf.get_text('defeat')
     else:
         img = conf.theme_selected.get_victory_pixmap()
         text = conf.get_text('victory')
     scene.addPixmap(img.scaled(QSize(640, 220)))
     gview.move(0, 30)
     gview.setScene(scene)
     label_title = QLabel(self)
     label_title.setText(text)
     label_title.setFixedSize(QSize(640, 30))
     label_title.setAlignment(Qt.AlignCenter)
     label_title.setFont(self.get_font_title())
Example #2
0
class splash_window(QWidget):

	def center(self):
		frameGm = self.frameGeometry()
		screen = QApplication.desktop().screenNumber(QApplication.desktop().cursor().pos())
		centerPoint = QApplication.desktop().screenGeometry(screen).center()
		frameGm.moveCenter(centerPoint)
		self.move(frameGm.topLeft())

	def callback_destroy(self):
		self.close()

	def __init__(self):
		QWidget.__init__(self)
		mul=1.1
		self.counts=0
		width=459*mul
		self.setFixedSize(width, 260)
		self.center()

		self.view=QGraphicsView(self)

		self.view.setStyleSheet("QProgressBar { border: 2px solid grey; border-radius: 5px; text-align: center; }")


		self.view.setFixedSize(width+2+2,261)
		self.view.move(-2,0)
		self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
		self.li=QLabel("ver",self)
		self.li.move(30,170)

		self.font = QFont()
		self.font.setFamily('DejaVu Sans')
		self.font.setBold(True)
		self.font.setStyleHint(QFont.Monospace)
		self.font.setFixedPitch(True)
		self.font.setPointSize(int(72))

		self.terminals=[]
		self.process=[]
	
		self.gpvdm=QLabel("gpvdm",self)
		self.gpvdm.setFont(self.font)
		self.gpvdm.move(80,40)


		self.li.setText(notice()+"\n"+version())
		self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
		self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
		window_h=self.height()
		window_w=self.width()

		QTimer.singleShot(2000, self.callback_destroy)

		files=glob.glob(os.path.join(get_image_file_path(),"splash","*.jpg"))
		files.extend(glob.glob(os.path.join(get_image_file_path(),"splash","*.png")))

		number=time.localtime().tm_yday

		number=number % len(files)

		if number>=len(files[number]):
			number=0

		image_file=files[number]

		image_path=os.path.join(get_image_file_path(),"splash",image_file)
		if os.path.isfile(image_path):
			image=QPixmap(image_path)
		
			image.scaledToHeight(window_h)

			w=image.width()
			h=image.height()
			x_max=w-window_h-window_w/2

			hour=float(time.strftime("%H"))*60
			m=float(time.strftime("%m"))
			tot=hour+m
			my_max=float(24*60)

			value=tot/my_max

			xpos=int(x_max*value)+window_w/2

			scene=QGraphicsScene();
			scene.setSceneRect(xpos, 0, 0, h)
			self.view.setScene(scene)


			scene.addPixmap(image);
		else:
			print("Image not found",image_path)

		self.pbar = QProgressBar(self)
		self.pbar.setGeometry(0, 261-20, width-5, 15)
		#self.pbar.move(50,150)
		


		self.show()

	def inc_value(self):
		#print(self.counts)
		self.counts=self.counts+1
		value=100.0*self.counts/29.0
		self.pbar.setValue(value)
		if value>=100.0:
			self.pbar.hide()
		QApplication.processEvents()

	def set_value(self,value):
		self.pbar.setValue(value)
		QApplication.processEvents()
Example #3
0
import sys
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QGraphicsProxyWidget
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsItem
#from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView, QWebEnginePage as QWebPage
from PyQt5.QtWebEngineWidgets import QWebEngineSettings as QWebSettings

app = QApplication(sys.argv)
scene = QGraphicsScene()

web = QWebView()
web.load(QtCore.QUrl("http://www.developpez.com"))
rect = scene.addRect(QtCore.QRectF(0, 0, 100, 100))
proxy = QGraphicsProxyWidget()
proxy.setWidget(web)
scene.addItem(proxy)

view = QGraphicsView(scene)
view.resize(500, 300)
view.move(500, 500)
view.show()
sys.exit(app.exec_())
Example #4
0
 parent.setWindowTitle('Vacuum Cleaner Intelligent Agent')
 w5 = QWidget(parent)
 labels = []
 for i in range(12):
     labels.append(QLabel(w5))
     labels[i].move(5, 100 + i * 30)
     labels[i].setText(Texts[i] + "0                         ")
     labels[i].setStyleSheet('color: Brown')
     labels[i].show()
 w5.resize(400, 1000)
 w5.show()
 w1 = QWidget(parent)
 s1 = QtScene(w1, (0, 179, 0))
 v1 = QGraphicsView(w1)
 v1.setScene(s1)
 v1.move(385, 0)
 v1.resize(300, 300)
 v1.show()
 l1 = QLabel(w1)
 l1.setText('BFS')
 l1.move(510, 5)
 l1.setStyleSheet('color: Brown')
 l1.show()
 w1.show()
 w2 = QWidget(parent)
 s2 = QtScene(w2, (255, 224, 0))
 v2 = QGraphicsView(w2)
 v2.setScene(s2)
 v2.move(730, 0)
 v2.resize(300, 300)
 v2.show()
Example #5
0
class GameWindow(QMainWindow):
    def __init__(self, frame_cnt):
        super().__init__()
        # 初始化,load数据
        self.img_list = []
        self.cter_img_list = []
        self.npc_img_list = []
        for frame_it in range(frame_cnt):
            self.img_list.append(QImage('data/%03d.png' % frame_it))
        for t in range(4):
            self.cter_img_list.append(QImage('imgs/001-Fighter01_big.png').copy(t * 96, 288, 96, 144))
            self.npc_img_list.append(QImage('imgs/066-Beast04.png').copy(t * 96, 96, 96, 96))
        self.dialog_img = QImage('imgs/001-Blue01.png').copy(130, 66, 28, 28)
        self.tri_img = [QImage('imgs/001-Blue01.png').copy(160, 64, 16, 16), QImage('imgs/001-Blue01.png').copy(160, 80, 16, 16)]
        # 准备图形界面
        self.init_ui()
        self.frame_cnt = frame_cnt
        self.curr_frame = 0  # 当前处于第几帧
        # 设置播放新帧的定时器
        self.frame_timer = QTimer(self)
        self.frame_timer.timeout.connect(self.on_new_frame)
        self.frame_timer.start(40)

    def init_ui(self):
        # 设置窗口主题、大小和背景图片
        self.setObjectName('MainWindow')
        self.setFixedSize(1300, 740)
        # 设置背景view
        self.bkgrd = QGraphicsView(self)
        self.bkgrd.setFixedSize(1280, 720)
        self.bkgrd.move(10, 10)
        self.bkgrd.setStyleSheet("background:transparent;border:none;")
        bkgrd_pixmap = QPixmap.fromImage((self.img_list[0]))
        bkgrd_pixmap.fromImage(self.img_list[0])
        self.bkgrd_scene = QGraphicsScene()
        self.bkgrd_scene.addItem(QGraphicsPixmapItem(bkgrd_pixmap))
        self.bkgrd.setScene(self.bkgrd_scene)
        # 小人
        self.character = QGraphicsView(self)
        self.character.setFixedSize(96, 144)
        self.character.move(0, 500)
        self.character.setStyleSheet("background:transparent;border:none;")
        cter_pixmap = QPixmap.fromImage((self.cter_img_list[0]))
        cter_pixmap.fromImage(self.img_list[0])
        self.cter_scene = QGraphicsScene()
        self.cter_scene.addItem(QGraphicsPixmapItem(cter_pixmap))
        self.character.setScene(self.cter_scene)
        # NPC
        self.npc = QGraphicsView(self)
        self.npc.setFixedSize(96, 96)
        self.npc.move(1050, 530)
        self.npc.setStyleSheet("background:transparent;border:none;")
        npc_pixmap = QPixmap.fromImage((self.npc_img_list[0]))
        self.npc_scene = QGraphicsScene()
        self.npc_scene.addItem(QGraphicsPixmapItem(npc_pixmap))
        self.npc.setScene(self.npc_scene)
        # 对话框
        self.dialog = QGraphicsView(self)
        self.dialog.setFixedSize(1248, 208)
        self.dialog.move(26, 496)
        dialog_pixmap = QPixmap.fromImage(self.dialog_img)
        palette = QPalette()
        palette.setBrush(self.dialog.backgroundRole(), QBrush(dialog_pixmap))
        self.dialog.setPalette(palette)
        self.dialog.hide()
        self.label = QLabel(self)
        self.label.setFont(QFont("宋体", 24, 40))
        self.label.setFixedSize(1000, 100)
        self.label.move(60, 496)
        self.label.setText("啦啦啦啦啦")
        self.label.hide()
        # 对话框下面的小三角
        self.tri = QGraphicsView(self)
        self.tri.setFixedSize(16, 16)
        self.tri.move(632, 696)
        self.tri.setStyleSheet("background:transparent;border:none;")
        tri_pixmap = QPixmap.fromImage(self.tri_img[0])
        self.tri_scene = QGraphicsScene()
        self.tri_scene.addItem(QGraphicsPixmapItem(tri_pixmap))
        self.tri.setScene(self.tri_scene)
        self.tri.hide()

        # 显示界面
        self.show()

    def on_new_frame(self):
        self.curr_frame += 1
        # 更新背景
        bkgrd_pixmap = QPixmap.fromImage((self.img_list[self.curr_frame]))
        self.bkgrd_scene.clear()
        self.bkgrd_scene.addItem(QGraphicsPixmapItem(bkgrd_pixmap))
        # 更新小人
        if self.curr_frame % 6 == 0:
            cter_pixmap = QPixmap.fromImage((self.cter_img_list[int(self.curr_frame % 24 // 6)]))
            self.cter_scene.clear()
            self.cter_scene.addItem(QGraphicsPixmapItem(cter_pixmap))
            npc_pixmap = QPixmap.fromImage((self.npc_img_list[int(self.curr_frame % 24 // 6)]))
            self.npc_scene.clear()
            self.npc_scene.addItem(QGraphicsPixmapItem(npc_pixmap))
        if self.curr_frame % 12 == 0:
            tri_pixmap = QPixmap.fromImage((self.tri_img[int(self.curr_frame % 24 // 12)]))
            self.tri_scene.clear()
            self.tri_scene.addItem(QGraphicsPixmapItem(tri_pixmap))
        if self.curr_frame <= 95:
            self.character.move(self.curr_frame * 10, 500)
        # 更新对话框
        if self.curr_frame == 100:
            self.dialog.show()
            self.label.show()
            self.tri.show()
        if self.curr_frame == 192:
            self.dialog.hide()
            self.label.hide()
            self.tri.hide()
        if self.curr_frame == self.frame_cnt - 1:  # 已达最后一帧
            self.frame_timer.stop()
 def __init__(self, conf, defeat):
     self.config = conf
     super().__init__()
     self.setWindowTitle(conf.get_text('victory'))
     self.setFixedSize(QSize(640, 480))
     self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.WindowTitleHint | Qt.FramelessWindowHint)
     button = QPushButton(conf.get_text('close'), self)
     button.setCheckable(True)
     button.setFixedSize(QSize(640, 30))
     button.move(0, 450)
     # noinspection PyUnresolvedReferences
     button.clicked.connect(self.close)
     result_output = QTextEdit(self)
     result_output.setReadOnly(True)
     result_output.setFixedSize(QSize(640, 200))
     result_output.move(0, 250)
     result_output.setLineWrapMode(QTextEdit.NoWrap)
     result_output.insertHtml(self.generate_result_text())
     gview = QGraphicsView(self)
     scene = QGraphicsScene()
     if defeat:
         img = conf.theme_selected.get_defeat_pixmap()
         text = conf.get_text('defeat')
     else:
         img = conf.theme_selected.get_victory_pixmap()
         text = conf.get_text('victory')
     scene.addPixmap(img.scaled(QSize(640, 220)))
     gview.move(0, 30)
     gview.setScene(scene)
     label_title = QLabel(self)
     label_title.setText(text)
     label_title.setFixedSize(QSize(640, 30))
     label_title.setAlignment(Qt.AlignCenter)
     label_title.setFont(self.get_font_title())