V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
qile1
V2EX  ›  Python

Python 窗体界面开发 tkinter 如何进行列表联动

  •  
  •   qile1 · 2018-09-07 17:22:03 +08:00 · 2476 次点击
    这是一个创建于 2049 天前的主题,其中的信息可能已经有所发展或是发生改变。

    想弄个左右都是列表的界面,点左侧列表项目右侧列表显示详情的 比如左侧是销售列表,点每个列表订单号,右侧出现对应订单的商品列表 pyQT 还在研究,但是使用 pandastable 这个感觉又太多功能,这个场景也不太好实现。 有没有别的方法 另外问下两个列表如何实现互动,点击左侧订单,右侧 from 销毁再重建一个和直接刷新列表数据应该选哪个方法

    第 1 条附言  ·  2018-09-09 12:19:12 +08:00

    我做了一个示例代码,获取按钮的文本字段并处理,但是获取的按钮文本都是最后一个按钮的,前面创建的按钮文本无法获取

    我想给每个按钮一个id值,点击的时候作为参数传给执行的函数,但没有成功。

    root = Tk()
    Label(root, text='ID').grid(row=0, column=1)
    Label(root, text='NAME').grid(row=0, column=2)
    Label(root, text='AGE').grid(row=0, column=3)
    sv = StringVar()
    def callback(sid,b,c):
        print(sid,b,c)
        print(sv.get())
        return True
    j=1
    entry_dict={}
    
    for i in range(1,3):
        j+=1
        # entry_dict[j]=None
        print(j)
        # entry_dict[j+10] = StringVar()
        # fram4.pack(side=TOP)
        Entry(root, textvariable=sv, validate="focusout", validatecommand=lambda: callback(sid=j, b=i, c=300)).grid(row=j, column=3)
        # 输入完成后执行,其他都是每输入一个字符触发执行一次
        Label(root, text=j).grid(row=j, column=1)
        Label(root, text='frm2').grid(row=j, column=2)
    root.mainloop()
    
    1 条回复    2018-09-17 19:58:20 +08:00
    jswangjieda
        1
    jswangjieda  
       2018-09-17 19:58:20 +08:00
    还是用 pyqt 吧,designer 设计 UI,然后 python 写业务逻辑,信号槽还是很方便的,后台任务更新 UI 都是可以的,更不用说控件联动了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3649 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:52 · PVG 12:52 · LAX 21:52 · JFK 00:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.