当前位置: 首页>>代码示例>>Python>>正文


Python Ui_MainWindow.setupUi方法代码示例

本文整理汇总了Python中ui_mainwindow.Ui_MainWindow.setupUi方法的典型用法代码示例。如果您正苦于以下问题:Python Ui_MainWindow.setupUi方法的具体用法?Python Ui_MainWindow.setupUi怎么用?Python Ui_MainWindow.setupUi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ui_mainwindow.Ui_MainWindow的用法示例。


在下文中一共展示了Ui_MainWindow.setupUi方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        # Load the ui.
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Assign the actions.
        self.ui.ui_exec_btn.setDefaultAction(self.ui.ui_exec_act)
        self.ui.ui_show_btn.setDefaultAction(self.ui.ui_show_act)
        self.ui.ui_count_btn.setDefaultAction(self.ui.ui_count_act)

        # Create the connections.
        self.ui.ui_exec_act.triggered.connect(self.execDialog)
        self.ui.ui_show_act.triggered.connect(self.showDialog)
        self.ui.ui_count_act.triggered.connect(self.showCount)

    def execDialog(self):
        dlg = SampleDialog(self)
        dlg.exec_()

    def showDialog(self):
        dlg = SampleDialog(self)
        dlg.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dlg.show()

    def showCount(self):
        count = len(self.findChildren(QtGui.QDialog))
        QtGui.QMessageBox.information(self, "Dialog Count", str(count))
开发者ID:mstreatfield,项目名称:bitesofcode,代码行数:32,代码来源:3_comparison_of_loading_techniques_pyuic4.py

示例2: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.nameLabel.setProperty("class", "mandatory QLabel")
        self.styleSheetEditor = StyleSheetEditor(self)
        self.statusBar().addWidget(QLabel("Ready"))
        self.ui.exitAction.triggered.connect(QApplication.instance().quit)
        self.ui.aboutQtAction.triggered.connect(QApplication.instance().aboutQt)

    def on_editStyleAction_triggered(self):
        self.styleSheetEditor.show()
        self.styleSheetEditor.activateWindow()

    def on_aboutAction_triggered(self):
        QMessageBox.about(
            self,
            "About Style sheet",
            "The <b>Style Sheet</b> example shows how widgets can be "
            "styled using "
            '<a href="http://doc.qt.digia.com/4.5/stylesheet.html">Qt '
            "Style Sheets</a>. Click <b>File|Edit Style Sheet</b> to pop "
            "up the style editor, and either choose an existing style "
            "sheet or design your own.",
        )
开发者ID:Magdno1,项目名称:Arianrhod,代码行数:29,代码来源:stylesheet.py

示例3: main

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
def main():
    app = QApplication(sys.argv)
    window = QDialog()
    mainmenu = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(mainmenu)
    
    mainmenu.show()
    sys.exit(app.exec_())
开发者ID:PeterRyder,项目名称:HackRU,代码行数:11,代码来源:GUI_2.0.py

示例4: setupUi

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
 def setupUi(self, MainWindowBase):
     """setup the window.
     
     First, the method of the base class is called, and then all the
     functionality is installed (signal/slot connections mainly).
     """
     Ui_MainWindow.setupUi(self, MainWindowBase)
     self.widget = MainWindowBase
     QObject.connect(self.actionAbout, SIGNAL("triggered()"), self.openAbout)
     QObject.connect(self.actionFileOpen, SIGNAL("triggered()"), self.openFile)
     self.statusBar().showMessage(self.tr("Ready"))
开发者ID:andreas-koukorinis,项目名称:PySPA,代码行数:13,代码来源:mainwindow.py

示例5: setupUi

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
def setupUi(window):
    pkg_path = os.path.dirname(__file__)
    mainwindow_file = os.path.join(pkg_path, 'mainwindow.ui')
    if os.path.exists(mainwindow_file):
        from PyQt4 import uic
        ui = uic.loadUi(mainwindow_file, window)
    else:
        from ui_mainwindow import Ui_MainWindow
        ui = Ui_MainWindow()
        ui.setupUi(window)
    return ui
开发者ID:mwicat,项目名称:batchui,代码行数:13,代码来源:qtutil.py

示例6: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QMainWindow):
	def __init__(self, parent=None):
		super(MainWindow, self).__init__(parent)
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)
		self.gl_widget = GLWidget()
		self.ui.gl_layout.addWidget(self.gl_widget)
		#singal slot connect
		# self.connect(self.ui.apk1_open, SIGNAL('clicked()'),self.apk1_open_onclicked)
	# @pyqtSlot()
	# def apk1_open_onclicked(self):
	# 	self.emit(SIGNAL('open_apk1'))
开发者ID:zombiecry,项目名称:GameFluid,代码行数:14,代码来源:mainwindow.py

示例7: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)

        # UI initialize
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.initModels()
        self.initProgress()

        self.connectProgress(self.jsonModel)

    def initModels(self):
        self.jsonModel = JsonTreeModel(self)
        self.ui.treeView.setModel(self.jsonModel)

    def initProgress(self):
        self.progress = QtWidgets.QProgressBar(self.ui.statusbar)
        self.progress.setVisible(False)

    def connectProgress(self, obj):
        obj.startProgress.connect(self.progress.setRange)
        obj.startProgress.connect(self.startProgress)
        obj.updateProgress.connect(self.progress.setValue)
        obj.finishProgress.connect(self.finishProgress)

    @QtCore.pyqtSlot()
    def startProgress(self):
        self.progress.setValue(0)
        self.progress.setVisible(True)

    @QtCore.pyqtSlot()
    def finishProgress(self):
        self.progress.setVisible(False)

    @QtCore.pyqtSlot()
    def on_actionOpen_triggered(self):
        filepath, ext_filter = QtWidgets.QFileDialog.getOpenFileName(self,
            '',
            '.',
            self.tr('Json (*.json)')
        )
        if not filepath:
            return
        with BusyCursor(self):
            data = json.load(open(str(filepath)))
            self.jsonModel.setJsonDocument(data)
开发者ID:mugwort-rc,项目名称:pyJsonViewer,代码行数:50,代码来源:mainwindow.py

示例8: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QWidget):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.resize(1024, 768)
        
        self.mostWatchedItems = MostWatchedItems()
        self.ui.tabWidget.addTab(self.mostWatchedItems, 'Most Watched Items')
        
        self.topSellingProducts = TopSellingProducts()
        self.ui.tabWidget.addTab(self.topSellingProducts, 'Top Selling Products')
        
        self.popularItems = PopularItems()
        self.ui.tabWidget.addTab(self.popularItems, 'Popular Items')
        
        self.popularSearches = PopularSearches()
        self.ui.tabWidget.addTab(self.popularSearches, 'Popular Searches')
开发者ID:xlongfeng,项目名称:oceanix,代码行数:21,代码来源:mainwindow.py

示例9: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.rerun_btn.clicked.connect(self.rerun)

        self.source = NI6009()
        self.timer = QtCore.QTimer()
        self.redraw_interval = 50 # (ms)
        self.timer.timeout.connect(self.replot)

    def replot(self):
        self.ui.plotter.replotWith(xs=np.arange(0,1000),
                                   ys=self.source.data())
        self.timer.start()

    def rerun(self):
        self.timer.stop()
        self.source.reads_per_run = int(self.ui.num_reads.text())
        self.source.sample_rate = int(self.ui.num_samples.text())
        self.timer.start()
开发者ID:garslo,项目名称:poscope,代码行数:25,代码来源:poscope.py

示例10: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.nameLabel.setProperty('class', 'mandatory QLabel')
        self.styleSheetEditor = StyleSheetEditor(self)
        self.statusBar().addWidget(QtGui.QLabel("Ready"))
        self.ui.exitAction.triggered.connect(QtGui.qApp.quit)
        self.ui.aboutQtAction.triggered.connect(QtGui.qApp.aboutQt)

    def on_editStyleAction_triggered(self):
        self.styleSheetEditor.show()
        self.styleSheetEditor.activateWindow()

    def on_aboutAction_triggered(self):
        QtGui.QMessageBox.about(self, "About Style sheet",
                "The <b>Style Sheet</b> example shows how widgets can be "
                "styled using "
                "<a href=\"http://qt.nokia.com/doc/4.7/stylesheet.html\">Qt "
                "Style Sheets</a>. Click <b>File|Edit Style Sheet</b> to pop "
                "up the style editor, and either choose an existing style "
                "sheet or design your own.")
开发者ID:CapB1ack,项目名称:PyQt4,代码行数:26,代码来源:stylesheet.py

示例11: GUI

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class GUI(QtGui.QMainWindow):
    def __init__(self, app):
        QtGui.QMainWindow.__init__(self)
        self.app = app
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
        self.ui.actionQuit.triggered.connect(self.quit)
        self.ui.quitBtn.clicked.connect(self.quit)
        self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
        self.ui.nextBtn.clicked.connect(self.nextTab)
        self.ui.prevBtn.clicked.connect(self.prevTab)
        self.welcome_container = QtGui.QWidget()
        self.welcomeTab = Ui_Welcome()
        self.welcomeTab.setupUi(self.welcome_container)
        self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
        self.createConfigTab()
        self.updateWizButtons()

    def updateWizButtons(self):
        if self.ui.moduleNotebook.currentIndex() <= 0:
            self.ui.prevBtn.setEnabled(False)
        else:
            self.ui.prevBtn.setEnabled(True)
        if self.isLast():
            self.ui.nextBtn.setText(_("Finish"))
        else:
            self.ui.nextBtn.setText(_("Next"))
        if self.ui.moduleNotebook.currentIndex() < 0:
            self.ui.nextBtn.setEnabled(False)
        else:
            self.ui.nextBtn.setEnabled(True)

    def nextTab(self, *args):
        if self.isLast():
            self.quit()
        else:
            self.chTab(1)

    def prevTab(self, *args):
        self.chTab(-1)

    def chTab(self, amt):
        self.ui.moduleNotebook.setCurrentIndex(self.ui.moduleNotebook.currentIndex() + amt)

    def isLast(self):
        return self.ui.moduleNotebook.count() - 1 <= self.ui.moduleNotebook.currentIndex()

    def createConfigTab(self):
        configs = config.Configuration
        self.configTab = QtGui.QWidget()
        self.configTab.vlayout = QtGui.QVBoxLayout(self.configTab)
        # Master notebook (stores the sections)
        self.configTab.notebook1 = QtGui.QTabWidget(self.configTab)
        self.configTab.vlayout.addWidget(self.configTab.notebook1)
        self.fillConfiguration(configs, self.configTab)
        self.ui.moduleNotebook.addTab(self.configTab, "Configuration")

    def fillConfiguration(self, configs, widget):
        # TODO: Clean this mess, or at least comment it
        l = chr(108)
        v = chr(118)
        for i in configs.keys():
            # If the section is not in the notebook, add it
            if not i in self.configTab.notebook1.__dict__:
                self.configTab.notebook1.__dict__[i] = QtGui.QWidget()
                self.configTab.notebook1.__dict__[i].vlayout = QtGui.QVBoxLayout(
                                                                self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].nbook = QtGui.QTabWidget(
                                                                self.configTab.notebook1.__dict__[i])
                self.configTab.notebook1.__dict__[i].vlayout.addWidget(
                                                        self.configTab.notebook1.__dict__[i].nbook)
                self.configTab.notebook1.addTab(self.configTab.notebook1.__dict__[i], i)
            for x in configs[i].keys():
                c = configutils.getValueP(configs[i][x], configutils.category)
                n = configutils.getValueP(configs[i][x], configutils.name)
                t = configutils.getValueP(configs[i][x], configutils.types)
                v_ = configutils.getValue(configs[i][x])
                c_ = configutils.getChoices(t)
                var = (i, x)
                # If the category is not in the section's notebook, add it
                if not c in self.configTab.notebook1.__dict__[i].nbook.__dict__:
                    fw = QtGui.QWidget(self.configTab.notebook1.__dict__[i].nbook)
                    vb = QtGui.QVBoxLayout(fw)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c] = QtGui.QScrollArea(fw)
                    vb.addWidget(self.configTab.notebook1.__dict__[i].nbook.__dict__[c])
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].setWidgetResizable(False)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout = QtGui.QFormLayout()
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setSizeConstraint(
                                                                QtGui.QLayout.SetFixedSize)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setFieldGrowthPolicy(
                                                        QtGui.QFormLayout.AllNonFixedFieldsGrow)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setLabelAlignment(
                                                                        QtCore.Qt.AlignLeft)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC = QtGui.QWidget()
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC.setLayout(
                            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout)
                    self.configTab.notebook1.__dict__[i].nbook.__dict__[c].setWidget(
                            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC)
                    self.configTab.notebook1.__dict__[i].nbook.addTab(
#.........这里部分代码省略.........
开发者ID:Smile4ever,项目名称:relinux,代码行数:103,代码来源:gui.py

示例12: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QtGui.QMainWindow):

    def __init__(self, parent=None):
        # Initialise the UI
        self.display = None
        super(MainWindow, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # Current file
        self._filename = None
        self._last_file_handler = None
        # Importers / Exporters
        self._file_handlers = []
        # Update our window caption
        self._caption = "Zoxel"
        # Our global state
        self.settings = QtCore.QSettings("Zoxel", "Zoxel")
        self.state = {}
        # Our animation timer
        self._timer = QtCore.QTimer(self)
        self.connect(self._timer, QtCore.SIGNAL("timeout()"), 
            self.on_animation_tick)
        self._anim_speed = 200
        # Load our state if possible
        self.load_state()
        # Create our GL Widget
        try:
            voxels = GLWidget(self.ui.glparent)
            self.ui.glparent.layout().addWidget(voxels)
            self.display = voxels
        except Exception as E:
            QtGui.QMessageBox.warning(self, "Initialisation Failed",
                str(E))
            exit(1)
        # Load default model dimensions
        width = self.get_setting("default_model_width")
        height = self.get_setting("default_model_height")
        depth = self.get_setting("default_model_depth")
        if width:
            self.resize_voxels(width, height, depth)
            # Resize is detected as a change, discard changes
            self.display.voxels.saved()
        # Create our palette widget
        voxels = PaletteWidget(self.ui.palette)
        self.ui.palette.layout().addWidget(voxels)
        self.colour_palette = voxels
        # More UI state
        value = self.get_setting("display_axis_grids")
        if value is not None:
            self.ui.action_axis_grids.setChecked(value)
            self.display.axis_grids = value
        value = self.get_setting("background_colour")
        if value is not None:
            self.display.background = QtGui.QColor.fromRgb(*value)
        value = self.get_setting("voxel_edges")
        if value is not None:
            self.display.voxel_edges = value
            self.ui.action_voxel_edges.setChecked(value)
        else:
            self.ui.action_voxel_edges.setChecked(self.display.voxel_edges)
        value = self.get_setting("occlusion")
        if value is None:
            value = True
        self.display.voxels.occlusion = value
        self.ui.action_occlusion.setChecked(value)
        # Connect some signals
        if self.display:
            self.display.voxels.notify = self.on_data_changed
            self.display.tool_activated.connect(self.on_tool_activated)
            self.display.tool_activated_alt.connect(self.on_tool_activated_alt)
            self.display.tool_dragged.connect(self.on_tool_dragged)
            self.display.tool_deactivated.connect(self.on_tool_deactivated)
        if self.colour_palette:
            self.colour_palette.changed.connect(self.on_colour_changed)
        # Initialise our tools
        self._tool_group = QtGui.QActionGroup(self.ui.toolbar_drawing)
        self._tools = []
        # Setup window
        self.update_caption()
        self.refresh_actions()

    def on_animation_tick(self):
        self.on_action_anim_next_triggered()

    @QtCore.Slot()
    def on_action_about_triggered(self):
        dialog = AboutDialog(self)
        if dialog.exec_():
            pass

    @QtCore.Slot()
    def on_action_axis_grids_triggered(self):
        self.display.axis_grids = self.ui.action_axis_grids.isChecked()
        self.set_setting("display_axis_grids", self.display.axis_grids)

    @QtCore.Slot()
    def on_action_voxel_edges_triggered(self):
        self.display.voxel_edges = self.ui.action_voxel_edges.isChecked()
        self.set_setting("voxel_edges", self.display.voxel_edges)

#.........这里部分代码省略.........
开发者ID:LRiecken,项目名称:zoxel,代码行数:103,代码来源:mainwindow.py

示例13: GUI

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class GUI(QtGui.QMainWindow):
    def __init__(self, app):
        QtGui.QMainWindow.__init__(self)
        self.app = app
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.actionAbout_Qt.triggered.connect(app.aboutQt)
        self.ui.actionAbout.triggered.connect(self.showAbout)
        self.ui.actionQuit.triggered.connect(self.quit)
        self.ui.quitBtn.clicked.connect(self.quit)
        self.ui.moduleNotebook.currentChanged.connect(self.updateWizButtons)
        self.ui.nextBtn.clicked.connect(self.nextTab)
        self.ui.prevBtn.clicked.connect(self.prevTab)
        self.welcome_container = QtGui.QWidget()
        self.welcomeTab = Ui_Welcome()
        self.welcomeTab.setupUi(self.welcome_container)
        self.ui.moduleNotebook.insertTab(0, self.welcome_container, "Welcome")
        self.createConfigTab()
        self.updateWizButtons()

    def updateWizButtons(self):
        if self.ui.moduleNotebook.currentIndex() <= 0:
            self.ui.prevBtn.setEnabled(False)
        else:
            self.ui.prevBtn.setEnabled(True)
        if self.isLast():
            self.ui.nextBtn.setText(_("Finish"))
        else:
            self.ui.nextBtn.setText(_("Next"))
        if self.ui.moduleNotebook.currentIndex() < 0:
            self.ui.nextBtn.setEnabled(False)
        else:
            self.ui.nextBtn.setEnabled(True)

    def nextTab(self, *args):
        if self.isLast():
            self.quit()
        else:
            self.chTab(1)

    def prevTab(self, *args):
        self.chTab(-1)

    def chTab(self, amt):
        self.ui.moduleNotebook.setCurrentIndex(
            self.ui.moduleNotebook.currentIndex() + amt)

    def isLast(self):
        return self.ui.moduleNotebook.count() - 1 <= self.ui.moduleNotebook.currentIndex()

    def createConfigTab(self):
        configs = config.Configuration
        self.configTab = QtGui.QWidget()
        self.configTab.vlayout = QtGui.QVBoxLayout(self.configTab)
        # Master notebook (stores the sections)
        self.configTab.notebook1 = QtGui.QTabWidget(self.configTab)
        self.configTab.vlayout.addWidget(self.configTab.notebook1)
        self.fillConfiguration(configs, self.configTab)
        self.ui.moduleNotebook.addTab(self.configTab, _("Configuration"))

    def addCategory(self, section, category):
        i = section
        c = category
        fw = QtGui.QWidget(self.configTab.notebook1.__dict__[i].nbook)
        vb = QtGui.QVBoxLayout(fw)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c] = QtGui.QScrollArea(fw)
        vb.addWidget(self.configTab.notebook1.__dict__[i].nbook.__dict__[c])
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].setWidgetResizable(True)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayout = QtGui.QFormLayout()
        #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setSizeConstraint(
        #                                            QtGui.QLayout.SetFixedSize)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setFieldGrowthPolicy(
            QtGui.QFormLayout.ExpandingFieldsGrow)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setLabelAlignment(
            QtCore.Qt.AlignLeft)
        #self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout.setFormAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop);
        self.configTab.notebook1.__dict__[i].nbook.__dict__[
            c].flayoutC = QtGui.QWidget()
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC.setLayout(
            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayout)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC.setSizePolicy(
            QtGui.QSizePolicy.MinimumExpanding,
            QtGui.QSizePolicy.Preferred)
        self.configTab.notebook1.__dict__[i].nbook.__dict__[c].setWidget(
            self.configTab.notebook1.__dict__[i].nbook.__dict__[c].flayoutC)
        self.configTab.notebook1.__dict__[i].nbook.addTab(
            fw, c)

    def fillConfiguration(self, configs, widget):
        # TODO: Clean this mess, or at least comment it
        l = "l"
        v = "v"
        for i in configs.keys():
            # If the section is not in the notebook, add it
            if not i in self.configTab.notebook1.__dict__:
                self.configTab.notebook1.__dict__[i] = QtGui.QWidget()
                self.configTab.notebook1.__dict__[i].vlayout = QtGui.QVBoxLayout(
#.........这里部分代码省略.........
开发者ID:KeithIMyers,项目名称:relinux,代码行数:103,代码来源:gui.py

示例14: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QtGui.QMainWindow):
    POLLING_DURATION = 10000  # 10000msec = 10sec
    SETTINGS_FILE_NAME = "nicopealert.dat"
    INIT_SETTINGS = {
        "version": "0.0.1",  # 設定ファイルが互換性がなくなるときに変更
        "watchList": {},
        "communityList": {},
        "tabList": [],
        "browserOpenMode": 0,
    }

    def checkSemaphore(self):
        self.sem = QtCore.QSystemSemaphore("nicopealert-app", 1)
        self.sem.acquire()
        self.firstApp = True
        self.inited = False

    def __init__(self, app, logger):
        # 同時に1起動制限
        self.firstApp = False

        t = threading.Thread(target=self.checkSemaphore)
        t.start()
        t.join(0.2)

        if not self.firstApp:
            sys.exit(1)

        # 初期化処理
        QtGui.QDialog.__init__(self)
        self.app = app
        self.logger = logger

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # load settings
        try:
            f = open(self.SETTINGS_FILE_NAME, "rb")
            self.settings = pickle.load(f)
            f.close()
            for k, v in self.INIT_SETTINGS.items():
                if not self.settings.has_key(k):
                    self.settings[k] = v
        except:
            self.settings = self.INIT_SETTINGS

        # models
        self.dicTableModel = NicoDicTableModel(self)
        self.liveTableModel = NicoLiveTableModel(self)
        self.watchListTableModel = WatchListTableModel(self)
        self.communityListTableModel = CommunityTableModel(self)

        # tab widget
        self.tabWidget = DraggableTabWidget(self.ui.centralwidget)
        self.tabWidget.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.ui.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
        self.connect(self.tabWidget, QtCore.SIGNAL("currentChanged(int)"), self.tabWidgetChangedHandler)

        # initial tabs
        DicUserTabWidget(self)
        LiveUserTabWidget(self)
        WatchListUserTabWidget(self)
        CommunityListUserTabWidget(self)
        self.tabWidget.setCurrentIndex(0)

        # trayIcon/trayIconMenu/trayIconImg
        self.trayIconImg = QtGui.QIcon(self.tr(":/dic.ico"))
        self.trayIconMenu = QtGui.QMenu(self)
        self.trayIconMenu.addAction(u"表示/非表示", lambda: self.toggleWindowVisibility())
        self.trayIconMenu.addAction(u"終了", lambda: self.app.quit())
        self.trayIcon = QtGui.QSystemTrayIcon(self)
        self.trayIcon.setContextMenu(self.trayIconMenu)
        self.trayIcon.setIcon(self.trayIconImg)
        self.trayIcon.show()
        self.connect(self.trayIcon, QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.trayIconHandler)

        # window style
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowMinimizeButtonHint)

        # first data fetch
        self.nicopoll = NicoPoll(self.dicTableModel, self.liveTableModel)
        self.nicopoll.fetch(self)

        # menu
        self.fileMenu = QtGui.QMenu(self.ui.menubar)
        self.fileMenu.addAction(u"設定", lambda: self.showSettingsDialog())
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(u"トレイアイコンに収納", lambda: self.hide())
        self.fileMenu.addAction(u"終了", lambda: self.app.quit())
        self.fileMenu.setTitle(self.trUtf8("ファイル"))
        self.ui.menubar.addAction(self.fileMenu.menuAction())

    def show(self):
        QtGui.QMainWindow.show(self)
        self.activateWindow()

        if not self.inited:
            # データ挿入
            self.watchListTableModel.appendItems(self.settings["watchList"])
#.........这里部分代码省略.........
开发者ID:gunyarakun,项目名称:nicopealert,代码行数:103,代码来源:nicopealert.py

示例15: MainWindow

# 需要导入模块: from ui_mainwindow import Ui_MainWindow [as 别名]
# 或者: from ui_mainwindow.Ui_MainWindow import setupUi [as 别名]
class MainWindow(QMainWindow):
    
    def __init__(self, filename=None, parent=None):
        QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        
        if filename is not None:
            self.initCommandModel(load_commands(filename))
        else:
            self.initCommandModel([])
        
        self.ui.action_Load.triggered.connect(self.loadCommands)
        self.ui.action_Save.triggered.connect(self.saveCommands)
        
        self.ui.action_Add.triggered.connect(self.addCommand)
        self.ui.action_Edit.triggered.connect(self.editCommand)
        self.ui.action_Remove.triggered.connect(self.removeCommand)
        self.ui.action_Apply.triggered.connect(self.render)
        
        self.ui.action_About_BashMate.triggered.connect(self.about)
        
        self.ui.commandView.activated.connect(self.changeDetailsView)
        self.ui.applyButton.clicked.connect(self.render)
        self.ui.filterEdit.textChanged.connect(self.filter_changed)
        #self.ui.addButton.clicked.connect(self.addCommand)
        #self.ui.editButton.clicked.connect(self.editCommand)
        #self.ui.removeButton.clicked.connect(self.removeCommand)
        #self.ui.commandView.model().dataChanged.connect(self.change)
        #self.ui.commandView.activated.connect(self.activate)
    
    def initCommandModel(self, commands=[]):
        self.cmdmodel = CommandModel(commands, self)
        proxymodel= QSortFilterProxyModel(self)
        proxymodel.setSourceModel(self.cmdmodel)
        proxymodel.setFilterKeyColumn(1)
        self.ui.commandView.setModel(proxymodel)
        
    def loadCommands(self):
        filename = unicode(QFileDialog.getOpenFileName(self, 
                            u"Load CommandTemplate File", ".",
                            u"CommandTemplate File (*.json)"))
        self.initCommandModel(load_commands(filename))
    
    def saveCommands(self):
        filename = unicode(QFileDialog.getSaveFileName(self, 
                            u"Save CommandTemplate File", ".",
                            u"CommandTemplate File (*.json)"))
        dump_commands(self.cmdmodel.commands, filename)
    

    def changeDetailsView(self, index):
        command = self.cmdmodel.currentCommand(index)
        self.ui.commandBrowser.setText(command.command)
        self.ui.infoBrowser.setText(command.info)
        self.ui.bindView.setModel(BindModel(command, self))
    
    def render(self):
        command = self.cmdmodel.currentCommand(
                self.ui.commandView.currentIndex())
        bindings = self.ui.bindView.model().bindings
        self.ui.cmdEdit.setText(command.render(**bindings))
        
    def addCommand(self):
        dialog = CommandDialog(parent=self)
        if dialog.exec_() == QDialog.Accepted:
            self.cmdmodel.addCommand(dialog.command)

    def editCommand(self):
        command = self.cmdmodel.currentCommand(
                self.ui.commandView.currentIndex())
        dialog = CommandDialog(command, parent=self)
        if dialog.exec_() == QDialog.Accepted:
            commands = self.cmdmodel.commands
            commands[commands.index(command)] = dialog.command

    def removeCommand(self):
        self.cmdmodel.removeCommand(self.ui.commandView.currentIndex())

    def filter_changed(self, pattern):
        regExp = QRegExp(pattern, Qt.CaseInsensitive)
        self.ui.commandView.model().setFilterRegExp(regExp)

    def change(self, left, right):
        print self.ui.commandView.currentIndex().row()
        self.changeDetailsView(self.ui.commandView.currentIndex())
        
    def about(self):
       box = QMessageBox()
       box.setText(u"BashMate - the beginner firendly Shell Snippet Manager")
       box.setInformativeText(
            u"(c) 2011 by Christian Hausknecht <[email protected]>")
       box.exec_()
开发者ID:Lysander,项目名称:BashMate,代码行数:95,代码来源:bashmate.py


注:本文中的ui_mainwindow.Ui_MainWindow.setupUi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。