示例#1
0
    def __init__(self, parent):
        wx.Dialog.__init__(self,
                           parent,
                           id=wx.ID_ANY,
                           title=u"车辆保险到期提醒",
                           pos=wx.DefaultPosition,
                           size=(800, 530),
                           style=wx.CAPTION | wx.STAY_ON_TOP
                           | wx.RESIZE_BORDER)

        self.alarm_time = None

        border = wx.BoxSizer(wx.VERTICAL)

        # 操作条
        opt_sizer = wx.BoxSizer(wx.HORIZONTAL)

        if not auth.Auth.logon_user[2] == 2:
            export_btn = wx.Button(self, wx.ID_ANY, u"导出")
            self.Bind(wx.EVT_BUTTON, self.on_export, export_btn)
            opt_sizer.Add(export_btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        border.Add(opt_sizer, 0, wx.ALIGN_RIGHT, 5)

        # 网格条
        grid_boxer = wx.BoxSizer(wx.HORIZONTAL)
        panel = ScrolledPanel(self, size=(780, 400))
        alarm_grid = vehiclepanel.VehicleGrid(panel)
        # 加载预警数据
        self.data = service.search_vehicle(30, None)
        alarm_grid.set_data(self.data)
        grid_boxer.Add(alarm_grid, 0, wx.ALIGN_TOP, 5)
        panel.SetSizer(grid_boxer)
        panel.Fit()
        panel.SetAutoLayout(1)
        panel.SetupScrolling()
        border.Add(panel, 0, wx.FIXED_MINSIZE, 5)

        # 按钮条
        buttons = wx.BoxSizer()
        self.close_btn = wx.Button(self, wx.ID_OK, u"关闭")
        self.close_btn.SetDefault()
        self.close_btn.Enable(False)
        buttons.Add(self.close_btn)
        border.Add(buttons, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.SetSizer(border)
示例#2
0
class ScrolledWindow(Frame):
    def __init__(self, contents, *args, **kw):
        super().__init__(*args, **kw)
        icon_bundle = self.GetParent().GetIcons()
        if not icon_bundle.IsEmpty():
            self.SetIcon(icon_bundle.GetIconByIndex(0))

        self.scrolled_panel = ScrolledPanel(self)
        self.contents = HelpText(self.scrolled_panel, style=TE_MULTILINE)
        self.layout()
        self.contents.SetLabel(contents)
        self.SetupScrolling()

    def layout(self):
        self.vbox = BoxSizer(VERTICAL)
        self.vbox.Add(self.contents, 0, ALL, 25)
        self.scrolled_panel.SetSizer(self.vbox)

    def Fit(self):
        self.scrolled_panel.Fit()
        return super().Fit()

    def SetupScrolling(self):
        self.Fit()
        width, height = self.GetSize()
        height = min(height, WINDOW_HEIGHT)
        self.SetSize(0, 0, width, height)

        self.scrolled_panel.SetupScrolling()

    def Show(self, show=True):
        if self.IsShown() and show:
            self.Raise()
        self.Center()
        return super().Show(show=show)

    def Destroy(self, is_destroy=False):
        self.Hide()
        return is_destroy