WxPython-size的wxdialog没有改变

时间:2016-06-06 10:18:22

标签: wxpython wxwidgets

在我的项目中,Wxdialog的声明是 wx.Dialog.__init__(self, parent, wx.ID_ANY, 'Launch dialog', size=(-1,-1), pos=(-1,-1))

我尝试通过将尺寸从size=(-1,-1)设置为size=(800,750)来增加对话框尺寸

但是没有任何改变......这背后有任何理由。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

您的代码看起来很好 这是一个来自实时项目的工作对话框

class Rem_mess(wx.Dialog):
    def __init__(self,parent,ddate,dtext,dtype):
        wx.Dialog.__init__(self, parent, wx.ID_ANY, dtype, size= (320,240), pos=(1000,10))
        font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
        font.SetPointSize(9)
        self.SetWindowStyle(wx.STAY_ON_TOP)
        self.snooze_list = ['Snooze for','5 Mins','15 Mins','30 Mins','1 Hour','1 Day','1 Week','No Snooze']
        self.snooze_mins = [0,5,15,30,60,1440,10080,0]
        time_panel = wx.Panel(self, wx.ID_ANY)
        time_panel.SetFont(font)

        label_date = wx.StaticText(time_panel, wx.ID_ANY, (ddate))
        label_text = wx.TextCtrl(time_panel, wx.ID_ANY, style= wx.TE_MULTILINE | wx.TE_READONLY, size=(300,110))
        self.snooze = wx.Choice(time_panel, wx.ID_ANY, choices=self.snooze_list,size=(200,28))
        self.quit_button = wx.Button(time_panel, label="&Close", size=(70,30))
        time_panel.SetBackgroundColour(wx.Colour(201, 196, 255))
        sizer = wx.GridBagSizer(hgap=2,vgap=2)
        sizer.Add(label_date, pos=(0,1), flag = wx.ALL|wx.EXPAND)
        sizer.Add(label_text, pos=(1,1), flag = wx.ALL|wx.EXPAND)
        sizer.Add(self.snooze, pos=(2,1), flag = wx.ALL|wx.EXPAND)
        sizer.Add(self.quit_button,pos=(4,1), flag =wx.ALL|wx.CENTER)
        time_panel.SetSizer(sizer)
        self.quit_button.Bind(wx.EVT_BUTTON, self.OnQuit)
        label_text.SetValue(dtext)

    def OnQuit(self, event):
        self.Close()

    def GetSelection(self):
        idx = self.snooze.GetSelection()
        return self.snooze_mins[idx]

    def GetSelectionString(self):
        return self.snooze.GetString(self.snooze.GetSelection())

它被称为:

    res = Rem_mess(parent=None, ddate=d_date,dtext=d_text,dtype="Reminder")
    if res.ShowModal() == wx.ID_OK:
        snooze_res = res.GetSelection()
    res.Destroy()

我希望它有所帮助!