python类QDialog()的实例源码

universal_tool_template_0904.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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);")
        '''
PCBcategories.py 文件源码 项目:FreeCAD-PCB 作者: marmni 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle(u'Add new category')
        #
        self.categoryName = QtGui.QLineEdit('')
        self.categoryName.setStyleSheet('background-color:#FFF;')

        self.categoryDescription = QtGui.QTextEdit('')
        # buttons
        buttons = QtGui.QDialogButtonBox()
        buttons.setOrientation(QtCore.Qt.Vertical)
        buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole)
        buttons.addButton("Add", QtGui.QDialogButtonBox.AcceptRole)
        self.connect(buttons, QtCore.SIGNAL("accepted()"), self, QtCore.SLOT("accept()"))
        self.connect(buttons, QtCore.SIGNAL("rejected()"), self, QtCore.SLOT("reject()"))
        #
        lay = QtGui.QGridLayout(self)
        lay.addWidget(QtGui.QLabel(u'Name'), 0, 0, 1, 1)
        lay.addWidget(self.categoryName, 0, 1, 1, 1)
        lay.addWidget(QtGui.QLabel(u'Desctiption'), 1, 0, 1, 1, QtCore.Qt.AlignTop)
        lay.addWidget(self.categoryDescription, 1, 1, 1, 1)
        lay.addWidget(buttons, 0, 2, 2, 1, QtCore.Qt.AlignCenter)
        lay.setRowStretch(1, 10)
PCBpartManaging.py 文件源码 项目:FreeCAD-PCB 作者: marmni 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, model, paths, parent=None):
        QtGui.QDialog.__init__(self, parent)

        self.setWindowTitle(u'Choose model')
        #
        self.modelsList = QtGui.QListWidget()
        for i in paths:
            self.modelsList.addItem(i)

        self.modelsList.setCurrentRow(0)
        #
        buttons = QtGui.QDialogButtonBox()
        buttons.setOrientation(QtCore.Qt.Vertical)
        buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole)
        buttons.addButton("Choose", QtGui.QDialogButtonBox.AcceptRole)
        self.connect(buttons, QtCore.SIGNAL("accepted()"), self, QtCore.SLOT("accept()"))
        self.connect(buttons, QtCore.SIGNAL("rejected()"), self, QtCore.SLOT("reject()"))
        #
        lay = QtGui.QGridLayout(self)
        lay.addWidget(QtGui.QLabel(u"Choose one of available models for part"), 0, 0, 1, 1)
        lay.addWidget(QtGui.QLabel(u"<div style='font-weight:bold;'>{0}</div>".format(model)), 1, 0, 1, 1, QtCore.Qt.AlignHCenter)
        lay.addWidget(self.modelsList, 2, 0, 1, 1)
        lay.addWidget(buttons, 2, 1, 1, 1)
universal_tool_template_v7.3.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
UITranslator_v1.0.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
tab_scene.py 文件源码 项目:kite 作者: pyrocko 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, plot, parent=None):
        QtGui.QDialog.__init__(self, parent)

        loadUi(get_resource('transect.ui'), baseinstance=self)

        pxmap = self.style().standardPixmap

        self.closeButton.setIcon(
            pxmap(QtGui.QStyle.SP_DialogCloseButton))
        self.createButton.setIcon(
            pxmap(QtGui.QStyle.SP_ArrowUp))
        self.removeButton.setIcon(
            pxmap(QtGui.QStyle.SP_DialogDiscardButton))

        self.plot = plot
        self.poly_line = None

        self.trans_plot = pg.PlotDataItem(
            antialias=True,
            fillLevel=0.,
            fillBrush=pg.mkBrush(0, 127, 0, 150))

        self.plt_wdgt = pg.PlotWidget()
        self.plt_wdgt.setLabels(
            bottom={'Distance', 'm'},
            left='Displacement [m]')

        self.plt_wdgt.showGrid(True, True, alpha=.5)
        self.plt_wdgt.enableAutoRange()
        self.plt_wdgt.addItem(self.trans_plot)

        self.layoutPlot.addWidget(self.plt_wdgt)
        self.plot.image.sigImageChanged.connect(self.updateTransPlot)
        self.createButton.released.connect(self.addPolyLine)
        self.removeButton.released.connect(self.removePolyLine)

        parent.model.sigConfigChanged.connect(self.close)
tab_covariance.py 文件源码 项目:kite 作者: pyrocko 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, model, parent=None):
        QtGui.QDialog.__init__(self, parent)

        loadUi(get_resource('covariance_matrix.ui'), baseinstance=self)
        self.closeButton.setIcon(
            self.style().standardPixmap(QtGui.QStyle.SP_DialogCloseButton))

        self.weight_matrix = self.MatrixPlot(model)
        self.dockarea = dockarea.DockArea(self)

        self.dockarea.addDock(
            dockarea.Dock(
                'Covariance.weight_matrix_focal',
                widget=self.weight_matrix,
                size=(4, 4),
                autoOrientation=False,),
            position='left')

        self.horizontalLayoutPlot.addWidget(self.dockarea)
CustomDialogs.py 文件源码 项目:TWTools 作者: ZeX2 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        QtGui.QDialog.__init__(self)
        self.setupUi()
CustomDialogs.py 文件源码 项目:TWTools 作者: ZeX2 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, servers_json_path):
        QtGui.QDialog.__init__(self)
        self.downloaded = False
        self.setupUi()
        self.servers_json_path = servers_json_path
        self.servers_download_function()
engine.py 文件源码 项目:tk-photoshopcc 作者: shotgunsoftware 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _define_qt_base(self):
        """
        This will be called at initialisation time and will allow
        a user to control various aspects of how QT is being used
        by Toolkit. The method should return a dictionary with a number
        of specific keys, outlined below.

        * qt_core - the QtCore module to use
        * qt_gui - the QtGui module to use
        * dialog_base - base class for to use for Toolkit's dialog factory

        :returns: dict
        """
        base = {}
        from PySide import QtCore, QtGui
        base["qt_core"] = QtCore
        base["qt_gui"] = QtGui
        base["dialog_base"] = QtGui.QDialog

        # tell QT to handle text strings as utf-8 by default
        utf8 = QtCore.QTextCodec.codecForName("utf-8")
        QtCore.QTextCodec.setCodecForCStrings(utf8)

        self._override_qmessagebox()

        return base
PCBcategories.py 文件源码 项目:FreeCAD-PCB 作者: marmni 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, categoryID, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle(u'Update category')

        self.categoryID = categoryID
        categoryData = readCategories()[self.categoryID]
        #
        self.categoryName = QtGui.QLineEdit('')
        self.categoryName.setStyleSheet('background-color:#FFF;')
        self.categoryName.setText(categoryData[0])

        self.categoryDescription = QtGui.QTextEdit('')
        self.categoryDescription.setText(categoryData[1])
        # buttons
        buttons = QtGui.QDialogButtonBox()
        buttons.setOrientation(QtCore.Qt.Vertical)
        buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole)
        buttons.addButton("Update", QtGui.QDialogButtonBox.AcceptRole)
        self.connect(buttons, QtCore.SIGNAL("accepted()"), self, QtCore.SLOT("accept()"))
        self.connect(buttons, QtCore.SIGNAL("rejected()"), self, QtCore.SLOT("reject()"))
        #
        lay = QtGui.QGridLayout(self)
        lay.addWidget(QtGui.QLabel(u'Name'), 0, 0, 1, 1)
        lay.addWidget(self.categoryName, 0, 1, 1, 1)
        lay.addWidget(QtGui.QLabel(u'Desctiption'), 1, 0, 1, 1, QtCore.Qt.AlignTop)
        lay.addWidget(self.categoryDescription, 1, 1, 1, 1)
        lay.addWidget(buttons, 0, 2, 2, 1, QtCore.Qt.AlignCenter)
        lay.setRowStretch(1, 10)
PCBtoolBar.py 文件源码 项目:FreeCAD-PCB 作者: marmni 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def defConstraintAreaF(self):
        ''' create constraint are dialog '''
        dial = QtGui.QDialog()
        dial.setWindowTitle("Create constraint area")
        # areas list
        lista = QtGui.QListWidget()
        for i, j in PCBconstraintAreas.items():
            a = QtGui.QListWidgetItem(j[0])
            a.setData(QtCore.Qt.UserRole, i)

            lista.addItem(a)
        lista.sortItems()
        ##########
        # przyciski
        buttons = QtGui.QDialogButtonBox()
        buttons.setOrientation(QtCore.Qt.Vertical)
        buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole)
        buttons.addButton("Create", QtGui.QDialogButtonBox.AcceptRole)
        dial.connect(buttons, QtCore.SIGNAL("accepted()"), dial, QtCore.SLOT("accept()"))
        dial.connect(buttons, QtCore.SIGNAL("rejected()"), dial, QtCore.SLOT("reject()"))
        ####
        lay = QtGui.QGridLayout()
        lay.addWidget(lista, 0, 0, 1, 1)
        lay.addWidget(buttons, 0, 1, 1, 1)
        dial.setLayout(lay)

        if dial.exec_():
            self.constraintAreaF(str(lista.currentItem().data(QtCore.Qt.UserRole)))
ViewWidget.py 文件源码 项目:zorro 作者: C-CINA 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self):
        QtGui.QDialog.__init__(self)

        self.setupUi(self)

        # Set up the user interface from Designer.  
        self.show()
UITranslator.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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')
GearBox_template_1010.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
universal_tool_template_v7.3.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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()
UITranslator_v1.0.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
UITranslator_v1.0.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
        '''
universal_tool_template_0904.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
universal_tool_template_0803.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
    #############################################
universal_tool_template_0903.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
universal_tool_template_0903.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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);")
        '''
universal_tool_template_1010.py 文件源码 项目:universal_tool_template.py 作者: shiningdesign 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
lineyka_manager.py 文件源码 项目:lineyka 作者: volodya-renderberg 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def tm_make_preview_ui(self):
        self.makePreviewDialog = QtGui.QDialog(self)
        self.makePreviewDialog.setModal(True)
        #self.makePreviewDialog.resize(300, 300)
        self.makePreviewDialog.setWindowTitle(('Make Preview: /// ' + self.current_task['asset']))

        # add widgets
        v_layout = QtGui.QVBoxLayout()
        # -- image Label
        self.makePreviewDialog.imageLabel = QtGui.QLabel()
        self.makePreviewDialog.imageLabel.setFixedSize(300,300)
        v_layout.addWidget(self.makePreviewDialog.imageLabel)

        # -- button
        h__layout = QtGui.QHBoxLayout()
        button_frame = QtGui.QFrame(parent = self.makePreviewDialog)
        cansel_button = QtGui.QPushButton('Cansel', parent = button_frame)
        h__layout.addWidget(cansel_button)
        paste_button = QtGui.QPushButton('Paste', parent = button_frame)
        h__layout.addWidget(paste_button)
        save_button = QtGui.QPushButton('Save', parent = button_frame)
        h__layout.addWidget(save_button)
        button_frame.setLayout(h__layout)

        v_layout.addWidget(button_frame)
        self.makePreviewDialog.setLayout(v_layout)

        # connect buttons
        cansel_button.clicked.connect(partial(self.close_window, self.makePreviewDialog))
        paste_button.clicked.connect(partial(self.tm_paste_image_from_clipboard, self.makePreviewDialog.imageLabel))
        save_button.clicked.connect(partial(self.tm_save_preview_image_action, self.makePreviewDialog))

        # -- load img to label
        img_path = os.path.join(self.db_chat.preview_img_path, (self.current_task['asset'] + '.png'))
        if not os.path.exists(img_path):
            self.makePreviewDialog.imageLabel.setText('No Image')
        else:
            image = QtGui.QImage(img_path)
            self.makePreviewDialog.imageLabel.setPixmap(QtGui.QPixmap.fromImage(image))

        self.makePreviewDialog.show()
tool_dialogs.py 文件源码 项目:kite 作者: pyrocko 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, sandbox, *args, **kwargs):
        QtGui.QDialog.__init__(self, *args, **kwargs)
        loadUi(get_resource('dialog_extent.ui'), self)
        self.setSizeGripEnabled(False)

        self.move(
            self.parent().window().mapToGlobal(
                self.parent().window().rect().center()) -
            self.mapToGlobal(self.rect().center()))

        self.sandbox = sandbox
        model = self.sandbox.model
        dE, dN = model.frame.dE, model.frame.dN

        def getKm(px, dp):
            return '%.2f km ' % (dp * px * 1e-3)

        self.spinEastPx.valueChanged.connect(
            lambda px: self.eastKm.setText(getKm(px, dE)))
        self.spinNorthPx.valueChanged.connect(
            lambda px: self.northKm.setText(getKm(px, dN)))

        self.applyButton.released.connect(self.updateValues)
        self.okButton.released.connect(self.updateValues)
        self.okButton.released.connect(self.close)

        self.setValues()
base.py 文件源码 项目:kite 作者: pyrocko 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, delegate, ui_file, *args, **kwargs):
        QtGui.QDialog.__init__(self, *args, **kwargs)
        loadUi(get_resource(ui_file), self)
        self.delegate = delegate

        self.delegate.sourceParametersChanged.connect(
            self.getSourceParameters)
        self.applyButton.released.connect(
            self.setSourceParameters)
        self.okButton.released.connect(
            self.setSourceParameters)
        self.okButton.released.connect(
            self.close)
config.py 文件源码 项目:kite 作者: pyrocko 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        QtGui.QDialog.__init__(self, *args, **kwargs)
        loadUi(get_resource('dialog_config.ui'), self)

        self.ok_button.released.connect(
            self.setAttributes)
        self.ok_button.released.connect(
            self.close)

        self.apply_button.released.connect(
            self.setAttributes)

        self.vector_color_picker = QtGui.QColorDialog(self)
        self.vector_color_picker.\
            setCurrentColor(QtGui.QColor(*config.vector_color))
        self.vector_color_picker.\
            setOption(self.vector_color_picker.ShowAlphaChannel)
        self.vector_color_picker.colorSelected.connect(
            self.updateVectorColor)
        self.vector_color_picker.setModal(True)
        self.vector_color.clicked.connect(
            self.vector_color_picker.show)

        self.vector_color.setValue = self.setButtonColor
        self.vector_color.value = self.getButtonColor

        self.chooseStoreDirButton.released.connect(
            self.chooseStoreDir)
        self.completer_model.setRootPath('')
        self.completer.setParent(self.default_gf_dir)
        self.default_gf_dir.setCompleter(self.completer)

        self.getAttributes()
talpa.py 文件源码 项目:kite 作者: pyrocko 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def aboutDialog(self):
        self._about = QtGui.QDialog()
        loadUi(get_resource('about.ui'), baseinstance=self._about)
        return self._about
spool.py 文件源码 项目:kite 作者: pyrocko 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def aboutDialog(self):
        self._about = QtGui.QDialog()
        loadUi(get_resource('about.ui'), baseinstance=self._about)
        return self._about
PopUpImage.py 文件源码 项目:FreeCAD-Reinforcement 作者: amrit3701 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, img):
        QtGui.QDialog.__init__(self)
        self.image = QtSvg.QSvgWidget(img)
        self.setWindowTitle(QtGui.QApplication.translate("RebarTool", "Detailed description", None))
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.addWidget(self.image)


问题


面经


文章

微信
公众号

扫码关注公众号