如何创建一个包含每个项目的复选框的组合框? [英] How to create a combobox that includes checkbox for each item?

查看:22
本文介绍了如何创建一个包含每个项目的复选框的组合框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对 tkinter 和 python 相当陌生,我想知道如何实现一个像这样的按钮:

Fairly new to tkinter and python I was wondering how to achieve a button that would act like this :

  • 点击按钮下拉列表(所以这是一个组合框)
  • 列表的每一行都有一个复选框.
  • 最后,如果单击复选框运行一个函数,或者(甚至更好)一旦组合框不再被删除,运行一个将项目检查为 args 的函数.

更新

按钮/菜单按钮必须充当过滤器.当下拉菜单时,用户可以取消选中他不想要的多个选项(每次单击项目时菜单都不会消失).因此,能够看到复选框以便用户知道当前哪些选项处于活动状态非常重要.

The button/menuButton will have to act like a filter. When menu is dropped down user can uncheck multiple options (without the menu to disappear each time an item is clicked) he don't want. Therefore it's really important to be able to see checkboxes so as the user know which options are currently active.

我最终通过创建顶级框架来使用 Bryan 的想法.这是我所拥有的:

I finally used the idea of Bryan by creating a top level frame. Here is what I have :

推荐答案

没有小部件可以做您想做的事.您必须创建一个带有一堆复选按钮的顶级窗口.然后,您可以使用普通按钮触发外观.

There is no widget to do what you want. You'll have to create a toplevel window with a bunch of checkbuttons. You can then trigger the appearance with a normal button.

这篇关于如何创建一个包含每个项目的复选框的组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆