我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用wx.GetDisplaySize()。
def __init__(self, parent, title): (self.display_length_, self.display_height_) = wx.GetDisplaySize() self.frame_width_ = self.display_length_ * 90 / 100 self.frame_height_ = self.display_height_ * 90 / 100 self.answer_panel_width_ = self.frame_width_ * 15 / 100 super(MainFrame, self).__init__(parent=parent, title=title, size=(self.frame_width_, self.frame_height_)) self.splitter = wx.SplitterWindow(parent=self, style=wx.SP_LIVE_UPDATE) self.splitter.SetMinimumPaneSize(min=100) self.web_panel = WebPanel(parent=self.splitter) self.answer_panel = wx.Panel(parent=self.splitter) self.answers_box = wx.BoxSizer(orient=wx.VERTICAL) self.answers_box.Add(item=self.answer_panel) self.splitter.SplitVertically(window1=self.answer_panel, window2=self.web_panel, sashPosition=self.answer_panel_width_) self.Sizer = wx.BoxSizer(orient=wx.VERTICAL) self.Sizer.Add(item=self.splitter, proportion=CAN_CHANGE, flag=wx.EXPAND) auto_answer_button = wx.Button(parent=self, label=u"????") self.Bind(event=wx.EVT_BUTTON, handler=self.click_search_answer, source=auto_answer_button) self.buttons_box = wx.BoxSizer(orient=wx.HORIZONTAL) self.buttons_box.Add(item=auto_answer_button, proportion=CAN_NOT_CHANGE, flag=wx.LEFT | wx.RIGHT, border=5) self.Sizer.Add(item=self.buttons_box, proportion=CAN_NOT_CHANGE, flag=wx.TOP | wx.BOTTOM, border=5) menu = wx.Menu() menu_about = menu.Append(id=wx.ID_ABOUT, text=u"&??", help=u" ?????") menu_feedback = menu.Append(id=wx.ID_OPEN, text=u"&??", help=u" ??") self.Bind(event=wx.EVT_MENU, handler=self.show_about, source=menu_about) self.Bind(event=wx.EVT_MENU, handler=self.show_feedback, source=menu_feedback) menu_bar = wx.MenuBar() menu_bar.Append(menu, u"&??") self.SetMenuBar(menu_bar) self.statusbar = self.CreateStatusBar() self.Centre()
def SetToolTipPosition(self, pos): """ Set tool tip position @param pos: New tool tip position """ # Get screen size to prevent tool tip to go out of the screen screen_width, screen_height = wx.GetDisplaySize() # Calculate position of tool tip to stay in screen limits tip_width, tip_height = self.GetToolTipSize() self.SetPosition(wx.Point( max(0, min(pos.x, screen_width - tip_width)), max(0, min(pos.y, screen_height - tip_height))))