Beispiel #1
0
class MainWindow(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)
        self.pushButtonSingle.clicked.connect(self.single)
        self.pushButtonNetwork.clicked.connect(self.network)

    def single(self):
        self.close()
        self.gameWindow = SinglePlayer()
        self.gameWindow.exitSignal.connect(self.game_over)
        self.gameWindow.backSignal.connect(self.show)
        self.gameWindow.show()

    def network(self):
        self.close()
        self.gameWindow = NetworkConfig(main_win=self, addr=ADDR)
        self.gameWindow.show()

    def game_over(self):
        sys.exit(app.exec_())
Beispiel #2
0
class GameStart(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        # 设置窗体图标
        self.setWindowIcon(QIcon("source/icon.ico"))
        # 设置窗体的标题
        self.setWindowTitle("五子棋-PA1801")
        # 设置窗体固定大小
        self.setFixedSize(760, 650)
        # 设置窗体的背景图片
        palette = QPalette()
        # setBrush(谁是给谁,设置什么)
        palette.setBrush(self.backgroundRole(),
                         QBrush(QPixmap("source/五子棋界面.png")))
        self.setPalette(palette)

        # 生成三个按钮,移动到对应位置
        self.single_btn = TDPushButton("source/人机对战_normal.png",
                                       "source/人机对战_hover.png",
                                       "source/人机对战_press.png", self)
        self.double_btn = TDPushButton("source/双人对战_normal.png",
                                       "source/双人对战_hover.png",
                                       "source/双人对战_press.png", self)
        self.network_btn = TDPushButton("source/联机对战_normal.png",
                                        "source/联机对战_hover.png",
                                        "source/联机对战_press.png", self)
        self.single_btn.move(250, 300)
        self.double_btn.move(250, 400)
        self.network_btn.move(250, 500)

        # 三个按钮绑定处理函数,处理函数中页面跳转
        self.single_btn.clicked.connect(self.single)
        self.double_btn.clicked.connect(self.double)
        self.network_btn.clicked.connect(self.network)

        self.game_window = None  # 游戏窗体

    def single(self):
        self.game_window = SinglePlayer()
        self.game_window.backSignal.connect(self.back)
        self.game_window.show()
        self.close()

    def double(self):
        self.game_window = DoublePlayer()
        self.game_window.backSignal.connect(self.back)
        self.game_window.show()
        self.close()

    def network(self):
        self.game_window = NetworkConfig(main_window=self)
        # self.game_window.backSignal.connect(self.back)
        self.game_window.show()
        self.close()

    def back(self):
        # 捕获到返回的信号
        # 把自己显示出来
        self.show()
Beispiel #3
0
class MainWindow(QWidget):
    def __init__(self,parent=None):
        super().__init__(parent)
        self.initUI() # 初始化界面

    def initUI(self):
        self.setFixedSize(760, 650)# 设置固定大小
        self.move(200, 10)
        self.setWindowTitle('五子棋-三级狗')
        self.setWindowIcon(QIcon('source/icon.ico'))
        # 设置背景图片
        palette1 = QPalette()
        palette1.setBrush(self.backgroundRole(), QBrush(QPixmap('source/五子棋界面.png')))   # 设置背景图片
        self.setPalette(palette1)
        # 加载选择按钮
        self.single_button = TDPushButton(self,'source/人机对战_normal.png','source/人机对战_hover.png','source/人机对战_press.png',parent=self)
        self.single_button.move(250,300)
        self.single_button.show()
        self.single_button.click_signal.connect(self.single_player) # 连接信号和槽,点击按钮触发函数
        self.double_button = TDPushButton(self,'source/双人对战_normal.png','source/双人对战_hover.png','source/双人对战_press.png',parent=self)
        self.double_button.move(250,400)
        self.double_button.show()
        self.double_button.click_signal.connect(self.double_player)
        self.network_button = TDPushButton(self,'source/联机对战_normal.png','source/联机对战_hover.png','source/联机对战_press.png',parent=self)
        self.network_button.move(250,500)
        self.network_button.show()
        self.network_button.click_signal.connect(self.network_player)
        self.game_window = None

    def single_player(self):
        self.close()
        self.game_window = SinglePlayer()
        self.game_window.exitSignal.connect(self.game_over) # 游戏结束
        self.game_window.backSignal.connect(self.show) # 游戏
        self.game_window.show()

    def double_player(self):
        self.close()
        self.game_window = DoublePlayer()
        self.game_window.exitSignal.connect(self.game_over) # 游戏结束
        self.game_window.backSignal.connect(self.show) # 游戏
        self.game_window.show()

    def network_player(self):
        self.close()
        self.game_window = NetworkConfig(main_window=self)
        self.game_window.show()

    def game_over(self):
        sys.exit(app.exec_())
Beispiel #4
0
 def network(self):
     self.game_window = NetworkConfig(main_window=self)
     # self.game_window.backSignal.connect(self.back)
     self.game_window.show()
     self.close()
Beispiel #5
0
 def double(self):
     self.game_window = DoublePlayer()
     self.game_window.backSignal.connect(self.back)
     self.game_window.show()
     self.close()
Beispiel #6
0
 def single(self):
     self.game_window = SinglePlayer()
     self.game_window.backSignal.connect(self.back)
     self.game_window.show()
     self.close()
Beispiel #7
0
 def network_player(self):
     self.close()
     self.game_window = NetworkConfig(main_window=self)
     self.game_window.show()
Beispiel #8
0
 def double_player(self):
     self.close()
     self.game_window = DoublePlayer()
     self.game_window.exitSignal.connect(self.game_over)  # 游戏结束
     self.game_window.backSignal.connect(self.show)  # 游戏
     self.game_window.show()
Beispiel #9
0
 def network(self):
     self.close()
     self.gameWindow = NetworkConfig(main_win=self, addr=ADDR)
     self.gameWindow.show()
Beispiel #10
0
 def single(self):
     self.close()
     self.gameWindow = SinglePlayer()
     self.gameWindow.exitSignal.connect(self.game_over)
     self.gameWindow.backSignal.connect(self.show)
     self.gameWindow.show()