哈喽哈喽!我是木木子,已经断更很久啦!忙碌很长一段时间了,现在告一段落。
后续会陆续更新,希望大家能够多多支持我!啾咪.jpg
2022年扬帆起航,持续为大家输出更多喜欢的内容,分享小编的学习到的知识给大家!

PS:“天上的每一颗星,都是爱过我们的人。”
不要太过惋惜亲人的离去,因为早晚有一天我们会在天上重逢。
在人间活着的日子,我们都有一个归期,而那些逝去的人,会希望我们好好地活下去。
——【人生大事】
我爱这离合悲欢,爱这烟火人间,电影《人生大事》将于6月24日上映。

很多人期待的电影点映不知道有人去看了没?小编刚好卡点去了第一场,这是一部笑着笑着就
哭了的电影。 之后要看的小伙伴儿记得带点儿纸巾哈。
今天小编是看了电影之后有感而发撒,代码源于生活。今天小编就教大家写一款电影院选票系
统给大家。想看的小朋友可以这周天去看看,真不错👍
本文是基于tkinter的界面化小程序!初级版本写的一个简单的选票系统哈。
模块安装:pip install -i https://pypi.douban.com/simple/+模块名
电影院座位是用Turtle绘制完成的。电影院的购票界面是Tkinter写的。
座位背景👇

界面电影选项素材(自选:小编随便找的几部截图的哈)话说下面的我还看过几部呢~

- import tkinter as tk
- from PIL import Image
- from PIL import ImageTk
- import turtle
- from tkinter import messagebox
- from cinemaclass import Movie as M
-
-
- def mainGui(x, y, z):
- image = Image.open(x)
- photo = ImageTk.PhotoImage(image)
- label = tk.Label(image=photo, width=300, height=300)
- label.image = photo
- label.place(relx=y, rely=z)
-
-
- window = tk.Tk()
-
- moives = []
- lst = []
- for i in range(1, 9):
- moives.append(M(str(i)))
-
-
- def xuanpiao(x):
- global window, moives
-
- window1 = tk.Tk()
- window1.geometry('1330x700')
- click = ()
-
- def callback(event):
- # print("clicked at:", event.x, event.y) # 打印出该事件(按下鼠标)的x,y轴
- # 打印出该事件(按下鼠标)的x,y轴
- s = (event.x, event.y) # 把它写到一个元组里
- x, y = s
- if (160 <= x <= 760) and (100 <= y <= 550):
- global click, lst
- row = int((x - 160) / 60)
- col = int((y - 100) / 45)
- click = (col + 1, row + 1)
-
- print(lst)
- if movie.isbook(col + 1, row + 1) == False:
- lst.append(click)
- drawp(canva, movie, lst)
- else:
- messagebox.showinfo("该位置已购买!")
-
- def yyyyyyyyyyyyyy(num):
- global moives
- mo = moives[x]
- if num == 0:
- global lst
- sp = '是否购买'
- if lst == []:
- messagebox.showinfo("请选座!")
- return None
-
- for l in lst:
- col, row = l
- sp += f'{col}排{row}列 '
- sp += "的座位?"
- y = messagebox.askyesno("确认", sp)
-
- if y:
- for l in lst:
- col, row = l
- mo.book(col, row)
- mo.save('data')
- lst=[]
- window1.destroy()
- else:
- lst = []
- drawp(canva, movie, [], lst)
- lst = []
- window1.destroy()
-
- b2 = tk.Button(window1, text='确认购座', font=('楷书', 12), command=lambda: yyyyyyyyyyyyyy(0))
- b2.pack(side=tk.LEFT)
- b2 = tk.Button(window1, text='返回', font=('楷书', 12), command=lambda: yyyyyyyyyyyyyy(1))
- b2.pack(side=tk.LEFT)
- window1.bind("<Button-1>", callback)
- if x == 1:
- window1.title('电影《你的世界如果没有我》请选择座位')
- elif x == 2:
- window1.title('电影《只要你过得比我好》请选择座位')
- elif x == 3:
- window1.title('电影《扬名立万》请选择座位')
- elif x == 4:
- window1.title('电影《梅艳芳》请选择座位')
- elif x == 5:
- window1.title('电影《笨鸟大冒险》请选择座位')
- elif x == 6:
- window1.title('电影《古董局中局》请选择座位')
- elif x == 7:
- window1.title('电影《长津湖》请选择座位')
- else:
- window1.title('电影《门锁》请选择座位')
-
- movie = moives[x]
-
- def drawp(canva, moive: M, lst=None, lst2=None):
- if lst == None:
- lst = []
- if lst2 == None:
- lst2 = []
- from turtle import Shape
- theScreen = turtle.TurtleScreen(canva)
- t = turtle.RawTurtle(theScreen, visible=True)
- s = Shape("compound")
- poly2 = ((-20, -10), (-30, -10), (-30, 15), (30, 15), (30, -10), (20, -10))
- s.addcomponent(poly2, "pink", "black")
- poly1 = (
- (0, 0), (10, 0), (10, -10), (20, -10), (20, -30), (-20, -30), (-20, -10), (-10, -10), (-10, 0), (0, 0),)
- s.addcomponent(poly1, "white", "black")
- theScreen.register_shape("myshape1", s)
- s2 = Shape("compound")
- # poly2 = ((-10.0, -5.0), (-15.0, -5.0), (-15.0, 7.5), (15.0, 7.5), (15.0, -5.0), (10.0, -5.0))
- s2.addcomponent(poly2, "white", "black")
- # poly1 = ((0.0, 0.0), (5.0, 0.0), (5.0, -5.0), (10.0, -5.0), (10.0, -15.0), (-10.0, -15.0), (-10.0, -5.0), (-5.0, -5.0), (-5.0, 0.0), (0.0, 0.0))
- s2.addcomponent(poly1, "red", "black")
- theScreen.register_shape("myshape2", s2)
- s3 = Shape("compound")
- # poly2 = ((-10.0, -5.0), (-15.0, -5.0), (-15.0, 7.5), (15.0, 7.5), (15.0, -5.0), (10.0, -5.0))
- s3.addcomponent(poly2, "white", "black")
- # poly1 = ((0.0, 0.0), (5.0, 0.0), (5.0, -5.0), (10.0, -5.0), (10.0, -15.0), (-10.0, -15.0), (-10.0, -5.0), (-5.0, -5.0), (-5.0, 0.0), (0.0, 0.0))
- s3.addcomponent(poly1, "green", "black")
- theScreen.register_shape("myshape3", s3)
-
- t.settiltangle(270)
- t.penup()
- t.ht()
- t.speed(10)
- moive.show()
-
- ##############
-
- ###############
-
- for j in range(10):
- for k in range(10):
- if (k + 1, j + 1) in lst:
- print('green:', lst)
- t.shape('myshape3')
- else:
- if ((k + 1, j + 1) in lst2) or moive.isbook(k + 1, j + 1):
- t.shape('myshape2')
- else:
- t.shape('myshape1')
- x = j * 60
- y = -k * 45
- t.goto(x, y)
- t.stamp()
- # theScreen.mainloop()
-
- canva = tk.Canvas(window1, relief=tk.FLAT)
- canva.pack(fill='both', expand='yes')
- drawp(canva, movie, )
-
- window1.mainloop()
-
- # aa = tk.Button(window1, text="Draw", command= lambda: drawp())
- # aa.pack()
-
-
- def chushi_jiemian():
- global window
- window.title('电影选座系统')
- window.geometry('1330x700')
- l = tk.Label(window, text='正在热映(8部)', fg='red', font=('楷书', 20), width=30, height=2)
- l.place(relx=0.37, rely=0.01)
- mainGui(r'你的世界如果没有我.jpg', 0.1, 0.1)
- mainGui(r'只要你过的比我好.jpg', 0.3, 0.1)
- mainGui(r'扬名立万.jpg', 0.5, 0.1)
- mainGui(r'梅艳芳.jpg', 0.7, 0.1)
- mainGui(r'笨鸟大冒险.jpg', 0.1, 0.5)
- mainGui(r'古董局中局.jpg', 0.3, 0.5)
- mainGui(r'长津湖.jpg', 0.5, 0.5)
- mainGui(r'门锁.jpg', 0.7, 0.5)
- b1 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(1))
- b1.place(relx=0.165, y=350, height=20, relwidth=0.1)
- b2 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(2))
- b2.place(relx=0.365, y=350, height=20, relwidth=0.1)
- b3 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(3))
- b3.place(relx=0.565, y=350, height=20, relwidth=0.1)
- b4 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(4))
- b4.place(relx=0.765, y=350, height=20, relwidth=0.1)
- b5 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(5))
- b5.place(relx=0.165, y=635, height=20, relwidth=0.1)
- b6 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(6))
- b6.place(relx=0.365, y=635, height=20, relwidth=0.1)
- b7 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(7))
- b7.place(relx=0.565, y=635, height=20, relwidth=0.1)
- b8 = tk.Button(window, text='点击购票', font=('楷书', 12), command=lambda: xuanpiao(8))
- b8.place(relx=0.765, y=635, height=20, relwidth=0.1)
- window.mainloop()
-
-
- chushi_jiemian()
- import turtle as t
-
-
- def goto(x, y):
- t.penup()
- t.goto(x, y)
- t.pendown()
-
-
- def seat(x, y,):
- t.pensize(1)
- t.color('black')
- for i in range(10):
- for j in range(10):
- goto(-50 + i * 40, -50 + j * 40)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(20)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(5)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.left(90)
- t.fd(5)
- t.fd(5)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(30)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(10)
- t.right(180)
- goto(350, 450)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(20)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(5)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.left(90)
- t.fd(5)
- t.fd(5)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(30)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(10)
- t.left(180)
- t.pencolor('white')
- goto(-50 + (x-1) * 40, -50 + (y-1) * 40)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(20)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(5)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.left(90)
- t.fd(5)
- t.fd(5)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(30)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(10)
- t.left(180)
- t.pencolor('black')
- goto(-50 + (x-1) * 40, -50 + (y-1) * 40)
- t.fillcolor('red')
- t.begin_fill()
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(20)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(5)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.left(90)
- t.fd(5)
- t.end_fill()
- t.fillcolor('pink')
- t.begin_fill()
- t.fd(5)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(30)
- t.left(90)
- t.fd(15)
- t.left(90)
- t.fd(10)
- t.left(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.right(90)
- t.fd(10)
- t.left(90)
- t.fd(5)
- t.end_fill()
- t.left(180)
-
-
-
- t.ht()
- t.tracer(False)
- seat(2, 1)
- t.done()
这款电影院选票系统主要就分为这两大块内容。简单的界面购票选票的都完成啦!




好啦!到这里这款电影选座购票系统就写完啦!虽然只是一款简单的界面小程序,但是该有的
效果还是都有滴啦!有大佬也可以自行优化嘻嘻!
老规矩啦源码文末免费拿,放心 都有哈!拿源码之前记得给我三连一下啦~非常感谢大家!

项目1.3 视频播放器
用了都说好的Python专属无广告视频播放器,良心到想为它疯狂打call
项目2.7 刮刮卡小程序
周末老板请吃东西,刮到多少算多少?Python带你制作一款刮刮卡小程序。
项目3.2 自动换壁纸
【Python高级技能】超炫酷,电脑每天自动换壁纸,这个神器适合你。
项目3.3 艺术字签名
【艺术字签名生成器】】试卷家长签字居然被嫌弃了|“我觉得我还能再抢救一下,你看行嘛?“
项目 3.9 码住雪景漫天飘雪小程序
【Python码住雪景小程序】雪景人像最强攻略:让你一下美10倍、美醉了(中国人不骗中国人)
项目 4.0 GIF制作神奇(斗罗大陆为例)
【Python神器】推荐这款傻瓜式GIF制作工具,以后别再说不会了(好用到爆~)
项目1.0 Python—2021 |已有文章汇总 | 持续更新,直接看这篇就够了
(更多内容+源码都在文章汇总哦!!欢迎阅读~)
