Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson19-diy1
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
1d4c2efa
authored
Aug 08, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
39bdb55e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
diy.py
diy.py
0 → 100644
View file @
1d4c2efa
import
tkinter
from
tkinter
import
*
alist
=
[
"星期六去打球"
,
"星期一去帮妈妈买东西"
,
"4号要回学校"
,
"周末写作业"
]
class
Note
:
def
__init__
(
self
):
#设置窗口
self
.
root
=
tkinter
.
Tk
()
self
.
root
.
title
(
"我的便签——待办事项"
)
self
.
root
.
geometry
(
"300x340+500+300"
)
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
#加载图片
self
.
bg
=
tkinter
.
PhotoImage
(
file
=
'bg.png'
)
#页面布局
def
show
(
self
):
#创建画布
self
.
canv
=
tkinter
.
Canvas
(
self
.
root
,
width
=
300
,
height
=
340
,
bg
=
'lightblue'
)
self
.
canv
.
place
(
x
=
0
,
y
=
0
)
#画布设置背景
self
.
canv
.
create_image
(
0
,
0
,
image
=
self
.
bg
,
anchor
=
NW
)
#画布添加文字
self
.
y
=
20
for
info
in
alist
:
self
.
canv
.
create_text
(
40
,
self
.
y
,
text
=
info
,
fill
=
'#ff9900'
,
anchor
=
W
,
font
=
(
'宋体'
,
11
))
self
.
y
+=
30
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
width
=
25
,
font
=
(
'宋体'
,
13
),
bg
=
'snow'
)
self
.
e1
.
place
(
x
=
10
,
y
=
310
)
self
.
btn
=
tkinter
.
Button
(
self
.
root
,
text
=
"添加"
,
font
=
(
'宋体'
,
12
),
width
=
5
,
bg
=
'lightblue'
,
command
=
self
.
get_input
)
self
.
btn
.
place
(
x
=
240
,
y
=
305
)
#命令函数
def
get_input
(
self
):
content
=
self
.
e1
.
get
()
if
content
!=
''
:
alist
.
append
(
content
)
print
(
alist
)
self
.
canv
.
create_text
(
40
,
self
.
y
,
text
=
content
,
fill
=
"#FF9900"
,
font
=
(
'宋体'
,
11
),
anchor
=
W
)
self
.
e1
.
delete
(
"0"
,
END
)
note
=
Note
()
note
.
show
()
note
.
root
.
mainloop
()
print
(
alist
)
\ No newline at end of file
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