Python PyQt4.QtGui.QWidget() Examples
The following are 30
code examples of PyQt4.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
PyQt4.QtGui
, or try the search function
.
Example #1
Source File: calc_app2.py From tutorials with MIT License | 6 votes |
def __init__(self, *args, **kwargs): super(Calculator, self).__init__(*args, **kwargs) # Single-inheritence approach: http://goo.gl/WNiHc # Calculator class only inherits from QWidget # A specific member attribute self.ui contains all # widgets set up in the designer. self.ui = Ui_Calculator() self.ui.setupUi(self) self.ui.calcButton = QtGui.QPushButton("Calculate") self.ui.horizontalLayout_2.addWidget(self.ui.calcButton) # Create a validator for each QLineEdit that only # allows a user to enter floats: 123.123 self.ui.inputA.setValidator(QtGui.QDoubleValidator()) self.ui.inputB.setValidator(QtGui.QDoubleValidator()) # instead of using the stock operator values set in the # ui file, lets set the box to match our class attribute self.ui.operatorBox.clear() self.ui.operatorBox.addItems(self.OPS.keys()) self.ui.clearButton.clicked.connect(self.clear) self.ui.calcButton.clicked.connect(self.calc)
Example #2
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 #3
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 #4
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 #5
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 #6
Source File: dataeditor.py From ddt4all with GNU General Public License v3.0 | 6 votes |
def init(self, num): if self.mainwidget: self.mainwidget.setParent(None) self.mainwidget.deleteLater() self.mainwidget = widgets.QWidget() self.layout = widgets.QHBoxLayout() self.layout.setSpacing(2) self.bc = [] for i in range(num): bc = Bit_container("00", i) self.bc.append(bc) self.layout.addWidget(bc) self.mainwidget.setLayout(self.layout) self.setWidget(self.mainwidget)
Example #7
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 #8
Source File: GUIElements.py From FlatCAM with MIT License | 6 votes |
def eventFilter(self, source, event): """ The event filter gets automatically installed when setWidget() is called. :param source: :param event: :return: """ if event.type() == QtCore.QEvent.Resize and source == self.widget(): # log.debug("VerticalScrollArea: Widget resized:") # log.debug(" minimumSizeHint().width() = %d" % self.widget().minimumSizeHint().width()) # log.debug(" verticalScrollBar().width() = %d" % self.verticalScrollBar().width()) self.setMinimumWidth(self.widget().sizeHint().width() + self.verticalScrollBar().sizeHint().width()) # if self.verticalScrollBar().isVisible(): # log.debug(" Scroll bar visible") # self.setMinimumWidth(self.widget().minimumSizeHint().width() + # self.verticalScrollBar().width()) # else: # log.debug(" Scroll bar hidden") # self.setMinimumWidth(self.widget().minimumSizeHint().width()) return QtGui.QWidget.eventFilter(self, source, event)
Example #9
Source File: FlatCAMTool.py From FlatCAM with MIT License | 6 votes |
def __init__(self, app, parent=None): """ :param app: The application this tool will run in. :type app: App :param parent: Qt Parent :return: FlatCAMTool """ QtGui.QWidget.__init__(self, parent) # self.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) self.layout = QtGui.QVBoxLayout() self.setLayout(self.layout) self.app = app self.menuAction = None
Example #10
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 #11
Source File: universal_tool_template_1020.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 #12
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 #13
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 #14
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 #15
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 #16
Source File: universal_tool_template_1116.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: universal_tool_template_1112.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 #18
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 #19
Source File: universal_tool_template_1112.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 #20
Source File: universal_tool_template_1020.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 #21
Source File: LNTextEdit.py From universal_tool_template.py with MIT License | 5 votes |
def paintEvent(self, event): self.edit.numberbarPaint(self, event) QtWidgets.QWidget.paintEvent(self, event)
Example #22
Source File: universal_tool_template_1116.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 #23
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
Example #24
Source File: universal_tool_template_1116.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 #25
Source File: universal_tool_template_1116.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 #26
Source File: universal_tool_template_1116.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 #27
Source File: fader.py From tutorials with MIT License | 5 votes |
def __init__(self): super(FadeExample, self).__init__() self.resize(600,600) self.vlayout = QtGui.QVBoxLayout(self) self.w1 = QtGui.QWidget() self.w1.setStyleSheet("QWidget {background-color: red;}") self.w2 = QtGui.QWidget() self.w2.setStyleSheet("QWidget {background-color: blue;}") self.stacked = QtGui.QStackedLayout() self.stacked.addWidget(self.w1) self.stacked.addWidget(self.w2) self.vlayout.addLayout(self.stacked) self.fadeButton = QtGui.QPushButton("Fade") self.resetButton = QtGui.QPushButton("Reset") buttonLayout = QtGui.QHBoxLayout() buttonLayout.addWidget(self.fadeButton) buttonLayout.addWidget(self.resetButton) self.vlayout.addLayout(buttonLayout) self.fadeButton.clicked.connect(self.fade) self.resetButton.clicked.connect(self.reset)
Example #28
Source File: coordinates.py From tutorials with MIT License | 5 votes |
def __init__(self): super(Widget, self).__init__() self.setObjectName("MainWindow") mainLayout = QtGui.QVBoxLayout(self) mainLayout.setSpacing(0) mainLayout.setMargin(20) self.feedback = QtGui.QLabel() self.feedback.setFixedHeight(50) mainLayout.addWidget(self.feedback) self.widgets = deque() self.widgets.append(None) self.widgets.append(self) for i, color in enumerate(('red', 'green', 'blue')): w = QtGui.QWidget() name = "widget%d" % i w.setObjectName(name) w.setStyleSheet("#%s { background: %s }" % (name, color)) mainLayout.addWidget(w) self.widgets.append(w) self.button = QtGui.QPushButton("Move", self) self.button.clicked.connect(self.random_move)
Example #29
Source File: blocking.py From tutorials with MIT License | 5 votes |
def main(self): app = QtGui.QApplication(sys.argv) self.win = QtGui.QWidget() self.win.resize(300,200) layout = QtGui.QVBoxLayout(self.win) blocking_button = QtGui.QPushButton("Block") blocking_button.clicked.connect(self.blocking) layout.addWidget(blocking_button) signal_button = QtGui.QPushButton("Signals") signal_button.clicked.connect(self.non_blocking) layout.addWidget(signal_button) self.output = QtGui.QLineEdit() layout.addWidget(self.output) clear_button = QtGui.QPushButton("Clear") clear_button.clicked.connect(self.output.clear) layout.addWidget(clear_button) self.win.show() self.win.raise_() app.exec_()
Example #30
Source File: calc_app3.py From tutorials with MIT License | 5 votes |
def __init__(self, *args, **kwargs): super(Calculator, self).__init__(*args, **kwargs) # Single-inheritence approach: http://goo.gl/WNiHc # Calculator class only inherits from QWidget # A specific member attribute self.ui contains all # widgets set up in the designer. self.ui = Ui_Calculator() self.ui.setupUi(self) # Create a validator for each QLineEdit that only # allows a user to enter floats: 123.123 self.ui.inputA.setValidator(QtGui.QDoubleValidator()) self.ui.inputB.setValidator(QtGui.QDoubleValidator()) # instead of using the stock operator values set in the # ui file, lets set the box to match our class attribute self.ui.operatorBox.clear() self.ui.operatorBox.addItems(self.OPS.keys()) self.ui.clearButton.clicked.connect(self.clear) # every time the text is edited in either input field, # calculate the result live self.ui.inputA.textEdited.connect(self.calc) self.ui.inputB.textEdited.connect(self.calc) # also when the operator box is changed self.ui.operatorBox.currentIndexChanged.connect(self.calc)