def __init__(self, parent): """Initialize.""" wx.Panel.__init__(self, parent, -1) #--Left sashPos = conf.settings.get('mash.utils.sashPos', 120) left = self.left = leftSash(self, defaultSize=(sashPos, 100), onSashDrag=self.OnSashDrag) right = self.right = wx.Panel(self, style=wx.NO_BORDER) #--Contents singletons.utilsList = UtilsList(left) singletons.utilsList.SetSizeHints(100, 100) #--Layout left.SetSizer(hSizer((singletons.utilsList, 1, wx.GROW), ((10, 0), 0))) self.gCommandLine = wx.TextCtrl(right, -1, style=wx.TE_READONLY) self.gArguments = wx.TextCtrl(right, -1, style=wx.TE_READONLY) self.gDescription = wx.TextCtrl(right, -1, style=wx.TE_MULTILINE | wx.TE_READONLY) singletons.utilsList.commandLine = self.gCommandLine singletons.utilsList.arguments = self.gArguments singletons.utilsList.description = self.gDescription right.SetSizer( vSizer((self.gCommandLine, 0, wx.GROW), (self.gArguments, 0, wx.GROW), (self.gDescription, 1, wx.GROW))) wx.LayoutAlgorithm().LayoutWindow(self, right) # --Events self.Bind(wx.EVT_SIZE, self.OnSize)
def sashD(self, evt): if evt.GetId() == ID_LWIN: self.lwin.SetDefaultSize((evt.GetDragRect().width, 1000)) if evt.GetId() == ID_RWIN: self.rwin.SetDefaultSize((evt.GetDragRect().width, 1000)) wx.LayoutAlgorithm().LayoutMDIFrame(self) self.GetClientWindow().Refresh()
def OnSashDrag(self, event): """Handle sash moved.""" wMin, wMax = 80, self.GetSizeTuple()[0] - 80 sashPos = max(wMin, min(wMax, event.GetDragRect().width)) self.left.SetDefaultSize((sashPos, 10)) wx.LayoutAlgorithm().LayoutWindow(self, self.right) conf.settings['mash.utils.sashPos'] = sashPos
def OnSashDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: self.log.write('drag is out of range') return eobj = event.GetEventObject() if eobj is self.topWindow: self.log.write('topwin received drag event') self.topWindow.SetDefaultSize((1000, event.GetDragRect().height)) elif eobj is self.leftWindow1: self.log.write('leftwin1 received drag event') self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000)) elif eobj is self.leftWindow2: self.log.write('leftwin2 received drag event') self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000)) elif eobj is self.bottomWindow: self.log.write('bottomwin received drag event') self.bottomWindow.SetDefaultSize( (1000, event.GetDragRect().height)) wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh()
def OnSize(self, event): """ Callback function for handing window resizing @param event: The current status of the event responsible for calling this method """ wx.LayoutAlgorithm().LayoutFrame(self)
def OnSize(self, event): width, height = self.GetSizeTuple() if self.BottomIsVisible: heightDocument = (height * (100 - self.bottomsize)) / 100 heightPrompt = (height * self.bottomsize) / 100 else: heightDocument = height heightPrompt = 0 if self.LeftIsVisible and self.RightIsVisible: w = (width * (100 - self.leftsize - self.rightsize)) / 100 elif self.LeftIsVisible: w = (width * (100 - self.leftsize)) / 100 elif self.RightIsVisible: w = (width * (100 - self.rightsize)) / 100 else: w = width wl = 0 wr = 0 if self.LeftIsVisible: wl = (width * self.leftsize) / 100 if self.RightIsVisible: wr = (width * self.rightsize) / 100 self.toptuple = (w, heightDocument) self.lefttuple = (wl, height) self.righttuple = (wr, height) self.bottomtuple = (w, heightPrompt) self.top.SetDefaultSize(self.toptuple) self.bottom.SetDefaultSize(self.bottomtuple) self.left.SetDefaultSize(self.lefttuple) self.right.SetDefaultSize(self.righttuple) wx.LayoutAlgorithm().LayoutWindow(self, self.top)
def __layout(self): ''' Handles UI layout. ''' sizer = wx.BoxSizer(wx.VERTICAL) vs = wx.BoxSizer(wx.VERTICAL) vs.Add(self.nameText, 0, wx.EXPAND | wx.ALL, 4) vs.Add(self.descriptionText, 0, wx.EXPAND | wx.ALL, 4) vs.Add(wx.StaticLine(self.panelTop, -1), 0, wx.EXPAND) vs.Add((5, 5)) vs.Add(self.partListCtrl, 2, wx.EXPAND | wx.ALL, 4) sizer.Add(vs, 1, wx.EXPAND | wx.ALL, 5) sizer2 = wx.BoxSizer(wx.VERTICAL) sizer2.Add(self.textCtrl, 1, wx.EXPAND | wx.ALL, 8) self.panelTop.SetSizer(sizer) sizer.Fit(self.panelTop) self.panelTop.SetAutoLayout(1) self.panelTop.Refresh() self.panelBottom.SetSizer(sizer2) sizer2.Fit(self.panelBottom) self.panelBottom.SetAutoLayout(1) self.panelBottom.Layout() wx.LayoutAlgorithm().LayoutWindow(self, self.panelTop)
def OnToggleWindow(self, event): self._leftWindow1.Show(not self._leftWindow1.IsShown()) # Leaves bits of itself behind sometimes wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh() event.Skip()
def OnSashDrag(self, e): #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if e.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return self.infowin.SetDefaultSize((e.GetDragRect().width, 1000)) wx.LayoutAlgorithm().LayoutMDIFrame(self) self.GetClientWindow().Refresh()
def OnSashDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return eobj = event.GetEventObject() self.leftWindow.SetMaximumSizeX(self.GetSize().width / 3) self.leftWindow.SetDefaultSize((event.GetDragRect().width, 1000)) wx.LayoutAlgorithm().LayoutWindow(self, self.rightWindow) self.rightWindow.Refresh()
def __init__(self, mashFrame,images): """Intialize.""" #--Data self.data = None self.counter = 0 #--Singleton global helpBrowser helpBrowser = self #--Window pos = conf.settings.get('mash.help.pos',(-1,-1)) size = conf.settings.get('mash.help.size',(400,600)) wx.Frame.__init__(self, mashFrame, -1, _('Help'), pos, size, style=wx.DEFAULT_FRAME_STYLE) self.SetBackgroundColour(wx.NullColour) self.SetSizeHints(250,250) #--Application Icons self.SetIcons(images['mash.icons2'].GetIconBundle()) #--Sizers mainSizer = wx.BoxSizer(wx.HORIZONTAL) sashPos = 250 if 'mash.help.sashPos' in conf.settings: sashPos = conf.settings['mash.help.sashPos'] left = self.left = leftSash(self,defaultSize=(sashPos,100), onSashDrag=self.OnSashDrag) right = self.right = wx.Panel(self,style=wx.NO_BORDER) self.htmlToc = TocHtmlWindow(left, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) self.htmlText = HelpPage(right, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) left.SetSizer(vSizer((self.htmlToc, 1, wx.GROW))) right.SetSizer(vSizer((self.htmlText, 1, wx.GROW|wx.ALIGN_RIGHT|wx.EXPAND))) mainSizer.Add(left,1,wx.GROW) mainSizer.Add(right,5,wx.GROW) #--Layout self.SetSizer(mainSizer) #--Events wx.EVT_CLOSE(self, self.OnCloseWindow) #--Content self.htmlToc.AddSelListener(self.htmlText.TocSelChanged) self.htmlText.SetTocObj(self.htmlToc) path = os.path.join(os.getcwd(), 'Wrye Mash.txt') txt = open(path).read() self.htmlText.SetHtmlData(txt) self.htmlToc.SetHtmlData(txt) wx.LayoutAlgorithm().LayoutWindow(self, right)
def doLayout(self): #wx.LayoutAlgorithm().LayoutWindow(self, self.panReportFront) #self.panReportFront.Refresh() #print 'lay out' if self: wx.LayoutAlgorithm().LayoutMDIFrame(self) self.GetClientWindow().Refresh() #print 'lay out1' return None
def OnSize(self, event): """ Sets correct column widths. """ wx.LayoutAlgorithm().LayoutWindow(self) w = self.partListCtrl.GetClientSize().width self.partListCtrl.SetColumnWidth(0, w * (0.50)) self.partListCtrl.SetColumnWidth(1, w * (0.50))
def layout(self): """ Called after a resize of the main or one of the subwindows if necessary """ if len(self.windowPropsList) == 0: return wx.LayoutAlgorithm().LayoutWindow( self.mainWindow, self.winNameToProxy[self.windowPropsList[0]["name"]])
def OnFoldPanelBarDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return if event.GetId() == self.ID_WINDOW_LEFT1: self._leftWindow1.SetDefaultSize( wx.Size(event.GetDragRect().width, 1000)) # Leaves bits of itself behind sometimes wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh() event.Skip()
def OnSashDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: print('drag is out of range') return eobj = event.GetEventObject() if isinstance(eobj, wx.SashLayoutWindow): print('event.GetDragRect()', event.GetDragRect().GetSize()) eobj.SetDefaultSize(event.GetDragRect().GetSize()) wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh()
def OnSashlayoutwindow1SashDragged(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return eID = event.GetId() if eID == wxID_WXMDIPARENTFRAME1SASHLAYOUTWINDOW1: self.sashLayoutWindow1.SetDefaultSize( wx.Size(event.GetDragRect().width, 0)) wx.LayoutAlgorithm().LayoutMDIFrame(self) self.GetClientWindow().Refresh()
def on_size(self, event=None): #print 'Mainframe.on_size' #self.tc.SetSize(self.GetSize()) #self.tc.SetSize(self.GetSize()) #self._viewtabs.SetSize(self.GetSize()) #pass #wx.LayoutAlgorithm().LayoutWindow(self, self.p1) #wx.LayoutAlgorithm().LayoutWindow(self, self.p1) # important: #wx.LayoutAlgorithm().LayoutWindow(self, self._viewtabs) wx.LayoutAlgorithm().LayoutWindow(self, self._splitter)
def OnSashDrag(self, event): #print "OnSashDrag: height=", event.GetDragRect().height (pW, pH) = self.parent.GetClientSize() #print "OnSashDrag: clientHeight=", pH eobj = event.GetEventObject() height = event.GetDragRect().height topWinHeight = max(30, min(pH - 30, height)) # Because bottomWin was created first, LayoutWindow doesn't care # about topWin's default size #self.topWin.SetDefaultSize((-1, topWinHeight)) self.bottomWin.SetDefaultSize((-1, pH - topWinHeight)) wx.LayoutAlgorithm().LayoutWindow(self, None)
def ToggleWorldWindow(self, dummy): if self.user_program.isRunning: return if self.rightWindow.isVisible: self.rightWindow.SetDefaultSize(wx.Size(0, 600)) self.rightWindow.isVisible = False else: self.rightWindow.SetDefaultSize(wx.Size(200, 600)) self.rightWindow.isVisible = True wx.LayoutAlgorithm().LayoutWindow(self.sash, self.WorldDisplay) self.rightWindow.DestroyChildren() # removes the old wx.StaticText wx.StaticText(self.rightWindow, -1, self.WorldDisplay.UpdateEditor(), (10, 10))
def OnFilterSizeButtonClick(self, event): size = self.bottomWindow.GetSize() self.expand = not self.expand if self.expand: size[1] = self.bottomWindow.GetMaximumSizeY() self.filtersizebutton.SetLabel(_('Filter') + ' <<') else: size[1] = self.bottomWindow.GetMinimumSizeY() self.filtersizebutton.SetLabel(_('Filter') + ' >>') self.bottomWindow.Show(self.expand) self.bottomWindow.SetSize(size) self.bottomWindow.SetDefaultSize(size) wx.LayoutAlgorithm().LayoutWindow(self, self.rightWindow) self.rightWindow.Refresh()
def OnSashDrag(self, event): ''' Called when a sash window has been dragged. ''' if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return id = event.GetId() if id == self.ID_WINDOW_TOP: self.topWindow.SetDefaultSize( wx.Size(1000, event.GetDragRect().height)) wx.LayoutAlgorithm().LayoutWindow(self)
def OnSashDrag(self, event): if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE: return eID = event.GetId() if eID == self.nametreeW_ID: self.treepanelW.SetDefaultSize((event.GetDragRect().width, 200)) elif eID == self.profileW_ID: self.profilepanelW.SetDefaultSize((event.GetDragRect().width, 200)) elif eID == self.logW_ID: print "logW_ID", self.logW_ID self.logW.SetDefaultSize((1000, event.GetDragRect().height)) wx.LayoutAlgorithm().LayoutMDIFrame(self) self.GetClientWindow().Refresh()
def OnSashDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return eID = event.GetId() if eID == ID_WINDOW_TOP: self.topWindow.SetDefaultSize((1000, event.GetDragRect().height)) elif eID == ID_WINDOW_LEFT1: self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000)) elif eID == ID_WINDOW_LEFT2: self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000)) elif eID == ID_WINDOW_BOTTOM: self.bottomWindow.SetDefaultSize((1000, event.GetDragRect().height)) wx.LayoutAlgorithm().LayoutMDIFrame(self) self.GetClientWindow().Refresh()
def AddInitParticipant(self, pDesc): """ Add a participant to the list. Initially done when connecting to a service. No event message is displayed. """ # Ignore participants without client profile (a monitor for example) if pDesc.clientProfile == "None" or pDesc.clientProfile == None: return idx = self.partListCtrl.GetItemCount() self.idToProfile[idx] = pDesc self.profileToId[pDesc.appId] = idx self.partListCtrl.InsertStringItem(idx, pDesc.clientProfile.name) self.partListCtrl.SetStringItem(idx, 1, pDesc.status) self.partListCtrl.SetItemData(idx, idx) wx.LayoutAlgorithm().LayoutWindow(self)
def OnSashDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return eID = event.GetId() if eID == self.ID_WINDOW_TOP: self.topWindow.SetDefaultSize( wx.Size(800, event.GetDragRect().height)) elif eID == self.ID_WINDOW_RIGHT: self.grand_parent.rightWindow.SetDefaultSize( wx.Size(event.GetDragRect().width, 600)) elif eID == self.ID_WINDOW_LEFT: self.leftWindow.SetDefaultSize( wx.Size(event.GetDragRect().width, 600)) elif eID == self.ID_WINDOW_BOTTOM: self.bottomWindow.SetDefaultSize( wx.Size(800, event.GetDragRect().height)) wx.LayoutAlgorithm().LayoutWindow(self, self.grand_parent.WorldDisplay) self.grand_parent.WorldDisplay.Refresh()
def OnSashDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: self.log.write('drag is out of range') return eobj = event.GetEventObject() if eobj is self.controlsWindow: self.controlsWindow.SetDefaultSize( (event.GetDragRect().width, 1000)) elif eobj is self.resultsWindow: self.resultsWindow.SetDefaultSize( (event.GetDragRect().width, 1000)) wx.LayoutAlgorithm().LayoutWindow(self, self.resultsWindow) #self.controlsWindow.Layout() self.resultsWindow.Refresh() x = self.scrolledPanel.GetSize()[0] y = self.GetSize()[1] self.scrolledPanel.SetSize((x, y)) print "sash dragged", (x, y)
def OnSize(self, event): wx.LayoutAlgorithm().LayoutWindow(self, self.rightWindow) self.bottomWindow.Refresh() self.bottomWindow.Layout() event.Skip()
def OnSashDrag(self, event): eobj = event.GetEventObject() if eobj is self.rightWindow: self.rightWindow.SetDefaultSize((event.GetDragRect().width, 600)) wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh()
def OnSize(self, event): wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)