Python PySide.QtGui.QWidget() Examples
The following are 30
code examples of PySide.QtGui.QWidget().
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: pyqt.py From mgear_core with MIT License | 6 votes |
def maya_main_window(): """Get Maya's main window Returns: QMainWindow: main window. """ main_window_ptr = omui.MQtUtil.mainWindow() return QtCompat.wrapInstance(long(main_window_ptr), QtWidgets.QWidget)
Example #2
Source File: universal_tool_template_1115.py From universal_tool_template.py with MIT License | 6 votes |
def quickMsg(self, msg, block=1): tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation tmpMsg.setWindowTitle("Info") lineCnt = len(msg.split('\n')) if lineCnt > 25: scroll = QtWidgets.QScrollArea() scroll.setWidgetResizable(1) content = QtWidgets.QWidget() scroll.setWidget(content) layout = QtWidgets.QVBoxLayout(content) tmpLabel = QtWidgets.QLabel(msg) tmpLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) layout.addWidget(tmpLabel) tmpMsg.layout().addWidget(scroll, 0, 0, 1, tmpMsg.layout().columnCount()) tmpMsg.setStyleSheet("QScrollArea{min-width:600 px; min-height: 400px}") else: tmpMsg.setText(msg) if block == 0: tmpMsg.setWindowModality( QtCore.Qt.NonModal ) tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole) if block: tmpMsg.exec_() else: tmpMsg.show()
Example #3
Source File: CountersunkHoles.py From FreeCAD_FastenersWB with GNU General Public License v2.0 | 6 votes |
def __init__(self, obj): self.object = obj if obj == None: self.baseObj = Gui.Selection.getSelection()[0] edgelist = [] else: edgelist = obj.diameters self.baseObj = obj.baseObject[0] Gui.ActiveDocument.getObject(obj.Name).Visibility = False Gui.ActiveDocument.getObject(self.baseObj.Name).Visibility = True FSFilletDialog = QtGui.QWidget() FSFilletDialog.ui = Ui_DlgCountersunktHoles() FSFilletDialog.ui.setupUi(FSFilletDialog) FreeCAD.Console.PrintLog(str(self.baseObj) + "\n") FSFilletDialog.ui.fillTable(FSFilletDialog, self.baseObj, edgelist) FSFilletDialog.ui.labelBaseObject.setText(self.baseObj.Name) FSFilletDialog.ui.model.itemChanged.connect(self.onItemChanged) self.form = FSFilletDialog self.form.setWindowTitle("Chamfer holes for countersunk screws") Gui.Selection.addSelectionGate(FSSelectionFilterGate) self.selobserver = FSSelObserver(self) Gui.Selection.addObserver(self.selobserver) self.RefreshSelection()
Example #4
Source File: IPythonConsole.py From pcloudpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, parent=None, App=None): super(IPythonConsole, self).__init__(parent) self.App = App self.console = EmbedIPython(App=self.App) self.console.kernel.shell.run_cell('%pylab qt') self.console.kernel.shell.run_cell("import numpy as np") self.console.kernel.shell.run_cell("from matplotlib import rcParams") self.console.kernel.shell.run_cell("rcParams['backend.qt4']='PySide'") self.console.kernel.shell.run_cell("import matplotlib.pyplot as plt") vbox = QtGui.QVBoxLayout() vbox.addWidget(self.console) b = QtGui.QWidget() b.setLayout(vbox) self.setCentralWidget(b)
Example #5
Source File: _compat.py From mGui with MIT License | 6 votes |
def _pyside_as_qt_object(widget): from PySide.QtCore import QObject from PySide.QtGui import QWidget from PySide import QtGui from shiboken import wrapInstance if hasattr(widget, '__qt_object__'): return widget.__qt_object__ ptr = _find_widget_ptr(widget) qobject = wrapInstance(long(ptr), QObject) meta = qobject.metaObject() _class = meta.className() _super = meta.superClass().className() qclass = getattr(QtGui, _class, getattr(QtGui, _super, QWidget)) return wrapInstance(long(ptr), qclass)
Example #6
Source File: _compat.py From mGui with MIT License | 6 votes |
def _pyside2_as_qt_object(widget): from PySide2.QtCore import QObject from PySide2.QtWidgets import QWidget from PySide2 import QtWidgets from shiboken2 import wrapInstance if hasattr(widget, '__qt_object__'): return widget.__qt_object__ ptr = _find_widget_ptr(widget) qobject = wrapInstance(long(ptr), QObject) meta = qobject.metaObject() _class = meta.className() _super = meta.superClass().className() qclass = getattr(QtWidgets, _class, getattr(QtWidgets, _super, QWidget)) return wrapInstance(long(ptr), qclass)
Example #7
Source File: universal_tool_template_1112.py From universal_tool_template.py with MIT License | 6 votes |
def quickMsg(self, msg, block=1): tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation tmpMsg.setWindowTitle("Info") lineCnt = len(msg.split('\n')) if lineCnt > 25: scroll = QtWidgets.QScrollArea() scroll.setWidgetResizable(1) content = QtWidgets.QWidget() scroll.setWidget(content) layout = QtWidgets.QVBoxLayout(content) layout.addWidget(QtWidgets.QLabel(msg)) tmpMsg.layout().addWidget(scroll, 0, 0, 1, tmpMsg.layout().columnCount()) tmpMsg.setStyleSheet("QScrollArea{min-width:600 px; min-height: 400px}") else: tmpMsg.setText(msg) if block == 0: tmpMsg.setWindowModality( QtCore.Qt.NonModal ) tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole) if block: tmpMsg.exec_() else: tmpMsg.show()
Example #8
Source File: sublink_edit.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def setupUi(self, DockWidget): DockWidget.setObjectName(_fromUtf8("DockWidget")) DockWidget.resize(400, 200) self.dockWidgetContents = QtGui.QWidget() self.dockWidgetContents.setObjectName(_fromUtf8("dockWidgetContents")) self.verticalLayout = QtGui.QVBoxLayout(self.dockWidgetContents) #self.verticalLayout.setMargin(0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) for link in self.link_sub: groupBox = myGrpBox(self.dockWidgetContents, link, self.obj) self.verticalLayout.addWidget(groupBox) self.pushButton_7 = QtGui.QPushButton(self.dockWidgetContents) self.pushButton_7.setObjectName(_fromUtf8("pushButton_7")) self.verticalLayout.addWidget(self.pushButton_7, 0, QtCore.Qt.AlignHCenter) spacerItem = QtGui.QSpacerItem(20, 237, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) DockWidget.setWidget(self.dockWidgetContents) self.retranslateUi(DockWidget) QtCore.QMetaObject.connectSlotsByName(DockWidget)
Example #9
Source File: shelf.py From dpa-pipe with MIT License | 6 votes |
def __init__(self, name, layout=None, widget=None, palette=None): self._name = name if not layout: layout = QtGui.QHBoxLayout() self._layout = layout if not widget: widget = QtGui.QWidget() widget.setLayout(self.layout) self._widget = widget if not palette: palette = mari.palettes.create(name, widget) self._palette = palette self._palette.show() # -------------------------------------------------------------------------
Example #10
Source File: LNTextEdit_v3.2.py From universal_tool_template.py with MIT License | 5 votes |
def paintEvent(self, event): self.edit.numberbarPaint(self, event) QtGui.QWidget.paintEvent(self, event)
Example #11
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 #12
Source File: universal_tool_template_1115.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self, layout='grid'): 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)
Example #13
Source File: universal_tool_template_1112.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self, layout='grid'): 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)
Example #14
Source File: UITranslator_v1.0.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self): #============================== # main_layout for QMainWindow main_widget = QtGui.QWidget() self.setCentralWidget(main_widget) main_layout = self.quickLayout('vbox') # grid for auto fill window size main_widget.setLayout(main_layout) ''' # main_layout for QDialog main_layout = self.quickLayout('vbox') self.setLayout(main_layout) ''' #------------------------------ # ui element creation part info_split = self.quickSplitUI( "info_split", self.quickUI(["dict_table;QTableWidget","source_txtEdit;LNTextEdit","result_txtEdit;LNTextEdit"]), "v" ) fileBtn_layout = self.quickUI(["filePath_input;QLineEdit", "fileLoad_btn;QPushButton;Load", "fileLang_choice;QComboBox", "fileExport_btn;QPushButton;Export"],"fileBtn_QHBoxLayout") self.quickUI( [info_split, "process_btn;QPushButton;Process and Update Memory From UI", 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 '''
Example #15
Source File: UITranslator_v1.0.py From universal_tool_template.py with MIT License | 5 votes |
def quickSplitUI(self, name, part_list, type): split_type = QtCore.Qt.Horizontal if type == 'v': split_type = QtCore.Qt.Vertical self.uiList[name]=QtGui.QSplitter(split_type) for each_part in part_list: if isinstance(each_part, QtGui.QWidget): self.uiList[name].addWidget(each_part) else: tmp_holder = QtGui.QWidget() tmp_holder.setLayout(each_part) self.uiList[name].addWidget(tmp_holder) return self.uiList[name]
Example #16
Source File: universal_tool_template_1115.py From universal_tool_template.py with MIT License | 5 votes |
def quickTabUI(self, name, tab_list, tab_names): self.uiList[name]=QtWidgets.QTabWidget() self.uiList[name].setStyleSheet("QTabWidget::tab-bar{alignment:center;}QTabBar::tab { min-width: 100px; }") for i in range( len(tab_list) ): each_tab = tab_list[i] each_name = tab_names[i] if isinstance(each_tab, QtWidgets.QWidget): self.uiList[name].addTab(each_tab, each_name) else: tmp_holder = QtWidgets.QWidget() tmp_holder.setLayout(each_tab) self.uiList[name].addTab(tmp_holder, each_name) return self.uiList[name]
Example #17
Source File: UITranslator_v1.0.py From universal_tool_template.py with MIT License | 5 votes |
def main(): parentWin = None app = None if deskMode == 0: if qtMode == 0: # ==== for pyside ==== parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtGui.QWidget) elif qtMode == 1: # ==== for PyQt==== parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject) if deskMode == 1: app = QtGui.QApplication(sys.argv) # single UI window code, so no more duplicate window instance when run this function global single_UITranslator if single_UITranslator is None: single_UITranslator = UITranslator(parentWin) # extra note: in Maya () for no parent; (parentWin,0) for extra mode input single_UITranslator.show() if deskMode == 1: sys.exit(app.exec_()) # example: show ui stored print(single_UITranslator.uiList.keys()) return single_UITranslator # If you want to be able to load multiple windows of the same ui, use code below
Example #18
Source File: universal_tool_template_0903.py From universal_tool_template.py with MIT License | 5 votes |
def quickTabUI(self, name, tab_list, tab_names): self.uiList[name]=QtWidgets.QTabWidget() self.uiList[name].setStyleSheet("QTabWidget::tab-bar{alignment:center;}QTabBar::tab { min-width: 100px; }") for i in range( len(tab_list) ): each_tab = tab_list[i] each_name = tab_names[i] if isinstance(each_tab, QtWidgets.QWidget): self.uiList[name].addTab(each_tab, each_name) else: tmp_holder = QtWidgets.QWidget() tmp_holder.setLayout(each_tab) self.uiList[name].addTab(tmp_holder, each_name) return self.uiList[name]
Example #19
Source File: universal_tool_template_1115.py From universal_tool_template.py with MIT License | 5 votes |
def quickSplitUI(self, name, part_list, type): split_type = QtCore.Qt.Horizontal if type == 'v': split_type = QtCore.Qt.Vertical self.uiList[name]=QtWidgets.QSplitter(split_type) for each_part in part_list: if isinstance(each_part, QtWidgets.QWidget): self.uiList[name].addWidget(each_part) else: tmp_holder = QtWidgets.QWidget() tmp_holder.setLayout(each_part) self.uiList[name].addWidget(tmp_holder) return self.uiList[name]
Example #20
Source File: universal_tool_template_1112.py From universal_tool_template.py with MIT License | 5 votes |
def mui_to_qt(self, mui_name): if hostMode != "maya": return ptr = mui.MQtUtil.findControl(mui_name) if ptr is None: ptr = mui.MQtUtil.findLayout(mui_name) if ptr is None: ptr = mui.MQtUtil.findMenuItem(mui_name) if ptr is not None: if qtMode in (0,2): # ==== for pyside ==== return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget) elif qtMode in (1,3): # ==== for PyQt==== return sip.wrapinstance(long(ptr), QtCore.QObject)
Example #21
Source File: UITranslator.py From universal_tool_template.py with MIT License | 5 votes |
def quickTabUI(self, name, tab_list, tab_names): self.uiList[name]=QtWidgets.QTabWidget() self.uiList[name].setStyleSheet("QTabWidget::tab-bar{alignment:center;}QTabBar::tab { min-width: 100px; }") for i in range( len(tab_list) ): each_tab = tab_list[i] each_name = tab_names[i] if isinstance(each_tab, QtWidgets.QWidget): self.uiList[name].addTab(each_tab, each_name) else: tmp_holder = QtWidgets.QWidget() tmp_holder.setLayout(each_tab) self.uiList[name].addTab(tmp_holder, each_name) return self.uiList[name]
Example #22
Source File: UITranslator.py From universal_tool_template.py with MIT License | 5 votes |
def quickSplitUI(self, name, part_list, type): split_type = QtCore.Qt.Horizontal if type == 'v': split_type = QtCore.Qt.Vertical self.uiList[name]=QtWidgets.QSplitter(split_type) for each_part in part_list: if isinstance(each_part, QtWidgets.QWidget): self.uiList[name].addWidget(each_part) else: tmp_holder = QtWidgets.QWidget() tmp_holder.setLayout(each_part) self.uiList[name].addWidget(tmp_holder) return self.uiList[name]
Example #23
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 #24
Source File: GearBox_template_1010.py From universal_tool_template.py with MIT License | 5 votes |
def mui_to_qt(self, mui_name): if hostMode != "maya": return ptr = mui.MQtUtil.findControl(mui_name) if ptr is None: ptr = mui.MQtUtil.findLayout(mui_name) if ptr is None: ptr = mui.MQtUtil.findMenuItem(mui_name) if ptr is not None: if qtMode in (0,2): # ==== for pyside ==== return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget) elif qtMode in (1,3): # ==== for PyQt==== return sip.wrapinstance(long(ptr), QtCore.QObject)
Example #25
Source File: GearBox_template_1010.py From universal_tool_template.py with MIT License | 5 votes |
def quickTabUI(self, name, tab_list, tab_names): self.uiList[name]=QtWidgets.QTabWidget() self.uiList[name].setStyleSheet("QTabWidget::tab-bar{alignment:center;}QTabBar::tab { min-width: 100px; }") for i in range( len(tab_list) ): each_tab = tab_list[i] each_name = tab_names[i] if isinstance(each_tab, QtWidgets.QWidget): self.uiList[name].addTab(each_tab, each_name) else: tmp_holder = QtWidgets.QWidget() tmp_holder.setLayout(each_tab) self.uiList[name].addTab(tmp_holder, each_name) return self.uiList[name]
Example #26
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 #27
Source File: universal_tool_template_2010.py From universal_tool_template.py with MIT License | 5 votes |
def quickMsg(self, msg, block=1, ask=0): tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation tmpMsg.setWindowTitle("Info") lineCnt = len(msg.split('\n')) if lineCnt > 25: scroll = QtWidgets.QScrollArea() scroll.setWidgetResizable(1) content = QtWidgets.QWidget() scroll.setWidget(content) layout = QtWidgets.QVBoxLayout(content) tmpLabel = QtWidgets.QLabel(msg) tmpLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) layout.addWidget(tmpLabel) tmpMsg.layout().addWidget(scroll, 0, 0, 1, tmpMsg.layout().columnCount()) tmpMsg.setStyleSheet("QScrollArea{min-width:600 px; min-height: 400px}") else: tmpMsg.setText(msg) if block == 0: tmpMsg.setWindowModality( QtCore.Qt.NonModal ) if ask==0: tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole) else: tmpMsg.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) if block: value = tmpMsg.exec_() if value == QtWidgets.QMessageBox.Ok: return 1 else: return 0 else: tmpMsg.show() return 0
Example #28
Source File: universal_tool_template_2010.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self, layout='grid'): main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) self.qui('main_layout;{0}'.format(layout)) main_widget.setLayout(self.uiList['main_layout'])
Example #29
Source File: ClassName_1010.py From universal_tool_template.py with MIT License | 5 votes |
def __init__(self): QtWidgets.QMainWindow.__init__(self) main_widget = QtWidgets.QWidget() self.setCentralWidget(main_widget) main_layout = QtWidgets.QVBoxLayout() main_widget.setLayout(main_layout)
Example #30
Source File: ClassName_1010.py From universal_tool_template.py with MIT License | 5 votes |
def quickMsg(self, msg, block=1, ask=0): tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation tmpMsg.setWindowTitle("Info") lineCnt = len(msg.split('\n')) if lineCnt > 25: scroll = QtWidgets.QScrollArea() scroll.setWidgetResizable(1) content = QtWidgets.QWidget() scroll.setWidget(content) layout = QtWidgets.QVBoxLayout(content) tmpLabel = QtWidgets.QLabel(msg) tmpLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) layout.addWidget(tmpLabel) tmpMsg.layout().addWidget(scroll, 0, 0, 1, tmpMsg.layout().columnCount()) tmpMsg.setStyleSheet("QScrollArea{min-width:600 px; min-height: 400px}") else: tmpMsg.setText(msg) if block == 0: tmpMsg.setWindowModality( QtCore.Qt.NonModal ) if ask==0: tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole) else: tmpMsg.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) if block: value = tmpMsg.exec_() if value == QtWidgets.QMessageBox.Ok: return 1 else: return 0 else: tmpMsg.show() return 0