Python PySide.QtGui.QDialog() Examples
The following are 30
code examples of PySide.QtGui.QDialog().
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: gui.py From autopilot with Mozilla Public License 2.0 | 6 votes |
def __init__(self): QtGui.QDialog.__init__(self) self.protocol_dir = prefs.PROTOCOLDIR tabWidget = QtGui.QTabWidget() self.bio_tab = self.Biography_Tab() tabWidget.addTab(self.bio_tab, "Biography") if self.protocol_dir: self.task_tab = self.Task_Tab() tabWidget.addTab(self.task_tab, "Protocol") buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(tabWidget) mainLayout.addWidget(buttonBox) self.setLayout(mainLayout) self.setWindowTitle("Setup New Subject")
Example #2
Source File: VariablesLib.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 6 votes |
def __init__(self): super(addVariable,self).__init__() self.UI = QtGui.QDialog() self.drawUI() self.allowedProperties = [ 'App::PropertyBool', 'App::PropertyBoolList', 'App::PropertyInteger', 'App::PropertyIntegerList', 'App::PropertyFloat', 'App::PropertyFloatList', 'App::PropertyString', 'App::PropertyEnumeration', #'App::PropertyLink', 'App::PropertyXLink', 'App::PropertyVector', 'App::PropertyMatrix', 'App::PropertyPlacement', 'App::PropertyColor', 'App::PropertyFile']
Example #3
Source File: universal_tool_template_v7.3.py From universal_tool_template.py with MIT License | 6 votes |
def setupWin(self): self.setWindowTitle("TMP_UniversalToolUI_TND" + " - v" + self.version) self.setGeometry(300, 300, 800, 600) # win icon setup path = os.path.join(os.path.dirname(self.location),'icons','TMP_UniversalToolUI_TND.png') self.setWindowIcon(QtGui.QIcon(path)) # initial win drag position self.drag_position=QtGui.QCursor.pos() #self.resize(250,250) # - for frameless or always on top option #self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # it will keep ui always on top of desktop, but to set this in Maya, dont set Maya as its parent #self.setWindowFlags(QtCore.Qt.FramelessWindowHint) # it will hide ui border frame, but in Maya, use QDialog instead as QMainWindow will disappear #self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) # best for Maya case with QDialog without parent, for always top frameless ui # - for transparent and non-regular shape ui #self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # use it if you set main ui to transparent and want to use alpha png as irregular shape window #self.setStyleSheet("background-color: rgba(0, 0, 0,0);") # black color better white color for get better look of semi trans edge, like pre-mutiply
Example #4
Source File: UITranslator_v1.0.py From universal_tool_template.py with MIT License | 6 votes |
def setupWin(self): self.setWindowTitle("UITranslator" + " - v" + self.version) self.setGeometry(300, 300, 300, 300) # win icon setup path = os.path.join(os.path.dirname(self.location),'icons','UITranslator.png') self.setWindowIcon(QtGui.QIcon(path)) # initial win drag position self.drag_position=QtGui.QCursor.pos() #self.resize(250,250) # - for frameless or always on top option #self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # it will keep ui always on top of desktop, but to set this in Maya, dont set Maya as its parent #self.setWindowFlags(QtCore.Qt.FramelessWindowHint) # it will hide ui border frame, but in Maya, use QDialog instead as QMainWindow will disappear #self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) # best for Maya case with QDialog without parent, for always top frameless ui # - for transparent and non-regular shape ui #self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # use it if you set main ui to transparent and want to use alpha png as irregular shape window #self.setStyleSheet("background-color: rgba(0, 0, 0,0);") # black color better white color for get better look of semi trans edge, like pre-mutiply
Example #5
Source File: AnimationLib.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self): super(animateVariable,self).__init__() self.UI = QtGui.QDialog() self.drawUI()
Example #6
Source File: PySimulator.py From PySimulator with GNU Lesser General Public License v3.0 | 5 votes |
def showAbout(self): widget = QtGui.QDialog(self) widget.setWindowTitle("About PySimulator") p = QtGui.QPalette() p.setColor(QtGui.QPalette.Background, QtGui.QColor("white")) widget.setPalette(p) layout = QtGui.QGridLayout(widget) widget.setLayout(layout) pixmap = QtGui.QPixmap(self.rootDir + "/Icons/dlr-splash.png") iconLabel = QtGui.QLabel() iconLabel.setPixmap(pixmap) layout.addWidget(iconLabel, 0, 0) layout.addWidget(QtGui.QLabel("Copyright (C) 2011-2015 German Aerospace Center DLR (Deutsches Zentrum fuer Luft- und Raumfahrt e.V.),\nInstitute of System Dynamics and Control. All rights reserved.\n\nPySimulator is free software: You can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nPySimulator is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with PySimulator. If not, see www.gnu.org/licenses."), 1, 0) layout.addWidget(QtGui.QLabel("PySimulator Version: " + str(version)), 2, 0) button = QtGui.QPushButton("OK") button.clicked.connect(widget.close) layout.addWidget(button, 3, 0) widget.show()
Example #7
Source File: plotWidget.py From PySimulator with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.setWindowTitle("Set Selection") layout = QtGui.QGridLayout(self) self.setLayout(layout) self.minIn = QtGui.QLineEdit(self) layout.addWidget(QtGui.QLabel("Min: "), 0, 0) layout.addWidget(self.minIn, 0, 1) self.maxIn = QtGui.QLineEdit(self) layout.addWidget(QtGui.QLabel("Max: "), 1, 0) layout.addWidget(self.maxIn, 1, 1) done = QtGui.QPushButton("Done", self) done.clicked.connect(self.selectionDone) layout.addWidget(done)
Example #8
Source File: gui.py From autopilot with Mozilla Public License 2.0 | 5 votes |
def __init__(self): # type: () -> None QtGui.QDialog.__init__(self) # Sound type dropdown type_label = QtGui.QLabel("Sound Type:") self.type_selection = QtGui.QComboBox() self.type_selection.insertItems(0, sounds.SOUND_LIST.keys()) self.type_selection.currentIndexChanged.connect(self.populate_params) # Param form self.param_layout = QtGui.QFormLayout() # Button box buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) # Layout layout = QtGui.QVBoxLayout() layout.addWidget(type_label) layout.addWidget(self.type_selection) layout.addLayout(self.param_layout) layout.addWidget(buttonBox) self.setLayout(layout) # dict for storing params self.param_dict = {}
Example #9
Source File: universal_tool_template_1010.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self, layout='grid'): #------------------------------ # main_layout auto creation for holding all the UI elements #------------------------------ main_layout = None if isinstance(self, QtWidgets.QMainWindow): main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size main_widget.setLayout(main_layout) else: # main_layout for QDialog main_layout = self.quickLayout(layout, 'main_layout') self.setLayout(main_layout)
Example #10
Source File: universal_tool_template_v7.3.py From universal_tool_template.py with MIT License | 5 votes |
def __init__(self, parent=None, mode=0): QtGui.QMainWindow.__init__(self, parent) #QtGui.QDialog.__init__(self, parent) self.version="0.1" self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.fileType='.TMP_UniversalToolUI_TND_EXT' # mode: example for receive extra user input as parameter self.mode = 0 if mode in [0,1]: self.mode = mode # mode validator self.location = "" if getattr(sys, 'frozen', False): # frozen - cx_freeze self.location = sys.executable else: # unfrozen self.location = os.path.realpath(__file__) # location: ref: sys.modules[__name__].__file__ #~~~~~~~~~~~~~~~~~~ # initial data #~~~~~~~~~~~~~~~~~~ self.memoData['data']=[] self.setupStyle() self.setupMenu() # only if you use QMainWindows Class self.setupWin() self.setupUI() self.Establish_Connections() self.loadData() self.loadLang()
Example #11
Source File: universal_tool_template_1000.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self, layout='grid'): #------------------------------ # main_layout auto creation for holding all the UI elements #------------------------------ main_layout = None if isinstance(self, QtWidgets.QMainWindow): main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size main_widget.setLayout(main_layout) else: # main_layout for QDialog main_layout = self.quickLayout(layout, 'main_layout') self.setLayout(main_layout)
Example #12
Source File: universal_tool_template_0904.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self, layout='grid'): #------------------------------ # main_layout auto creation for holding all the UI elements #------------------------------ main_layout = None if isinstance(self, QtWidgets.QMainWindow): main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size main_widget.setLayout(main_layout) else: # main_layout for QDialog main_layout = self.quickLayout(layout, 'main_layout') self.setLayout(main_layout)
Example #13
Source File: universal_tool_template_0803.py From universal_tool_template.py with MIT License | 5 votes |
def setupWin(self): self.setWindowTitle(self.name + " - v" + self.version + " - host: " + hostMode) self.setWindowIcon(self.icon) # initial win drag position self.drag_position=QtGui.QCursor.pos() self.setGeometry(500, 300, 250, 110) # self.resize(250,250) #------------------------------ # template list: for frameless or always on top option #------------------------------ # - template : keep ui always on top of all; # While in Maya, dont set Maya as its parent ''' self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) ''' # - template: hide ui border frame; # While in Maya, use QDialog instead, as QMainWindow will make it disappear ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint) ''' # - template: best solution for Maya QDialog without parent, for always on-Top frameless ui ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) ''' # - template: for transparent and non-regular shape ui # note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window # note: black color better than white for better look of semi trans edge, like pre-mutiply ''' self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setStyleSheet("background-color: rgba(0, 0, 0,0);") ''' ############################################# # customized SUPER quick ui function for speed up programming #############################################
Example #14
Source File: universal_tool_template_0903.py From universal_tool_template.py with MIT License | 5 votes |
def setupWin(self): super(self.__class__,self).setupWin() self.setGeometry(500, 300, 250, 110) # self.resize(250,250) #------------------------------ # template list: for frameless or always on top option #------------------------------ # - template : keep ui always on top of all; # While in Maya, dont set Maya as its parent ''' self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) ''' # - template: hide ui border frame; # While in Maya, use QDialog instead, as QMainWindow will make it disappear ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint) ''' # - template: best solution for Maya QDialog without parent, for always on-Top frameless ui ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) ''' # - template: for transparent and non-regular shape ui # note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window # note: black color better than white for better look of semi trans edge, like pre-mutiply ''' self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setStyleSheet("background-color: rgba(0, 0, 0,0);") '''
Example #15
Source File: universal_tool_template_0903.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self): #------------------------------ # main_layout auto creation for holding all the UI elements #------------------------------ main_layout = None if isinstance(self, QtWidgets.QMainWindow): main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size main_widget.setLayout(main_layout) else: # main_layout for QDialog main_layout = self.quickLayout('vbox', 'main_layout') self.setLayout(main_layout)
Example #16
Source File: UITranslator.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self): #------------------------------ # main_layout auto creation for holding all the UI elements #------------------------------ main_layout = None if isinstance(self, QtWidgets.QMainWindow): main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size main_widget.setLayout(main_layout) else: # main_layout for QDialog main_layout = self.quickLayout('vbox', 'main_layout') self.setLayout(main_layout) #------------------------------ # user ui creation part #------------------------------ # + template: qui version since universal tool template v7 # - no extra variable name, all text based creation and reference self.qui('dict_table | source_txtEdit | result_txtEdit','info_split;v') self.qui('filePath_input | fileLoad_btn;Load | fileLang_choice | fileExport_btn;Export', 'fileBtn_layout;hbox') self.qui('info_split | process_btn;Process and Update Memory From UI | fileBtn_layout', 'main_layout') self.uiList["source_txtEdit"].setWrap(0) self.uiList["result_txtEdit"].setWrap(0) #------------- end ui creation -------------------- for name,each in self.uiList.items(): if isinstance(each, QtWidgets.QLayout) and name!='main_layout' and not name.endswith('_grp_layout'): each.setContentsMargins(0,0,0,0) # clear extra margin some nested layout #self.quickInfo('Ready')
Example #17
Source File: UITranslator_v1.0.py From universal_tool_template.py with MIT License | 5 votes |
def __init__(self, parent=None, mode=0): QtGui.QMainWindow.__init__(self, parent) #QtGui.QDialog.__init__(self, parent) self.version="1.0" self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.fileType='.UITranslator_EXT' # mode: example for receive extra user input as parameter self.mode = 0 if mode in [0,1]: self.mode = mode # mode validator self.location = "" if getattr(sys, 'frozen', False): # frozen - cx_freeze self.location = sys.executable else: # unfrozen self.location = os.path.realpath(__file__) # location: ref: sys.modules[__name__].__file__ self.setupStyle() self.setupMenu() # only if you use QMainWindows Class self.setupWin() self.setupUI() self.Establish_Connections() self.loadData() self.loadLang()
Example #18
Source File: QtShim.py From grap with MIT License | 5 votes |
def get_QDialog(): """QDialog getter.""" try: import PySide.QtGui as QtGui return QtGui.QDialog except ImportError: import PyQt5.QtWidgets as QtWidgets return QtWidgets.QDialog
Example #19
Source File: GearBox_template_1010.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self, layout='grid'): #------------------------------ # main_layout auto creation for holding all the UI elements #------------------------------ main_layout = None if isinstance(self, QtWidgets.QMainWindow): main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size main_widget.setLayout(main_layout) else: # main_layout for QDialog main_layout = self.quickLayout(layout, 'main_layout') self.setLayout(main_layout)
Example #20
Source File: HelpCmd.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self): super(Asm4Help,self).__init__() self.UI = QtGui.QDialog() self.drawUI()
Example #21
Source File: VariablesLib.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 5 votes |
def __init__(self): super(delVariable,self).__init__() self.UI = QtGui.QDialog() self.drawUI()
Example #22
Source File: makeBomCmd.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 5 votes |
def drawUI(self): # Our main window will be a QDialog self.UI.setWindowTitle('Parts List / BOM') self.UI.setWindowIcon( QtGui.QIcon( os.path.join( Asm4.iconPath , 'FreeCad.svg' ) ) ) self.UI.setWindowFlags( QtCore.Qt.WindowStaysOnTopHint ) self.UI.setModal(False) # set main window widgets layout self.mainLayout = QtGui.QVBoxLayout(self.UI) # The list, is a plain text field self.BOM = QtGui.QPlainTextEdit() self.BOM.setMinimumSize(600,500) self.BOM.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap) self.mainLayout.addWidget(self.BOM) # the button row definition self.buttonLayout = QtGui.QHBoxLayout() self.buttonLayout.addStretch() # Save button self.CopyButton = QtGui.QPushButton('Copy') self.buttonLayout.addWidget(self.CopyButton) # Save button #self.SaveButton = QtGui.QPushButton('Save') #self.buttonLayout.addWidget(self.SaveButton) # OK button self.OkButton = QtGui.QPushButton('Close') self.OkButton.setDefault(True) self.buttonLayout.addWidget(self.OkButton) self.mainLayout.addLayout(self.buttonLayout) # finally, apply the layout to the main window self.UI.setLayout(self.mainLayout) # Actions self.CopyButton.clicked.connect(self.onCopy) #self.SaveButton.clicked.connect(self.onSave) self.OkButton.clicked.connect(self.onOK) # add the command to the workbench
Example #23
Source File: makeBomCmd.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 5 votes |
def Activated(self): self.UI = QtGui.QDialog() # get the current active document to avoid errors if user changes tab self.modelDoc = App.ActiveDocument self.model = self.modelDoc.Model self.drawUI() self.UI.show() self.BOM.clear() self.PartsList = '' self.listParts(self.model) self.BOM.setPlainText(self.PartsList)
Example #24
Source File: FMU.py From PySimulator with GNU Lesser General Public License v3.0 | 4 votes |
def Settings(model, gui): class SettingsControl(QtGui.QDialog): ''' Class for the Settings Control GUI ''' def __init__(self): QtGui.QDialog.__init__(self) self.setModal(False) self.setWindowTitle("FMU Settings") _mainGrid = QtGui.QGridLayout(self) _ImportFMU = QtGui.QGroupBox("Importing FMUs", self) _mainGrid.addWidget(_ImportFMU, 0, 0, 1, 3) _ImportFMULayout = QtGui.QGridLayout() _ImportFMU.setLayout(_ImportFMULayout) _ImportFMULayout.addWidget(QtGui.QLabel("Default FMI type:"), 0, 0) self.me = QtGui.QRadioButton("Model Exchange", self) _ImportFMULayout.addWidget(self.me, 0, 1) self.me.toggled.connect(self.changeToME) self.cs = QtGui.QRadioButton("CoSimulation", self) _ImportFMULayout.addWidget(self.cs, 0, 2) self.cs.toggled.connect(self.changeToCS) _ImportFMULayout.addWidget(QtGui.QLabel("The default FMI type will be used, if an FMU containing"), 1, 0, 1, 3) _ImportFMULayout.addWidget(QtGui.QLabel("both Model Exchange and CoSimulation models is opened."), 2, 0, 1, 3) self.closeButton = QtGui.QPushButton("Close", self) _mainGrid.addWidget(self.closeButton, 1, 1) self.closeButton.clicked.connect(self.close) if not gui.config['Plugins']['FMU'].has_key('importType'): gui.config['Plugins']['FMU']['importType'] = 'me' gui.config.write() if gui.config['Plugins']['FMU']['importType'] == 'me': self.me.setChecked(True) else: self.cs.setChecked(True) def changeToCS(self): gui.config['Plugins']['FMU']['importType'] = 'cs' gui.config.write() def changeToME(self): gui.config['Plugins']['FMU']['importType'] = 'me' gui.config.write() # Code of function gui.FMUSettingscontrol = SettingsControl() gui.FMUSettingscontrol.show()
Example #25
Source File: exportPartToVRML.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 4 votes |
def determineColors(Gui, objects, know_material_substitutions=None): global ui if know_material_substitutions is None: know_material_substitutions={} Dialog = QtGui.QDialog() ui = Ui_Dialog() ui.setupUi(Dialog) #ui.comboBox.addItems(["as is"]+shaderColors.named_colors.keys()) ui.comboBox.addItems(["as is"]+list(shaderColors.named_colors)) material="as is" objs = [] for obj in objects: freecad_object = Gui.ActiveDocument.getObject(obj.Name) face_colors = [] for color in freecad_object.DiffuseColor: color = color[:-1] if color not in know_material_substitutions: #say(color) pal = QtGui.QPalette() bgc = QtGui.QColor(color[0]*255, color[1]*255, color[2]*255) pal.setColor(QtGui.QPalette.Base, bgc) ui.plainTextEdit.viewport().setPalette(pal) #ui.comboBox.addItems(color_list) reply=Dialog.exec_() #Dialog.exec_() #say(reply) if reply==1: retval = str(ui.comboBox.currentText()) if retval == "as is": material = color else: material = retval else: #material="as is" material=color know_material_substitutions.update({color:material}) #say(material) face_colors.append(material) else: face_colors.append(know_material_substitutions[color]) objs.append(exportObject(freecad_object = obj, shape_color=face_colors[0], face_colors=face_colors)) return (objs, getNamedColors(know_material_substitutions.values()))
Example #26
Source File: exportPartToVRML.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 4 votes |
def determineColors(Gui, objects, know_material_substitutions=None): global ui if know_material_substitutions is None: know_material_substitutions={} Dialog = QtGui.QDialog() ui = Ui_Dialog() ui.setupUi(Dialog) ui.comboBox.addItems(["as is"]+shaderColors.named_colors.keys()) material="as is" objs = [] for obj in objects: freecad_object = Gui.ActiveDocument.getObject(obj.Name) face_colors = [] for color in freecad_object.DiffuseColor: color = color[:-1] if color not in know_material_substitutions: say(color) pal = QtGui.QPalette() bgc = QtGui.QColor(color[0]*255, color[1]*255, color[2]*255) pal.setColor(QtGui.QPalette.Base, bgc) ui.plainTextEdit.viewport().setPalette(pal) #ui.comboBox.addItems(color_list) reply=Dialog.exec_() #Dialog.exec_() #say(reply) if reply==1: retval = str(ui.comboBox.currentText()) if retval == "as is": material = color else: material = retval else: #material="as is" material=color know_material_substitutions.update({color:material}) #say(material) face_colors.append(material) else: face_colors.append(know_material_substitutions[color]) objs.append(exportObject(freecad_object = obj, shape_color=face_colors[0], face_colors=face_colors)) return (objs, getNamedColors(know_material_substitutions.values()))
Example #27
Source File: HelpCmd.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 4 votes |
def drawUI(self): # Our main window will be a QDialog self.UI.setWindowTitle('Help for FreeCAD and Assembly4') self.UI.setWindowIcon( QtGui.QIcon( os.path.join( Asm4.iconPath , 'FreeCad.svg' ) ) ) self.UI.setWindowFlags( QtCore.Qt.WindowStaysOnTopHint ) self.UI.setMinimumSize(600, 600) self.UI.setModal(False) # set main window widgets layout self.mainLayout = QtGui.QVBoxLayout(self.UI) # FreeCAD version info FCmajor = App.ConfigGet('ExeVersion') FCminor = App.ConfigGet('BuildRevision') FCversion = FCmajor+'-'+FCminor self.mainLayout.addWidget(QtGui.QLabel('FreeCAD version : \t'+FCversion)) # Assembly4 version info versionPath = os.path.join( Asm4.wbPath, 'VERSION' ) versionFile = open(versionPath,"r") Asm4version = versionFile.readlines()[1] versionFile.close() self.mainLayout.addWidget(QtGui.QLabel('Assembly4 version : \t'+Asm4version)) # Help text self.helpSource = QtGui.QTextBrowser() self.helpSource.setSearchPaths( [os.path.join( Asm4.wbPath, 'Resources' )] ) self.helpSource.setSource( 'Asm4_Help.html' ) self.mainLayout.addWidget(self.helpSource) self.mainLayout.addWidget(QtGui.QLabel(' ')) # the button row definition self.buttonLayout = QtGui.QHBoxLayout() self.buttonLayout.addStretch() # OK button self.OkButton = QtGui.QPushButton('OK') self.OkButton.setDefault(True) self.buttonLayout.addWidget(self.OkButton) self.mainLayout.addLayout(self.buttonLayout) # finally, apply the layout to the main window self.UI.setLayout(self.mainLayout) # Actions self.OkButton.clicked.connect(self.onOK)
Example #28
Source File: universal_tool_template_v8.1.py From universal_tool_template.py with MIT License | 4 votes |
def setupWin(self): self.setWindowTitle("UniversalToolUI" + " - v" + self.version + " - host: " + hostMode) self.setGeometry(500, 300, 250, 110) # self.resize(250,250) #------------------------------ # auto window icon setup path = os.path.join(os.path.dirname(self.location),'icons','UniversalToolUI.png') self.setWindowIcon(QtGui.QIcon(path)) #------------------------------ # initial win drag position self.drag_position=QtGui.QCursor.pos() #------------------------------ # template list: for frameless or always on top option #------------------------------ # - template : keep ui always on top of all; # While in Maya, dont set Maya as its parent ''' self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) ''' # - template: hide ui border frame; # While in Maya, use QDialog instead, as QMainWindow will make it disappear ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint) ''' # - template: best solution for Maya QDialog without parent, for always on-Top frameless ui ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) ''' # - template: for transparent and non-regular shape ui # note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window # note: black color better than white for better look of semi trans edge, like pre-mutiply ''' self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setStyleSheet("background-color: rgba(0, 0, 0,0);") ''' ############################################# # customized SUPER quick ui function for speed up programming #############################################
Example #29
Source File: universal_tool_template_v7.3.py From universal_tool_template.py with MIT License | 4 votes |
def setupUI(self): #============================== # main_layout for QMainWindow main_widget = QtGui.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size main_widget.setLayout(main_layout) ''' # main_layout for QDialog main_layout = self.quickLayout('vbox', 'main_layout') self.setLayout(main_layout) ''' #------------------------------ # ui element creation part # quickUI version from universal tool template v6 ''' upper_layout = self.quickUI(["source_txtEdit;LNTextEdit","process_btn;QPushButton;Process and Update"],"upper_QVBoxLayout") upper_layout.setContentsMargins(0,0,0,0) input_split = self.quickSplitUI("input_split", [ upper_layout, self.quickUI(["result_txtEdit;LNTextEdit"])[0] ], "v") fileBtn_layout = self.quickUI(["filePath_input;QLineEdit", "fileLoad_btn;QPushButton;Load", "fileExport_btn;QPushButton;Export"],"fileBtn_QHBoxLayout") self.quickUI([input_split, fileBtn_layout], main_layout) self.uiList["source_txtEdit"].setWrap(0) self.uiList["result_txtEdit"].setWrap(0) ''' #------------------------------ # qui version from template 7 # no extra variable name, all text based creation and reference self.qui('source_txtEdit | process_btn;Process and Update', 'upper_vbox') self.qui('upper_vbox | result_txtEdit', 'input_split;v') self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox') self.qui('input_split | fileBtn_layout', 'main_layout') self.uiList["source_txtEdit"].setWrap(0) self.uiList["result_txtEdit"].setWrap(0) ''' self.uiList['secret_btn'] = QtGui.QPushButton(self) # invisible but functional button self.uiList['secret_btn'].setText("") self.uiList['secret_btn'].setGeometry(0, 0, 50, 20) self.uiList['secret_btn'].setStyleSheet("QPushButton{background-color: rgba(0, 0, 0,0);} QPushButton:pressed{background-color: rgba(0, 0, 0,0); border: 0px;} QPushButton:hover{background-color: rgba(0, 0, 0,0); border: 0px;}") #:hover:pressed:focus:hover:disabled ''' #------------- end ui creation -------------------- for name,each in self.uiList.items(): if isinstance(each, QtGui.QLayout) and name!='main_layout' and not name.endswith('_grp_layout'): each.setContentsMargins(0,0,0,0) self.quickInfo('Ready')
Example #30
Source File: VariablesLib.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 4 votes |
def drawUI(self): # Our main window will be a QDialog # make this dialog stay above the others, always visible self.UI.setWindowFlags( QtCore.Qt.WindowStaysOnTopHint ) self.UI.setWindowTitle('Add Variable') self.UI.setWindowIcon( QtGui.QIcon( os.path.join( Asm4.iconPath , 'FreeCad.svg' ) ) ) self.UI.setMinimumWidth(470) self.UI.resize(470,300) self.UI.setModal(False) # the layout for the main window is vertical (top to down) self.mainLayout = QtGui.QVBoxLayout(self.UI) # Define the fields for the form ( label + widget ) self.formLayout = QtGui.QFormLayout() # Variable Type, combobox showing all available App::PropertyType self.typeList = QtGui.QComboBox() self.formLayout.addRow(QtGui.QLabel('Type'),self.typeList) # Variable Name self.varName = QtGui.QLineEdit() self.formLayout.addRow(QtGui.QLabel('Name'),self.varName) # Variable Value self.varValue = QtGui.QDoubleSpinBox() self.varValue.setRange( -1000000.0, 1000000.0 ) self.formLayout.addRow(QtGui.QLabel('Value'),self.varValue) # Documentation self.description = QtGui.QTextEdit() self.formLayout.addRow(QtGui.QLabel('Description'),self.description) # apply the layout self.mainLayout.addLayout(self.formLayout) self.mainLayout.addStretch() # Buttons self.buttonLayout = QtGui.QHBoxLayout() # Cancel button self.CancelButton = QtGui.QPushButton('Cancel') # OK button self.OkButton = QtGui.QPushButton('OK') self.OkButton.setDefault(True) # the button layout self.buttonLayout.addWidget(self.CancelButton) self.buttonLayout.addStretch() self.buttonLayout.addWidget(self.OkButton) self.mainLayout.addLayout(self.buttonLayout) # finally, apply the layout to the main window self.UI.setLayout(self.mainLayout) # Actions self.CancelButton.clicked.connect(self.onCancel) self.OkButton.clicked.connect(self.onOK)