Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson17-diy3
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51ee197c
authored
Sep 16, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
9c34ad18
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
2 deletions
1.py
1.txt
my_window.py
1.py
0 → 100644
View file @
51ee197c
import
tkinter
as
tk
import
random
import
threading
import
time
def
dow
():
window
=
tk
.
Tk
()
width
=
window
.
winfo_screenwidth
()
height
=
window
.
winfo_screenheight
()
a
=
random
.
randrange
(
0
,
width
)
b
=
random
.
randrange
(
0
,
height
)
window
.
title
(
'中毒了!'
)
window
.
geometry
(
"200x50"
+
"+"
+
str
(
a
)
+
"+"
+
str
(
b
))
tk
.
Label
(
window
,
text
=
'电脑有病毒!'
,
# 标签的文字
bg
=
'Red'
,
# 背景颜色
font
=
(
'楷体'
,
17
),
# 字体和字体大小
width
=
15
,
height
=
2
# 标签长宽
)
.
pack
()
# 固定窗口位置
window
.
mainloop
()
threads
=
[]
for
i
in
range
(
100
):
# 需要的弹框数量
t
=
threading
.
Thread
(
target
=
dow
)
threads
.
append
(
t
)
time
.
sleep
(
0.1
)
threads
[
i
]
.
start
()
\ No newline at end of file
1.txt
View file @
51ee197c
import tkinter as tk
import random
import threading
import time
def dow():
window = tk.Tk()
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
a = random.randrange(0, width)
b = random.randrange(0, height)
window.title('中毒了!')
window.geometry("200x50" +"+" +str(a) +"+" +str(b))
tk.Label(window,
text='电脑有病毒!',# 标签的文字
bg='Red',# 背景颜色
font=('楷体',17),# 字体和字体大小
width=15,height=2 # 标签长宽
).pack()# 固定窗口位置
window.mainloop()
threads = []
for iin range(100):# 需要的弹框数量
t = threading.Thread(target=dow)
threads.append(t)
time.sleep(0.1)
threads[i].start()
\ No newline at end of file
my_window.py
View file @
51ee197c
...
...
@@ -11,7 +11,9 @@ def command():
name
=
e1
.
get
()
password
=
e2
.
get
()
print
(
name
,
" "
,
password
)
if
e2
!=
e3
:
print
(
"错误"
)
with
open
(
r'C:)
# 输入框entry;用户输入框
e1 = tkinter.Entry(root,show=None,font=('
宋体
',14),bg="light grey",width=18) # 显示成明文形式
e1.place(x=140, y=80)
...
...
@@ -39,7 +41,7 @@ lab3= tkinter.Label(root, text='确认密码:', font=('宋体', 15),
fg="black")
lab3.place(x=20,y=200)
lab4
=
tkinter
.
Button
(
root
,
text
=
"完成"
,
command
=
command
)
lab4=tkinter.Button(root,text="完成",command=command
,width=20
)
lab4.place(x=150,y=250)
# 保持窗口监听,进入消息循环
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment