用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

请选择技术分类

 *如果你找不到更细的分类,可以选择上级分类
当前位置:云代码 - 技术问答 - 开发笔记

写小程序代码

 悬赏:10|提问者:可爱可爱的无名指|浏览:1555
举报|2021-01-16
求小程序代码,健全代码一份,完善代码沟通,我的微信sunhanqqww

我来回答

所有回答
举报|(3)|(3)2021-03-15
adawdsaf
举报|(3)|(3)2021-06-02
啊这
举报|(3)|(3)2021-06-14
111111
举报|(3)|(3)2021-07-24
??
举报|(3)|(3)2021-08-23
????
#6
举报|(3)|(3)2021-08-24
import tkinter import sys, random, math class Point(object): def __init__(self, x, y): self.x = x self.y = y def __str__(self): return "<Point>: (%f, %f)" % (self.x, self.y) class Branch(object): def __init__(self, bottom, top, branches, level=0): self.bottom = bottom self.top = top self.level = level self.branches = branches self.children = [] def __str__(self):
        s = "Top: %s, Bottom: %s, Children Count: %d" % \
            (self.top, self.bottom, len(self.children)) return s def nextGen(self, n=-1, rnd=1): if n <= 0: n = self.branches if rnd == 1:
            n = random.randint(n / 2, n * 2) if n <= 0: n = 1  dx = self.top.x - self.bottom.x
        dy = self.top.y - self.bottom.y
        r = 0.20 + random.random() * 0.2  if self.top.x == self.bottom.x: # 如果是一条竖线  x = self.top.x
            y = dy * r + self.bottom.y elif self.top.y == self.bottom.y: # 如果是一条横线  x = dx * r + self.bottom.x
            y = self.top.y else:
            x = dx * r
            y = x * dy / dx
            x += self.bottom.x
            y += self.bottom.y
        oldTop = self.top self.top = Point(x, y)
        a = math.pi / (2 * n) for i in range(n):
            a2 = -a * (n - 1) / 2 + a * i - math.pi
            a2 *= 0.9 + random.random() * 0.2  self.children.append(self.mkNewBranch(self.top, oldTop, a2)) def mkNewBranch(self, bottom, top, a):
        dx1 = top.x - bottom.x
        dy1 = top.y - bottom.y
        r = 0.9 + random.random() * 0.2  c = math.sqrt(dx1 ** 2 + dy1 ** 2) * r if dx1 == 0:
            a2 = math.pi / 2  else:
            a2 = math.atan(dy1 / dx1) if (a2 < 0 and bottom.y > top.y) \ or (a2 > 0 and bottom.y < top.y) \
                    :
                a2 += math.pi
        b = a2 - a
        dx2 = c * math.cos(b)
        dy2 = c * math.sin(b)
        newTop = Point(dx2 + bottom.x, dy2 + bottom.y) return Branch(bottom, newTop, self.branches, self.level + 1) class Tree(object): def __init__(self, root, canvas, bottom, top, branches=3, depth=3): self.root = root self.canvas = canvas self.bottom = bottom self.top = top self.branches = branches self.depth = depth self.new() def gen(self, n=1): for i in range(n): self.getLeaves() for node in self.leaves:
                node.nextGen() self.show() def new(self): self.leavesCount = 0  self.branch = Branch(self.bottom, self.top, self.branches) self.gen(self.depth) print("leaves count: %d" % self.leavesCount) def chgDepth(self, d): self.depth += d if self.depth < 0: self.depth = 0  if self.depth > 10: self.depth = 10  self.new() def chgBranch(self, d): self.branches += d if self.branches < 1: self.branches = 1  if self.branches > 10: self.branches = 10  self.new() def getLeaves(self): self.leaves = [] self.map(self.findLeaf) def findLeaf(self, node): if len(node.children) == 0: self.leaves.append(node) def show(self): for i in self.canvas.find_all(): self.canvas.delete(i) self.map(self.drawNode) self.canvas.tag_raise("leaf") def exit(self, evt):
        sys.exit(0) def map(self, func=lambda node: node): # 遍历树  children = [self.branch] while len(children) != 0:
            newChildren = [] for node in children:
                func(node)
                newChildren.extend(node.children)
            children = newChildren def drawNode(self, node): self.line2( #       self.canvas.create_line(  node.bottom.x,  node.bottom.y,  node.top.x,  node.top.y,  fill="#100",  width=1.5 ** (self.depth - node.level),  tags="branch level_%d" % node.level,  ) if len(node.children) == 0: # 画叶子  self.leavesCount += 1  self.canvas.create_oval(
                node.top.x - 3,  node.top.y - 3,  node.top.x + 3,  node.top.y + 3,  fill="#090",  tag="leaf",  ) self.canvas.update() def line2(self, x0, y0, x1, y1, width=1, fill="#000", minDist=10, tags=""):
        dots = midDots(x0, y0, x1, y1, minDist)
        dots2 = [] for i in range(len(dots) - 1):
            dots2.extend([dots[i].x,  dots[i].y,  dots[i + 1].x,  dots[i + 1].y]) self.canvas.create_line(
            dots2,  fill=fill,  width=width,  smooth=True,  tags=tags,  ) def midDots(x0, y0, x1, y1, d):
    dots = []
    dx, dy, r = x1 - x0, y1 - y0, 0  if dx != 0:
        r = float(dy) / dx
    c = math.sqrt(dx ** 2 + dy ** 2)
    n = int(c / d) + 1  for i in range(n): if dx != 0:
            x = dx * i / n
            y = x * r else:
            x = dx
            y = dy * i / n if i > 0:
            x += d * (0.5 - random.random()) * 0.25  y += d * (0.5 - random.random()) * 0.25  x += x0
        y += y0
        dots.append(Point(x, y))
    dots.append(Point(x1, y1)) return dots if __name__ == "__main__":
    root = tkinter.Tk()
    root.title("Tree")
    gw, gh = 800, 600  canvas = tkinter.Canvas(root,  width=gw,  height=gh,  )
    canvas.pack()
    tree = Tree(root, canvas, Point(gw / 2, gh - 20), Point(gw / 2, gh * 0.2), \ branches=2, depth=8)
    root.bind("n", lambda evt: tree.new())
    root.bind("=", lambda evt: tree.chgDepth(1))
    root.bind("+", lambda evt: tree.chgDepth(1))
    root.bind("-", lambda evt: tree.chgDepth(-1))
    root.bind("b", lambda evt: tree.chgBranch(1))
    root.bind("c", lambda evt: tree.chgBranch(-1))
    root.bind("q", tree.exit)
    root.mainloop()
举报|(3)|(3)2021-10-11
cCCCC
举报|(2)|(2)2021-10-31
import qrcode
from tkinter import *
from PIL import Image
from PIL import ImageTk
root = Tk()
root.title('二维码之谜')
root.geometry('400x600+300+100')
root.resizable(0,0)

img = qrcode.make('https: // kbhgames.com/game/friday-night-funkin-the-tricky-mod').resize((150, 150))
img.save('mcc.png')
img = Image.open('mcc.png')
pic = ImageTk.PhotoImage(img)

img_label = Label(root,image = pic)
img_label.place(x=130,y=450)
name_label = Label(root, text='姓名', font=('微软雅黑', 20))
name_label.place(x=50,y=30)
name_entry = Entry(root, font=('微软雅黑', 15))
name_entry.place(x=150,y=35)

age_label = Label(root, text='地区', font=('微软雅黑', 20))
age_label.place(x=50, y=100)
age_entry = Entry(root, font=('微软雅黑', 15))
age_entry.place(x=150, y=105)

inter_label = Label(root, text='简介', font=('微软雅黑', 20))
inter_label.place(x=50, y=170)
inter_text = Text(root, font=('微软雅黑', 15),width=20,height=4)
inter_text.place(x=150, y=175)

area_label = Label(root, text='地区', font=('微软雅黑', 20))
area_label.place(x=50, y=300)
area_entry = Entry(root, font=('微软雅黑', 15))
area_entry.place(x=150, y=305)

def clear():
name_entry.delete(0,'end')
age_entry.delete(0,'end')
area_entry.delete(0, 'end')
inter_text.delete(0.0,'end')

clear_btn = Button(root, text='清空内容', font=('微软雅黑', 15), command=clear)
clear_btn.place(x=80,y=400)

def create():
n = name_entry.get()
a = age_entry.get()
r = area_entry.get()
i = inter_text.get(0.0,'end')
t = '姓名:%s\n地区:%s\n年龄:%s\n简介:%s'%(n,r,a,i)
img = qrcode.make(t).resize((150, 150))
img.save('mcc.png')
img = Image.open('mcc.png')
pic = ImageTk.PhotoImage(img)
img_label.configure(image = pic)
img_label.image=pic

create_btn = Button(root, text='生成二维码', font=('微软雅黑', 15), command=create)
create_btn.place(x=230,y=400)
root.mainloop()

举报|(2)|(2)2021-11-06
111
举报|(2)|(2)2021-11-07
111
#11FN
举报|(2)|(2)2021-12-04
.。。
举报|(2)|(2)2022-01-12
111111
举报|(2)|(2)2022-01-26
用哪种语言

相关提问

2021-01-16
10