Python PySide.QtGui.QMdiArea() Examples
The following are 8
code examples of PySide.QtGui.QMdiArea().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PySide.QtGui
, or try the search function
.
Example #1
Source File: Shared.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def clearActiveDocument(): """Clears the currently active 3D view so that we can re-render""" # Grab our code editor so we can interact with it mw = FreeCADGui.getMainWindow() mdi = mw.findChild(QtGui.QMdiArea) currentWin = mdi.currentSubWindow() if currentWin == None: return winName = currentWin.windowTitle().split(" ")[0].split('.')[0] # Translate dashes so that they can be safetly used since theyare common if '-' in winName: winName= winName.replace('-', "__") try: doc = FreeCAD.getDocument(winName) # Make sure we have an active document to work with if doc is not None: for obj in doc.Objects: doc.removeObject(obj.Name) except: pass
Example #2
Source File: Shared.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def closeActiveCodeWindow(): mw = FreeCADGui.getMainWindow() mdi = mw.findChild(QtGui.QMdiArea) # We cannot trust the current subwindow to be a script window, it may be the associated 3D view mdiWin = mdi.currentSubWindow() # We have a 3D view selected so we need to find the corresponding script window if mdiWin == 0 or ".py" not in mdiWin.windowTitle(): subList = mdi.subWindowList() for sub in subList: if sub.windowTitle() == mdiWin.windowTitle().split(" ")[0] + ".py": sub.close() return mdiWin.close()
Example #3
Source File: Shared.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def setActiveWindowTitle(title): """Sets the title of the currently active MDI window, as long as it is a scripting window""" mw = FreeCADGui.getMainWindow() mdi = mw.findChild(QtGui.QMdiArea) # We cannot trust the current subwindow to be a script window, it may be the associated 3D view mdiWin = mdi.currentSubWindow() if mdiWin == 0 or ".py" not in mdiWin.windowTitle(): subList = mdi.subWindowList() for sub in subList: if sub.windowTitle() == mdiWin.windowTitle() + ".py": mdiWin = sub # Change the window title if there is something there to change if (mdiWin != 0): mdiWin.setWindowTitle(title) cqCodePane = mdiWin.findChild(QtGui.QPlainTextEdit) cqCodePane.setObjectName("cqCodePane_" + title.split('.')[0])
Example #4
Source File: a2p_importpart.py From A2plus with GNU Lesser General Public License v2.1 | 5 votes |
def Activated(self): doc = FreeCAD.activeDocument() try: doc.save() FreeCAD.closeDocument(doc.Name) except: FreeCADGui.SendMsgToActiveView("Save") if not FreeCADGui.activeDocument().Modified: # user really saved the file FreeCAD.closeDocument(doc.Name) # mw = FreeCADGui.getMainWindow() mdi = mw.findChild(QtGui.QMdiArea) sub = mdi.activeSubWindow() if sub != None: sub.showMaximized()
Example #5
Source File: vfpfunc.py From vfp2py with MIT License | 5 votes |
def __init__(self): super(type(self), self).__init__() self.mdiarea = QtGui.QMdiArea() self.mdiarea.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding); self.setCentralWidget(self.mdiarea)
Example #6
Source File: Shared.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def getActiveCodePane(): """Gets the currently active code pane, even if its 3D view is selected.""" # Grab our code editor so we can interact with it mw = FreeCADGui.getMainWindow() mdi = mw.findChild(QtGui.QMdiArea) # If our current subwindow doesn't contain a script, we need to find the one that does mdiWin = mdi.currentSubWindow() if mdiWin == None: return None # We need to warn the caller that there is no code pane windowTitle = mdiWin.windowTitle() if mdiWin == 0 or ".py" not in mdiWin.windowTitle(): if '__' in mdiWin.windowTitle(): windowTitle = mdiWin.windowTitle().replace("__", '-') subList = mdi.subWindowList() for sub in subList: if sub.windowTitle() == windowTitle.split(" ")[0] + ".py": mdiWin = sub winName = mdiWin.windowTitle().split('.')[0] cqCodePane = mw.findChild(QtGui.QPlainTextEdit, "cqCodePane_" + winName) return cqCodePane
Example #7
Source File: ImportCQ.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 4 votes |
def open(filename): #All of the CQGui.* calls in the Python console break after opening if we don't do this FreeCADGui.doCommand("import FreeCADGui as CQGui") # Make sure that we enforce a specific version (2.7) of the Python interpreter ver = hex(sys.hexversion) interpreter = "python%s.%s" % (ver[2], ver[4]) # => 'python2.7' # The extra version numbers won't work on Windows if sys.platform.startswith('win'): interpreter = 'python' # Set up so that we can import from our embedded packages module_base_path = module_locator.module_path() libs_dir_path = os.path.join(module_base_path, 'Libs') # Make sure we get the right libs under the FreeCAD installation fc_base_path = os.path.dirname(os.path.dirname(module_base_path)) fc_lib_path = os.path.join(fc_base_path, 'lib') #Getting the main window will allow us to find the children we need to work with mw = FreeCADGui.getMainWindow() # Grab just the file name from the path/file that's being executed docname = os.path.basename(filename) # Pull the font size from the FreeCAD-stored settings fontSize = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/cadquery-freecad-module").GetInt("fontSize") # Set up the code editor codePane = CodeEditor() codePane.setFont(QtGui.QFont('SansSerif', fontSize)) codePane.setObjectName("cqCodePane_" + os.path.splitext(os.path.basename(filename))[0]) mdi = mw.findChild(QtGui.QMdiArea) # add a code editor widget to the mdi area sub = mdi.addSubWindow(codePane) sub.setWindowTitle(docname) sub.setWindowIcon(QtGui.QIcon(':/icons/applications-python.svg')) sub.show() mw.update() #Pull the text of the CQ script file into our code pane codePane.open(filename) msg = QtGui.QApplication.translate( "cqCodeWidget", "Opened ", None) FreeCAD.Console.PrintMessage(msg + filename + "\r\n") return
Example #8
Source File: core.py From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 | 4 votes |
def getDrawingPageGUIVars(): ''' Get the FreeCAD window, graphicsScene, drawing page object, ... ''' # get the active window mw = QtGui.QApplication.activeWindow() MdiArea = [c for c in mw.children() if isinstance(c,QtGui.QMdiArea)][0] try: subWinMW = MdiArea.activeSubWindow().children()[3] except AttributeError: QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), notDrawingPage_title, notDrawingPage_msg ) raise ValueError(notDrawingPage_title) # The drawing 'page' is really a group in the model tree # The objectName for the group object is not the same as the name shown in # the model view, this is the 'Label' property, it *should* be unique. # To find the page we are on, we get all the pages which have the same label as # the current object. In theory there should therefore only be one page in the list # returned by getObjectsByLabel, so we'll just take the first in the list pages = App.ActiveDocument.getObjectsByLabel( encode_if_py2(subWinMW.objectName()) ) # raise an error explaining that the page wasn't found if the list is empty if len(pages) != 1: QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), notDrawingPage_title, notDrawingPage_msg ) raise ValueError(notDrawingPage_title) # get the page from the list page = pages[0] try: graphicsView = [ c for c in subWinMW.children() if isinstance(c,QtGui.QGraphicsView)][0] except IndexError: QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(), notDrawingPage_title, notDrawingPage_msg ) raise ValueError(notDrawingPage_title) graphicsScene = graphicsView.scene() pageRect = graphicsScene.items()[0] #hope this index does not change! width = pageRect.rect().width() height = pageRect.rect().height() #ViewResult has an additional tranform on it [VRT]. #if width > 1400: #then A3 # or == 1488 in FreeCAD v 0.15 # VRT_scale = width / 420.0 #VRT = view result transform, where 420mm is the width of an A3 page. #else: #assuming A4 # VRT_scale = width / 297.0 VRT_scale = 3.542 #i wonder where this number comes from VRT_ox = pageRect.rect().left() / VRT_scale VRT_oy = pageRect.rect().top() / VRT_scale transform = QtGui.QTransform() transform.translate(VRT_ox, VRT_oy) transform.scale(VRT_scale, VRT_scale) return DrawingPageGUIVars(locals())