如何使用wxPython。选择在一个wxPython对话?

2024-07-04 07:43:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在一个对话框中显示一个图像,并在其旁边添加一个液滴来显示一些选项。以下是我的代码(所有内容都在我定义的类中):

""" Create main App """
self._app = wx.App()

""" Load image """
png = wx.Image('show_work.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()

""" Create dialog """
self._dialog = wx.Dialog(None, -1, 'Graphical Output', size = (png.GetWidth()+25, png.GetHeight()+150), style=wx.DEFAULT_DIALOG_STYLE & ~wx.RESIZE_BORDER)

""" Bind image to dialog """
wx.StaticBitmap(self._dialog, -1, png, (10,5), (png.GetWidth(), png.GetHeight()))

""" Create choice list """
choice_list = []
for number in xrange(self._upper_limit):
    choice_list.append(str(number +1))

""" Create choice list """
self._droplist = wx.Choice(self._dialog, -1, (280, 200), choices = choice_list)

""" Show dialog """
self._dialog.ShowModal()

""" Start main App """
self._app.MainLoop()

结果显示,图像显示正确。但是,我创建的下拉列表没有显示。我确信我为创建它而指定的位置在对话框的中心,并且框中有足够的空间来显示它。在

那么我能知道我在上面的部分有什么错吗?在

谢谢。在


Tags: 图像imageselfapppngmaincreatelist
1条回答
网友
1楼 · 发布于 2024-07-04 07:43:11

嗯,这对我很好

import wx
class  P:
    def __init__(self):
        """ Create main App """
        self._app = wx.App(redirect=False)

        #""" Load image """
        #png = wx.Image('show_work.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()

        """ Create dialog """
        self._dialog = wx.Dialog(None, -1, 'Graphical Output', size = (500,500), style=wx.DEFAULT_DIALOG_STYLE & ~wx.RESIZE_BORDER)

        """ Bind image to dialog """
        #wx.StaticBitmap(self._dialog, -1, png, (10,5), (png.GetWidth(), png.GetHeight()))

        """ Create choice list """
        choice_list = []
        for number in xrange(10):
            choice_list.append(str(number +1))

        """ Create choice list """
        self._droplist = wx.Choice(self._dialog, -1, (280, 200), choices = choice_list)

        """ Show dialog """
        self._dialog.ShowModal()

        """ Start main App """
        self._app.MainLoop()

P()

相关问题 更多 >

    热门问题