猫史档案馆


QBZ_

QBZ_

Lv.1

获赞:35收藏:10浏览:540作品收藏:19

签名:已润

回复帖子评论
上一页1 页 / 共 35下一页

Python【编程小讲堂】第十期 Tkinter高级实战3 中回复

你确定这是高级?

 

2019-08-24T17:40:33 点赞:0

【Python作品分享】G6 25课【作业帖】 中回复

把一个pyecharts饼图(甚至没有做改动的代码)放出来刷帖真的好吗?

2019-08-24T17:42:42 点赞:0

【Python分享】多协程爬虫【作品秀】 中回复

兄弟你学多少节课了?

2019-08-24T17:46:25 点赞:0

【Python作品分享】一键画图V3.0.17 中回复

from tkinter import*
from tkinter.colorchooser import*
from tkinter import messagebox

#说明
introduction = Tk()

introduction.withdraw()
messagebox.showinfo(title='说明',
                    message='此为一个画图软件,灵感来自于人工智能————御眼重明,目前仍在开发阶段,现在版本为V7 .0(点击确定继续)')
messagebox.showinfo(title='说明',
                    message='用鼠标操控画笔,按住滑动便可画出图案,可以设置线条颜色和填充颜色,左边是形状按钮,还有背景颜色设置,点击便可画出不同的形状(点击确定开始)')

#设置背景颜色
#创建按钮和画布
window = Tk()
window.configure(background="gray", cursor="fleur", width=1000, height=900)
window.title("绘图软件 V.7.0")
window.geometry("2000x2000")

instruction = Label(window, text="用鼠标左键在下方画布上绘画",
                    background="gray", cursor="shuttle")
instruction.pack()

BlackButton = Button(window, bg="black", fg="white",
                     text="背景黑色", cursor="fleur")
BlackButton.pack()
BlackButton.place(x=10, y=450)

whiteButton = Button(window, bg="white",
                     text="背景白色", cursor="fleur")
whiteButton.pack()
whiteButton.place(x=10, y=420)

fillButton = Button(window, bg="blue", fg="white", activebackground="blue",
                    activeforeground="white", text="填充颜色", cursor="gumby gumby")
fillButton.pack()
fillButton.place(x=10, y=350)

colorButton = Button(window, bg="skyblue", activebackground="skyblue",
                     text="线条颜色", cursor="gumby gumby")
colorButton.pack()
colorButton.place(x=10, y=380)

rectButton = Button(window, bg="green", text="方形",
                    cursor="dotbox")
rectButton.pack()
rectButton.place(x=10, y=310)

lineButton = Button(window, bg="red",
                    text="铅笔", cursor="gumby gumby")
lineButton.pack()
lineButton.place(x=10, y=270)

circleButton = Button(window, bg="orange",
                      text="圆圈", cursor="circle")
circleButton.pack()
circleButton.place(x=10, y=230)

explosiveButton = Button(window, bg="pink",
                         text="线段", cursor="gumby gumby")
explosiveButton.pack()
explosiveButton.place(x=10, y=190)

clearButton = Button(window, bg="yellow",
                     text="清除", cursor="dotbox")
clearButton.pack()
clearButton.place(x=10, y=150)

myCanvas = Canvas(window, width=1300, height=1000,
                  cursor="spraycan", bg="white")
myCanvas.pack()


#背景颜色
def Black(event):
    myCanvas.configure(bg="black")
    window.update()


BlackButton.bind("<Button-1>", Black)


def white(event):
    myCanvas.configure(bg="white")
    window.update()


whiteButton.bind("<Button-1>", white)

#改变画笔颜色的程序
myColor = "black"
myShape = "line"
myfill = "white"

#定义x,y轴


def pen_down(event):
    global prevX
    global prevY
    prevX = event.x
    prevY = event.y


myCanvas.bind("<ButtonPress-1>", pen_down)

#画线的程序


def draw(event):
    global prevX
    global prevY
    if myShape == "line":
        myCanvas.create_line(prevX, prevY, event.x, event.y, fill=myColor)
        prevX = event.x
        prevY = event.y


myCanvas.bind("<B1-Motion>", draw)


def pen_up(event):
    if myShape == "circle":
        myCanvas.create_oval(prevX, prevY, event.x,
                             event.y, outline=myColor, width=5, fill=myfill)
    if myShape == "rectangle":
        myCanvas.create_rectangle(
            prevX, prevY, event.x, event.y, outline=myColor, width=5, fill=myfill)
    if myShape == "explosive":
        myCanvas.create_polygon(prevX, prevY, event.x,
                                event.y, outline=myColor, width=5, fill=myfill)


myCanvas.bind("<ButtonRelease-1>", pen_up)

#改变颜色


def pick_color(event):
    global myColor
    myColor = askcolor()
    myColor = myColor[1]


colorButton.bind("<Button-1>", pick_color)


def pick_fill(event):
    global myfill
    myfill = askcolor()
    myfill = myfill[1]


fillButton.bind("<Button-1>", pick_fill)

#清除画布的程序


def clear(event):
    myCanvas.delete(ALL)


clearButton.bind("<Button-1>", clear)


def set_line(event):
    global myShape
    myShape = "line"


lineButton.bind("<Button-1>", set_line)


def set_rect(event):
    global myShape
    myShape = "rectangle"


rectButton.bind("<Button-1>", set_rect)


def set_circle(event):
    global myShape
    myShape = "circle"


circleButton.bind("<Button-1>", set_circle)


def set_explosive(event):
    global myShape
    myShape = "explosive"


explosiveButton.bind("<Button-1>", set_explosive)

window.mainloop()

2019-08-24T17:52:12 点赞:0

【Python作品分享】一键画图V3.0.17 中回复

我这也是各画图软件偶

2019-08-24T17:52:34 点赞:0

【Python作品分享】一键画图V3.0.17 中回复

你可以复制粘贴试试

2019-08-24T17:52:53 点赞:0

【CC工作室,跃动工作室】用源码编辑器制作3D立体字 中回复

顶顶顶顶顶

2019-08-25T21:31:00 点赞:0

【CC工作室,跃动工作室】用源码编辑器制作3D立体字 中回复

顶顶顶

2019-08-25T21:31:17 点赞:0

【CC工作室,跃动工作室】用源码编辑器制作3D立体字 中回复

这个不顶都不行

2019-08-25T21:31:34 点赞:0

CJW c++萌新教程【第2期】揭开c++的奥秘 中回复

还可以,顶

2019-08-25T21:31:55 点赞:0

【Python作品分享】python 画画 中回复

加油!

 

2019-08-29T11:19:05 点赞:0

【Python作品分享】python 画画 中回复

试试我的绘图软件

from tkinter import*
from tkinter.colorchooser import*
from tkinter import messagebox


# 主程序
# 设置背景颜色
# 创建按钮和画布

window = Tk()
window.configure(background="gray", cursor="fleur", width=1000, height=1000)
window.title("绘图软件 7.0")
window.geometry("2000x2000")

instruction = Label(window, text="用鼠标左键在下方画布上绘画",
                    background="gray", cursor="shuttle",)
instruction.pack()

speak = Button(window, bg="orange", fg="black",
            text="帮助", cursor="fleur", bd="5px", activebackground="orange",)
speak.pack()
speak.place(x=10, y=110)

BlackButton = Button(window, bg="black", fg="white",
                    text="背景黑色", cursor="fleur", bd="5px")
BlackButton.pack()
BlackButton.place(x=10, y=510)

whiteButton = Button(window, bg="white",
                    text="背景白色", cursor="fleur", bd="5px")
whiteButton.pack()
whiteButton.place(x=10, y=470)

fillButton = Button(window, bg="blue", fg="white", activebackground="blue",
                    activeforeground="white", text="填充颜色", cursor="gumby gumby", bd="5px")
fillButton.pack()
fillButton.place(x=10, y=430)

colorButton = Button(window, bg="skyblue", activebackground="skyblue",
                    text="线条颜色", cursor="gumby gumby", bd="5px")
colorButton.pack()
colorButton.place(x=10, y=390)

rectButton = Button(window, bg="green", text="方形",
                    cursor="dotbox", bd="5px")
rectButton.pack()
rectButton.place(x=10, y=310)

lineButton = Button(window, bg="red",
                    text="铅笔", cursor="gumby gumby", bd="5px")
lineButton.pack()
lineButton.place(x=10, y=270)

circleButton = Button(window, bg="orange",
                    text="圆圈", cursor="circle", bd="5px")
circleButton.pack()
circleButton.place(x=10, y=230)

explosiveButton = Button(window, bg="pink",
                        text="线段", cursor="gumby gumby", bd="5px")
explosiveButton.pack()
explosiveButton.place(x=10, y=190)

clearButton = Button(window, bg="yellow",
                    text="清除", cursor="dotbox", bd="5px")
clearButton.pack()
clearButton.place(x=10, y=150)

myCanvas = Canvas(window, width=1600, height=900,
                cursor="spraycan", bg="white")
myCanvas.pack()

# 背景颜色
def Black(event):
    myCanvas.configure(bg="black")
    window.update()


BlackButton.bind("<Button-1>", Black)


def white(event):
    myCanvas.configure(bg="white")
    window.update()


whiteButton.bind("<Button-1>", white)

#帮助
#说明
def Help(event):
    introduction = Tk()
    introduction.withdraw()
    messagebox.showinfo(title='说明',
                        message='此为一个画图软件,灵感来自于人工智能————御眼重明,目前仍在开发阶段,现在版本为7 .0(点击确定继续)')
    messagebox.showinfo(title='说明',
                        message='用鼠标操控画笔,按住滑动便可画出图案,可以设置线条颜色和填充颜色,左边是形状按钮,还有背景颜色设置,点击便可画出不同的形状(点击确定开始)')


speak.bind("<Button-1>", Help)

# 改变画笔颜色的程序
myColor = "black"
myShape = "line"
myfill = "white"

# 定义x,y轴
def pen_down(event):
    global prevX
    global prevY
    prevX = event.x
    prevY = event.y


myCanvas.bind("<ButtonPress-1>", pen_down)

# 画线的程序
def draw(event):
    global prevX
    global prevY
    if myShape == "line":
        myCanvas.create_line(prevX, prevY, event.x, event.y, fill=myColor)
        prevX = event.x
        prevY = event.y

myCanvas.bind("<B1-Motion>", draw)


def pen_up(event):
    if myShape == "circle":
        myCanvas.create_oval(prevX, prevY, event.x,
                            event.y, outline=myColor, width=5, fill=myfill)
    if myShape == "rectangle":
        myCanvas.create_rectangle(
            prevX, prevY, event.x, event.y, outline=myColor, width=5, fill=myfill)
    if myShape == "explosive":
        myCanvas.create_polygon(prevX, prevY, event.x,
                                event.y, outline=myColor, width=5, fill=myfill)


myCanvas.bind("<ButtonRelease-1>", pen_up)

# 改变颜色
def pick_color(event):
    global myColor
    myColor = askcolor()
    myColor = myColor[1]

colorButton.bind("<Button-1>", pick_color)


def pick_fill(event):
    global myfill
    myfill = askcolor()
    myfill = myfill[1]


fillButton.bind("<Button-1>", pick_fill)

# 清除画布的程序
def clear(event):
    myCanvas.delete(ALL)


clearButton.bind("<Button-1>", clear)


def set_line(event):
    global myShape
    myShape = "line"


lineButton.bind("<Button-1>", set_line)


def set_rect(event):
    global myShape
    myShape = "rectangle"


rectButton.bind("<Button-1>", set_rect)


def set_circle(event):
    global myShape
    myShape = "circle"


circleButton.bind("<Button-1>", set_circle)


def set_explosive(event):
    global myShape
    myShape = "explosive"


explosiveButton.bind("<Button-1>", set_explosive)

window.mainloop()

2019-08-29T11:21:26 点赞:0

【N新闻】第二期:编程猫平台竟出现这种人! 中回复

我也遇到过,可是吵吵就算了,没必要这么激动,朋友

2019-08-29T11:38:20 点赞:0

在吃荔枝这件事上,我们比皇帝幸福多了 中回复

一骑红尘妃子笑,无人知是荔枝来----

2019-08-29T13:07:20 点赞:0

【手机编程】口袋里的编程神器,随时随地创造世界! 中回复

加油

2019-08-29T13:10:57 点赞:0

【公告】申诉流程指南 中回复

客服喵?我的帖子已经删除了,为什么还要删除言论?

2019-08-29T13:14:29 点赞:0

【Python作品分享】第一個圖表【作品秀】 中回复

其实你用pyecharts也可以

2019-08-30T10:29:30 点赞:0

【PySide2:图形编程】教你用代码薅软件 Part0尝试篇 中回复

这是ui吗?还是H喵L?

 

2019-08-30T10:30:49 点赞:0

【Python作品分享】字画【作品秀】 中回复

不就是字符画吗?用pillow还可以做浮雕

2019-08-30T10:32:20 点赞:0

Python基础入门图 中回复

 

2019-08-30T20:20:11 点赞:1

【python:错误和异常】教你知错能改 中回复

try,except方法顶多是让程序好看一点(没有错误)

2019-08-31T16:43:45 点赞:0

【python:错误和异常】教你知错能改 中回复

我的想法

2019-08-31T16:44:19 点赞:0

【Python作品分享】字画【作品秀】 中回复

center_image

2019-08-31T16:45:39 点赞:0

【Python作品分享】绘图软件V 7 .1【作品秀】 中回复

center_image

2019-08-31T16:51:03 点赞:0

【Python作品分享】绘图软件V 7 .1【作品秀】 中回复

这是最新截图

 

2019-08-31T16:51:14 点赞:0

【Python作品分享】绘图软件V 7 .1【作品秀】 中回复

你们能看出来有什么不同吗?

 

2019-08-31T16:51:38 点赞:0

【Python作品分享】一键画图V3.0.17 中回复

center_image

2019-08-31T16:58:32 点赞:0

【Python作品分享】一键画图V3.0.17 中回复

谁要结盟?

2019-08-31T16:58:40 点赞:0

【无聊灌水】你觉得编程猫的默认头像哪个最漂亮? 中回复

导弹鲨

2019-09-02T21:08:09 点赞:0

震惊!十年前的动画片,他们把动物叠起来,再拼成人型 中回复

emotion_雷电猴_笑趴

2019-09-02T21:10:37 点赞:0