简体   繁体   English

Tkinter:OptionMenu下拉列表多屏定位控制

[英]Tkinter: OptionMenu Drop down list positioning control on multiple screens

I have a program, which runs on two displays - secondary screen is a video feed, the primary screen is a Tkinter GUI on a touch screen.我有一个程序,它在两个显示器上运行 - 辅助屏幕是视频源,主屏幕是触摸屏上的 Tkinter GUI。

In the GUI are multiple drop down lists, some have a significant amount of contents (50+). GUI 中有多个下拉列表,其中一些包含大量内容(50 多个)。 These, if pressed, show the drop down list on the secondary screen, not on the primary (which is the touch screen).这些,如果按下,会在辅助屏幕上显示下拉列表,而不是在主屏幕(即触摸屏)上。

How can I ensure the drop down lists, independently of the amount of items, appear on the primary screen (limited view with scroll arrows OK)?如何确保与项目数量无关的下拉列表出现在主屏幕上(使用滚动箭头确定的有限视图)? (Problem does not appear on lists with less than 30 items) (问题不会出现在少于 30 项的列表中)

Problem Description Principle问题描述原理

root = tk.Tk()
root.state('zoomed') ##ensure GUI full screen on primary screen
.....................
popupMenu = tk.OptionMenu(root, tkvar, *data)
popupMenu.config(font=helv36, width=12)
menu = root.nametowidget(popupMenu.menuname) ##thanks to martineau
menu.config(font=helv36)
popupMenu.grid(row = 8, column =0, sticky='nw')
tkvar.trace('w', change_dropdown))

Workaround to the Problem I raised.我提出的问题的解决方法。 To avoid the problem described, I re-arranged the displays in the OS display setting menu next to each other, not on top of each other.为避免出现所描述的问题,我将操作系统显示设置菜单中的显示重新排列在一起,而不是彼此重叠。 By doing so, the drop down list is now shown for all instances on the correct primary screen.通过这样做,现在在正确的主屏幕上为所有实例显示下拉列表。 If somebody still knows how to actively place in Tkinter the drop down list on a specific screen, please let me know.如果有人仍然知道如何在 Tkinter 中主动放置特定屏幕上的下拉列表,请告诉我。 Thanks!谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM