简体   繁体   English

在Mac Cocoa应用程序中使用Tkinter框架

[英]use a Tkinter frame in a Mac Cocoa app

I wrote a diff and merge program in Python using the Tkinter UI framework. 我使用Tkinter UI框架在Python中编写了一个diff和merge程序。 Running it on OS-X there are two problems: 在OS-X上运行它有两个问题:

  1. when starting it the window does not get displayed unless switching back and forth with other running apps. 启动时,除非与其他正在运行的应用程序来回切换,否则不会显示该窗口。 There has been a thread here recommending top.call('wm', 'attributes', '.', '-topmost', '1') which is no solution since it keeps the window on top of all - always. 这里有一个线程建议top.call('wm','attributes','。','-topmost','1')这是没有解决方案的,因为它始终使窗口始终处于顶层。 Other say that when packaging with py2app this behavior goes away - I tried and it does not! 有人说用py2app打包时这种行为消失了-我试过了,但没有!
  2. There is no way to change the Menu - The first entry is dictated by TK, so the first "About xxx" does bring up the TCL credits and can not be replaced with my own apps about info. 无法更改菜单-第一个条目由TK决定,因此第一个“关于xxx”确实会显示TCL积分,并且不能用我自己的信息应用程序代替。

So my Idea was to make a cocoa app window wich displays on start and on top and I can define what is in the menu - and integrate the Tk frame with my Python code somehow. 因此,我的想法是制作一个在开始和顶部均显示的可可应用窗口,然后我可以定义菜单中的内容-并以某种方式将Tk框架与我的Python代码集成在一起。

Is that possible? 那可能吗?

Try some variant of this command: 尝试以下命令的变体:

self.createcommand('tkAboutDialog', self.aboutProgram) self.createcommand('tkAboutDialog',self.aboutProgram)

and put your app "about" dialog code in the aboutProgram() function. 并将您的应用“关于”对话框代码放入aboutProgram()函数中。

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

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