控制 Pmw.MessageDialog(和其他类似小部件)的位置

发布于 2024-11-16 09:56:08 字数 929 浏览 6 评论 0原文

这里是 Python 新手,对 Pmw 还比较新:

我定义了以下方法来显示 Pmw 消息对话框,它按预期工作,结果值返回并发布在 edit1 中,这是一个 Tkinter.Text 小部件;这里的“self”是一个 Tkinter.Frame。 (运行Win7-32​​和Python v2.7.2):

def _showMessageBar(self):

        dialog = Pmw.MessageDialog(self, title = 'DBox',defaultbutton = 0,buttons('OK',Cancel'), message_text = 'DBox')
        dialog.iconname(dialog['title'])
        try:
            result = dialog.activate()
        finally:
            dialog.deactivate() 
        self.edit1.insert(END, result+ "\n")

问题是,对dialog.activate()的调用不允许我控制messageBox的位置。

如果我将该调用更改为:

result = dialog.activate(geometry = first+50+20)

那么 messageBox 小部件将放置在指定的坐标处,但这有两个副作用:

1) messageBox 小部件现在具有主窗口的按钮(关闭、最小化、最大化)而不是对话框(只是关闭“X”按钮)

2) 结果值永远不会发布到 edit1。

问题:如何控制 messageBox 的位置,同时维护对话框按钮/边框并获取发布到 Text (edit1) 小部件的值。

TIA

Python newbie here, newer still to Pmw:

I have the following method defined for showing a Pmw MessageDialog box, and it works as expected and the result value is returned and posted in edit1, which is a Tkinter.Text widget; 'self' here is a Tkinter.Frame. (running Win7-32 and Python v2.7.2):

def _showMessageBar(self):

        dialog = Pmw.MessageDialog(self, title = 'DBox',defaultbutton = 0,buttons('OK',Cancel'), message_text = 'DBox')
        dialog.iconname(dialog['title'])
        try:
            result = dialog.activate()
        finally:
            dialog.deactivate() 
        self.edit1.insert(END, result+ "\n")

The problem is, the call to dialog.activate() doesn't allow me to control the location of the messageBox.

If I change that call to:

result = dialog.activate(geometry = first+50+20)

then the messageBox widget is placed at the specified coordinates, but this has two side effects:

1) The messageBox widget now has the buttons of main window (close, minimize,maximize) rather than a dialog box (just the close 'X' button)

2) The result value is never posted to edit1.

Question: How do I control the location of the messageBox while maintaining the dialog box buttons/border and getting the value posted to the Text (edit1) widget.

TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情何以堪。 2024-11-23 09:56:08

答案是几何选项需要用引号引起来,我没有看到正确的结果,因为不正确的几何说明符引发了异常。这段代码:

result = dialog.activate(geometry = "first+50+20")

工作正常。

The answer is that the geometry options need to be in quotes, I wasn't seeing the proper results because an exception was being thrown by the improper geometry specifier. This code:

result = dialog.activate(geometry = "first+50+20")

works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文