-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
146 lines (129 loc) · 4.85 KB
/
test.py
File metadata and controls
146 lines (129 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# import sys
# from copy import copy
#
# from PyQt5 import QtCore, QtWidgets
# from PyQt5.QtCore import QCoreApplication, Qt, QPoint, QUrl
# from PyQt5.QtGui import QMouseEvent, QColor, QIcon
# from PyQt5.QtMultimedia import QMediaContent, QMediaPlaylist, QMediaPlayer
# from PyQt5.QtWidgets import QMainWindow, QMessageBox, QTableWidgetItem
#
# from UI.UI_gamescreen import Ui_MainWindow
# from database.database_root import Database_root
# from database.database_user import Database_user
# from cpgames import CPGames
# from core.games.gobang.gobang import GobangGame
#
#
# # 使用界面窗口
# class GameScreen_music(Ui_MainWindow):
# def __init__(self):
# super(GameScreen_music, self).__init__()
# self.setupUi(self) # 引入UI界面
#
#
# # 连接按钮和对应的函数
# def connecter_music(self):
# self.pushButton_test1.clicked.connect(self.close1)
#
# def close1(self):
# sys.exit()
# # 使用界面窗口
# class GameScreen_music2(GameScreen_music):
# def __init__(self):
# super(GameScreen_music2, self).__init__()
# # self.setupUi(self) # 引入UI界面
# self.connecter_music1()
# # 连接按钮和对应的函数
# def connecter_music1(self):
# self.pushButton_test.clicked.connect(self.close2)
#
# def close2(self):
# sys.exit()
#
# class GameScreen_music3(GameScreen_music):
# def __init__(self):
# super(GameScreen_music3, self).__init__()
# # self.setupUi(self) # 引入UI界面
# self.connecter_music3()
# # 连接按钮和对应的函数
# def connecter_music3(self):
# self.pushButton_test2.clicked.connect(self.close3)
#
# def close3(self):
# sys.exit()
# class GameScreen_music:
# def __init__(self):
# self.aa("ss")
# self.aa("ww")
#
# def aa(self, x):
# exec('self.{} = 1'.format(x))
# print(self.ss)
#
#
# a = GameScreen_music()
# coding:utf-8
import re
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QFileDialog
# class MyWindow(QtWidgets.QWidget):
# def __init__(self):
# super(MyWindow, self).__init__()
# self.resize(900, 600)
# self.myButton = QtWidgets.QPushButton(self)
# self.myButton.setObjectName("myButton")
# self.myButton.setText("click")
# self.myButton.clicked.connect(self.msg)
#
# def msg(self):
# # directory1 = QFileDialog.getExistingDirectory(self,"选取文件夹","./") #起始路径
# # print(directory1)
#
# # fileName1, filetype = QFileDialog.getOpenFileName(self, "选取文件", "./",
# # "All Files (*);;Excel Files (*.mp3)") # 设置文件扩展名过滤,注意用双分号间隔
# # print(fileName1, filetype)
#
# # files, ok1 = QFileDialog.getOpenFileNames(self,"多文件选择", "./", "All Files (*);;Text Files (*.txt)")
# # print(files)
# files = QFileDialog.getOpenFileName(self, "请选择要添加的文件", "musics", "All Files (*)")
# print(files)
# music_name = re.findall(r'(.+?)\.mp3', re.findall(r'[^\\/:*?"<>|\r\n]+$',files[0])[0])[0]
# print(music_name)
# music_path = files[0]
# # end_pos = music_path.rfind('/') - 1 # 倒数第一个"/"的位置再左移一位
# # start_pos = music_path.rfind('/', 0, end_pos) # 网址从开始截至到end_pos的位置,从右往左出现的第一个"/"也就是我们要找的倒数第二个"/"
# # filename = music_path[start_pos + 1:] # 截取网址的倒数第二个 "/" 后面的内容
# filename = music_path[music_path.rfind('/', 0, music_path.rfind('/') - 1) + 1:]
# print(filename)
# # fileName2, ok2 = QFileDialog.getSaveFileName(self,"文件保存", "./","All Files (*);;Text Files (*.txt)")
#
#
# if __name__ == "__main__":
# import sys
#
# app = QtWidgets.QApplication(sys.argv)
# myshow = MyWindow()
# myshow.show()
# sys.exit(app.exec_())
# -*- coding:utf-8 -*-
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton
from ProjectPath import projectPath
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.resize(600, 300)
self.setWindowTitle('创建按钮和按钮点击事件的例子')
self.button1 = QPushButton('按键1', self)
self.button1.clicked.connect(self.clickButton)
def clickButton(self):
sender = self.sender()
import os
os.startfile(projectPath + r"/games/我的计算器.exe")
# os.startfile(r"E:\workspace\software_course\homework_2.2\GamingPlatform\games/我的计算器.exe")
print(sender.text() + '被点击')
if __name__ == '__main__':
app = QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())