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
3434ca4d
authored
Aug 27, 2021
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
29 additions
and
4 deletions
client.py
client.py
View file @
3434ca4d
import
tkinter
from
tkinter
import
*
#从一个模块/库中导入所有的函数常量
alist
=
[
"星期六下午打篮球"
,
"星期天下午和小美一起看电影"
,
"12月18日给蒂法过生日"
,
"12.24送妈妈圣诞礼物"
]
class
Note
():
# 便签、笔记
def
__init__
(
self
):
def
__init__
(
self
):
#初始化
self
.
root
=
tkinter
.
Tk
()
self
.
root
.
geometry
(
'300x340+1000+200'
)
self
.
root
.
title
(
"我的便签-待办事项"
)
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
#加载图片tkinter.PhotoImage(file = "文件名.后缀名")
self
.
bg
=
tkinter
.
PhotoImage
(
file
=
"bg.png"
)
def
show
(
self
):
# 布置窗口界面 显示
#将背景图显示出来
#创建一个画布窗口来覆盖我们的窗口tkinter.Canvas(窗口,宽,高,背景颜色)
self
.
canves
=
tkinter
.
Canvas
(
self
.
root
,
width
=
300
,
height
=
340
)
#创建图像self.canves.create_image(开始创建的坐标(左上角坐标),image = 要创建的图片名字,对齐方式)
self
.
canves
.
create_image
(
0
,
0
,
image
=
self
.
bg
,
anchor
=
NW
)
#把画布布置在窗口上
self
.
canves
.
place
(
x
=
0
,
y
=
0
)
#先设置y坐标的初始值
self
.
y
=
20
#遍历一下alist列表
for
i
in
alist
:
#向画布中添加文字self.canves.create_text(x坐标,y坐标,text = 文字内容,font = (字体参数),对齐方式,fill = 十六进制的颜色)
self
.
canves
.
create_text
(
40
,
self
.
y
,
text
=
i
,
font
=
(
"宋体"
,
14
),
anchor
=
W
,
fill
=
'#808000'
)
#改变y坐标
self
.
y
+=
30
def
show
(
self
):
# 布置窗口界面
# 输入框
self
.
ent
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
13
),
bg
=
"snow"
,
width
=
25
)
...
...
@@ -21,7 +39,14 @@ class Note(): # 便签、笔记
self
.
but
.
place
(
x
=
240
,
y
=
305
)
def
get_info
(
self
):
pass
info
=
self
.
ent
.
get
()
if
info
!=
''
:
alist
.
append
(
info
)
self
.
canves
.
create_text
(
40
,
self
.
y
,
text
=
info
,
font
=
(
"宋体"
,
14
),
anchor
=
W
,
fill
=
'#808000'
)
#改变y坐标
self
.
y
+=
30
#删除输入框的数据
app
=
Note
()
app
.
show
()
...
...
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