Python/选课列表程序(附Python代码)

使用Python编写选课程序。
左侧列表框显示学生可以选择的课程名称,右侧列表框显示学生已经选择的课程名通过四个按钮可以使两个列表框中移动数据项。
演示图:
在这里插入图片描述

代码:

from tkinter import *

window=Tk()


def callbutton1():
    for i in theLB.curselection():
        theRB.insert(0,theLB.get(i))
        theLB.delete(i)
        
def callbutton2():
    for i in theRB.curselection():
        theLB.insert(0,theRB.get(i))
        theRB.delete(i)
def callbutton3():
    for i in range(0,theLB.size()):
        theRB.insert(0,theLB.get(i))
    for i in range(theLB.size()-1,-1,-1):
        theLB.delete(i)
def callbutton4():
    for i in range(0,theRB.size()):
        theLB.insert(0,theRB.get(i))
    for i in range(theRB.size()-1,-1,-1):
        theRB.delete(i)
LYL=['数电','python','java','大数据实验','操作系统','组成原理']

window.geometry('600x600')

theRB=Listbox(window)
theLB=Listbox(window)

for item in LYL:
    theLB.insert(0,item)
    theLB.grid(row=0,column=0,rowspan=4)

tb1=Button(window,text='>',command=callbutton1,width=20)
tb2=Button(window,text='<',command=callbutton2,width=20)
tb3=Button(window,text='>>',command=callbutton3,width=20)
tb4=Button(window,text='<<',command=callbutton4,width=20)

tb1.grid(row=0,column=1)
tb2.grid(row=1,column=1)
tb3.grid(row=2,column=1)
tb4.grid(row=3,column=1)
theRB.grid(row=0,column=2,rowspan=4)

window.mainloop()

基本运用到的就是python中的各种器件的使用和位置设置

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值