主代码
import sys
from multiprocessing import Process
from PyQt5 import QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication
import PKQ
import ccccccc
import untitled
import woman_health
class CenterForm:
# 初始化
def __init__(self):
# 只有直接运行这个脚本,才会往下执行
# 别的脚本文件执行,不会调用这个条件句
# 实例化,传参
self.app = QApplication(sys.argv)
# 创建对象
self.widget = QMainWindow()
# 创建ui,引用demo1文件中的Ui_MainWindow类
self.ui = untitled.Ui_MainWindow()
# 调用Ui_MainWindow类的setupUi,创建初始组件
self.ui.setupUi(self.widget)
# self.widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) # 置顶,且去掉边框
# self.widget.setAttribute(Qt.WA_TranslucentBackground)
self._translate = QtCore.QCoreApplication.translate
self.ui.pushButton.clicked.connect(self.onClick_Button)
self.ui.pushButton_2.clicked.connect(self.onClick_Button2)
self.ui.pushButton_3.clicked.connect(self.onClick_Button3)
self.ui.dial.actionTriggered.connect(self.onClick_dial)
self.ui.pushButton_5.clicked.connect(self.onClick_Button5)
self.ui.pushButton_6.clicked.connect(self.onClick_Button6)
self.ui.pushButton_7.clicked.connect(self.onClick_Button7)
self.ui.pushButton_8.clicked.connect(self.onClick_Button8)
self.ui.pushButton_9.clicked.connect(self.onClick_Button9)
self.ui.pushButton_10.clicked.connect(self.onClick_Button10)
self.ui.pushButton_11.clicked.connect(self.onClick_Button11)
self.ui.pushButton_12.clicked.connect(self.onClick_Button12)
self.ui.pushButton_13.clicked.connect(self.onClick_Button13)
# self.ui.pushButton_14.clicked.connect(self.onClick_Button14)
self.t1 = Process(target=PKQ.pkq_show)
self.t2 = Process(target=ccccccc.do)
self.t3 = Process(target=ccccccc.do)
self.t4 = Process(target=ccccccc.do)
self.t5 = Process(target=ccccccc.do)
self.t6 = Process(target=ccccccc.do)
self.t7 = Process(target=ccccccc.do)
self.t8 = Process(target=ccccccc.do)
self.t9 = Process(target=ccccccc.do)
self.t10 = 0
# 进入程序的主循环,并通过exit函数确保主循环安全结束(该释放资源的一定要释放)
# def center(self):
# # 创建实例,获得屏幕对象,得到屏幕的坐标系
# screen = QDesktopWidget().screenGeometry()
#
# # 得到窗口的坐标系
# size = self.geometry()
#
# # 获取屏幕的宽度、高度
# # 窗口左边缘的坐标等于(屏幕的宽度-窗口的宽度)/2
# newLeft = (screen.width() - size.width()) / 2
#
# # 屏幕上边缘的坐标等于(屏幕的高度-窗口的高度) / 2
# newTop = (screen.height() - size.height()) / 2
#
# # 移动窗口
# self.move(newLeft, newTop)
def onClick_Button5(self):
self.t1 = Process(target=PKQ.pkq_show)
self.t1.start()
def onClick_Button6(self):
pass
def onClick_Button7(self):
pass
def onClick_Button8(self):
pass
def onClick_Button9(self):
self.t9.start()
print(1)
def onClick_Button10(self):
pass
def onClick_Button11(self):
pass
def onClick_Button12(self):
pass
def onClick_Button13(self):
pass
def onClick_Button14(self):
print(2)
self.t10 = Process(target=woman_health.woman)
self.t10.start()
def onClick_dial(self):
value = self.ui.dial.value()
self.ui.label_2.setText(str(value))
def onClick_Button2(self):
Value = self.ui.progressBar.value() + 1
self.ui.progressBar.setProperty("value", Value)
def onClick_Button3(self):
Value = self.ui.progressBar.value() - 1
self.ui.progressBar.setProperty("value", Value)
def onClick_Button(self):
s = f"以屏幕为原点的窗口横坐标 = {self.widget.x()}\n以屏幕为原点的窗口纵坐标,不包含标题栏 = {self.widget.y()}\n窗口宽度={self.widget.width()}\n工作区高度= {self.widget.height()}"
self.ui.textEdit.setText(self._translate("MainWindow", s))
# print("第一种方式获取各个值")
# # 窗口离屏幕原点到y轴的距离
# print("以屏幕为原点的窗口横坐标 = %d" % self.widget.x()) # 600 (以屏幕为原点的窗口横坐标)
# # 窗口离屏幕原点到x轴的距离
# print("以屏幕为原点的窗口纵坐标,不包含标题栏 = %d" % self.widget.y()) # 200 (以屏幕为原点的窗口纵坐标,不包含标题栏)
# # 窗口本身的宽度
# print("窗口宽度=%d" % self.widget.width()) # 300 (窗口宽度)
# # 窗口本身的高度
# print("工作区高度= %d" % self.widget.height()) # 240 (工作区高度)
def main():
win = CenterForm()
win.widget.show()
sys.exit(win.app.exec_())
if __name__ == '__main__':
main()
为什么我点击按键9时,会弹出womam_health的调用。
且woman_health的调用我全注释了,只有一个导入库。
import tkinter as tk
import tkinter.ttk as ttk
import datetime
import calendar
import re
import tkinter.messagebox
import time
today_date = datetime.date.today()
today_date_year = int(today_date.year)
today_date_month = int(today_date.month)
today_date_week = today_date.isocalendar()
date_num_list = calendar.monthcalendar(today_date_year, today_date_month)
my_win = tk.Tk()
my_win.title("生理周期")
my_win.geometry("380x395")
................
# 持续时间
# 时间间隔
date = tk.StringVar()
date.set(today_date)
period_interval_list = tuple(range(24, 32))
period_sustain_list = tuple(range(2, 12))
setting_frame = tk.LabelFrame(my_win, text="设置窗口", fg="green", height=110, width=200)
setting_frame.place(x=10, y=10)
# 上次开始时间
tk.Label(setting_frame, text="上次开始时:", width=10).place(x=2, y=2)
last_period_entry = tk.Entry(setting_frame, width=12)
last_period_entry.insert(0, date.get())
last_period_entry.place(x=75, y=2)
tk.Label(setting_frame, text="间隔时间:", width=10).place(x=2, y=30)
period_interval = ttk.Combobox(setting_frame, values=period_interval_list, width=5)
period_interval.current(4)
period_interval.place(x=75, y=30)
tk.Label(setting_frame, text="持续时间:", width=10).place(x=2, y=60)
period_sustain = ttk.Combobox(setting_frame, values=period_sustain_list, width=5)
period_sustain.current(5)
period_sustain.place(x=75, y=60)
today_label = tk.Label(my_win, text=date.get(), height=7, width=20, bg="green")
today_label.place(x=230, y=15)
tk.Button(setting_frame, text="OK", font=("kaiti", 14), height=2, width=5, command=period_algorithm).place(x=135, y=30)
def woman():
my_win.mainloop()
这是女性健康的代码